From 00f380dee5c395704b8b83c462d0d735ff0e810e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 13 Oct 2013 16:20:49 +0200 Subject: [PATCH] Document nixos-generate-config --- .../doc/manual/man-nixos-generate-config.xml | 191 ++++++++++++++++++ nixos/doc/manual/man-pages.xml | 11 +- 2 files changed, 196 insertions(+), 6 deletions(-) create mode 100644 nixos/doc/manual/man-nixos-generate-config.xml diff --git a/nixos/doc/manual/man-nixos-generate-config.xml b/nixos/doc/manual/man-nixos-generate-config.xml new file mode 100644 index 000000000000..ff69d8d91701 --- /dev/null +++ b/nixos/doc/manual/man-nixos-generate-config.xml @@ -0,0 +1,191 @@ + + + + nixos-generate-config + 8 + NixOS + + + + + nixos-generate-config + generate NixOS configuration modules + + + + + nixos-generate-config + + + + root + + + + dir + + + + + +Description + +This command writes two NixOS configuration modules: + + + + + + + This module sets NixOS configuration options based on your + current hardware configuration. In particular, it sets the + option to reflect all currently + mounted file systems, the option to + reflect active swap devices, and the + 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 /etc/nixos/configuration.nix, and + re-run nixos-generate-config 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, + nixos-generate-config will write a template + for you to customise. + + + + + + + + + + +Options + +This command accepts the following options: + + + + + + + If this option is given, treat the directory + root as the root of the file system. + This means that configuration files will be written to + root/etc/nixos, + and that any file systems outside of + root are ignored for the purpose of + generating the option. + + + + + + + If this option is given, write the configuration files to + the directory dir instead of + /etc/nixos. + + + + + + + Overwrite + /etc/nixos/configuration.nix if it already + exists. + + + + + + + + +Examples + +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 /mnt and +/mnt/boot, you would run: + + +$ nixos-generate-config --root /mnt + + +The resulting file +/mnt/etc/nixos/hardware-configuration.nix might +look like this: + + +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, pkgs, ... }: + +{ + imports = + [ <nixos/modules/installer/scan/not-detected.nix> + ]; + + boot.initrd.availableKernelModules = [ "ehci_hcd" "ahci" ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-label/nixos"; + fsType = "ext3"; + options = "rw,data=ordered,relatime"; + }; + + fileSystems."/boot" = + { device = "/dev/sda1"; + fsType = "ext3"; + options = "rw,errors=continue,user_xattr,acl,barrier=1,data=writeback,relatime"; + }; + + swapDevices = + [ { device = "/dev/sda2"; } + ]; + + nix.maxJobs = 8; +} + + +It will also create a basic +/mnt/etc/nixos/configuration.nix, which you +should edit to customise the logical configuration of your system. +This file includes the result of the hardware scan as follows: + + + imports = [ ./hardware-configuration.nix ]; + + + +After installation, if your hardware configuration changes, you +can run: + + +$ nixos-generate-config + + +to update /etc/nixos/hardware-configuration.nix. +Your /etc/nixos/configuration.nix will +not be overwritten. + + + + diff --git a/nixos/doc/manual/man-pages.xml b/nixos/doc/manual/man-pages.xml index 7840e1b897b0..5178d595fda6 100644 --- a/nixos/doc/manual/man-pages.xml +++ b/nixos/doc/manual/man-pages.xml @@ -15,17 +15,16 @@ - 2007 - 2008 - 2009 + 2007-2013 Eelco Dolstra - + - + + - +