3
0
Fork 0
forked from mirrors/nixpkgs

lib.generators: Handle no drvPath in toPretty

Previously, if a derivation without a `drvPath` was handled, an error
would be thrown:

    nix-repl> lib.generators.toPretty {} { type = "derivation"; }
    error: attribute 'drvPath' missing, at /home/infinisil/src/nixpkgs/lib/generators.nix:251:24

With this commit it doesn't anymore:

    nix-repl> lib.generators.toPretty {} { type = "derivation"; }
    "<derivation ???>"

This matches what `nix repl` outputs:

    nix-repl> { type = "derivation"; }
    «derivation ???»
This commit is contained in:
Silvan Mosberger 2021-08-11 15:50:33 +02:00
parent 6d96191fe5
commit 307c0237d7

View file

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