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