Skip to content

Commit

Permalink
Check in recent flake work
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Oct 29, 2023
1 parent 15ada49 commit ee29c34
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 9 deletions.
33 changes: 24 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,28 @@

exeAttr = "haskell-notebook-language-server:exe:haskell-notebook-language-server";

allVersions = with pkgs.lib; (
packageForGitHub = hnls: ghcName: pkgs.runCommand "haskell-notebook-language-server-${hnls.version}" { nativeBuildInputs = [pkgs.binutils]; } ''
name="haskell-notebook-language-server-${hnls.version}-${ghcName}-x86_64-linux"
mkdir -p $out
cp ${hnls}/bin/haskell-notebook-language-server $out/$name
cd $out
chmod u+w "$name"
strip "$name"
tar -czvf $name.tar.gz $name
'';

allVersions = with pkgs.lib; listToAttrs (
concatMap (info: [
(nameValuePair info.name (flake info.name (srcWithStackYaml info.stackYaml)).packages.${exeAttr})
(nameValuePair "${info.name}-static" (flakeStatic info.name (srcWithStackYaml info.stackYaml)).packages.${exeAttr})
]) [
{ name = "ghc8107"; stackYaml = "stack-8.10.7.yaml"; }
{ name = "ghc902"; stackYaml = "stack-9.0.2.yaml"; }
{ name = "ghc928"; stackYaml = "stack-9.2.8.yaml"; }
{ name = "ghc945"; stackYaml = "stack-9.4.5.yaml"; }
# { name = "ghc947"; stackYaml = "stack-9.4.7.yaml"; }
# { name = "ghc962"; stackYaml = "stack-9.6.2.yaml"; }
]
);
Expand All @@ -62,13 +75,15 @@
inherit (pkgs) cabal2nix;
# inherit lsp-types;

all = with pkgs.lib; pkgs.linkFarm "haskell-notebook-language-server-all" (
map (x: {
inherit (x) name;
path = x.value;
}) allVersions
);
} // pkgs.lib.listToAttrs allVersions;
inherit allVersions;
staticVersions = pkgs.lib.filterAttrs (n: v: pkgs.lib.hasSuffix "-static" n) allVersions;
all = pkgs.linkFarm "haskell-notebook-language-server-all" allVersions;

githubArtifacts = with pkgs; symlinkJoin {
name = "haskell-notebook-language-server-artifacts";
paths = lib.mapAttrsToList (n: v: packageForGitHub v (lib.removeSuffix "-static" n)) staticVersions;
};
} // allVersions;

inherit flake;

Expand Down
35 changes: 35 additions & 0 deletions upload_to_github.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p jq github-cli

set -e

BUILT=$(nix build .#githubArtifacts --no-link --json | jq -r '.[0].outputs.out')
echo "Built: $BUILT"
ls "$BUILT"
VERSION="$(nix eval .#ghc928-static.version --raw)"
IFS=$'\n'
ARTIFACTS=$(find "$BUILT" -name "*.tar.gz")
unset IFS
echo "Saw artifacts: $ARTIFACTS"
# Smoke check
# FIRST_EXECUTABLE=$(find "$BUILT" -type f -executable | head -n 1)
# echo "FIRST_EXECUTABLE: $FIRST_EXECUTABLE"
# $FIRST_EXECUTABLE --help > /dev/null 2>&1
TAG=v"$VERSION"
echo "Tagging at $TAG"
git tag "$TAG" -f
echo ""
echo "Pushing tags"
git push --tags
echo ""
echo "Creating release $TAG"
gh release create "$TAG" \
${ARTIFACTS[@]} \
--title "$TAG" \
--notes ""

0 comments on commit ee29c34

Please sign in to comment.