Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 86 lines 1.8 kB view raw
1{ 2 stdenv, 3 lib, 4 writeScript, 5 wrapFish, 6}: 7 8attrs@{ 9 pname, 10 version, 11 src, 12 13 name ? "fishplugin-${pname}-${version}", 14 unpackPhase ? "", 15 configurePhase ? ":", 16 buildPhase ? ":", 17 preInstall ? "", 18 postInstall ? "", 19 20 nativeCheckInputs ? [ ], 21 # plugin packages to add to the vendor paths of the test fish shell 22 checkPlugins ? [ ], 23 # vendor directories to add to the function path of the test fish shell 24 checkFunctionDirs ? [ ], 25 # test script to be executed in a fish shell 26 checkPhase ? "", 27 doCheck ? checkPhase != "", 28 29 ... 30}: 31 32let 33 # Do not pass attributes that are only relevant to buildFishPlugin to mkDerivation. 34 drvAttrs = builtins.removeAttrs attrs [ 35 "checkPlugins" 36 "checkFunctionDirs" 37 ]; 38in 39 40stdenv.mkDerivation ( 41 drvAttrs 42 // { 43 inherit name; 44 inherit unpackPhase configurePhase buildPhase; 45 46 inherit preInstall postInstall; 47 installPhase = '' 48 runHook preInstall 49 50 ( 51 install_vendor_files() { 52 source="$1" 53 target="$out/share/fish/vendor_$2.d" 54 55 # Check if any .fish file exists in $source 56 [ -n "$(shopt -s nullglob; echo $source/*.fish)" ] || return 0 57 58 mkdir -p $target 59 cp $source/*.fish "$target/" 60 } 61 62 install_vendor_files completions completions 63 install_vendor_files functions functions 64 install_vendor_files conf conf 65 install_vendor_files conf.d conf 66 ) 67 68 runHook postInstall 69 ''; 70 71 inherit doCheck; 72 73 nativeCheckInputs = [ 74 (wrapFish { 75 pluginPkgs = checkPlugins; 76 functionDirs = checkFunctionDirs; 77 }) 78 ] 79 ++ nativeCheckInputs; 80 81 checkPhase = '' 82 export HOME=$(mktemp -d) # fish wants a writable home 83 fish "${writeScript "${name}-test" checkPhase}" 84 ''; 85 } 86)