lib/generators.toPretty: don't evaluate derivations

With the goal of making `toPretty` suitable for rendering option
values, render derivations as `<derivation foo-1.0>` instead of
`<derivation /nix/store/…-foo-1.0.drv>`.

This is to avoid causing sudden evaluation errors for out-of-tree
projects that have options with `default = pkgs.someUnfreePackage;` and
no `defaultText`.
This commit is contained in:
Naïm Favier 2022-11-04 17:31:41 +01:00 committed by pennae
parent 0ff3b35356
commit 0fa7b1b004
2 changed files with 2 additions and 2 deletions

View file

@ -330,7 +330,7 @@ rec {
then v.__pretty v.val
else if v == {} then "{ }"
else if v ? type && v.type == "derivation" then
"<derivation ${v.drvPath or "???"}>"
"<derivation ${v.name or "???"}>"
else "{" + introSpace
+ libStr.concatStringsSep introSpace (libAttr.mapAttrsToList
(name: value:

View file

@ -754,7 +754,7 @@ runTests {
emptylist = "[ ]";
attrs = "{ foo = null; \"foo bar\" = \"baz\"; }";
emptyattrs = "{ }";
drv = "<derivation ${deriv.drvPath}>";
drv = "<derivation ${deriv.name}>";
};
};