Nixos-generate-config: Difference between revisions
Includes usage and fill out details |
m change syntax highlighting to console |
||
Line 7: | Line 7: | ||
= Usage = | = Usage = | ||
<syntaxHighlight lang= | <syntaxHighlight lang=console> | ||
# nixos-generate-config | # nixos-generate-config | ||
</syntaxHighlight> | </syntaxHighlight> | ||
Line 17: | Line 17: | ||
To generate configuration files with a specific root directory (commonly used during installation): | To generate configuration files with a specific root directory (commonly used during installation): | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="console"> | ||
# nixos-generate-config --root /mnt | # nixos-generate-config --root /mnt | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 27: | Line 27: | ||
To print the detected hardware configuration to standard output without writing to disk: | To print the detected hardware configuration to standard output without writing to disk: | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="console"> | ||
# nixos-generate-config --show-hardware-config | # nixos-generate-config --show-hardware-config | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 06:04, 21 April 2025
Generate NixOS configuration modules.
This command is part of the nixos-install-tools
package. It analyzes your hardware configuration and generates two files of:
/etc/nixos/configuration.nix
- the main system configuration file./etc/nixos/hardware-configuration.nix
- a hardware-specific configuration file, including detected devices and modules.
Usage
# nixos-generate-config
This will create configuration files based on the currently mounted system. This is typically used where NixOS is already installed. By default, nixos-generate-config
will not overwrite an existing configuration.nix
. To force overwrite an existing file, pass the --force
option.
Generate configuration for a target root
To generate configuration files with a specific root directory (commonly used during installation):
# nixos-generate-config --root /mnt
This writes configuration files to /mnt/etc/nixos/
.
Show hardware configuration
To print the detected hardware configuration to standard output without writing to disk:
# nixos-generate-config --show-hardware-config
Hardware specific notes
If you are using an SSD it may be useful to enable TRIM support as well as set filesystem flags to improve the SSD performance:
fileSystems."/".options = [ "noatime" "nodiratime" "discard" ];
A collection of hardware specific platforms with their config can be found at NixOS Hardware repository