···1010rec {
11111212 /* Run the shell command `buildCommand' to produce a store path named
1313- * `name'. The attributes in `env' are added to the environment
1414- * prior to running the command. By default `runCommand` runs in a
1515- * stdenv with no compiler environment. `runCommandCC` uses the default
1616- * stdenv, `pkgs.stdenv`.
1717- *
1818- * Examples:
1919- * runCommand "name" {envVariable = true;} ''echo hello > $out''
2020- * runCommandCC "name" {} ''gcc -o myfile myfile.c; cp myfile $out'';
2121- *
2222- * The `*Local` variants force a derivation to be built locally,
2323- * it is not substituted.
2424- *
2525- * This is intended for very cheap commands (<1s execution time).
2626- * It saves on the network roundrip and can speed up a build.
2727- *
2828- * It is the same as adding the special fields
2929- * `preferLocalBuild = true;`
3030- * `allowSubstitutes = false;`
3131- * to a derivation’s attributes.
1313+ `name'. The attributes in `env' are added to the environment
1414+ prior to running the command. By default `runCommand` runs in a
1515+ stdenv with no compiler environment. `runCommandCC` uses the default
1616+ stdenv, `pkgs.stdenv`.
1717+1818+ Example:
1919+2020+2121+ runCommand "name" {envVariable = true;} ''echo hello > $out''
2222+ runCommandCC "name" {} ''gcc -o myfile myfile.c; cp myfile $out'';
2323+2424+2525+ The `*Local` variants force a derivation to be built locally,
2626+ it is not substituted.
2727+2828+ This is intended for very cheap commands (<1s execution time).
2929+ It saves on the network roundrip and can speed up a build.
3030+3131+ It is the same as adding the special fields
3232+3333+ `preferLocalBuild = true;`
3434+ `allowSubstitutes = false;`
3535+3636+ to a derivation’s attributes.
3237 */
3338 runCommand = name: env: runCommandWith {
3439 stdenv = stdenvNoCC;
···5358 # We shouldn’t force the user to have a cc in scope.
54595560 /* Generalized version of the `runCommand`-variants
5656- * which does customized behavior via a single
5757- * attribute set passed as the first argument
5858- * instead of having a lot of variants like
5959- * `runCommand*`. Additionally it allows changing
6060- * the used `stdenv` freely and has a more explicit
6161- * approach to changing the arguments passed to
6262- * `stdenv.mkDerivation`.
6161+ which does customized behavior via a single
6262+ attribute set passed as the first argument
6363+ instead of having a lot of variants like
6464+ `runCommand*`. Additionally it allows changing
6565+ the used `stdenv` freely and has a more explicit
6666+ approach to changing the arguments passed to
6767+ `stdenv.mkDerivation`.
6368 */
6469 runCommandWith =
6570 let
···919692979398 /* Writes a text file to the nix store.
9494- * The contents of text is added to the file in the store.
9595- *
9696- * Examples:
9797- * # Writes my-file to /nix/store/<store path>
9898- * writeTextFile {
9999- * name = "my-file";
100100- * text = ''
101101- * Contents of File
102102- * '';
103103- * }
104104- * # See also the `writeText` helper function below.
105105- *
106106- * # Writes executable my-file to /nix/store/<store path>/bin/my-file
107107- * writeTextFile {
108108- * name = "my-file";
109109- * text = ''
110110- * Contents of File
111111- * '';
112112- * executable = true;
113113- * destination = "/bin/my-file";
114114- * }
9999+ The contents of text is added to the file in the store.
100100+101101+ Example:
102102+103103+104104+ # Writes my-file to /nix/store/<store path>
105105+ writeTextFile {
106106+ name = "my-file";
107107+ text = ''
108108+ Contents of File
109109+ '';
110110+ }
111111+112112+113113+ See also the `writeText` helper function below.
114114+115115+116116+ # Writes executable my-file to /nix/store/<store path>/bin/my-file
117117+ writeTextFile {
118118+ name = "my-file";
119119+ text = ''
120120+ Contents of File
121121+ '';
122122+ executable = true;
123123+ destination = "/bin/my-file";
124124+ }
125125+126126+115127 */
116128 writeTextFile =
117129 { name # the name of the derivation
···144156 '';
145157146158 /*
147147- * Writes a text file to nix store with no optional parameters available.
148148- *
149149- * Example:
150150- * # Writes contents of file to /nix/store/<store path>
151151- * writeText "my-file"
152152- * ''
153153- * Contents of File
154154- * '';
155155- *
159159+ Writes a text file to nix store with no optional parameters available.
160160+161161+ Example:
162162+163163+164164+ # Writes contents of file to /nix/store/<store path>
165165+ writeText "my-file"
166166+ ''
167167+ Contents of File
168168+ '';
169169+170170+156171 */
157172 writeText = name: text: writeTextFile {inherit name text;};
158173159174 /*
160160- * Writes a text file to nix store in a specific directory with no
161161- * optional parameters available.
162162- *
163163- * Example:
164164- * # Writes contents of file to /nix/store/<store path>/share/my-file
165165- * writeTextDir "share/my-file"
166166- * ''
167167- * Contents of File
168168- * '';
169169- *
175175+ Writes a text file to nix store in a specific directory with no
176176+ optional parameters available.
177177+178178+ Example:
179179+180180+181181+ # Writes contents of file to /nix/store/<store path>/share/my-file
182182+ writeTextDir "share/my-file"
183183+ ''
184184+ Contents of File
185185+ '';
186186+187187+170188 */
171189 writeTextDir = path: text: writeTextFile {
172190 inherit text;
···175193 };
176194177195 /*
178178- * Writes a text file to /nix/store/<store path> and marks the file as
179179- * executable.
180180- *
181181- * If passed as a build input, will be used as a setup hook. This makes setup
182182- * hooks more efficient to create: you don't need a derivation that copies
183183- * them to $out/nix-support/setup-hook, instead you can use the file as is.
184184- *
185185- * Example:
186186- * # Writes my-file to /nix/store/<store path> and makes executable
187187- * writeScript "my-file"
188188- * ''
189189- * Contents of File
190190- * '';
191191- *
196196+ Writes a text file to /nix/store/<store path> and marks the file as
197197+ executable.
198198+199199+ If passed as a build input, will be used as a setup hook. This makes setup
200200+ hooks more efficient to create: you don't need a derivation that copies
201201+ them to $out/nix-support/setup-hook, instead you can use the file as is.
202202+203203+ Example:
204204+205205+206206+ # Writes my-file to /nix/store/<store path> and makes executable
207207+ writeScript "my-file"
208208+ ''
209209+ Contents of File
210210+ '';
211211+212212+192213 */
193214 writeScript = name: text: writeTextFile {inherit name text; executable = true;};
194215195216 /*
196196- * Writes a text file to /nix/store/<store path>/bin/<name> and
197197- * marks the file as executable.
198198- *
199199- * Example:
200200- * # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable.
201201- * writeScriptBin "my-file"
202202- * ''
203203- * Contents of File
204204- * '';
205205- *
217217+ Writes a text file to /nix/store/<store path>/bin/<name> and
218218+ marks the file as executable.
219219+220220+ Example:
221221+222222+223223+224224+ # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable.
225225+ writeScriptBin "my-file"
226226+ ''
227227+ Contents of File
228228+ '';
229229+230230+206231 */
207232 writeScriptBin = name: text: writeTextFile {inherit name text; executable = true; destination = "/bin/${name}";};
208233209234 /*
210210- * Similar to writeScript. Writes a Shell script and checks its syntax.
211211- * Automatically includes interpreter above the contents passed.
212212- *
213213- * Example:
214214- * # Writes my-file to /nix/store/<store path> and makes executable.
215215- * writeShellScript "my-file"
216216- * ''
217217- * Contents of File
218218- * '';
219219- *
235235+ Similar to writeScript. Writes a Shell script and checks its syntax.
236236+ Automatically includes interpreter above the contents passed.
237237+238238+ Example:
239239+240240+241241+ # Writes my-file to /nix/store/<store path> and makes executable.
242242+ writeShellScript "my-file"
243243+ ''
244244+ Contents of File
245245+ '';
246246+247247+220248 */
221249 writeShellScript = name: text:
222250 writeTextFile {
···232260 };
233261234262 /*
235235- * Similar to writeShellScript and writeScriptBin.
236236- * Writes an executable Shell script to /nix/store/<store path>/bin/<name> and checks its syntax.
237237- * Automatically includes interpreter above the contents passed.
238238- *
239239- * Example:
240240- * # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable.
241241- * writeShellScriptBin "my-file"
242242- * ''
243243- * Contents of File
244244- * '';
245245- *
263263+ Similar to writeShellScript and writeScriptBin.
264264+ Writes an executable Shell script to /nix/store/<store path>/bin/<name> and checks its syntax.
265265+ Automatically includes interpreter above the contents passed.
266266+267267+ Example:
268268+269269+270270+ # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable.
271271+ writeShellScriptBin "my-file"
272272+ ''
273273+ Contents of File
274274+ '';
275275+276276+246277 */
247278 writeShellScriptBin = name : text :
248279 writeTextFile {
···259290 };
260291261292 /*
262262- * Similar to writeShellScriptBin and writeScriptBin.
263263- * Writes an executable Shell script to /nix/store/<store path>/bin/<name> and
264264- * checks its syntax with shellcheck and the shell's -n option.
265265- * Automatically includes sane set of shellopts (errexit, nounset, pipefail)
266266- * and handles creation of PATH based on runtimeInputs
267267- *
268268- * Note that the checkPhase uses stdenv.shell for the test run of the script,
269269- * while the generated shebang uses runtimeShell. If, for whatever reason,
270270- * those were to mismatch you might lose fidelity in the default checks.
271271- *
272272- * Example:
273273- * # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable.
274274- * writeShellApplication {
275275- * name = "my-file";
276276- * runtimeInputs = [ curl w3m ];
277277- * text = ''
278278- * curl -s 'https://nixos.org' | w3m -dump -T text/html
279279- * '';
280280- * }
293293+ Similar to writeShellScriptBin and writeScriptBin.
294294+ Writes an executable Shell script to /nix/store/<store path>/bin/<name> and
295295+ checks its syntax with shellcheck and the shell's -n option.
296296+ Automatically includes sane set of shellopts (errexit, nounset, pipefail)
297297+ and handles creation of PATH based on runtimeInputs
298298+299299+ Note that the checkPhase uses stdenv.shell for the test run of the script,
300300+ while the generated shebang uses runtimeShell. If, for whatever reason,
301301+ those were to mismatch you might lose fidelity in the default checks.
302302+303303+ Example:
304304+305305+ Writes my-file to /nix/store/<store path>/bin/my-file and makes executable.
306306+307307+308308+ writeShellApplication {
309309+ name = "my-file";
310310+ runtimeInputs = [ curl w3m ];
311311+ text = ''
312312+ curl -s 'https://nixos.org' | w3m -dump -T text/html
313313+ '';
314314+ }
315315+281316 */
282317 writeShellApplication =
283318 { name
···334369335370336371 /* concat a list of files to the nix store.
337337- * The contents of files are added to the file in the store.
338338- *
339339- * Examples:
340340- * # Writes my-file to /nix/store/<store path>
341341- * concatTextFile {
342342- * name = "my-file";
343343- * files = [ drv1 "${drv2}/path/to/file" ];
344344- * }
345345- * # See also the `concatText` helper function below.
346346- *
347347- * # Writes executable my-file to /nix/store/<store path>/bin/my-file
348348- * concatTextFile {
349349- * name = "my-file";
350350- * files = [ drv1 "${drv2}/path/to/file" ];
351351- * executable = true;
352352- * destination = "/bin/my-file";
353353- * }
372372+ The contents of files are added to the file in the store.
373373+374374+ Example:
375375+376376+377377+ # Writes my-file to /nix/store/<store path>
378378+ concatTextFile {
379379+ name = "my-file";
380380+ files = [ drv1 "${drv2}/path/to/file" ];
381381+ }
382382+383383+384384+ See also the `concatText` helper function below.
385385+386386+387387+ # Writes executable my-file to /nix/store/<store path>/bin/my-file
388388+ concatTextFile {
389389+ name = "my-file";
390390+ files = [ drv1 "${drv2}/path/to/file" ];
391391+ executable = true;
392392+ destination = "/bin/my-file";
393393+ }
394394+395395+354396 */
355397 concatTextFile =
356398 { name # the name of the derivation
···373415374416375417 /*
376376- * Writes a text file to nix store with no optional parameters available.
377377- *
378378- * Example:
379379- * # Writes contents of files to /nix/store/<store path>
380380- * concatText "my-file" [ file1 file2 ]
381381- *
418418+ Writes a text file to nix store with no optional parameters available.
419419+420420+ Example:
421421+422422+423423+ # Writes contents of files to /nix/store/<store path>
424424+ concatText "my-file" [ file1 file2 ]
425425+426426+382427 */
383428 concatText = name: files: concatTextFile { inherit name files; };
384429385385- /*
386386- * Writes a text file to nix store with and mark it as executable.
387387- *
388388- * Example:
389389- * # Writes contents of files to /nix/store/<store path>
390390- * concatScript "my-file" [ file1 file2 ]
391391- *
430430+ /*
431431+ Writes a text file to nix store with and mark it as executable.
432432+433433+ Example:
434434+ # Writes contents of files to /nix/store/<store path>
435435+ concatScript "my-file" [ file1 file2 ]
436436+392437 */
393438 concatScript = name: files: concatTextFile { inherit name files; executable = true; };
394439395440396441 /*
397397- * Create a forest of symlinks to the files in `paths'.
398398- *
399399- * This creates a single derivation that replicates the directory structure
400400- * of all the input paths.
401401- *
402402- * BEWARE: it may not "work right" when the passed paths contain symlinks to directories.
403403- *
404404- * Examples:
405405- * # adds symlinks of hello to current build.
406406- * symlinkJoin { name = "myhello"; paths = [ pkgs.hello ]; }
407407- *
408408- * # adds symlinks of hello and stack to current build and prints "links added"
409409- * symlinkJoin { name = "myexample"; paths = [ pkgs.hello pkgs.stack ]; postBuild = "echo links added"; }
410410- *
411411- * This creates a derivation with a directory structure like the following:
412412- *
413413- * /nix/store/sglsr5g079a5235hy29da3mq3hv8sjmm-myexample
414414- * |-- bin
415415- * | |-- hello -> /nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10/bin/hello
416416- * | `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/bin/stack
417417- * `-- share
418418- * |-- bash-completion
419419- * | `-- completions
420420- * | `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/bash-completion/completions/stack
421421- * |-- fish
422422- * | `-- vendor_completions.d
423423- * | `-- stack.fish -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/fish/vendor_completions.d/stack.fish
424424- * ...
425425- *
426426- * symlinkJoin and linkFarm are similar functions, but they output
427427- * derivations with different structure.
428428- *
429429- * symlinkJoin is used to create a derivation with a familiar directory
430430- * structure (top-level bin/, share/, etc), but with all actual files being symlinks to
431431- * the files in the input derivations.
432432- *
433433- * symlinkJoin is used many places in nixpkgs to create a single derivation
434434- * that appears to contain binaries, libraries, documentation, etc from
435435- * multiple input derivations.
436436- *
437437- * linkFarm is instead used to create a simple derivation with symlinks to
438438- * other derivations. A derivation created with linkFarm is often used in CI
439439- * as a easy way to build multiple derivations at once.
442442+ Create a forest of symlinks to the files in `paths'.
443443+444444+ This creates a single derivation that replicates the directory structure
445445+ of all the input paths.
446446+447447+ BEWARE: it may not "work right" when the passed paths contain symlinks to directories.
448448+449449+ Example:
450450+451451+452452+ # adds symlinks of hello to current build.
453453+ symlinkJoin { name = "myhello"; paths = [ pkgs.hello ]; }
454454+455455+456456+457457+458458+ # adds symlinks of hello and stack to current build and prints "links added"
459459+ symlinkJoin { name = "myexample"; paths = [ pkgs.hello pkgs.stack ]; postBuild = "echo links added"; }
460460+461461+462462+ This creates a derivation with a directory structure like the following:
463463+464464+465465+ /nix/store/sglsr5g079a5235hy29da3mq3hv8sjmm-myexample
466466+ |-- bin
467467+ | |-- hello -> /nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10/bin/hello
468468+ | `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/bin/stack
469469+ `-- share
470470+ |-- bash-completion
471471+ | `-- completions
472472+ | `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/bash-completion/completions/stack
473473+ |-- fish
474474+ | `-- vendor_completions.d
475475+ | `-- stack.fish -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/fish/vendor_completions.d/stack.fish
476476+ ...
477477+478478+479479+ symlinkJoin and linkFarm are similar functions, but they output
480480+ derivations with different structure.
481481+482482+ symlinkJoin is used to create a derivation with a familiar directory
483483+ structure (top-level bin/, share/, etc), but with all actual files being symlinks to
484484+ the files in the input derivations.
485485+486486+ symlinkJoin is used many places in nixpkgs to create a single derivation
487487+ that appears to contain binaries, libraries, documentation, etc from
488488+ multiple input derivations.
489489+490490+ linkFarm is instead used to create a simple derivation with symlinks to
491491+ other derivations. A derivation created with linkFarm is often used in CI
492492+ as a easy way to build multiple derivations at once.
440493 */
441494 symlinkJoin =
442495 args_@{ name
···462515 '';
463516464517 /*
465465- * Quickly create a set of symlinks to derivations.
466466- *
467467- * This creates a simple derivation with symlinks to all inputs.
468468- *
469469- * entries can be a list of attribute sets like
470470- * [ { name = "name" ; path = "/nix/store/..."; } ]
471471- *
472472- * or an attribute set name -> path like:
473473- * { name = "/nix/store/..."; other = "/nix/store/..."; }
474474- *
475475- * Example:
476476- *
477477- * # Symlinks hello and stack paths in store to current $out/hello-test and
478478- * # $out/foobar.
479479- * linkFarm "myexample" [ { name = "hello-test"; path = pkgs.hello; } { name = "foobar"; path = pkgs.stack; } ]
480480- *
481481- * This creates a derivation with a directory structure like the following:
482482- *
483483- * /nix/store/qc5728m4sa344mbks99r3q05mymwm4rw-myexample
484484- * |-- foobar -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1
485485- * `-- hello-test -> /nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10
486486- *
487487- * See the note on symlinkJoin for the difference between linkFarm and symlinkJoin.
518518+ Quickly create a set of symlinks to derivations.
519519+520520+ This creates a simple derivation with symlinks to all inputs.
521521+522522+ entries can be a list of attribute sets like
523523+524524+ [ { name = "name" ; path = "/nix/store/..."; } ]
525525+526526+527527+ or an attribute set name -> path like:
528528+529529+ { name = "/nix/store/..."; other = "/nix/store/..."; }
530530+531531+532532+ Example:
533533+534534+ # Symlinks hello and stack paths in store to current $out/hello-test and
535535+ # $out/foobar.
536536+ linkFarm "myexample" [ { name = "hello-test"; path = pkgs.hello; } { name = "foobar"; path = pkgs.stack; } ]
537537+538538+ This creates a derivation with a directory structure like the following:
539539+540540+ /nix/store/qc5728m4sa344mbks99r3q05mymwm4rw-myexample
541541+ |-- foobar -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1
542542+ `-- hello-test -> /nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10
543543+544544+545545+ See the note on symlinkJoin for the difference between linkFarm and symlinkJoin.
488546 */
489547 linkFarm = name: entries:
490548 let
···510568 '';
511569512570 /*
513513- * Easily create a linkFarm from a set of derivations.
514514- *
515515- * This calls linkFarm with a list of entries created from the list of input
516516- * derivations. It turns each input derivation into an attribute set
517517- * like { name = drv.name ; path = drv }, and passes this to linkFarm.
518518- *
519519- * Example:
520520- *
521521- * # Symlinks the hello, gcc, and ghc derivations in $out
522522- * linkFarmFromDrvs "myexample" [ pkgs.hello pkgs.gcc pkgs.ghc ]
523523- *
524524- * This creates a derivation with a directory structure like the following:
525525- *
526526- * /nix/store/m3s6wkjy9c3wy830201bqsb91nk2yj8c-myexample
527527- * |-- gcc-wrapper-9.2.0 -> /nix/store/fqhjxf9ii4w4gqcsx59fyw2vvj91486a-gcc-wrapper-9.2.0
528528- * |-- ghc-8.6.5 -> /nix/store/gnf3s07bglhbbk4y6m76sbh42siym0s6-ghc-8.6.5
529529- * `-- hello-2.10 -> /nix/store/k0ll91c4npk4lg8lqhx00glg2m735g74-hello-2.10
530530- */
571571+ Easily create a linkFarm from a set of derivations.
572572+573573+ This calls linkFarm with a list of entries created from the list of input
574574+ derivations. It turns each input derivation into an attribute set
575575+ like { name = drv.name ; path = drv }, and passes this to linkFarm.
576576+577577+ Example:
578578+579579+ # Symlinks the hello, gcc, and ghc derivations in $out
580580+ linkFarmFromDrvs "myexample" [ pkgs.hello pkgs.gcc pkgs.ghc ]
581581+582582+ This creates a derivation with a directory structure like the following:
583583+584584+585585+ /nix/store/m3s6wkjy9c3wy830201bqsb91nk2yj8c-myexample
586586+ |-- gcc-wrapper-9.2.0 -> /nix/store/fqhjxf9ii4w4gqcsx59fyw2vvj91486a-gcc-wrapper-9.2.0
587587+ |-- ghc-8.6.5 -> /nix/store/gnf3s07bglhbbk4y6m76sbh42siym0s6-ghc-8.6.5
588588+ `-- hello-2.10 -> /nix/store/k0ll91c4npk4lg8lqhx00glg2m735g74-hello-2.10
589589+590590+ */
531591 linkFarmFromDrvs = name: drvs:
532592 let mkEntryFromDrv = drv: { name = drv.name; path = drv; };
533593 in linkFarm name (map mkEntryFromDrv drvs);
534594535595536596 /*
537537- * Make a package that just contains a setup hook with the given contents.
538538- * This setup hook will be invoked by any package that includes this package
539539- * as a buildInput. Optionally takes a list of substitutions that should be
540540- * applied to the resulting script.
541541- *
542542- * Examples:
543543- * # setup hook that depends on the hello package and runs ./myscript.sh
544544- * myhellohook = makeSetupHook { deps = [ hello ]; } ./myscript.sh;
545545- *
546546- * # writes a Linux-exclusive setup hook where @bash@ myscript.sh is substituted for the
547547- * # bash interpreter.
548548- * myhellohookSub = makeSetupHook {
549549- * name = "myscript-hook";
550550- * deps = [ hello ];
551551- * substitutions = { bash = "${pkgs.bash}/bin/bash"; };
552552- * meta.platforms = lib.platforms.linux;
553553- * } ./myscript.sh;
554554- *
555555- * # setup hook with a package test
556556- * myhellohookTested = makeSetupHook {
557557- * name = "myscript-hook";
558558- * deps = [ hello ];
559559- * substitutions = { bash = "${pkgs.bash}/bin/bash"; };
560560- * meta.platforms = lib.platforms.linux;
561561- * passthru.tests.greeting = callPackage ./test { };
562562- * } ./myscript.sh;
597597+ Make a package that just contains a setup hook with the given contents.
598598+ This setup hook will be invoked by any package that includes this package
599599+ as a buildInput. Optionally takes a list of substitutions that should be
600600+ applied to the resulting script.
601601+602602+ Examples:
603603+ # setup hook that depends on the hello package and runs ./myscript.sh
604604+ myhellohook = makeSetupHook { deps = [ hello ]; } ./myscript.sh;
605605+606606+ # writes a Linux-exclusive setup hook where @bash@ myscript.sh is substituted for the
607607+ # bash interpreter.
608608+ myhellohookSub = makeSetupHook {
609609+ name = "myscript-hook";
610610+ deps = [ hello ];
611611+ substitutions = { bash = "${pkgs.bash}/bin/bash"; };
612612+ meta.platforms = lib.platforms.linux;
613613+ } ./myscript.sh;
614614+615615+ # setup hook with a package test
616616+ myhellohookTested = makeSetupHook {
617617+ name = "myscript-hook";
618618+ deps = [ hello ];
619619+ substitutions = { bash = "${pkgs.bash}/bin/bash"; };
620620+ meta.platforms = lib.platforms.linux;
621621+ passthru.tests.greeting = callPackage ./test { };
622622+ } ./myscript.sh;
563623 */
564624 makeSetupHook =
565625 { name ? lib.warn "calling makeSetupHook without passing a name is deprecated." "hook"
···636696637697638698 /*
639639- * Extract a string's references to derivations and paths (its
640640- * context) and write them to a text file, removing the input string
641641- * itself from the dependency graph. This is useful when you want to
642642- * make a derivation depend on the string's references, but not its
643643- * contents (to avoid unnecessary rebuilds, for example).
644644- *
645645- * Note that this only works as intended on Nix >= 2.3.
699699+ Extract a string's references to derivations and paths (its
700700+ context) and write them to a text file, removing the input string
701701+ itself from the dependency graph. This is useful when you want to
702702+ make a derivation depend on the string's references, but not its
703703+ contents (to avoid unnecessary rebuilds, for example).
704704+705705+ Note that this only works as intended on Nix >= 2.3.
646706 */
647707 writeStringReferencesToFile = string:
648708 /*
649649- * The basic operation this performs is to copy the string context
650650- * from `string' to a second string and wrap that string in a
651651- * derivation. However, that alone is not enough, since nothing in the
652652- * string refers to the output paths of the derivations/paths in its
653653- * context, meaning they'll be considered build-time dependencies and
654654- * removed from the wrapper derivation's closure. Putting the
655655- * necessary output paths in the new string is however not very
656656- * straightforward - the attrset returned by `getContext' contains
657657- * only references to derivations' .drv-paths, not their output
658658- * paths. In order to "convert" them, we try to extract the
659659- * corresponding paths from the original string using regex.
709709+ The basic operation this performs is to copy the string context
710710+ from `string' to a second string and wrap that string in a
711711+ derivation. However, that alone is not enough, since nothing in the
712712+ string refers to the output paths of the derivations/paths in its
713713+ context, meaning they'll be considered build-time dependencies and
714714+ removed from the wrapper derivation's closure. Putting the
715715+ necessary output paths in the new string is however not very
716716+ straightforward - the attrset returned by `getContext' contains
717717+ only references to derivations' .drv-paths, not their output
718718+ paths. In order to "convert" them, we try to extract the
719719+ corresponding paths from the original string using regex.
660720 */
661721 let
662722 # Taken from https://github.com/NixOS/nix/blob/130284b8508dad3c70e8160b15f3d62042fc730a/src/libutil/hash.cc#L84
···718778719779720780 /* Print an error message if the file with the specified name and
721721- * hash doesn't exist in the Nix store. This function should only
722722- * be used by non-redistributable software with an unfree license
723723- * that we need to require the user to download manually. It produces
724724- * packages that cannot be built automatically.
725725- *
726726- * Examples:
727727- *
728728- * requireFile {
729729- * name = "my-file";
730730- * url = "http://example.com/download/";
731731- * sha256 = "ffffffffffffffffffffffffffffffffffffffffffffffffffff";
732732- * }
781781+ hash doesn't exist in the Nix store. This function should only
782782+ be used by non-redistributable software with an unfree license
783783+ that we need to require the user to download manually. It produces
784784+ packages that cannot be built automatically.
785785+786786+ Example:
787787+788788+ requireFile {
789789+ name = "my-file";
790790+ url = "http://example.com/download/";
791791+ sha256 = "ffffffffffffffffffffffffffffffffffffffffffffffffffff";
792792+ }
793793+733794 */
734795 requireFile = { name ? null
735796 , sha256 ? null
···776837 };
777838778839779779- # Copy a path to the Nix store.
780780- # Nix automatically copies files to the store before stringifying paths.
781781- # If you need the store path of a file, ${copyPathToStore <path>} can be
782782- # shortened to ${<path>}.
840840+ /*
841841+ Copy a path to the Nix store.
842842+ Nix automatically copies files to the store before stringifying paths.
843843+ If you need the store path of a file, ${copyPathToStore <path>} can be
844844+ shortened to ${<path>}.
845845+ */
783846 copyPathToStore = builtins.filterSource (p: t: true);
784847785848786786- # Copy a list of paths to the Nix store.
849849+ /*
850850+ Copy a list of paths to the Nix store.
851851+ */
787852 copyPathsToStore = builtins.map copyPathToStore;
788853789854 /* Applies a list of patches to a source directory.
790790- *
791791- * Examples:
792792- *
793793- * # Patching nixpkgs:
794794- * applyPatches {
795795- * src = pkgs.path;
796796- * patches = [
797797- * (pkgs.fetchpatch {
798798- * url = "https://github.com/NixOS/nixpkgs/commit/1f770d20550a413e508e081ddc08464e9d08ba3d.patch";
799799- * sha256 = "1nlzx171y3r3jbk0qhvnl711kmdk57jlq4na8f8bs8wz2pbffymr";
800800- * })
801801- * ];
802802- * }
855855+856856+ Example:
857857+858858+ # Patching nixpkgs:
859859+860860+ applyPatches {
861861+ src = pkgs.path;
862862+ patches = [
863863+ (pkgs.fetchpatch {
864864+ url = "https://github.com/NixOS/nixpkgs/commit/1f770d20550a413e508e081ddc08464e9d08ba3d.patch";
865865+ sha256 = "1nlzx171y3r3jbk0qhvnl711kmdk57jlq4na8f8bs8wz2pbffymr";
866866+ })
867867+ ];
868868+ }
869869+803870 */
804871 applyPatches =
805872 { src