trivial: make pkgs.writeText always fixed output

This can prevent a cascade of rebuilds across nixpkgs versions because these
small files tend to be found at the leaves of dependency trees.
This commit is contained in:
Hraban Luyat 2024-06-14 15:35:15 -04:00
parent 5aa55272c2
commit 9f4b1064c6

View File

@ -133,7 +133,14 @@ rec {
pkgs.writeText ${lib.strings.escapeNixString name}: The second argument should be a string, but it's a ${builtins.typeOf text} instead.'';
lib.warnIf (! lib.isString text) ''
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.''
writeTextFile { inherit name text; };
writeTextFile {
inherit name text;
derivationArgs = rec {
outputHashAlgo = "sha256";
outputHashMode = "flat";
outputHash = builtins.hashString outputHashAlgo (builtins.toString text);
};
};
# See doc/build-helpers/trivial-build-helpers.chapter.md
# or https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-text-writing