since we want to move away from docbook and having docbook manpages around is going to block further progress we have to translate the current nixos manpages from docbook it *something* else. mdoc seems the most appropriate choice since markdown can't represent all the things manpages can differentiate with even more extensions. if we ever need html manpages we can render them using troff, like many of the online manpage viewers, or rewrite them again. since we haven't had html manpages for any of these in many years that seems unlikely to happen. unlike most of the recent markdown conversions this comes with a lot of minor rendering changes, mostly in spacing. docbook-xslt creates manual pages in a very different dialect than mdoc (which is used here).
170 lines
4.2 KiB
Groff
170 lines
4.2 KiB
Groff
.Dd January 1, 1980
|
||
.\" nixpkgs groff will use Nixpkgs as the OS in the title by default, taking it from
|
||
.\" doc-default-operating-system. mandoc doesn't have this register set by default,
|
||
.\" so we can use it as a groff/mandoc switch.
|
||
.ie ddoc-default-operating-system .Dt nixos-generate-config \&8 "NixOS System Manager's Manual"
|
||
.el .Dt nixos-generate-config 8
|
||
.Os NixOS
|
||
.Sh NAME
|
||
.Nm nixos-generate-config
|
||
.Nd generate NixOS configuration modules
|
||
.
|
||
.
|
||
.
|
||
.Sh SYNOPSIS
|
||
.Nm nixos-generate-config
|
||
.Op Fl -force
|
||
.Op Fl -root Ar root
|
||
.Op Fl -dir Ar dir
|
||
.
|
||
.
|
||
.
|
||
.Sh DESCRIPTION
|
||
This command writes two NixOS configuration modules:
|
||
.Bl -tag -width indent
|
||
.It Pa /etc/nixos/hardware-configuration.nix
|
||
This module sets NixOS configuration options based on your current hardware
|
||
configuration. In particular, it sets the
|
||
.Va fileSystem
|
||
option to reflect all currently mounted file systems, the
|
||
.Va swapDevices
|
||
option to reflect active swap devices, and the
|
||
.Va boot.initrd.*
|
||
options to ensure that the initial ramdisk contains any kernel modules necessary
|
||
for mounting the root file system.
|
||
.Pp
|
||
If this file already exists, it is overwritten. Thus, you should not modify it
|
||
manually. Rather, you should include it from your
|
||
.Pa /etc/nixos/configuration.nix Ns
|
||
, and re-run
|
||
.Nm
|
||
to update it whenever your hardware configuration changes.
|
||
.
|
||
.It Pa /etc/nixos/configuration.nix
|
||
This is the main NixOS system configuration module. If it already exists, it’s
|
||
left unchanged. Otherwise,
|
||
.Nm
|
||
will write a template for you to customise.
|
||
.El
|
||
.
|
||
.
|
||
.
|
||
.Sh OPTIONS
|
||
.Bl -tag -width indent
|
||
.It Fl -root Ar root
|
||
If this option is given, treat the directory
|
||
.Ar root
|
||
as the root of the file system. This means that configuration files will be written to
|
||
.Ql Ar root Ns /etc/nixos Ns
|
||
, and that any file systems outside of
|
||
.Ar root
|
||
are ignored for the purpose of generating the
|
||
.Va fileSystems
|
||
option.
|
||
.
|
||
.It Fl -dir Ar dir
|
||
If this option is given, write the configuration files to the directory
|
||
.Ar dir
|
||
instead of
|
||
.Pa /etc/nixos Ns
|
||
\&.
|
||
.
|
||
.It Fl -force
|
||
Overwrite
|
||
.Pa /etc/nixos/configuration.nix
|
||
if it already exists.
|
||
.
|
||
.It Fl -no-filesystems
|
||
Omit everything concerning file systems and swap devices from the hardware configuration.
|
||
.
|
||
.It Fl -show-hardware-config
|
||
Don't generate
|
||
.Pa configuration.nix
|
||
or
|
||
.Pa hardware-configuration.nix
|
||
and print the hardware configuration to stdout only.
|
||
.El
|
||
.
|
||
.
|
||
.
|
||
.Sh 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
|
||
.Pa /mnt
|
||
and
|
||
.Pa /mnt/boot Ns
|
||
, you would run:
|
||
.Bd -literal -offset indent
|
||
$ nixos-generate-config --root /mnt
|
||
.Ed
|
||
.
|
||
.Pp
|
||
The resulting file
|
||
.Pa /mnt/etc/nixos/hardware-configuration.nix
|
||
might look like this:
|
||
.Bd -literal -offset indent
|
||
# 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;
|
||
}
|
||
.Ed
|
||
.
|
||
.Pp
|
||
It will also create a basic
|
||
.Pa /mnt/etc/nixos/configuration.nix Ns
|
||
, which you should edit to customise the logical configuration of your system. \
|
||
This file includes the result of the hardware scan as follows:
|
||
.Bd -literal -offset indent
|
||
imports = [ ./hardware-configuration.nix ];
|
||
.Ed
|
||
.
|
||
.Pp
|
||
After installation, if your hardware configuration changes, you can run:
|
||
.Bd -literal -offset indent
|
||
$ nixos-generate-config
|
||
.Ed
|
||
.
|
||
.Pp
|
||
to update
|
||
.Pa /etc/nixos/hardware-configuration.nix Ns
|
||
\&. Your
|
||
.Pa /etc/nixos/configuration.nix
|
||
will
|
||
.Em not
|
||
be overwritten.
|
||
.
|
||
.Sh AUTHORS
|
||
.An -nosplit
|
||
.An Eelco Dolstra
|
||
and
|
||
.An the Nixpkgs/NixOS contributors
|