1{
2 lib,
3 stdenv,
4 core,
5
6 bash,
7 bat,
8 fish,
9 getconf,
10 makeWrapper,
11 zsh,
12}:
13let
14 cleanArgs = lib.flip builtins.removeAttrs [
15 "dependencies"
16 "meta"
17 ];
18in
19{
20 name,
21 dependencies,
22 meta ? { },
23 ...
24}@args:
25stdenv.mkDerivation (
26 finalAttrs:
27 cleanArgs args
28 // {
29 inherit (core) version;
30
31 src = core;
32
33 nativeBuildInputs = [ makeWrapper ];
34 # Make the dependencies available to the tests.
35 buildInputs = dependencies;
36
37 # Patch shebangs now because our tests rely on them
38 postPatch = ''
39 patchShebangs --host bin/${name}
40 '';
41
42 dontConfigure = true;
43 dontBuild = true; # we've already built
44
45 doCheck = true;
46 nativeCheckInputs = [
47 bat
48 bash
49 fish
50 zsh
51 ]
52 ++ (lib.optionals stdenv.hostPlatform.isDarwin [ getconf ]);
53 checkPhase = ''
54 runHook preCheck
55 bash ./test.sh --compiled --suite ${name}
56 runHook postCheck
57 '';
58
59 installPhase = ''
60 runHook preInstall
61 mkdir -p $out/bin
62 cp -p bin/${name} $out/bin/${name}
63 ''
64 + lib.optionalString (dependencies != [ ]) ''
65 wrapProgram $out/bin/${name} \
66 --prefix PATH : ${lib.makeBinPath dependencies}
67 ''
68 + ''
69 runHook postInstall
70 '';
71
72 # We already patched
73 dontPatchShebangs = true;
74
75 meta = core.meta // { mainProgram = name; } // meta;
76 }
77)