From 0fa7b1b004788881733dc117edd7699f77384166 Mon Sep 17 00:00:00 2001 From: Naïm Favier Date: Fri, 4 Nov 2022 17:31:41 +0100 Subject: lib/generators.toPretty: don't evaluate derivations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the goal of making `toPretty` suitable for rendering option values, render derivations as `` instead of ``. This is to avoid causing sudden evaluation errors for out-of-tree projects that have options with `default = pkgs.someUnfreePackage;` and no `defaultText`. --- lib/generators.nix | 2 +- lib/tests/misc.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/generators.nix b/lib/generators.nix index b77cca75010f9..9620b8b27b9b9 100644 --- a/lib/generators.nix +++ b/lib/generators.nix @@ -330,7 +330,7 @@ rec { then v.__pretty v.val else if v == {} then "{ }" else if v ? type && v.type == "derivation" then - "" + "" else "{" + introSpace + libStr.concatStringsSep introSpace (libAttr.mapAttrsToList (name: value: diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index b73da4f1010d4..9267e1f57694c 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -754,7 +754,7 @@ runTests { emptylist = "[ ]"; attrs = "{ foo = null; \"foo bar\" = \"baz\"; }"; emptyattrs = "{ }"; - drv = ""; + drv = ""; }; }; -- cgit 1.4.1