Nixos-generate-config: Difference between revisions

imported>Makefu
cleanup
Pigs (talk | contribs)
move ssd trim info to filesystems wiki page, other minor formatting
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This command analyzes your hardware configuration and generates two files of:
Generate NixOS configuration modules.
* <code>configuration.nix</code>
* <code>hardware-configuration.nix</code>


== hardware specific notes ==
This command is part of the {{nixos:package|nixos-install-tools}} 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.


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:
For details on configuring the system configuration file, see [[Overview of the NixOS Linux distribution#Declarative Configuration]].


<syntaxHighlight lang=nix>
= Usage =
fileSystems."/".options = [ "noatime" "nodiratime" "discard" ];
 
<syntaxHighlight lang=console>
# nixos-generate-config
</syntaxHighlight>
</syntaxHighlight>


A collection of hardware specific platforms with their config can be found at [https://github.com/NixOS/nixos-hardware NixOS Hardware repository]
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.
 
== Generate configuration for a target root ==
 
To generate configuration files with a specific root directory (commonly used during installation):
 
<syntaxhighlight lang="console">
# 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="console">
# nixos-generate-config --show-hardware-config
</syntaxhighlight>
 
= Specifying specific hardware =
 
A collection of hardware specific platforms with their config can be found at [https://github.com/NixOS/nixos-hardware NixOS Hardware repository].
 
[[Category:NixOS]]
[[Category:Configuration]]