From 640428d3c515c1837c9c2bff28f765d53fc93355 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Sat, 20 Dec 2014 19:16:43 +0100 Subject: nixos-option: Handle 'attrsOf submodule' options. --- nixos/modules/installer/tools/nixos-option.sh | 78 ++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 12 deletions(-) (limited to 'nixos/modules/installer') 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; -- cgit 1.4.1