diff --git a/nixos/modules/installer/tools/nixos-option.sh b/nixos/modules/installer/tools/nixos-option.sh index 96d09c3a6058..4478059813d1 100644 --- a/nixos/modules/installer/tools/nixos-option.sh +++ b/nixos/modules/installer/tools/nixos-option.sh @@ -69,14 +69,45 @@ fi ############################# evalNix(){ - nix-instantiate - --eval-only "$@" + result=$(nix-instantiate - --eval-only "$@" 2>&1) + if test $? -eq 0; then + cat < {}).$prefix${option:+.$option}${suffix:+.$suffix}" | evalNix ${strict:+--strict} + + # 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) +EOF } evalOpt(){