This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

lib/make-wrapper: add support for creating command aliases

Adds 'aliases' parameter to create additional symlinks to wrapped executables.
This allows tools to be accessible under multiple names.

+21 -2
+21 -2
lib/make-wrapper.nix
··· 12 12 - `flagSeparator`: Separator between flag names and values (optional, defaults to " ") 13 13 - `preHook`: Shell script to run before executing the command (optional) 14 14 - `passthru`: Attribute set to pass through to the wrapped derivation (optional) 15 + - `aliases`: List of additional names to symlink to the wrapped executable (optional) 15 16 - `wrapper`: Custom wrapper function (optional, defaults to exec'ing the original binary with flags) 16 17 - Called with { env, flags, envString, flagsString, exePath, preHook } 17 18 ··· 52 53 flagSeparator ? " ", # " " for "--flag value" or "=" for "--flag=value" 53 54 preHook ? "", 54 55 passthru ? { }, 56 + aliases ? [ ], 55 57 wrapper ? ( 56 58 { 57 59 exePath, ··· 115 117 originalOutputs ? { }, 116 118 passthru ? { }, 117 119 meta ? { }, 120 + aliases ? [ ], 121 + binName ? null, 118 122 ... 119 123 }@args: 120 124 pkgs.stdenv.mkDerivation ( ··· 127 131 for path in ${lib.concatStringsSep " " (map toString paths)}; do 128 132 ${pkgs.lndir}/bin/lndir -silent "$path" $out 129 133 done 134 + 135 + # Create symlinks for aliases 136 + ${lib.optionalString (aliases != [ ] && binName != null) '' 137 + mkdir -p $out/bin 138 + for alias in ${lib.concatStringsSep " " (map lib.escapeShellArg aliases)}; do 139 + ln -sf ${lib.escapeShellArg binName} $out/bin/$alias 140 + done 141 + ''} 130 142 131 143 # Handle additional outputs by symlinking from the original package's outputs 132 144 ${lib.concatMapStringsSep "\n" ( ··· 153 165 "originalOutputs" 154 166 "passthru" 155 167 "meta" 168 + "aliases" 169 + "binName" 156 170 ]) 157 171 ); 158 172 ··· 181 195 package 182 196 ]; 183 197 outputs = if package ? outputs then package.outputs else [ "out" ]; 184 - inherit originalOutputs; 198 + inherit originalOutputs aliases binName; 185 199 passthru = 186 200 (package.passthru or { }) 187 201 // passthru 188 202 // { 189 - inherit env flags preHook; 203 + inherit 204 + env 205 + flags 206 + preHook 207 + aliases 208 + ; 190 209 }; 191 210 # Pass through original attributes 192 211 meta = package.meta or { };