From 640428d3c515c1837c9c2bff28f765d53fc93355 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sat, 20 Dec 2014 19:16:43 +0100 Subject: [PATCH 1/3] nixos-option: Handle 'attrsOf submodule' options. --- nixos/modules/installer/tools/nixos-option.sh | 78 ++++++++++++++++--- 1 file changed, 66 insertions(+), 12 deletions(-) diff --git a/nixos/modules/installer/tools/nixos-option.sh b/nixos/modules/installer/tools/nixos-option.sh index 4478059813d..e565eca9720 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; From c9682a22ffc93a89b66c12cc4df7d0e022d17043 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sat, 20 Dec 2014 19:52:28 +0100 Subject: [PATCH 2/3] nixos-option: Produce nicer error messages in case of typos. --- 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 e565eca9720..ffd624227fb 100644 --- a/nixos/modules/installer/tools/nixos-option.sh +++ b/nixos/modules/installer/tools/nixos-option.sh @@ -94,7 +94,7 @@ in with nixpkgs.lib; # the user into accessors for reaching the definition and the declaration # corresponding to this option. generateAccessors(){ - evalNix --strict --show-trace < Date: Sun, 21 Dec 2014 01:33:06 +0100 Subject: [PATCH 3/3] nixos-option: Use instead of . --- nixos/modules/installer/tools/nixos-option.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nixos/modules/installer/tools/nixos-option.sh b/nixos/modules/installer/tools/nixos-option.sh index ffd624227fb..3016536ecdd 100644 --- a/nixos/modules/installer/tools/nixos-option.sh +++ b/nixos/modules/installer/tools/nixos-option.sh @@ -83,9 +83,8 @@ EOF fi } -header=" -let - nixos = import {}; +header="let + nixos = import {}; nixpkgs = import {}; in with nixpkgs.lib; "