nixos-option: enable all flags by default and make output a bit readable cc @nbp
This commit is contained in:
parent
43d9f92c82
commit
2e97c06999
@ -17,11 +17,6 @@
|
|||||||
<refsynopsisdiv>
|
<refsynopsisdiv>
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>nixos-option</command>
|
<command>nixos-option</command>
|
||||||
<group choice="opt">
|
|
||||||
<option>-v</option>
|
|
||||||
<option>-d</option>
|
|
||||||
<option>-l</option>
|
|
||||||
</group>
|
|
||||||
<arg choice='plain'><replaceable>option.name</replaceable></arg>
|
<arg choice='plain'><replaceable>option.name</replaceable></arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
@ -31,50 +26,13 @@
|
|||||||
|
|
||||||
<para>This command evaluates the configuration specified in
|
<para>This command evaluates the configuration specified in
|
||||||
<filename>/etc/nixos/configuration.nix</filename> and returns the properties
|
<filename>/etc/nixos/configuration.nix</filename> and returns the properties
|
||||||
of the option name given as argument. By default, it returns the value of
|
of the option name given as argument.</para>
|
||||||
the option.</para>
|
|
||||||
|
|
||||||
<para>When the option name is not an option, the command prints the list of
|
<para>When the option name is not an option, the command prints the list of
|
||||||
attributes contained in the attribute set.</para>
|
attributes contained in the attribute set.</para>
|
||||||
|
|
||||||
</refsection>
|
</refsection>
|
||||||
|
|
||||||
<refsection><title>Options</title>
|
|
||||||
|
|
||||||
<para>This command accepts the following options:</para>
|
|
||||||
|
|
||||||
<variablelist>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--value</option>, <option>-v</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>Returns the value of the option. This is the default operation
|
|
||||||
if no other options are defined.</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--description</option>, <option>-d</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>Return the default value, the example and the description of the
|
|
||||||
option when available.</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><option>--lookup</option>, <option>-l</option></term>
|
|
||||||
<listitem>
|
|
||||||
<para>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.</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
</variablelist>
|
|
||||||
|
|
||||||
</refsection>
|
|
||||||
|
|
||||||
|
|
||||||
<refsection><title>Environment</title>
|
<refsection><title>Environment</title>
|
||||||
|
|
||||||
<variablelist>
|
<variablelist>
|
||||||
@ -103,27 +61,21 @@ grub
|
|||||||
initScript
|
initScript
|
||||||
|
|
||||||
$ nixos-option boot.loader.grub.enable
|
$ nixos-option boot.loader.grub.enable
|
||||||
true</screen></para>
|
Value:
|
||||||
|
true
|
||||||
|
|
||||||
<para>Prints option information:
|
Default:
|
||||||
|
true
|
||||||
|
|
||||||
<screen>$ nixos-option -d networking.hostName
|
|
||||||
Default: "nixos"
|
|
||||||
Description:
|
Description:
|
||||||
The name of the machine. Leave it empty if you want to obtain
|
Whether to enable the GNU GRUB boot loader.
|
||||||
it from a DHCP server (if using DHCP).</screen></para>
|
|
||||||
|
|
||||||
<para>Find the locations which are declaring and defining an option:
|
|
||||||
|
|
||||||
<screen>$ nixos-option -l hardware.firmware
|
|
||||||
Declared by:
|
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:
|
Defined by:
|
||||||
/path/to/nixpkgs/nixos/modules/system/boot/kernel.nix
|
"/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/system/boot/loader/grub/grub.nix"
|
||||||
/path/to/nixpkgs/nixos/modules/hardware/network/rt73.nix
|
</screen></para>
|
||||||
/path/to/nixpkgs/nixos/modules/hardware/network/intel-3945abg.nix
|
|
||||||
/path/to/nixpkgs/nixos/modules/hardware/network/intel-2200bg.nix</screen></para>
|
|
||||||
|
|
||||||
</refsection>
|
</refsection>
|
||||||
|
|
||||||
|
@ -11,9 +11,6 @@ usage () {
|
|||||||
# Process Arguments #
|
# Process Arguments #
|
||||||
#####################
|
#####################
|
||||||
|
|
||||||
desc=false
|
|
||||||
defs=false
|
|
||||||
value=false
|
|
||||||
xml=false
|
xml=false
|
||||||
verbose=false
|
verbose=false
|
||||||
|
|
||||||
@ -24,14 +21,11 @@ for arg; do
|
|||||||
if test -z "$argfun"; then
|
if test -z "$argfun"; then
|
||||||
case $arg in
|
case $arg in
|
||||||
-*)
|
-*)
|
||||||
longarg=""
|
|
||||||
sarg="$arg"
|
sarg="$arg"
|
||||||
|
longarg=""
|
||||||
while test "$sarg" != "-"; do
|
while test "$sarg" != "-"; do
|
||||||
case $sarg in
|
case $sarg in
|
||||||
--*) longarg=$arg; sarg="--";;
|
--*) longarg=$arg; sarg="--";;
|
||||||
-d*) longarg="$longarg --description";;
|
|
||||||
-v*) longarg="$longarg --value";;
|
|
||||||
-l*) longarg="$longarg --lookup";;
|
|
||||||
-*) usage;;
|
-*) usage;;
|
||||||
esac
|
esac
|
||||||
# remove the first letter option
|
# remove the first letter option
|
||||||
@ -42,9 +36,6 @@ for arg; do
|
|||||||
esac
|
esac
|
||||||
for larg in $longarg; do
|
for larg in $longarg; do
|
||||||
case $larg in
|
case $larg in
|
||||||
--description) desc=true;;
|
|
||||||
--value) value=true;;
|
|
||||||
--lookup) defs=true;;
|
|
||||||
--xml) xml=true;;
|
--xml) xml=true;;
|
||||||
--verbose) verbose=true;;
|
--verbose) verbose=true;;
|
||||||
--help) usage;;
|
--help) usage;;
|
||||||
@ -67,16 +58,6 @@ for arg; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if $xml; then
|
|
||||||
value=true
|
|
||||||
desc=true
|
|
||||||
defs=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! $defs && ! $desc; then
|
|
||||||
value=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $verbose; then
|
if $verbose; then
|
||||||
set -x
|
set -x
|
||||||
else
|
else
|
||||||
@ -95,8 +76,7 @@ evalAttr(){
|
|||||||
local prefix="$1"
|
local prefix="$1"
|
||||||
local strict="$2"
|
local strict="$2"
|
||||||
local suffix="$3"
|
local suffix="$3"
|
||||||
echo "(import <nixos> {}).$prefix${option:+.$option}${suffix:+.$suffix}" |
|
echo "(import <nixos> {}).$prefix${option:+.$option}${suffix:+.$suffix}" | evalNix ${strict:+--strict}
|
||||||
evalNix ${strict:+--strict}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
evalOpt(){
|
evalOpt(){
|
||||||
@ -189,35 +169,35 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$(evalOpt "_type" 2> /dev/null)" = '"option"'; then
|
if test "$(evalOpt "_type" 2> /dev/null)" = '"option"'; then
|
||||||
$value && evalCfg 1
|
echo "Value:"
|
||||||
|
evalCfg 1
|
||||||
|
|
||||||
if $desc; then
|
echo
|
||||||
$value && echo;
|
|
||||||
|
|
||||||
if default=$(evalOpt "default" - 2> /dev/null); then
|
echo "Default:"
|
||||||
echo "Default: $default"
|
if default=$(evalOpt "default" - 2> /dev/null); then
|
||||||
else
|
echo "$default"
|
||||||
echo "Default: <None>"
|
else
|
||||||
fi
|
echo "<None>"
|
||||||
if example=$(evalOpt "example" - 2> /dev/null); then
|
|
||||||
echo "Example: $example"
|
|
||||||
fi
|
|
||||||
echo "Description:"
|
|
||||||
eval printf $(evalOpt "description")
|
|
||||||
fi
|
fi
|
||||||
|
echo
|
||||||
if $defs; then
|
if example=$(evalOpt "example" - 2> /dev/null); then
|
||||||
$desc || $value && echo;
|
echo "Example: $example"
|
||||||
|
|
||||||
printPath () { echo " $1"; }
|
|
||||||
|
|
||||||
echo "Declared by:"
|
|
||||||
nixMap printPath "$(findSources "declarations")"
|
|
||||||
echo ""
|
|
||||||
echo "Defined by:"
|
|
||||||
nixMap printPath "$(findSources "files")"
|
|
||||||
echo ""
|
|
||||||
fi
|
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
|
else
|
||||||
# echo 1>&2 "Warning: This value is not an option."
|
# echo 1>&2 "Warning: This value is not an option."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user