mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 23:13:19 +00:00
trivial: input type assertions for writeText
This commit is contained in:
parent
d544b1259a
commit
5aa55272c2
@ -127,7 +127,13 @@ rec {
|
||||
|
||||
# See doc/build-helpers/trivial-build-helpers.chapter.md
|
||||
# or https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-text-writing
|
||||
writeText = name: text: writeTextFile { inherit name text; };
|
||||
writeText = name: text:
|
||||
# TODO: To fully deprecate, replace the assertion with `lib.isString` and remove the warning
|
||||
assert lib.assertMsg (lib.strings.isConvertibleWithToString text) ''
|
||||
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; };
|
||||
|
||||
# See doc/build-helpers/trivial-build-helpers.chapter.md
|
||||
# or https://nixos.org/manual/nixpkgs/unstable/#trivial-builder-text-writing
|
||||
|
Loading…
Reference in New Issue
Block a user