git.iko.soy/typeable/nixpkgs
on master help sign in
nixos-option: Produce nicer error messages in case of typos.
commitc9682a22ffc93a89b66c12cc4df7d0e022d17043 authorNicolas B. Pierron <nicolas.b.pierron@gmail.com> dateSat 20 Dec 2014, 19:52 (12 years ago) parent640428d
1 file changed+12−1
nixos/modules/installer/tools/nixos-option.sh+12−1
nixos/modules/installer/tools/nixos-option.sh+12−1
@@ -94,7 +94,7 @@ in with nixpkgs.lib;
9494# the user into accessors for reaching the definition and the declaration
9595# corresponding to this option.
9696generateAccessors(){
97− evalNix --strict --show-trace <<EOF
97+ if result=$(evalNix --strict --show-trace <<EOF
9898$header
9999
100100let
@@ -129,6 +129,17 @@ let
129129in
130130 ''let option = \${walkResult.opt}; config = \${walkResult.cfg}; in''
131131EOF
132+)
133+ then
134+ echo $result
135+ else
136+ # In case of error we want to ignore the error message roduced by the
137+ # script above, as it is iterating over each attribute, which does not
138+ # produce a nice error message. The following code is a fallback
139+ # solution which is cause a nicer error message in the next
140+ # evaluation.
141+ echo "\"let option = nixos.options${option:+.$option}; config = nixos.config${option:+.$option}; in\""
142+ fi
132143}
133144
134145header="$header