about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/continuous-integration/hci/default.nix
blob: 1acafb10eabc5daf79cdfd255c3940785751bb3a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{ haskell, haskellPackages, lib, makeWrapper, runc, stdenv, emptyDirectory }:
let
  inherit (haskell.lib.compose) overrideCabal addBuildTools justStaticExecutables appendConfigureFlags;
  inherit (lib) makeBinPath;
  bundledBins = lib.optional stdenv.isLinux runc;

  overrides = old: {
    hercules-ci-agent =
      overrideCabal
        (o: {
          isLibrary = true;
          isExecutable = false;
          postInstall = ""; # ignore completions
          enableSharedExecutables = false;
          buildTarget = "lib:hercules-ci-agent hercules-ci-agent-unit-tests";
          configureFlags = o.configureFlags or [ ] ++ [
            "--bindir=${emptyDirectory}/hercules-ci-built-without-binaries/no-bin"
          ];
        })
        old.hercules-ci-agent;
  };

  pkg =
    # justStaticExecutables is needed due to https://github.com/NixOS/nix/issues/2990
    overrideCabal
      (o: {
        postInstall = ''
          ${o.postInstall or ""}
          mkdir -p $out/libexec
          mv $out/bin/hci $out/libexec
          makeWrapper $out/libexec/hci $out/bin/hci --prefix PATH : ${lib.escapeShellArg (makeBinPath bundledBins)}
        '';
      })
      (addBuildTools [ makeWrapper ] (justStaticExecutables (haskellPackages.hercules-ci-cli.override overrides)));
in pkg // {
    meta = pkg.meta // {
      position = toString ./default.nix + ":1";
    };
  }