1 { lib, config, stdenv, stdenvNoCC, jq, lndir, runtimeShell, shellcheck-minimal }:
12 # Docs in doc/build-helpers/trivial-build-helpers.chapter.md
13 # See https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-runCommand
14 runCommand = name: env: runCommandWith {
20 # Docs in doc/build-helpers/trivial-build-helpers.chapter.md
21 # See https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-runCommandLocal
22 runCommandLocal = name: env: runCommandWith {
28 # Docs in doc/build-helpers/trivial-build-helpers.chapter.md
29 # See https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-runCommandCC
30 runCommandCC = name: env: runCommandWith {
36 # `runCommandCCLocal` left out on purpose.
37 # We shouldn’t force the user to have a cc in scope.
39 # Docs in doc/build-helpers/trivial-build-helpers.chapter.md
40 # See https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-runCommandWith
43 # prevent infinite recursion for the default stdenv value
44 defaultStdenv = stdenv;
47 # which stdenv to use, defaults to a stdenv with a C compiler, pkgs.stdenv
48 stdenv ? defaultStdenv
49 # whether to build this derivation locally instead of substituting
51 # extra arguments to pass to stdenv.mkDerivation
52 , derivationArgs ? { }
53 # name of the resulting derivation
55 # TODO(@Artturin): enable strictDeps always
57 stdenv.mkDerivation ({
58 enableParallelBuilding = true;
59 inherit buildCommand name;
60 passAsFile = [ "buildCommand" ]
61 ++ (derivationArgs.passAsFile or [ ]);
63 // lib.optionalAttrs (! derivationArgs?meta) {
64 pos = let args = builtins.attrNames derivationArgs; in
65 if builtins.length args > 0
66 then builtins.unsafeGetAttrPos (builtins.head args) derivationArgs
69 // (lib.optionalAttrs runLocal {
70 preferLocalBuild = true;
71 allowSubstitutes = false;
73 // builtins.removeAttrs derivationArgs [ "passAsFile" ]);
76 # Docs in doc/build-helpers/trivial-build-helpers.chapter.md
77 # See https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-writeTextFile
86 , allowSubstitutes ? false
87 , preferLocalBuild ? true
88 , derivationArgs ? { }
90 assert lib.assertMsg (destination != "" -> (lib.hasPrefix "/" destination && destination != "/")) ''
91 destination must be an absolute path, relative to the derivation's out path,
92 got '${destination}' instead.
94 Ensure that the path starts with a / and specifies at least the filename.
98 matches = builtins.match "/bin/([^/]+)" destination;
102 inherit text executable checkPhase allowSubstitutes preferLocalBuild;
103 passAsFile = [ "text" ]
104 ++ derivationArgs.passAsFile or [ ];
105 meta = lib.optionalAttrs (executable && matches != null)
107 mainProgram = lib.head matches;
108 } // meta // derivationArgs.meta or {};
109 passthru = passthru // derivationArgs.passthru or {};
110 } // removeAttrs derivationArgs [ "passAsFile" "meta" "passthru" ])
112 target=$out${lib.escapeShellArg destination}
113 mkdir -p "$(dirname "$target")"
115 if [ -e "$textPath" ]; then
116 mv "$textPath" "$target"
118 echo -n "$text" > "$target"
121 if [ -n "$executable" ]; then
128 # See doc/build-helpers/trivial-build-helpers.chapter.md
129 # or https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-text-writing
130 writeText = name: text:
131 # TODO: To fully deprecate, replace the assertion with `lib.isString` and remove the warning
132 assert lib.assertMsg (lib.strings.isConvertibleWithToString text) ''
133 pkgs.writeText ${lib.strings.escapeNixString name}: The second argument should be a string, but it's a ${builtins.typeOf text} instead.'';
134 lib.warnIf (! lib.isString text) ''
135 pkgs.writeText ${lib.strings.escapeNixString name}: The second argument should be a string, but it's a ${builtins.typeOf text} instead, which is deprecated. Use `toString` to convert the value to a string first.''
136 writeTextFile { inherit name text; };
138 # See doc/build-helpers/trivial-build-helpers.chapter.md
139 # or https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-text-writing
140 writeTextDir = path: text: writeTextFile {
142 name = builtins.baseNameOf path;
143 destination = "/${path}";
146 # See doc/build-helpers/trivial-build-helpers.chapter.md
147 # or https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-text-writing
148 writeScript = name: text: writeTextFile { inherit name text; executable = true; };
150 # See doc/build-helpers/trivial-build-helpers.chapter.md
151 # or https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-text-writing
152 writeScriptBin = name: text: writeTextFile {
155 destination = "/bin/${name}";
158 # See doc/build-helpers/trivial-build-helpers.chapter.md
159 # or https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-text-writing
160 writeShellScript = name: text:
169 ${stdenv.shellDryRun} "$target"
173 # See doc/build-helpers/trivial-build-helpers.chapter.md
174 # or https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-text-writing
175 writeShellScriptBin = name: text:
179 destination = "/bin/${name}";
185 ${stdenv.shellDryRun} "$target"
187 meta.mainProgram = name;
190 # TODO: move parameter documentation to the Nixpkgs manual
191 # See doc/build-helpers/trivial-build-helpers.chapter.md
192 # or https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-writeShellApplication
193 writeShellApplication =
196 The name of the script to write.
202 The shell script's text, not including a shebang.
208 Inputs to add to the shell script's `$PATH` at runtime.
210 Type: [String|Derivation]
214 Extra environment variables to set at runtime.
220 `stdenv.mkDerivation`'s `meta` argument.
226 `stdenv.mkDerivation`'s `passthru` argument.
232 The `checkPhase` to run. Defaults to `shellcheck` on supported
233 platforms and `bash -n`.
235 The script path will be given as `$target` in the `checkPhase`.
241 Checks to exclude when running `shellcheck`, e.g. `[ "SC2016" ]`.
243 See <https://www.shellcheck.net/wiki/> for a list of checks.
247 excludeShellChecks ? [ ],
249 Extra command-line flags to pass to ShellCheck.
253 extraShellCheckFlags ? [ ],
255 Bash options to activate with `set -o` at the start of the script.
257 Defaults to `[ "errexit" "nounset" "pipefail" ]`.
261 bashOptions ? [ "errexit" "nounset" "pipefail" ],
262 /* Extra arguments to pass to `stdenv.mkDerivation`.
265 Certain derivation attributes are used internally,
266 overriding those could cause problems.
271 derivationArgs ? { },
274 inherit name meta passthru derivationArgs;
276 destination = "/bin/${name}";
277 allowSubstitutes = true;
278 preferLocalBuild = false;
281 ${lib.concatMapStringsSep "\n" (option: "set -o ${option}") bashOptions}
282 '' + lib.optionalString (runtimeEnv != null)
286 ${lib.toShellVar name value}
290 + lib.optionalString (runtimeInputs != [ ]) ''
292 export PATH="${lib.makeBinPath runtimeInputs}:$PATH"
299 # GHC (=> shellcheck) isn't supported on some platforms (such as risc-v)
300 # but we still want to use writeShellApplication on those platforms
302 shellcheckSupported = lib.meta.availableOn stdenv.buildPlatform shellcheck-minimal.compiler;
303 excludeFlags = lib.optionals (excludeShellChecks != [ ]) [ "--exclude" (lib.concatStringsSep "," excludeShellChecks) ];
304 shellcheckCommand = lib.optionalString shellcheckSupported ''
305 # use shellcheck which does not include docs
306 # pandoc takes long to build and documentation isn't needed for just running the cli
307 ${lib.getExe shellcheck-minimal} ${lib.escapeShellArgs (excludeFlags ++ extraShellCheckFlags)} "$target"
310 if checkPhase == null then ''
312 ${stdenv.shellDryRun} "$target"
320 # TODO: add to writers? pkgs/build-support/writers
321 writeCBin = pname: code:
326 passAsFile = [ "code" ];
327 # Pointless to do this on a remote machine.
328 preferLocalBuild = true;
329 allowSubstitutes = false;
336 mkdir -p "$(dirname "$n")"
337 mv "$codePath" code.c
338 $CC -x c code.c -o "$n"
341 # TODO: deduplicate with documentation in doc/build-helpers/trivial-build-helpers.chapter.md
342 # see also https://github.com/NixOS/nixpkgs/pull/249721
343 # See https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-concatText
344 /* concat a list of files to the nix store.
345 The contents of files are added to the file in the store.
350 # Writes my-file to /nix/store/<store path>
353 files = [ drv1 "${drv2}/path/to/file" ];
357 See also the `concatText` helper function below.
360 # Writes executable my-file to /nix/store/<store path>/bin/my-file
363 files = [ drv1 "${drv2}/path/to/file" ];
365 destination = "/bin/my-file";
371 { name # the name of the derivation
373 , executable ? false # run chmod +x ?
374 , destination ? "" # relative path appended to $out eg "/bin/foo"
375 , checkPhase ? "" # syntax checks, e.g. for scripts
380 { inherit files executable checkPhase meta passthru destination; }
382 file=$out$destination
383 mkdir -p "$(dirname "$file")"
386 if [ -n "$executable" ]; then
393 # TODO: deduplicate with documentation in doc/build-helpers/trivial-build-helpers.chapter.md
394 # see also https://github.com/NixOS/nixpkgs/pull/249721
395 # See https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-concatText
397 Writes a text file to nix store with no optional parameters available.
402 # Writes contents of files to /nix/store/<store path>
403 concatText "my-file" [ file1 file2 ]
407 concatText = name: files: concatTextFile { inherit name files; };
409 # TODO: deduplicate with documentation in doc/build-helpers/trivial-build-helpers.chapter.md
410 # see also https://github.com/NixOS/nixpkgs/pull/249721
411 # See https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-concatText
413 Writes a text file to nix store with and mark it as executable.
416 # Writes contents of files to /nix/store/<store path>
417 concatScript "my-file" [ file1 file2 ]
420 concatScript = name: files: concatTextFile { inherit name files; executable = true; };
424 TODO: Deduplicate this documentation.
425 More docs in doc/build-helpers/trivial-build-helpers.chapter.md
426 See https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-symlinkJoin
428 Create a forest of symlinks to the files in `paths`.
430 This creates a single derivation that replicates the directory structure
431 of all the input paths.
433 BEWARE: it may not "work right" when the passed paths contain symlinks to directories.
438 # adds symlinks of hello to current build.
439 symlinkJoin { name = "myhello"; paths = [ pkgs.hello ]; }
444 # adds symlinks of hello and stack to current build and prints "links added"
445 symlinkJoin { name = "myexample"; paths = [ pkgs.hello pkgs.stack ]; postBuild = "echo links added"; }
448 This creates a derivation with a directory structure like the following:
451 /nix/store/sglsr5g079a5235hy29da3mq3hv8sjmm-myexample
453 | |-- hello -> /nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10/bin/hello
454 | `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/bin/stack
458 | `-- stack -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/bash-completion/completions/stack
460 | `-- vendor_completions.d
461 | `-- stack.fish -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1/share/fish/vendor_completions.d/stack.fish
465 symlinkJoin and linkFarm are similar functions, but they output
466 derivations with different structure.
468 symlinkJoin is used to create a derivation with a familiar directory
469 structure (top-level bin/, share/, etc), but with all actual files being symlinks to
470 the files in the input derivations.
472 symlinkJoin is used many places in nixpkgs to create a single derivation
473 that appears to contain binaries, libraries, documentation, etc from
474 multiple input derivations.
476 linkFarm is instead used to create a simple derivation with symlinks to
477 other derivations. A derivation created with linkFarm is often used in CI
478 as a easy way to build multiple derivations at once.
483 assert lib.assertMsg (args_ ? pname && args_ ? version)
484 "symlinkJoin requires either a `name` OR `pname` and `version`";
485 "${args_.pname}-${args_.version}"
487 , preferLocalBuild ? true
488 , allowSubstitutes ? false
493 args = removeAttrs args_ [ "name" "postBuild" ]
495 inherit preferLocalBuild allowSubstitutes;
496 passAsFile = [ "paths" ];
497 }; # pass the defaults
502 for i in $(cat $pathsPath); do
503 ${lndir}/bin/lndir -silent $i $out
508 # TODO: move linkFarm docs to the Nixpkgs manual
510 Quickly create a set of symlinks to derivations.
512 This creates a simple derivation with symlinks to all inputs.
514 entries can be a list of attribute sets like
516 [ { name = "name" ; path = "/nix/store/..."; } ]
519 or an attribute set name -> path like:
521 { name = "/nix/store/..."; other = "/nix/store/..."; }
526 # Symlinks hello and stack paths in store to current $out/hello-test and
528 linkFarm "myexample" [ { name = "hello-test"; path = pkgs.hello; } { name = "foobar"; path = pkgs.stack; } ]
530 This creates a derivation with a directory structure like the following:
532 /nix/store/qc5728m4sa344mbks99r3q05mymwm4rw-myexample
533 |-- foobar -> /nix/store/6lzdpxshx78281vy056lbk553ijsdr44-stack-2.1.3.1
534 `-- hello-test -> /nix/store/qy93dp4a3rqyn2mz63fbxjg228hffwyw-hello-2.10
537 See the note on symlinkJoin for the difference between linkFarm and symlinkJoin.
539 linkFarm = name: entries:
542 if (lib.isAttrs entries) then entries
543 # We do this foldl to have last-wins semantics in case of repeated entries
544 else if (lib.isList entries) then lib.foldl (a: b: a // { "${b.name}" = b.path; }) { } entries
545 else throw "linkFarm entries must be either attrs or a list!";
547 linkCommands = lib.mapAttrsToList
549 mkdir -p "$(dirname ${lib.escapeShellArg "${name}"})"
550 ln -s ${lib.escapeShellArg "${path}"} ${lib.escapeShellArg "${name}"}
556 preferLocalBuild = true;
557 allowSubstitutes = false;
558 passthru.entries = entries';
562 ${lib.concatStrings linkCommands}
565 # TODO: move linkFarmFromDrvs docs to the Nixpkgs manual
567 Easily create a linkFarm from a set of derivations.
569 This calls linkFarm with a list of entries created from the list of input
570 derivations. It turns each input derivation into an attribute set
571 like { name = drv.name ; path = drv }, and passes this to linkFarm.
575 # Symlinks the hello, gcc, and ghc derivations in $out
576 linkFarmFromDrvs "myexample" [ pkgs.hello pkgs.gcc pkgs.ghc ]
578 This creates a derivation with a directory structure like the following:
581 /nix/store/m3s6wkjy9c3wy830201bqsb91nk2yj8c-myexample
582 |-- gcc-wrapper-9.2.0 -> /nix/store/fqhjxf9ii4w4gqcsx59fyw2vvj91486a-gcc-wrapper-9.2.0
583 |-- ghc-8.6.5 -> /nix/store/gnf3s07bglhbbk4y6m76sbh42siym0s6-ghc-8.6.5
584 `-- hello-2.10 -> /nix/store/k0ll91c4npk4lg8lqhx00glg2m735g74-hello-2.10
587 linkFarmFromDrvs = name: drvs:
588 let mkEntryFromDrv = drv: { name = drv.name; path = drv; };
589 in linkFarm name (map mkEntryFromDrv drvs);
591 # TODO: move onlyBin docs to the Nixpkgs manual
593 Produce a derivation that links to the target derivation's `/bin`,
596 This is useful when your favourite package doesn't have a separate
597 bin output and other contents of the package's output (e.g. setup
598 hooks) cause trouble when used in your environment.
600 onlyBin = drv: runCommand "${drv.name}-only-bin" { } ''
602 ln -s ${lib.getBin drv}/bin $out/bin
606 # Docs in doc/build-helpers/special/makesetuphook.section.md
607 # See https://nixos.org/manual/nixpkgs/unstable/#sec-pkgs.makeSetupHook
609 { name ? lib.warn "calling makeSetupHook without passing a name is deprecated." "hook"
610 # hooks go in nativeBuildInputs so these will be nativeBuildInputs
611 , propagatedBuildInputs ? [ ]
612 # these will be buildInputs
613 , depsTargetTargetPropagated ? [ ]
616 , substitutions ? { }
621 # TODO(@Artturin:) substitutions should be inside the env attrset
622 # but users are likely passing non-substitution arguments through substitutions
623 # turn off __structuredAttrs to unbreak substituteAll
624 __structuredAttrs = false;
626 inherit depsTargetTargetPropagated;
627 inherit propagatedBuildInputs;
629 # TODO 2023-01, no backport: simplify to inherit passthru;
631 // optionalAttrs (substitutions?passthru)
632 (warn "makeSetupHook (name = ${lib.strings.escapeNixString name}): `substitutions.passthru` is deprecated. Please set `passthru` directly."
633 substitutions.passthru);
636 mkdir -p $out/nix-support
637 cp ${script} $out/nix-support/setup-hook
638 recordPropagatedDependencies
639 '' + lib.optionalString (substitutions != { }) ''
640 substituteAll ${script} $out/nix-support/setup-hook
643 # Remove after 25.05 branch-off
644 writeReferencesToFile = throw "writeReferencesToFile has been removed. Use writeClosure instead.";
646 # Docs in doc/build-helpers/trivial-build-helpers.chapter.md
647 # See https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-writeClosure
648 writeClosure = paths: runCommand "runtime-deps"
650 # Get the cleaner exportReferencesGraph interface
651 __structuredAttrs = true;
652 exportReferencesGraph.graph = paths;
653 nativeBuildInputs = [ jq ];
656 jq -r ".graph | map(.path) | sort | .[]" "$NIX_ATTRS_JSON_FILE" > "$out"
659 # Docs in doc/build-helpers/trivial-build-helpers.chapter.md
660 # See https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-writeDirectReferencesToFile
661 writeDirectReferencesToFile = path: runCommand "runtime-references"
663 exportReferencesGraph = [ "graph" path ];
671 if [[ $p == $path ]]; then
672 for ((i = 0; i < nrRefs; i++)); do
674 echo $ref >>./references
677 for ((i = 0; i < nrRefs; i++)); do
682 sort ./references >$out
685 # TODO: move writeStringReferencesToFile docs to the Nixpkgs manual
687 Extract a string's references to derivations and paths (its
688 context) and write them to a text file, removing the input string
689 itself from the dependency graph. This is useful when you want to
690 make a derivation depend on the string's references, but not its
691 contents (to avoid unnecessary rebuilds, for example).
693 Note that this only works as intended on Nix >= 2.3.
695 writeStringReferencesToFile = string:
697 The basic operation this performs is to copy the string context
698 from `string` to a second string and wrap that string in a
699 derivation. However, that alone is not enough, since nothing in the
700 string refers to the output paths of the derivations/paths in its
701 context, meaning they'll be considered build-time dependencies and
702 removed from the wrapper derivation's closure. Putting the
703 necessary output paths in the new string is however not very
704 straightforward - the attrset returned by `getContext` contains
705 only references to derivations' .drv-paths, not their output
706 paths. In order to "convert" them, we try to extract the
707 corresponding paths from the original string using regex.
710 # Taken from https://github.com/NixOS/nix/blob/130284b8508dad3c70e8160b15f3d62042fc730a/src/libutil/hash.cc#L84
711 nixHashChars = "0123456789abcdfghijklmnpqrsvwxyz";
712 context = builtins.getContext string;
713 derivations = lib.filterAttrs (n: v: v ? outputs) context;
714 # Objects copied from outside of the store, such as paths and
715 # `builtins.fetch*`ed ones
716 sources = lib.attrNames (lib.filterAttrs (n: v: v ? path) context);
722 name = lib.head (builtins.match "${builtins.storeDir}/[${nixHashChars}]+-(.*)\.drv" name);
725 # The syntax of output paths differs between outputs named `out`
726 # and other, explicitly named ones. For explicitly named ones,
727 # the output name is suffixed as `-name`, but `out` outputs
728 # aren't suffixed at all, and thus aren't easily distinguished
729 # from named output paths. Therefore, we find all the named ones
730 # first so we can use them to remove false matches when looking
731 # for `out` outputs (see the definition of `outputPaths`).
740 (builtins.split "(${builtins.storeDir}/[${nixHashChars}]+-${name}-${output})" string))
741 (lib.remove "out" value.outputs)))
748 if lib.elem "out" value.outputs then
751 # If the matched path is in `namedOutputPaths`,
752 # it's a partial match of an output path where
753 # the output name isn't `out`
754 lib.all (o: !lib.hasPrefix (lib.head x) o) namedOutputPaths)
755 (builtins.split "(${builtins.storeDir}/[${nixHashChars}]+-${name})" string)
759 allPaths = lib.concatStringsSep "\n" (lib.unique (sources ++ namedOutputPaths ++ outputPaths));
760 allPathsWithContext = builtins.appendContext allPaths context;
762 if builtins ? getContext then
763 writeText "string-references" allPathsWithContext
765 writeDirectReferencesToFile (writeText "string-file" string);
768 # Docs in doc/build-helpers/fetchers.chapter.md
769 # See https://nixos.org/manual/nixpkgs/unstable/#requirefile
779 assert (message != null) || (url != null);
780 assert (sha256 != null) || (sha1 != null) || (hash != null);
781 assert (name != null) || (url != null);
784 if message != null then message
786 Unfortunately, we cannot download file ${name_} automatically.
787 Please go to ${url} to download it yourself, and add it to the Nix store
789 nix-store --add-fixed ${hashAlgo} ${name_}
791 nix-prefetch-url --type ${hashAlgo} file:///path/to/${name_}
794 if hash != null then (builtins.head (lib.strings.splitString "-" hash))
795 else if sha256 != null then "sha256"
797 hashAlgo_ = if hash != null then "" else hashAlgo;
799 if hash != null then hash
800 else if sha256 != null then sha256
802 name_ = if name == null then baseNameOf (toString url) else name;
804 stdenvNoCC.mkDerivation {
806 outputHashMode = hashMode;
807 outputHashAlgo = hashAlgo_;
809 preferLocalBuild = true;
810 allowSubstitutes = false;
811 builder = writeScript "restrict-message" ''
812 source ${stdenvNoCC}/setup
825 # TODO: move copyPathToStore docs to the Nixpkgs manual
827 Copy a path to the Nix store.
828 Nix automatically copies files to the store before stringifying paths.
829 If you need the store path of a file, ${copyPathToStore <path>} can be
830 shortened to ${<path>}.
832 copyPathToStore = builtins.filterSource (p: t: true);
835 # TODO: move copyPathsToStore docs to the Nixpkgs manual
837 Copy a list of paths to the Nix store.
839 copyPathsToStore = builtins.map copyPathToStore;
841 # TODO: move applyPatches docs to the Nixpkgs manual
842 /* Applies a list of patches to a source directory.
852 url = "https://github.com/NixOS/nixpkgs/commit/1f770d20550a413e508e081ddc08464e9d08ba3d.patch";
853 sha256 = "1nlzx171y3r3jbk0qhvnl711kmdk57jlq4na8f8bs8wz2pbffymr";
861 , name ? (if builtins.typeOf src == "path"
862 then builtins.baseNameOf src
864 if builtins.isAttrs src && builtins.hasAttr "name" src
866 else throw "applyPatches: please supply a `name` argument because a default name can only be computed when the `src` is a path or is an attribute set with a `name` attribute."
873 if patches == [ ] && prePatch == "" && postPatch == ""
874 then src # nothing to do, so use original src to avoid additional drv
875 else stdenvNoCC.mkDerivation
877 inherit name src patches prePatch postPatch;
878 preferLocalBuild = true;
879 allowSubstitutes = false;
880 phases = "unpackPhase patchPhase installPhase";
881 installPhase = "cp -R ./ $out";
883 # Carry `meta` information from the underlying `src` if present.
884 // (optionalAttrs (src?meta) { inherit (src) meta; })
885 // (removeAttrs args [ "src" "name" "patches" "prePatch" "postPatch" ]));
887 # TODO: move docs to Nixpkgs manual
888 /* An immutable file in the store with a length of 0 bytes. */
889 emptyFile = runCommand "empty-file"
891 outputHash = "sha256-d6xi4mKdjkX2JFicDIv5niSzpyI0m/Hnm8GGAIU04kY=";
892 outputHashMode = "recursive";
893 preferLocalBuild = true;
896 # TODO: move docs to Nixpkgs manual
897 /* An immutable empty directory in the store. */
898 emptyDirectory = runCommand "empty-directory"
900 outputHashAlgo = "sha256";
901 outputHashMode = "recursive";
902 outputHash = "0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5";
903 preferLocalBuild = true;