Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 56 lines 1.9 kB view raw
1{ 2 hare, 3 lib, 4 makeSetupHook, 5 makeWrapper, 6 runCommand, 7 stdenv, 8 writeShellApplication, 9}: 10let 11 arch = stdenv.targetPlatform.uname.processor; 12 harePropagationInputs = builtins.attrValues { inherit (hare) harec qbe; }; 13 hareWrappedScript = writeShellApplication { 14 # `name` MUST be `hare`, since its role is to replace the hare binary. 15 name = "hare"; 16 runtimeInputs = [ hare ]; 17 excludeShellChecks = [ "SC2086" ]; 18 # ''${cmd:+"$cmd"} is used on the default case to keep the same behavior as 19 # the hare binary: If "$cmd" is passed directly and it's empty, the hare 20 # binary will treat it as an unrecognized command. 21 text = '' 22 readonly cmd="$1" 23 shift 24 case "$cmd" in 25 "test"|"run"|"build") exec hare "$cmd" $NIX_HAREFLAGS "$@" ;; 26 *) exec hare ''${cmd:+"$cmd"} "$@" 27 esac 28 ''; 29 }; 30 hareWrapper = runCommand "hare-wrapper" { nativeBuildInputs = [ makeWrapper ]; } '' 31 mkdir -p $out/bin 32 install ${lib.getExe hareWrappedScript} $out/bin/hare 33 makeWrapper ${lib.getExe hare} $out/bin/hare-native \ 34 --inherit-argv0 \ 35 --unset AR \ 36 --unset LD \ 37 --unset CC 38 ''; 39in 40makeSetupHook { 41 name = "hare-hook"; 42 # The propagation of `qbe` and `harec` (harePropagationInputs) is needed for 43 # build frameworks like `haredo`, which set the HAREC and QBE env vars to 44 # `harec` and `qbe` respectively. We use the derivations from the `hare` 45 # package to assure that there's no different behavior between the `hareHook` 46 # and `hare` packages. 47 propagatedBuildInputs = [ hareWrapper ] ++ harePropagationInputs; 48 substitutions = { 49 hare_unconditional_flags = "-q -a${arch}"; 50 hare_stdlib = "${hare}/src/hare/stdlib"; 51 }; 52 meta = { 53 description = "Setup hook for the Hare compiler"; 54 inherit (hare.meta) badPlatforms platforms; 55 }; 56} ./setup-hook.sh