Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 21.05 60 lines 1.5 kB view raw
1{ lib, stdenv 2, rtpPath ? "share/vim-plugins" 3, vim 4}: 5 6rec { 7 addRtp = path: attrs: derivation: 8 derivation // { rtp = "${derivation}/${path}"; } // { 9 overrideAttrs = f: buildVimPlugin (attrs // f attrs); 10 }; 11 12 buildVimPlugin = attrs@{ 13 name ? "${attrs.pname}-${attrs.version}", 14 namePrefix ? "vimplugin-", 15 src, 16 unpackPhase ? "", 17 configurePhase ? "", 18 buildPhase ? "", 19 preInstall ? "", 20 postInstall ? "", 21 path ? lib.getName name, 22 addonInfo ? null, 23 ... 24 }: 25 addRtp "${rtpPath}/${path}" attrs (stdenv.mkDerivation (attrs // { 26 name = namePrefix + name; 27 28 inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall; 29 30 installPhase = '' 31 runHook preInstall 32 33 target=$out/${rtpPath}/${path} 34 mkdir -p $out/${rtpPath} 35 cp -r . $target 36 37 # build help tags 38 if [ -d "$target/doc" ]; then 39 echo "Building help tags" 40 if ! ${vim}/bin/vim -N -u NONE -i NONE -n -E -s -V1 -c "helptags $target/doc" +quit!; then 41 echo "Failed to build help tags!" 42 exit 1 43 fi 44 else 45 echo "No docs available" 46 fi 47 48 if [ -n "$addonInfo" ]; then 49 echo "$addonInfo" > $target/addon-info.json 50 fi 51 52 runHook postInstall 53 ''; 54 })); 55 56 buildVimPluginFrom2Nix = attrs: buildVimPlugin ({ 57 buildPhase = ":"; 58 configurePhase =":"; 59 } // attrs); 60}