about summary refs log tree commit diff
path: root/pkgs/by-name/ha/haredo/package.nix
blob: a6db89149eb8c8832f2e1bf4d234f8522872e429 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{
  stdenv,
  lib,
  fetchFromSourcehut,
  hare,
  scdoc,
  nix-update-script,
  makeWrapper,
  bash,
  substituteAll,
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "haredo";
  version = "1.0.5";

  outputs = [
    "out"
    "man"
  ];

  src = fetchFromSourcehut {
    owner = "~autumnull";
    repo = "haredo";
    rev = finalAttrs.version;
    hash = "sha256-gpui5FVRw3NKyx0AB/4kqdolrl5vkDudPOgjHc/IE4U=";
  };

  patches = [
    # Use nix store's bash instead of sh. `@bash@/bin/sh` is used, since haredo expects a posix shell.
    (substituteAll {
      src = ./001-use-nix-store-sh.patch;
      inherit bash;
    })
  ];

  nativeBuildInputs = [
    hare
    makeWrapper
    scdoc
  ];

  enableParallelChecking = true;

  doCheck = true;

  dontConfigure = true;

  preBuild = ''
    HARECACHE="$(mktemp -d --tmpdir harecache.XXXXXXXX)"
    export HARECACHE
    export PREFIX=${builtins.placeholder "out"}
  '';

  buildPhase = ''
    runHook preBuild

    ./bootstrap.sh

    runHook postBuild
  '';

  checkPhase = ''
    runHook preCheck

    ./bin/haredo ''${enableParallelChecking:+-j$NIX_BUILD_CORES} test

    runHook postCheck
  '';

  installPhase = ''
    runHook preInstall

    ./bootstrap.sh install

    runHook postInstall
  '';

  setupHook = ./setup-hook.sh;

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "A simple and unix-idiomatic build automator";
    homepage = "https://sr.ht/~autumnull/haredo/";
    license = lib.licenses.wtfpl;
    maintainers = with lib.maintainers; [ onemoresuza ];
    mainProgram = "haredo";
    inherit (hare.meta) platforms badPlatforms;
  };
})