LinuxCommandLibrary

nixos-option

Display information about NixOS configuration options

TLDR

List all subkeys of a given option key

$ nixos-option [option_key]
copy

List current boot kernel modules
$ nixos-option boot.kernelModules
copy

List authorized keys for a specific user
$ nixos-option users.users.[username].openssh.authorizedKeys.[keyFiles|keys]
copy

List all remote builders
$ nixos-option nix.buildMachines
copy

List all subkeys of a given key on another NixOS configuration
$ NIXOS_CONFIG=[path_to_configuration.nix] nixos-option [option_key]
copy

Show recursively all values of a user
$ nixos-option [[-r|--recursive]] users.users.[user]
copy

SYNOPSIS

nixos-option [options] [option-name]

PARAMETERS

--help
    Displays help text.

--version
    Shows the version number.

-j
    Use concurrent workers for evaluating Nix expressions. Defaults to the number of CPUs.

--eval-cache
    Enable the Nix expression evaluation cache. Can improve performance for repeated lookups.

--read-only-mode
    Do not allow option value setting. This option prevents accidental modifications during inspection.

[option-name]
    The specific option to query. If omitted, all options are displayed.

DESCRIPTION

The `nixos-option` command provides a way to browse and query configuration options within the NixOS operating system. It allows users to discover available settings, understand their purpose, and view their default values. This is crucial for customizing NixOS systems to meet specific needs. The command retrieves information from the NixOS option definitions, often located within the Nixpkgs repository. It displays the option name, type, default value, description, and any relevant documentation. This helps administrators understand how to configure services, hardware, and other system aspects managed through NixOS's declarative configuration system. Users can filter options by name or type using various flags, making it easier to find the desired configuration setting. The command's output is formatted for readability, enhancing the user experience when exploring NixOS configuration possibilities.

OUTPUT FORMATTING

The output is generally formatted for easy reading in a terminal. It typically includes the option name, type, default value, and a detailed description. The display can be influenced by command-line arguments.

USAGE EXAMPLES

Example:
`nixos-option services.openssh.enable`
Shows the details of the `services.openssh.enable` option.
Example:
`nixos-option`
Lists all available options (potentially very long).
Example:
`nixos-option services.openssh | less`
Lists information related to options under 'services.openssh', and pipes the output to 'less'.

NIX EXPRESSION EVALUATION

Behind the scenes, `nixos-option` evaluates Nix expressions to determine the current values and descriptions of the options. This evaluation process is handled by the Nix package manager itself.

SEE ALSO

nix(1), nix-shell(1), nix-build(1)

Copied to clipboard