Nixos-generate-config: Difference between revisions

Pigs (talk | contribs)
No edit summary
Pigs (talk | contribs)
Includes usage and fill out details
Line 1: Line 1:
Generate NixOS configuration modules.
This command is part of the <code>nixos-install-tools</code> package. It analyzes your hardware configuration and generates two files of:
* <code>/etc/nixos/configuration.nix</code> - the main system configuration file.
* <code>/etc/nixos/hardware-configuration.nix</code> - a hardware-specific configuration file, including detected devices and modules.
= Usage =
<syntaxHighlight lang=bash>
<syntaxHighlight lang=bash>
# nixos-generate-config
# nixos-generate-config
</syntaxHighlight>
</syntaxHighlight>


This command is part of the <code>nixos-install-tools</code> package. It analyzes your hardware configuration and generates two files of:
This will create configuration files based on the currently mounted system. This is typically used where NixOS is already installed. By default, <code>nixos-generate-config</code> will not overwrite an existing <code>configuration.nix</code>. To force overwrite an existing file, pass the <code>--force</code> option.
* <code>/etc/nixos/configuration.nix</code>
 
* <code>/etc/nixos/hardware-configuration.nix</code>
== Generate configuration for a target root ==
 
To generate configuration files with a specific root directory (commonly used during installation):
 
<syntaxhighlight lang="bash">
# nixos-generate-config --root /mnt
</syntaxhighlight>
 
This writes configuration files to <code>/mnt/etc/nixos/</code>.
 
== Show hardware configuration ==
 
To print the detected hardware configuration to standard output without writing to disk:
 
<syntaxhighlight lang="bash">
# nixos-generate-config --show-hardware-config
</syntaxhighlight>


== hardware specific notes ==
= 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:
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: