diff --git a/nixos/doc/manual/man-nixos-option.xml b/nixos/doc/manual/man-nixos-option.xml index 7952847d4db5..554b29691805 100644 --- a/nixos/doc/manual/man-nixos-option.xml +++ b/nixos/doc/manual/man-nixos-option.xml @@ -17,11 +17,6 @@ nixos-option - - - - - option.name @@ -31,50 +26,13 @@ This command evaluates the configuration specified in /etc/nixos/configuration.nix and returns the properties -of the option name given as argument. By default, it returns the value of -the option. +of the option name given as argument. When the option name is not an option, the command prints the list of attributes contained in the attribute set. -Options - -This command accepts the following options: - - - - - , - - Returns the value of the option. This is the default operation - if no other options are defined. - - - - - , - - Return the default value, the example and the description of the - option when available. - - - - - , - - Return the locations where the option is declared and where it - is defined. This is extremely useful to find sources of errors in - your configuration. - - - - - - - - Environment @@ -103,27 +61,21 @@ grub initScript $ nixos-option boot.loader.grub.enable -true +Value: +true -Prints option information: +Default: +true -$ nixos-option -d networking.hostName -Default: "nixos" Description: -The name of the machine. Leave it empty if you want to obtain -it from a DHCP server (if using DHCP). +Whether to enable the GNU GRUB boot loader. -Find the locations which are declaring and defining an option: - -$ nixos-option -l hardware.firmware Declared by: - /mnt/data/nix-sources/nixos/modules/services/hardware/udev.nix + "/path/to/nixpkgs/nixos/modules/system/boot/loader/grub/grub.nix" Defined by: - /path/to/nixpkgs/nixos/modules/system/boot/kernel.nix - /path/to/nixpkgs/nixos/modules/hardware/network/rt73.nix - /path/to/nixpkgs/nixos/modules/hardware/network/intel-3945abg.nix - /path/to/nixpkgs/nixos/modules/hardware/network/intel-2200bg.nix + "/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/system/boot/loader/grub/grub.nix" + diff --git a/nixos/modules/installer/tools/nixos-option.sh b/nixos/modules/installer/tools/nixos-option.sh index edc94d732084..d995787c76fe 100644 --- a/nixos/modules/installer/tools/nixos-option.sh +++ b/nixos/modules/installer/tools/nixos-option.sh @@ -11,9 +11,6 @@ usage () { # Process Arguments # ##################### -desc=false -defs=false -value=false xml=false verbose=false @@ -24,14 +21,11 @@ for arg; do if test -z "$argfun"; then case $arg in -*) - longarg="" sarg="$arg" + longarg="" while test "$sarg" != "-"; do case $sarg in --*) longarg=$arg; sarg="--";; - -d*) longarg="$longarg --description";; - -v*) longarg="$longarg --value";; - -l*) longarg="$longarg --lookup";; -*) usage;; esac # remove the first letter option @@ -42,9 +36,6 @@ for arg; do esac for larg in $longarg; do case $larg in - --description) desc=true;; - --value) value=true;; - --lookup) defs=true;; --xml) xml=true;; --verbose) verbose=true;; --help) usage;; @@ -67,16 +58,6 @@ for arg; do fi done -if $xml; then - value=true - desc=true - defs=true -fi - -if ! $defs && ! $desc; then - value=true -fi - if $verbose; then set -x else @@ -95,8 +76,7 @@ evalAttr(){ local prefix="$1" local strict="$2" local suffix="$3" - echo "(import {}).$prefix${option:+.$option}${suffix:+.$suffix}" | - evalNix ${strict:+--strict} + echo "(import {}).$prefix${option:+.$option}${suffix:+.$suffix}" | evalNix ${strict:+--strict} } evalOpt(){ @@ -189,35 +169,35 @@ EOF fi if test "$(evalOpt "_type" 2> /dev/null)" = '"option"'; then - $value && evalCfg 1 + echo "Value:" + evalCfg 1 - if $desc; then - $value && echo; + echo - if default=$(evalOpt "default" - 2> /dev/null); then - echo "Default: $default" - else - echo "Default: " - fi - if example=$(evalOpt "example" - 2> /dev/null); then - echo "Example: $example" - fi - echo "Description:" - eval printf $(evalOpt "description") + echo "Default:" + if default=$(evalOpt "default" - 2> /dev/null); then + echo "$default" + else + echo "" fi - - if $defs; then - $desc || $value && echo; - - printPath () { echo " $1"; } - - echo "Declared by:" - nixMap printPath "$(findSources "declarations")" - echo "" - echo "Defined by:" - nixMap printPath "$(findSources "files")" - echo "" + echo + if example=$(evalOpt "example" - 2> /dev/null); then + echo "Example: $example" fi + echo "Description:" + echo + eval printf $(evalOpt "description") + + echo $desc; + + printPath () { echo " $1"; } + + echo "Declared by:" + nixMap printPath "$(findSources "declarations")" + echo + echo "Defined by:" + nixMap printPath "$(findSources "files")" + echo else # echo 1>&2 "Warning: This value is not an option."