lol

Docs/fix: make doc-strings nixdoc compliant (#213570)

* re-format all doc-strings to make them nixdoc compliant

* reformat comments to make them markdown-renderable

authored by

Johannes Kirschbauer and committed by
GitHub
a2780dc5 652f69f9

+385 -318
+385 -318
pkgs/build-support/trivial-builders.nix
··· 10 10 rec { 11 11 12 12 /* Run the shell command `buildCommand' to produce a store path named 13 - * `name'. The attributes in `env' are added to the environment 14 - * prior to running the command. By default `runCommand` runs in a 15 - * stdenv with no compiler environment. `runCommandCC` uses the default 16 - * stdenv, `pkgs.stdenv`. 17 - * 18 - * Examples: 19 - * runCommand "name" {envVariable = true;} ''echo hello > $out'' 20 - * runCommandCC "name" {} ''gcc -o myfile myfile.c; cp myfile $out''; 21 - * 22 - * The `*Local` variants force a derivation to be built locally, 23 - * it is not substituted. 24 - * 25 - * This is intended for very cheap commands (<1s execution time). 26 - * It saves on the network roundrip and can speed up a build. 27 - * 28 - * It is the same as adding the special fields 29 - * `preferLocalBuild = true;` 30 - * `allowSubstitutes = false;` 31 - * to a derivation’s attributes. 13 + `name'. The attributes in `env' are added to the environment 14 + prior to running the command. By default `runCommand` runs in a 15 + stdenv with no compiler environment. `runCommandCC` uses the default 16 + stdenv, `pkgs.stdenv`. 17 + 18 + Example: 19 + 20 + 21 + runCommand "name" {envVariable = true;} ''echo hello > $out'' 22 + runCommandCC "name" {} ''gcc -o myfile myfile.c; cp myfile $out''; 23 + 24 + 25 + The `*Local` variants force a derivation to be built locally, 26 + it is not substituted. 27 + 28 + This is intended for very cheap commands (<1s execution time). 29 + It saves on the network roundrip and can speed up a build. 30 + 31 + It is the same as adding the special fields 32 + 33 + `preferLocalBuild = true;` 34 + `allowSubstitutes = false;` 35 + 36 + to a derivation’s attributes. 32 37 */ 33 38 runCommand = name: env: runCommandWith { 34 39 stdenv = stdenvNoCC; ··· 53 58 # We shouldn’t force the user to have a cc in scope. 54 59 55 60 /* Generalized version of the `runCommand`-variants 56 - * which does customized behavior via a single 57 - * attribute set passed as the first argument 58 - * instead of having a lot of variants like 59 - * `runCommand*`. Additionally it allows changing 60 - * the used `stdenv` freely and has a more explicit 61 - * approach to changing the arguments passed to 62 - * `stdenv.mkDerivation`. 61 + which does customized behavior via a single 62 + attribute set passed as the first argument 63 + instead of having a lot of variants like 64 + `runCommand*`. Additionally it allows changing 65 + the used `stdenv` freely and has a more explicit 66 + approach to changing the arguments passed to 67 + `stdenv.mkDerivation`. 63 68 */ 64 69 runCommandWith = 65 70 let ··· 91 96 92 97 93 98 /* Writes a text file to the nix store. 94 - * The contents of text is added to the file in the store. 95 - * 96 - * Examples: 97 - * # Writes my-file to /nix/store/<store path> 98 - * writeTextFile { 99 - * name = "my-file"; 100 - * text = '' 101 - * Contents of File 102 - * ''; 103 - * } 104 - * # See also the `writeText` helper function below. 105 - * 106 - * # Writes executable my-file to /nix/store/<store path>/bin/my-file 107 - * writeTextFile { 108 - * name = "my-file"; 109 - * text = '' 110 - * Contents of File 111 - * ''; 112 - * executable = true; 113 - * destination = "/bin/my-file"; 114 - * } 99 + The contents of text is added to the file in the store. 100 + 101 + Example: 102 + 103 + 104 + # Writes my-file to /nix/store/<store path> 105 + writeTextFile { 106 + name = "my-file"; 107 + text = '' 108 + Contents of File 109 + ''; 110 + } 111 + 112 + 113 + See also the `writeText` helper function below. 114 + 115 + 116 + # Writes executable my-file to /nix/store/<store path>/bin/my-file 117 + writeTextFile { 118 + name = "my-file"; 119 + text = '' 120 + Contents of File 121 + ''; 122 + executable = true; 123 + destination = "/bin/my-file"; 124 + } 125 + 126 + 115 127 */ 116 128 writeTextFile = 117 129 { name # the name of the derivation ··· 144 156 ''; 145 157 146 158 /* 147 - * Writes a text file to nix store with no optional parameters available. 148 - * 149 - * Example: 150 - * # Writes contents of file to /nix/store/<store path> 151 - * writeText "my-file" 152 - * '' 153 - * Contents of File 154 - * ''; 155 - * 159 + Writes a text file to nix store with no optional parameters available. 160 + 161 + Example: 162 + 163 + 164 + # Writes contents of file to /nix/store/<store path> 165 + writeText "my-file" 166 + '' 167 + Contents of File 168 + ''; 169 + 170 + 156 171 */ 157 172 writeText = name: text: writeTextFile {inherit name text;}; 158 173 159 174 /* 160 - * Writes a text file to nix store in a specific directory with no 161 - * optional parameters available. 162 - * 163 - * Example: 164 - * # Writes contents of file to /nix/store/<store path>/share/my-file 165 - * writeTextDir "share/my-file" 166 - * '' 167 - * Contents of File 168 - * ''; 169 - * 175 + Writes a text file to nix store in a specific directory with no 176 + optional parameters available. 177 + 178 + Example: 179 + 180 + 181 + # Writes contents of file to /nix/store/<store path>/share/my-file 182 + writeTextDir "share/my-file" 183 + '' 184 + Contents of File 185 + ''; 186 + 187 + 170 188 */ 171 189 writeTextDir = path: text: writeTextFile { 172 190 inherit text; ··· 175 193 }; 176 194 177 195 /* 178 - * Writes a text file to /nix/store/<store path> and marks the file as 179 - * executable. 180 - * 181 - * If passed as a build input, will be used as a setup hook. This makes setup 182 - * hooks more efficient to create: you don't need a derivation that copies 183 - * them to $out/nix-support/setup-hook, instead you can use the file as is. 184 - * 185 - * Example: 186 - * # Writes my-file to /nix/store/<store path> and makes executable 187 - * writeScript "my-file" 188 - * '' 189 - * Contents of File 190 - * ''; 191 - * 196 + Writes a text file to /nix/store/<store path> and marks the file as 197 + executable. 198 + 199 + If passed as a build input, will be used as a setup hook. This makes setup 200 + hooks more efficient to create: you don't need a derivation that copies 201 + them to $out/nix-support/setup-hook, instead you can use the file as is. 202 + 203 + Example: 204 + 205 + 206 + # Writes my-file to /nix/store/<store path> and makes executable 207 + writeScript "my-file" 208 + '' 209 + Contents of File 210 + ''; 211 + 212 + 192 213 */ 193 214 writeScript = name: text: writeTextFile {inherit name text; executable = true;}; 194 215 195 216 /* 196 - * Writes a text file to /nix/store/<store path>/bin/<name> and 197 - * marks the file as executable. 198 - * 199 - * Example: 200 - * # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable. 201 - * writeScriptBin "my-file" 202 - * '' 203 - * Contents of File 204 - * ''; 205 - * 217 + Writes a text file to /nix/store/<store path>/bin/<name> and 218 + marks the file as executable. 219 + 220 + Example: 221 + 222 + 223 + 224 + # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable. 225 + writeScriptBin "my-file" 226 + '' 227 + Contents of File 228 + ''; 229 + 230 + 206 231 */ 207 232 writeScriptBin = name: text: writeTextFile {inherit name text; executable = true; destination = "/bin/${name}";}; 208 233 209 234 /* 210 - * Similar to writeScript. Writes a Shell script and checks its syntax. 211 - * Automatically includes interpreter above the contents passed. 212 - * 213 - * Example: 214 - * # Writes my-file to /nix/store/<store path> and makes executable. 215 - * writeShellScript "my-file" 216 - * '' 217 - * Contents of File 218 - * ''; 219 - * 235 + Similar to writeScript. Writes a Shell script and checks its syntax. 236 + Automatically includes interpreter above the contents passed. 237 + 238 + Example: 239 + 240 + 241 + # Writes my-file to /nix/store/<store path> and makes executable. 242 + writeShellScript "my-file" 243 + '' 244 + Contents of File 245 + ''; 246 + 247 + 220 248 */ 221 249 writeShellScript = name: text: 222 250 writeTextFile { ··· 232 260 }; 233 261 234 262 /* 235 - * Similar to writeShellScript and writeScriptBin. 236 - * Writes an executable Shell script to /nix/store/<store path>/bin/<name> and checks its syntax. 237 - * Automatically includes interpreter above the contents passed. 238 - * 239 - * Example: 240 - * # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable. 241 - * writeShellScriptBin "my-file" 242 - * '' 243 - * Contents of File 244 - * ''; 245 - * 263 + Similar to writeShellScript and writeScriptBin. 264 + Writes an executable Shell script to /nix/store/<store path>/bin/<name> and checks its syntax. 265 + Automatically includes interpreter above the contents passed. 266 + 267 + Example: 268 + 269 + 270 + # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable. 271 + writeShellScriptBin "my-file" 272 + '' 273 + Contents of File 274 + ''; 275 + 276 + 246 277 */ 247 278 writeShellScriptBin = name : text : 248 279 writeTextFile { ··· 259 290 }; 260 291 261 292 /* 262 - * Similar to writeShellScriptBin and writeScriptBin. 263 - * Writes an executable Shell script to /nix/store/<store path>/bin/<name> and 264 - * checks its syntax with shellcheck and the shell's -n option. 265 - * Automatically includes sane set of shellopts (errexit, nounset, pipefail) 266 - * and handles creation of PATH based on runtimeInputs 267 - * 268 - * Note that the checkPhase uses stdenv.shell for the test run of the script, 269 - * while the generated shebang uses runtimeShell. If, for whatever reason, 270 - * those were to mismatch you might lose fidelity in the default checks. 271 - * 272 - * Example: 273 - * # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable. 274 - * writeShellApplication { 275 - * name = "my-file"; 276 - * runtimeInputs = [ curl w3m ]; 277 - * text = '' 278 - * curl -s 'https://nixos.org' | w3m -dump -T text/html 279 - * ''; 280 - * } 293 + Similar to writeShellScriptBin and writeScriptBin. 294 + Writes an executable Shell script to /nix/store/<store path>/bin/<name> and 295 + checks its syntax with shellcheck and the shell's -n option. 296 + Automatically includes sane set of shellopts (errexit, nounset, pipefail) 297 + and handles creation of PATH based on runtimeInputs 298 + 299 + Note that the checkPhase uses stdenv.shell for the test run of the script, 300 + while the generated shebang uses runtimeShell. If, for whatever reason, 301 + those were to mismatch you might lose fidelity in the default checks. 302 + 303 + Example: 304 + 305 + Writes my-file to /nix/store/<store path>/bin/my-file and makes executable. 306 + 307 + 308 + writeShellApplication { 309 + name = "my-file"; 310 + runtimeInputs = [ curl w3m ]; 311 + text = '' 312 + curl -s 'https://nixos.org' | w3m -dump -T text/html 313 + ''; 314 + } 315 + 281 316 */ 282 317 writeShellApplication = 283 318 { name ··· 334 369 335 370 336 371 /* concat a list of files to the nix store. 337 - * The contents of files are added to the file in the store. 338 - * 339 - * Examples: 340 - * # Writes my-file to /nix/store/<store path> 341 - * concatTextFile { 342 - * name = "my-file"; 343 - * files = [ drv1 "${drv2}/path/to/file" ]; 344 - * } 345 - * # See also the `concatText` helper function below. 346 - * 347 - * # Writes executable my-file to /nix/store/<store path>/bin/my-file 348 - * concatTextFile { 349 - * name = "my-file"; 350 - * files = [ drv1 "${drv2}/path/to/file" ]; 351 - * executable = true; 352 - * destination = "/bin/my-file"; 353 - * } 372 + The contents of files are added to the file in the store. 373 + 374 + Example: 375 + 376 + 377 + # Writes my-file to /nix/store/<store path> 378 + concatTextFile { 379 + name = "my-file"; 380 + files = [ drv1 "${drv2}/path/to/file" ]; 381 + } 382 + 383 + 384 + See also the `concatText` helper function below. 385 + 386 + 387 + # Writes executable my-file to /nix/store/<store path>/bin/my-file 388 + concatTextFile { 389 + name = "my-file"; 390 + files = [ drv1 "${drv2}/path/to/file" ]; 391 + executable = true; 392 + destination = "/bin/my-file"; 393 + } 394 + 395 + 354 396 */ 355 397 concatTextFile = 356 398 { name # the name of the derivation ··· 373 415 374 416 375 417 /* 376 - * Writes a text file to nix store with no optional parameters available. 377 - * 378 - * Example: 379 - * # Writes contents of files to /nix/store/<store path> 380 - * concatText "my-file" [ file1 file2 ] 381 - * 418 + Writes a text file to nix store with no optional parameters available. 419 + 420 + Example: 421 + 422 + 423 + # Writes contents of files to /nix/store/<store path> 424 + concatText "my-file" [ file1 file2 ] 425 + 426 + 382 427 */ 383 428 concatText = name: files: concatTextFile { inherit name files; }; 384 429 385 - /* 386 - * Writes a text file to nix store with and mark it as executable. 387 - * 388 - * Example: 389 - * # Writes contents of files to /nix/store/<store path> 390 - * concatScript "my-file" [ file1 file2 ] 391 - * 430 + /* 431 + Writes a text file to nix store with and mark it as executable. 432 + 433 + Example: 434 + # Writes contents of files to /nix/store/<store path> 435 + concatScript "my-file" [ file1 file2 ] 436 + 392 437 */ 393 438 concatScript = name: files: concatTextFile { inherit name files; executable = true; }; 394 439 395 440 396 441 /* 397 - * Create a forest of symlinks to the files in `paths'. 398 - * 399 - * This creates a single derivation that replicates the directory structure 400 - * of all the input paths. 401 - * 402 - * BEWARE: it may not "work right" when the passed paths contain symlinks to directories. 403 - * 404 - * Examples: 405 - * # adds symlinks of hello to current build. 406 - * symlinkJoin { name = "myhello"; paths = [ pkgs.hello ]; } 407 - * 408 - * # adds symlinks of hello and stack to current build and prints "links added" 409 - * symlinkJoin { name = "myexample"; paths = [ pkgs.hello pkgs.stack ]; postBuild = "echo links added"; } 410 - * 411 - * This creates a derivation with a directory structure like the following: 412 - * 413 - * /nix/store/sglsr5g079a5235hy29da3mq3hv8sjmm-myexample 414 - * |-- bin 415 - * | |-- hello -> /nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10/bin/hello 416 - * | `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/bin/stack 417 - * `-- share 418 - * |-- bash-completion 419 - * | `-- completions 420 - * | `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/bash-completion/completions/stack 421 - * |-- fish 422 - * | `-- vendor_completions.d 423 - * | `-- stack.fish -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/fish/vendor_completions.d/stack.fish 424 - * ... 425 - * 426 - * symlinkJoin and linkFarm are similar functions, but they output 427 - * derivations with different structure. 428 - * 429 - * symlinkJoin is used to create a derivation with a familiar directory 430 - * structure (top-level bin/, share/, etc), but with all actual files being symlinks to 431 - * the files in the input derivations. 432 - * 433 - * symlinkJoin is used many places in nixpkgs to create a single derivation 434 - * that appears to contain binaries, libraries, documentation, etc from 435 - * multiple input derivations. 436 - * 437 - * linkFarm is instead used to create a simple derivation with symlinks to 438 - * other derivations. A derivation created with linkFarm is often used in CI 439 - * as a easy way to build multiple derivations at once. 442 + Create a forest of symlinks to the files in `paths'. 443 + 444 + This creates a single derivation that replicates the directory structure 445 + of all the input paths. 446 + 447 + BEWARE: it may not "work right" when the passed paths contain symlinks to directories. 448 + 449 + Example: 450 + 451 + 452 + # adds symlinks of hello to current build. 453 + symlinkJoin { name = "myhello"; paths = [ pkgs.hello ]; } 454 + 455 + 456 + 457 + 458 + # adds symlinks of hello and stack to current build and prints "links added" 459 + symlinkJoin { name = "myexample"; paths = [ pkgs.hello pkgs.stack ]; postBuild = "echo links added"; } 460 + 461 + 462 + This creates a derivation with a directory structure like the following: 463 + 464 + 465 + /nix/store/sglsr5g079a5235hy29da3mq3hv8sjmm-myexample 466 + |-- bin 467 + | |-- hello -> /nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10/bin/hello 468 + | `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/bin/stack 469 + `-- share 470 + |-- bash-completion 471 + | `-- completions 472 + | `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/bash-completion/completions/stack 473 + |-- fish 474 + | `-- vendor_completions.d 475 + | `-- stack.fish -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/fish/vendor_completions.d/stack.fish 476 + ... 477 + 478 + 479 + symlinkJoin and linkFarm are similar functions, but they output 480 + derivations with different structure. 481 + 482 + symlinkJoin is used to create a derivation with a familiar directory 483 + structure (top-level bin/, share/, etc), but with all actual files being symlinks to 484 + the files in the input derivations. 485 + 486 + symlinkJoin is used many places in nixpkgs to create a single derivation 487 + that appears to contain binaries, libraries, documentation, etc from 488 + multiple input derivations. 489 + 490 + linkFarm is instead used to create a simple derivation with symlinks to 491 + other derivations. A derivation created with linkFarm is often used in CI 492 + as a easy way to build multiple derivations at once. 440 493 */ 441 494 symlinkJoin = 442 495 args_@{ name ··· 462 515 ''; 463 516 464 517 /* 465 - * Quickly create a set of symlinks to derivations. 466 - * 467 - * This creates a simple derivation with symlinks to all inputs. 468 - * 469 - * entries can be a list of attribute sets like 470 - * [ { name = "name" ; path = "/nix/store/..."; } ] 471 - * 472 - * or an attribute set name -> path like: 473 - * { name = "/nix/store/..."; other = "/nix/store/..."; } 474 - * 475 - * Example: 476 - * 477 - * # Symlinks hello and stack paths in store to current $out/hello-test and 478 - * # $out/foobar. 479 - * linkFarm "myexample" [ { name = "hello-test"; path = pkgs.hello; } { name = "foobar"; path = pkgs.stack; } ] 480 - * 481 - * This creates a derivation with a directory structure like the following: 482 - * 483 - * /nix/store/qc5728m4sa344mbks99r3q05mymwm4rw-myexample 484 - * |-- foobar -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1 485 - * `-- hello-test -> /nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10 486 - * 487 - * See the note on symlinkJoin for the difference between linkFarm and symlinkJoin. 518 + Quickly create a set of symlinks to derivations. 519 + 520 + This creates a simple derivation with symlinks to all inputs. 521 + 522 + entries can be a list of attribute sets like 523 + 524 + [ { name = "name" ; path = "/nix/store/..."; } ] 525 + 526 + 527 + or an attribute set name -> path like: 528 + 529 + { name = "/nix/store/..."; other = "/nix/store/..."; } 530 + 531 + 532 + Example: 533 + 534 + # Symlinks hello and stack paths in store to current $out/hello-test and 535 + # $out/foobar. 536 + linkFarm "myexample" [ { name = "hello-test"; path = pkgs.hello; } { name = "foobar"; path = pkgs.stack; } ] 537 + 538 + This creates a derivation with a directory structure like the following: 539 + 540 + /nix/store/qc5728m4sa344mbks99r3q05mymwm4rw-myexample 541 + |-- foobar -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1 542 + `-- hello-test -> /nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10 543 + 544 + 545 + See the note on symlinkJoin for the difference between linkFarm and symlinkJoin. 488 546 */ 489 547 linkFarm = name: entries: 490 548 let ··· 510 568 ''; 511 569 512 570 /* 513 - * Easily create a linkFarm from a set of derivations. 514 - * 515 - * This calls linkFarm with a list of entries created from the list of input 516 - * derivations. It turns each input derivation into an attribute set 517 - * like { name = drv.name ; path = drv }, and passes this to linkFarm. 518 - * 519 - * Example: 520 - * 521 - * # Symlinks the hello, gcc, and ghc derivations in $out 522 - * linkFarmFromDrvs "myexample" [ pkgs.hello pkgs.gcc pkgs.ghc ] 523 - * 524 - * This creates a derivation with a directory structure like the following: 525 - * 526 - * /nix/store/m3s6wkjy9c3wy830201bqsb91nk2yj8c-myexample 527 - * |-- gcc-wrapper-9.2.0 -> /nix/store/fqhjxf9ii4w4gqcsx59fyw2vvj91486a-gcc-wrapper-9.2.0 528 - * |-- ghc-8.6.5 -> /nix/store/gnf3s07bglhbbk4y6m76sbh42siym0s6-ghc-8.6.5 529 - * `-- hello-2.10 -> /nix/store/k0ll91c4npk4lg8lqhx00glg2m735g74-hello-2.10 530 - */ 571 + Easily create a linkFarm from a set of derivations. 572 + 573 + This calls linkFarm with a list of entries created from the list of input 574 + derivations. It turns each input derivation into an attribute set 575 + like { name = drv.name ; path = drv }, and passes this to linkFarm. 576 + 577 + Example: 578 + 579 + # Symlinks the hello, gcc, and ghc derivations in $out 580 + linkFarmFromDrvs "myexample" [ pkgs.hello pkgs.gcc pkgs.ghc ] 581 + 582 + This creates a derivation with a directory structure like the following: 583 + 584 + 585 + /nix/store/m3s6wkjy9c3wy830201bqsb91nk2yj8c-myexample 586 + |-- gcc-wrapper-9.2.0 -> /nix/store/fqhjxf9ii4w4gqcsx59fyw2vvj91486a-gcc-wrapper-9.2.0 587 + |-- ghc-8.6.5 -> /nix/store/gnf3s07bglhbbk4y6m76sbh42siym0s6-ghc-8.6.5 588 + `-- hello-2.10 -> /nix/store/k0ll91c4npk4lg8lqhx00glg2m735g74-hello-2.10 589 + 590 + */ 531 591 linkFarmFromDrvs = name: drvs: 532 592 let mkEntryFromDrv = drv: { name = drv.name; path = drv; }; 533 593 in linkFarm name (map mkEntryFromDrv drvs); 534 594 535 595 536 596 /* 537 - * Make a package that just contains a setup hook with the given contents. 538 - * This setup hook will be invoked by any package that includes this package 539 - * as a buildInput. Optionally takes a list of substitutions that should be 540 - * applied to the resulting script. 541 - * 542 - * Examples: 543 - * # setup hook that depends on the hello package and runs ./myscript.sh 544 - * myhellohook = makeSetupHook { deps = [ hello ]; } ./myscript.sh; 545 - * 546 - * # writes a Linux-exclusive setup hook where @bash@ myscript.sh is substituted for the 547 - * # bash interpreter. 548 - * myhellohookSub = makeSetupHook { 549 - * name = "myscript-hook"; 550 - * deps = [ hello ]; 551 - * substitutions = { bash = "${pkgs.bash}/bin/bash"; }; 552 - * meta.platforms = lib.platforms.linux; 553 - * } ./myscript.sh; 554 - * 555 - * # setup hook with a package test 556 - * myhellohookTested = makeSetupHook { 557 - * name = "myscript-hook"; 558 - * deps = [ hello ]; 559 - * substitutions = { bash = "${pkgs.bash}/bin/bash"; }; 560 - * meta.platforms = lib.platforms.linux; 561 - * passthru.tests.greeting = callPackage ./test { }; 562 - * } ./myscript.sh; 597 + Make a package that just contains a setup hook with the given contents. 598 + This setup hook will be invoked by any package that includes this package 599 + as a buildInput. Optionally takes a list of substitutions that should be 600 + applied to the resulting script. 601 + 602 + Examples: 603 + # setup hook that depends on the hello package and runs ./myscript.sh 604 + myhellohook = makeSetupHook { deps = [ hello ]; } ./myscript.sh; 605 + 606 + # writes a Linux-exclusive setup hook where @bash@ myscript.sh is substituted for the 607 + # bash interpreter. 608 + myhellohookSub = makeSetupHook { 609 + name = "myscript-hook"; 610 + deps = [ hello ]; 611 + substitutions = { bash = "${pkgs.bash}/bin/bash"; }; 612 + meta.platforms = lib.platforms.linux; 613 + } ./myscript.sh; 614 + 615 + # setup hook with a package test 616 + myhellohookTested = makeSetupHook { 617 + name = "myscript-hook"; 618 + deps = [ hello ]; 619 + substitutions = { bash = "${pkgs.bash}/bin/bash"; }; 620 + meta.platforms = lib.platforms.linux; 621 + passthru.tests.greeting = callPackage ./test { }; 622 + } ./myscript.sh; 563 623 */ 564 624 makeSetupHook = 565 625 { name ? lib.warn "calling makeSetupHook without passing a name is deprecated." "hook" ··· 636 696 637 697 638 698 /* 639 - * Extract a string's references to derivations and paths (its 640 - * context) and write them to a text file, removing the input string 641 - * itself from the dependency graph. This is useful when you want to 642 - * make a derivation depend on the string's references, but not its 643 - * contents (to avoid unnecessary rebuilds, for example). 644 - * 645 - * Note that this only works as intended on Nix >= 2.3. 699 + Extract a string's references to derivations and paths (its 700 + context) and write them to a text file, removing the input string 701 + itself from the dependency graph. This is useful when you want to 702 + make a derivation depend on the string's references, but not its 703 + contents (to avoid unnecessary rebuilds, for example). 704 + 705 + Note that this only works as intended on Nix >= 2.3. 646 706 */ 647 707 writeStringReferencesToFile = string: 648 708 /* 649 - * The basic operation this performs is to copy the string context 650 - * from `string' to a second string and wrap that string in a 651 - * derivation. However, that alone is not enough, since nothing in the 652 - * string refers to the output paths of the derivations/paths in its 653 - * context, meaning they'll be considered build-time dependencies and 654 - * removed from the wrapper derivation's closure. Putting the 655 - * necessary output paths in the new string is however not very 656 - * straightforward - the attrset returned by `getContext' contains 657 - * only references to derivations' .drv-paths, not their output 658 - * paths. In order to "convert" them, we try to extract the 659 - * corresponding paths from the original string using regex. 709 + The basic operation this performs is to copy the string context 710 + from `string' to a second string and wrap that string in a 711 + derivation. However, that alone is not enough, since nothing in the 712 + string refers to the output paths of the derivations/paths in its 713 + context, meaning they'll be considered build-time dependencies and 714 + removed from the wrapper derivation's closure. Putting the 715 + necessary output paths in the new string is however not very 716 + straightforward - the attrset returned by `getContext' contains 717 + only references to derivations' .drv-paths, not their output 718 + paths. In order to "convert" them, we try to extract the 719 + corresponding paths from the original string using regex. 660 720 */ 661 721 let 662 722 # Taken from https://github.com/NixOS/nix/blob/130284b8508dad3c70e8160b15f3d62042fc730a/src/libutil/hash.cc#L84 ··· 718 778 719 779 720 780 /* Print an error message if the file with the specified name and 721 - * hash doesn't exist in the Nix store. This function should only 722 - * be used by non-redistributable software with an unfree license 723 - * that we need to require the user to download manually. It produces 724 - * packages that cannot be built automatically. 725 - * 726 - * Examples: 727 - * 728 - * requireFile { 729 - * name = "my-file"; 730 - * url = "http://example.com/download/"; 731 - * sha256 = "ffffffffffffffffffffffffffffffffffffffffffffffffffff"; 732 - * } 781 + hash doesn't exist in the Nix store. This function should only 782 + be used by non-redistributable software with an unfree license 783 + that we need to require the user to download manually. It produces 784 + packages that cannot be built automatically. 785 + 786 + Example: 787 + 788 + requireFile { 789 + name = "my-file"; 790 + url = "http://example.com/download/"; 791 + sha256 = "ffffffffffffffffffffffffffffffffffffffffffffffffffff"; 792 + } 793 + 733 794 */ 734 795 requireFile = { name ? null 735 796 , sha256 ? null ··· 776 837 }; 777 838 778 839 779 - # Copy a path to the Nix store. 780 - # Nix automatically copies files to the store before stringifying paths. 781 - # If you need the store path of a file, ${copyPathToStore <path>} can be 782 - # shortened to ${<path>}. 840 + /* 841 + Copy a path to the Nix store. 842 + Nix automatically copies files to the store before stringifying paths. 843 + If you need the store path of a file, ${copyPathToStore <path>} can be 844 + shortened to ${<path>}. 845 + */ 783 846 copyPathToStore = builtins.filterSource (p: t: true); 784 847 785 848 786 - # Copy a list of paths to the Nix store. 849 + /* 850 + Copy a list of paths to the Nix store. 851 + */ 787 852 copyPathsToStore = builtins.map copyPathToStore; 788 853 789 854 /* Applies a list of patches to a source directory. 790 - * 791 - * Examples: 792 - * 793 - * # Patching nixpkgs: 794 - * applyPatches { 795 - * src = pkgs.path; 796 - * patches = [ 797 - * (pkgs.fetchpatch { 798 - * url = "https://github.com/NixOS/nixpkgs/commit/1f770d20550a413e508e081ddc08464e9d08ba3d.patch"; 799 - * sha256 = "1nlzx171y3r3jbk0qhvnl711kmdk57jlq4na8f8bs8wz2pbffymr"; 800 - * }) 801 - * ]; 802 - * } 855 + 856 + Example: 857 + 858 + # Patching nixpkgs: 859 + 860 + applyPatches { 861 + src = pkgs.path; 862 + patches = [ 863 + (pkgs.fetchpatch { 864 + url = "https://github.com/NixOS/nixpkgs/commit/1f770d20550a413e508e081ddc08464e9d08ba3d.patch"; 865 + sha256 = "1nlzx171y3r3jbk0qhvnl711kmdk57jlq4na8f8bs8wz2pbffymr"; 866 + }) 867 + ]; 868 + } 869 + 803 870 */ 804 871 applyPatches = 805 872 { src