···11{ config, lib, callPackages }:
2233+# If you are reading this, you can test these writers by running: nix-build . -A tests.writers
34let
45 aliases = if config.allowAliases then (import ./aliases.nix lib) else prev: {};
56
+18-16
pkgs/build-support/writers/scripts.nix
···1313in
1414rec {
1515 # Base implementation for non-compiled executables.
1616- # Takes an interpreter, for example `${pkgs.bash}/bin/bash`
1616+ # Takes an interpreter, for example `${lib.getExe pkgs.bash}`
1717 #
1818 # Examples:
1919 # writeBash = makeScriptWriter { interpreter = "${pkgs.bash}/bin/bash"; }
···116116 # echo hello world
117117 # ''
118118 writeBash = makeScriptWriter {
119119- interpreter = "${pkgs.bash}/bin/bash";
119119+ interpreter = "${lib.getExe pkgs.bash}";
120120 };
121121122122 # Like writeScriptBin but the first line is a shebang to bash
···130130 # echo hello world
131131 # ''
132132 writeDash = makeScriptWriter {
133133- interpreter = "${pkgs.dash}/bin/dash";
133133+ interpreter = "${lib.getExe pkgs.dash}";
134134 };
135135136136 # Like writeScriptBin but the first line is a shebang to dash
···144144 # echo hello world
145145 # ''
146146 writeFish = makeScriptWriter {
147147- interpreter = "${pkgs.fish}/bin/fish --no-config";
148148- check = "${pkgs.fish}/bin/fish --no-config --no-execute"; # syntax check only
147147+ interpreter = "${lib.getExe pkgs.fish} --no-config";
148148+ check = "${lib.getExe pkgs.fish} --no-config --no-execute"; # syntax check only
149149 };
150150151151 # Like writeScriptBin but the first line is a shebang to fish
···175175 in makeBinWriter {
176176 compileScript = ''
177177 cp $contentPath tmp.hs
178178- ${ghc.withPackages (_: libraries )}/bin/ghc ${lib.escapeShellArgs ghcArgs'} tmp.hs
178178+ ${(ghc.withPackages (_: libraries ))}/bin/ghc ${lib.escapeShellArgs ghcArgs'} tmp.hs
179179 mv tmp $out
180180 '';
181181 inherit strip;
···192192 # echo hello world
193193 # ''
194194 writeNu = makeScriptWriter {
195195- interpreter = "${pkgs.nushell}/bin/nu --no-config-file";
195195+ interpreter = "${lib.getExe pkgs.nushell} --no-config-file";
196196 };
197197198198 # Like writeScriptBin but the first line is a shebang to nu
···206206 # puts "hello world"
207207 # ''
208208 writeRuby = makeScriptWriter {
209209- interpreter = "${pkgs.ruby}/bin/ruby";
209209+ interpreter = "${lib.getExe pkgs.ruby}";
210210 };
211211212212 writeRubyBin = name:
···219219 # print("hello world")
220220 # ''
221221 writeLua = makeScriptWriter {
222222- interpreter = "${pkgs.lua}/bin/lua";
222222+ interpreter = "${lib.getExe pkgs.lua}";
223223 };
224224225225 writeLuaBin = name:
···236236 makeBinWriter {
237237 compileScript = ''
238238 cp "$contentPath" tmp.rs
239239- PATH=${lib.makeBinPath [pkgs.gcc]} ${lib.getBin rustc}/bin/rustc ${lib.escapeShellArgs rustcArgs} ${lib.escapeShellArgs darwinArgs} -o "$out" tmp.rs
239239+ PATH=${lib.makeBinPath [pkgs.gcc]} ${rustc}/bin/rustc ${lib.escapeShellArgs rustcArgs} ${lib.escapeShellArgs darwinArgs} -o "$out" tmp.rs
240240 '';
241241 inherit strip;
242242 } name;
···265265 };
266266 in writeDash name ''
267267 export NODE_PATH=${node-env}/lib/node_modules
268268- exec ${pkgs.nodejs}/bin/node ${pkgs.writeText "js" content} "$@"
268268+ exec ${lib.getExe pkgs.nodejs} ${pkgs.writeText "js" content} "$@"
269269 '';
270270271271 # writeJSBin takes the same arguments as writeJS but outputs a directory (like writeScriptBin)
···300300 # ''
301301 writePerl = name: { libraries ? [] }:
302302 makeScriptWriter {
303303- interpreter = "${pkgs.perl.withPackages (p: libraries)}/bin/perl";
303303+ interpreter = "${lib.getExe (pkgs.perl.withPackages (p: libraries))}";
304304 } name;
305305306306 # writePerlBin takes the same arguments as writePerl but outputs a directory (like writeScriptBin)
···316316 in
317317 makeScriptWriter {
318318 interpreter =
319319- if libraries == []
320320- then python.interpreter
321321- else (python.withPackages (ps: libraries)).interpreter
319319+ if pythonPackages != pkgs.pypy2Packages || pythonPackages != pkgs.pypy3Packages then
320320+ if libraries == []
321321+ then python.interpreter
322322+ else (python.withPackages (ps: libraries)).interpreter
323323+ else python.interpreter
322324 ;
323325 check = optionalString python.isPy3k (writeDash "pythoncheck.sh" ''
324326 exec ${buildPythonPackages.flake8}/bin/flake8 --show-source ${ignoreAttribute} "$1"
···398400 export DOTNET_CLI_TELEMETRY_OPTOUT=1
399401 export DOTNET_NOLOGO=1
400402 script="$1"; shift
401401- ${dotnet-sdk}/bin/dotnet fsi --quiet --nologo --readline- ${fsi-flags} "$@" < "$script"
403403+ ${lib.getExe dotnet-sdk} fsi --quiet --nologo --readline- ${fsi-flags} "$@" < "$script"
402404 '';
403405404406 in content: makeScriptWriter {