From 9db6a84f0bcce1602f17eca3fa17f5a016a93aac Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Fri, 19 Dec 2014 22:33:24 +0100 Subject: [PATCH 1/3] nixos-option: Print the outPath of derivation for option values. --- nixos/modules/installer/tools/nixos-option.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nixos/modules/installer/tools/nixos-option.sh b/nixos/modules/installer/tools/nixos-option.sh index 96d09c3a605..a2b963d7661 100644 --- a/nixos/modules/installer/tools/nixos-option.sh +++ b/nixos/modules/installer/tools/nixos-option.sh @@ -76,7 +76,18 @@ evalAttr(){ local prefix="$1" local strict="$2" local suffix="$3" - echo "(import {}).$prefix${option:+.$option}${suffix:+.$suffix}" | evalNix ${strict:+--strict} + evalNix ${strict:+--strict} < {}; + nixpkgs = import {}; + cleanOutput = x: with nixpkgs.lib; + if isDerivation x then x.outPath + else if isFunction x then "" + else x; +in + cleanOutput (reach nixos.$prefix) +EOF } evalOpt(){ From b2abfe54b3da8eddda3135561c0c841c3023966d Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Fri, 19 Dec 2014 23:00:00 +0100 Subject: [PATCH 2/3] nixos-option: Print derivation outPath within attribute sets and list, when the strict mode is used. --- nixos/modules/installer/tools/nixos-option.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nixos/modules/installer/tools/nixos-option.sh b/nixos/modules/installer/tools/nixos-option.sh index a2b963d7661..b5f69f07826 100644 --- a/nixos/modules/installer/tools/nixos-option.sh +++ b/nixos/modules/installer/tools/nixos-option.sh @@ -76,14 +76,23 @@ evalAttr(){ local prefix="$1" local strict="$2" local suffix="$3" + + # If strict is set, then set it to "true". + test -n "$strict" && strict=true + evalNix ${strict:+--strict} < {}; nixpkgs = import {}; + strict = ${strict:-false}; cleanOutput = x: with nixpkgs.lib; if isDerivation x then x.outPath else if isFunction x then "" + else if strict then + if isAttrs x then mapAttrs (n: cleanOutput) x + else if isList x then map cleanOutput x + else x else x; in cleanOutput (reach nixos.$prefix) From cd2f7ce9f9f10894c6d2a5995f06fb9d2a7f6795 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Fri, 19 Dec 2014 23:00:52 +0100 Subject: [PATCH 3/3] nixos-option: Improve error messages to avoid reporting internal location and traces. --- nixos/modules/installer/tools/nixos-option.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nixos/modules/installer/tools/nixos-option.sh b/nixos/modules/installer/tools/nixos-option.sh index b5f69f07826..4478059813d 100644 --- a/nixos/modules/installer/tools/nixos-option.sh +++ b/nixos/modules/installer/tools/nixos-option.sh @@ -69,7 +69,18 @@ fi ############################# evalNix(){ - nix-instantiate - --eval-only "$@" + result=$(nix-instantiate - --eval-only "$@" 2>&1) + if test $? -eq 0; then + cat <