summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorNicolas B. Pierron <nicolas.b.pierron@gmail.com>2014-12-20 19:52:28 +0100
committerNicolas B. Pierron <nicolas.b.pierron@gmail.com>2014-12-20 19:52:28 +0100
commitc9682a22ffc93a89b66c12cc4df7d0e022d17043 (patch)
tree63743ab17bb76ad22f4175464de2129b3e8f692f /nixos
parent640428d3c515c1837c9c2bff28f765d53fc93355 (diff)
downloadnixlib-c9682a22ffc93a89b66c12cc4df7d0e022d17043.tar
nixlib-c9682a22ffc93a89b66c12cc4df7d0e022d17043.tar.gz
nixlib-c9682a22ffc93a89b66c12cc4df7d0e022d17043.tar.bz2
nixlib-c9682a22ffc93a89b66c12cc4df7d0e022d17043.tar.lz
nixlib-c9682a22ffc93a89b66c12cc4df7d0e022d17043.tar.xz
nixlib-c9682a22ffc93a89b66c12cc4df7d0e022d17043.tar.zst
nixlib-c9682a22ffc93a89b66c12cc4df7d0e022d17043.zip
nixos-option: Produce nicer error messages in case of typos.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/installer/tools/nixos-option.sh13
1 files changed, 12 insertions, 1 deletions
diff --git a/nixos/modules/installer/tools/nixos-option.sh b/nixos/modules/installer/tools/nixos-option.sh
index e565eca97204..ffd624227fbd 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 <<EOF
+  if result=$(evalNix --strict --show-trace <<EOF
 $header
 
 let
@@ -129,6 +129,17 @@ let
 in
   ''let option = \${walkResult.opt}; config = \${walkResult.cfg}; in''
 EOF
+)
+  then
+      echo $result
+  else
+      # In case of error we want to ignore the error message roduced by the
+      # script above, as it is iterating over each attribute, which does not
+      # produce a nice error message.  The following code is a fallback
+      # solution which is cause a nicer error message in the next
+      # evaluation.
+      echo "\"let option = nixos.options${option:+.$option}; config = nixos.config${option:+.$option}; in\""
+  fi
 }
 
 header="$header