···1{ config, lib, callPackages }:
203let
4 aliases = if config.allowAliases then (import ./aliases.nix lib) else prev: {};
5
···1{ config, lib, callPackages }:
23+# If you are reading this, you can test these writers by running: nix-build . -A tests.writers
4let
5 aliases = if config.allowAliases then (import ./aliases.nix lib) else prev: {};
6
+18-16
pkgs/build-support/writers/scripts.nix
···13in
14rec {
15 # Base implementation for non-compiled executables.
16- # Takes an interpreter, for example `${pkgs.bash}/bin/bash`
17 #
18 # Examples:
19 # writeBash = makeScriptWriter { interpreter = "${pkgs.bash}/bin/bash"; }
···116 # echo hello world
117 # ''
118 writeBash = makeScriptWriter {
119- interpreter = "${pkgs.bash}/bin/bash";
120 };
121122 # Like writeScriptBin but the first line is a shebang to bash
···130 # echo hello world
131 # ''
132 writeDash = makeScriptWriter {
133- interpreter = "${pkgs.dash}/bin/dash";
134 };
135136 # Like writeScriptBin but the first line is a shebang to dash
···144 # echo hello world
145 # ''
146 writeFish = makeScriptWriter {
147- interpreter = "${pkgs.fish}/bin/fish --no-config";
148- check = "${pkgs.fish}/bin/fish --no-config --no-execute"; # syntax check only
149 };
150151 # Like writeScriptBin but the first line is a shebang to fish
···175 in makeBinWriter {
176 compileScript = ''
177 cp $contentPath tmp.hs
178- ${ghc.withPackages (_: libraries )}/bin/ghc ${lib.escapeShellArgs ghcArgs'} tmp.hs
179 mv tmp $out
180 '';
181 inherit strip;
···192 # echo hello world
193 # ''
194 writeNu = makeScriptWriter {
195- interpreter = "${pkgs.nushell}/bin/nu --no-config-file";
196 };
197198 # Like writeScriptBin but the first line is a shebang to nu
···206 # puts "hello world"
207 # ''
208 writeRuby = makeScriptWriter {
209- interpreter = "${pkgs.ruby}/bin/ruby";
210 };
211212 writeRubyBin = name:
···219 # print("hello world")
220 # ''
221 writeLua = makeScriptWriter {
222- interpreter = "${pkgs.lua}/bin/lua";
223 };
224225 writeLuaBin = name:
···236 makeBinWriter {
237 compileScript = ''
238 cp "$contentPath" tmp.rs
239- PATH=${lib.makeBinPath [pkgs.gcc]} ${lib.getBin rustc}/bin/rustc ${lib.escapeShellArgs rustcArgs} ${lib.escapeShellArgs darwinArgs} -o "$out" tmp.rs
240 '';
241 inherit strip;
242 } name;
···265 };
266 in writeDash name ''
267 export NODE_PATH=${node-env}/lib/node_modules
268- exec ${pkgs.nodejs}/bin/node ${pkgs.writeText "js" content} "$@"
269 '';
270271 # writeJSBin takes the same arguments as writeJS but outputs a directory (like writeScriptBin)
···300 # ''
301 writePerl = name: { libraries ? [] }:
302 makeScriptWriter {
303- interpreter = "${pkgs.perl.withPackages (p: libraries)}/bin/perl";
304 } name;
305306 # writePerlBin takes the same arguments as writePerl but outputs a directory (like writeScriptBin)
···316 in
317 makeScriptWriter {
318 interpreter =
319- if libraries == []
320- then python.interpreter
321- else (python.withPackages (ps: libraries)).interpreter
00322 ;
323 check = optionalString python.isPy3k (writeDash "pythoncheck.sh" ''
324 exec ${buildPythonPackages.flake8}/bin/flake8 --show-source ${ignoreAttribute} "$1"
···398 export DOTNET_CLI_TELEMETRY_OPTOUT=1
399 export DOTNET_NOLOGO=1
400 script="$1"; shift
401- ${dotnet-sdk}/bin/dotnet fsi --quiet --nologo --readline- ${fsi-flags} "$@" < "$script"
402 '';
403404 in content: makeScriptWriter {
···13in
14rec {
15 # Base implementation for non-compiled executables.
16+ # Takes an interpreter, for example `${lib.getExe pkgs.bash}`
17 #
18 # Examples:
19 # writeBash = makeScriptWriter { interpreter = "${pkgs.bash}/bin/bash"; }
···116 # echo hello world
117 # ''
118 writeBash = makeScriptWriter {
119+ interpreter = "${lib.getExe pkgs.bash}";
120 };
121122 # Like writeScriptBin but the first line is a shebang to bash
···130 # echo hello world
131 # ''
132 writeDash = makeScriptWriter {
133+ interpreter = "${lib.getExe pkgs.dash}";
134 };
135136 # Like writeScriptBin but the first line is a shebang to dash
···144 # echo hello world
145 # ''
146 writeFish = makeScriptWriter {
147+ interpreter = "${lib.getExe pkgs.fish} --no-config";
148+ check = "${lib.getExe pkgs.fish} --no-config --no-execute"; # syntax check only
149 };
150151 # Like writeScriptBin but the first line is a shebang to fish
···175 in makeBinWriter {
176 compileScript = ''
177 cp $contentPath tmp.hs
178+ ${(ghc.withPackages (_: libraries ))}/bin/ghc ${lib.escapeShellArgs ghcArgs'} tmp.hs
179 mv tmp $out
180 '';
181 inherit strip;
···192 # echo hello world
193 # ''
194 writeNu = makeScriptWriter {
195+ interpreter = "${lib.getExe pkgs.nushell} --no-config-file";
196 };
197198 # Like writeScriptBin but the first line is a shebang to nu
···206 # puts "hello world"
207 # ''
208 writeRuby = makeScriptWriter {
209+ interpreter = "${lib.getExe pkgs.ruby}";
210 };
211212 writeRubyBin = name:
···219 # print("hello world")
220 # ''
221 writeLua = makeScriptWriter {
222+ interpreter = "${lib.getExe pkgs.lua}";
223 };
224225 writeLuaBin = name:
···236 makeBinWriter {
237 compileScript = ''
238 cp "$contentPath" tmp.rs
239+ PATH=${lib.makeBinPath [pkgs.gcc]} ${rustc}/bin/rustc ${lib.escapeShellArgs rustcArgs} ${lib.escapeShellArgs darwinArgs} -o "$out" tmp.rs
240 '';
241 inherit strip;
242 } name;
···265 };
266 in writeDash name ''
267 export NODE_PATH=${node-env}/lib/node_modules
268+ exec ${lib.getExe pkgs.nodejs} ${pkgs.writeText "js" content} "$@"
269 '';
270271 # writeJSBin takes the same arguments as writeJS but outputs a directory (like writeScriptBin)
···300 # ''
301 writePerl = name: { libraries ? [] }:
302 makeScriptWriter {
303+ interpreter = "${lib.getExe (pkgs.perl.withPackages (p: libraries))}";
304 } name;
305306 # writePerlBin takes the same arguments as writePerl but outputs a directory (like writeScriptBin)
···316 in
317 makeScriptWriter {
318 interpreter =
319+ if pythonPackages != pkgs.pypy2Packages || pythonPackages != pkgs.pypy3Packages then
320+ if libraries == []
321+ then python.interpreter
322+ else (python.withPackages (ps: libraries)).interpreter
323+ else python.interpreter
324 ;
325 check = optionalString python.isPy3k (writeDash "pythoncheck.sh" ''
326 exec ${buildPythonPackages.flake8}/bin/flake8 --show-source ${ignoreAttribute} "$1"
···400 export DOTNET_CLI_TELEMETRY_OPTOUT=1
401 export DOTNET_NOLOGO=1
402 script="$1"; shift
403+ ${lib.getExe dotnet-sdk} fsi --quiet --nologo --readline- ${fsi-flags} "$@" < "$script"
404 '';
405406 in content: makeScriptWriter {