1{
2 crun,
3 haskell,
4 haskellPackages,
5 lib,
6 makeWrapper,
7 stdenv,
8 emptyDirectory,
9}:
10let
11 inherit (haskell.lib.compose)
12 overrideCabal
13 addBuildTools
14 justStaticExecutables
15 appendConfigureFlags
16 ;
17 inherit (lib) makeBinPath;
18 bundledBins = lib.optional stdenv.hostPlatform.isLinux crun;
19
20 overrides = old: {
21 hercules-ci-agent = overrideCabal (o: {
22 isLibrary = true;
23 isExecutable = false;
24 postInstall = ""; # ignore completions
25 enableSharedExecutables = false;
26 buildTarget = "lib:hercules-ci-agent hercules-ci-agent-unit-tests";
27 configureFlags = o.configureFlags or [ ] ++ [
28 "--bindir=${emptyDirectory}/hercules-ci-built-without-binaries/no-bin"
29 ];
30 }) old.hercules-ci-agent;
31 };
32
33 pkg =
34 # justStaticExecutables is needed due to https://github.com/NixOS/nix/issues/2990
35 overrideCabal
36 (o: {
37 postInstall = ''
38 ${o.postInstall or ""}
39 mkdir -p $out/libexec
40 mv $out/bin/hci $out/libexec
41 makeWrapper $out/libexec/hci $out/bin/hci --prefix PATH : ${lib.escapeShellArg (makeBinPath bundledBins)}
42 '';
43 })
44 (
45 addBuildTools [ makeWrapper ]
46 # TODO: Erroneous references to GHC on aarch64-darwin: https://github.com/NixOS/nixpkgs/issues/318013
47 (
48 (
49 if stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 then
50 lib.id
51 else
52 haskell.lib.compose.justStaticExecutables
53 )
54 (haskellPackages.hercules-ci-cli.override overrides)
55 )
56 );
57in
58pkg
59// {
60 meta = pkg.meta // {
61 position = toString ./default.nix + ":1";
62 };
63}