diff --git a/nixos/modules/installer/tools/nixos-option.sh b/nixos/modules/installer/tools/nixos-option.sh index 4478059813d1..e565eca97204 100644 --- a/nixos/modules/installer/tools/nixos-option.sh +++ b/nixos/modules/installer/tools/nixos-option.sh @@ -83,6 +83,58 @@ EOF fi } +header=" +let + nixos = import {}; + nixpkgs = import {}; +in with nixpkgs.lib; +" + +# This function is used for converting the option definition path given by +# the user into accessors for reaching the definition and the declaration +# corresponding to this option. +generateAccessors(){ + evalNix --strict --show-trace < {}; - nixpkgs = import {}; + value = $prefix${suffix:+.$suffix}; strict = ${strict:-false}; cleanOutput = x: with nixpkgs.lib; if isDerivation x then x.outPath @@ -106,12 +158,12 @@ let else x else x; in - cleanOutput (reach nixos.$prefix) + cleanOutput value EOF } evalOpt(){ - evalAttr "options" "" "$@" + evalAttr "option" "" "$@" } evalCfg(){ @@ -121,8 +173,11 @@ evalCfg(){ findSources(){ local suffix=$1 - echo "(import {}).options${option:+.$option}.$suffix" | - evalNix --strict + evalNix --strict < {}; - nixpkgs = import {}; sources = builtins.map (f: f.source); - opt = reach nixos.options; - cfg = reach nixos.config; + opt = option; + cfg = config; in with nixpkgs.lib;