Skip to content

Commit

Permalink
Merge pull request #95 from input-output-hk/andrea/update-flake
Browse files Browse the repository at this point in the history
Update flake
  • Loading branch information
michaelpj authored Jan 16, 2024
2 parents 677fb75 + cb6d627 commit 197ea64
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 62 deletions.
114 changes: 82 additions & 32 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 28 additions & 30 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
inputs = {
nixpkgs.follows = "haskell-nix/nixpkgs-unstable";
haskell-nix.url = "github:input-output-hk/haskell.nix";
haskell-nix.inputs.hackage.follows = "hackage-nix";
hackage-nix.url = "github:input-output-hk/hackage.nix";
hackage-nix.flake = false;
flake-utils.url = "github:numtide/flake-utils";
};

Expand All @@ -16,8 +13,7 @@
systems = [
"x86_64-linux"
"x86_64-darwin"
# TODO switch back on when ci.iog.io has builders for aarch64-linux
# "aarch64-linux"
"aarch64-linux"
"aarch64-darwin"
];
in
Expand All @@ -39,43 +35,45 @@
haskell-language-server = "latest";
fourmolu = "0.14.0.0";
};

modules = [{
# Wrap executables with the needed dependencies in PATH. See #71.
packages.foliage.postInstall = ''
for exe in $(find $out/bin -type f -executable); do
wrapProgram "$exe" \
--prefix PATH : ${with pkgs; lib.makeBinPath [ coreutils curl gnutar gitMinimal patch ]}
done
'';
}];
};

flake = project.flake (
lib.attrsets.optionalAttrs (system == "x86_64-linux")
{ crossPlatforms = p: [ p.musl64 ]; }
);

# Wrap the foliage executable with the needed dependencies in PATH.
# See #71.
wrapExe = drv:
pkgs.runCommand "foliage"
{
nativeBuildInputs = [ pkgs.makeWrapper ];
} ''
mkdir -p $out/bin
makeWrapper ${drv}/bin/foliage $out/bin/foliage \
--prefix PATH : ${with pkgs; lib.makeBinPath [ curl patch ]}:$out/bin
'';

in

flake // {
inherit project;

# This is way too much boilerplate. I only want the default package to
# be the main exe (package or app) and "static" the static version on
# the systems where it is available.
apps =
flake.apps
// { default = flake.apps."foliage:exe:foliage"; }
# Expose the derivation for a static executable as "static"
// lib.attrsets.optionalAttrs (system == "x86_64-linux")
{ static = flake.apps."x86_64-unknown-linux-musl:foliage:exe:foliage"; }
// lib.attrsets.optionalAttrs (system == "aarch64-linux")
{ static = flake.apps."aarch64-multiplatform-musl:foliage:exe:foliage"; }
;

apps = { default = flake.apps."foliage:exe:foliage"; }
// lib.attrsets.optionalAttrs (system == "x86_64-linux")
{ static = wrapExe flake.apps."x86_64-unknown-linux-musl:foliage:exe:foliage"; }
// lib.attrsets.optionalAttrs (system == "aarch64-linux")
{ static = wrapExe flake.apps."aarch64-multiplatform-musl:foliage:exe:foliage"; };
packages =
flake.packages
// { default = flake.packages."foliage:exe:foliage"; }

packages = { default = flake.packages."foliage:exe:foliage"; }
// lib.attrsets.optionalAttrs (system == "x86_64-linux")
{ static = flake.packages."x86_64-unknown-linux-musl:foliage:exe:foliage"; }
# Expose the derivation for a static executable as "static"
// lib.attrsets.optionalAttrs (system == "x86_64-linux")
{ static = flake.packages."x86_64-unknown-linux-musl:foliage:exe:foliage"; }
// lib.attrsets.optionalAttrs (system == "aarch64-linux")
{ static = flake.packages."aarch64-multiplatform-musl:foliage:exe:foliage"; }
;
}
);
Expand Down

0 comments on commit 197ea64

Please sign in to comment.