Skip to content

Commit

Permalink
make nix build just take a list of exes to include
Browse files Browse the repository at this point in the history
  • Loading branch information
chessai committed Jul 15, 2024
1 parent 9fa333c commit 30c62e5
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,28 @@ let haskellSrc = with nix-filter.lib; filter {
};
pact = pactFromCached pkgs pact passthru.cached;
};
default = pkgs.runCommandCC "chainweb" { inherit passthru; } ''
mkdir -pv $out/bin
cp ${flake.packages."chainweb:exe:chainweb-node"}/bin/chainweb-node $out/bin/chainweb-node
cp ${flake.packages."chainweb:exe:cwtool"}/bin/cwtool $out/bin/cwtool
cp ${flake.packages."chainweb:exe:compact"}/bin/compact $out/bin/compact
chmod +w $out/bin/{cwtool,chainweb-node,compact}
$STRIP $out/bin/{cwtool,chainweb-node,compact}
${pkgs.lib.optionalString (pkgs.stdenv.isLinux) ''
patchelf --shrink-rpath $out/bin/{cwtool,chainweb-node,compact}
''}
'';
default =
let
exes = [
"chainweb-node"
"cwtool"
"compact"
"pact-diff"
];

for = xs: f: builtins.map f xs;
in
pkgs.runCommandCC "chainweb" { inherit passthru; } ''
mkdir -pv $out/bin
${builtins.concatStringsSep "\n" (for exes (exe: ''
cp ${flake.packages."chainweb:exe:${exe}"}/bin/${exe} $out/bin/${exe}
chmod +w $out/bin/${exe}
$STRIP $out/bin/${exe}
${pkgs.lib.optionalString (pkgs.stdenv.isLinux) ''
patchelf --shrink-rpath $out/bin/${exe}
''}
''))}
'';
in {
# The Haskell project flake: Used by flake.nix
inherit flake;
Expand Down

0 comments on commit 30c62e5

Please sign in to comment.