This module sets NixOS configuration options based on your current hardware configuration. In particular, it sets the <option>fileSystem</option> option to reflect all currently mounted file systems, the <option>swapDevices</option> option to reflect active swap devices, and the <option>boot.initrd.*</option> options to ensure that the initial ramdisk contains any kernel modules necessary for mounting the root file system.
If this file already exists, it is overwritten. Thus, you should not modify it manually. Rather, you should include it from your <filename>/etc/nixos/configuration.nix</filename>, and re-run <command>nixos-generate-config</command> to update it whenever your hardware configuration changes.
This is the main NixOS system configuration module. If it already exists, it’s left unchanged. Otherwise, <command>nixos-generate-config</command> will write a template for you to customise.
If this option is given, treat the directory <replaceable>root</replaceable> as the root of the file system. This means that configuration files will be written to <filename><replaceable>root</replaceable>/etc/nixos</filename>, and that any file systems outside of <replaceable>root</replaceable> are ignored for the purpose of generating the <option>fileSystems</option> option.
Don't generate <filename>configuration.nix</filename> or <filename>hardware-configuration.nix</filename> and print the hardware configuration to stdout only.
This command is typically used during NixOS installation to write initial configuration modules. For example, if you created and mounted the target file systems on <filename>/mnt</filename> and <filename>/mnt/boot</filename>, you would run:
It will also create a basic <filename>/mnt/etc/nixos/configuration.nix</filename>, which you should edit to customise the logical configuration of your system. This file includes the result of the hardware scan as follows:
to update <filename>/etc/nixos/hardware-configuration.nix</filename>. Your <filename>/etc/nixos/configuration.nix</filename> will <emphasis>not</emphasis> be overwritten.