Micros Documentation Options

_module.args Link copied!

Type: lazy attribute set of raw value

Additional arguments passed to each module in addition to ones like lib, config, and pkgs, modulesPath.

This option is also available to all submodules. Submodules do not inherit args from their parent module, nor do they provide args to their parent module or sibling submodules. The sole exception to this is the argument name which is provided by parent modules to a submodule and contains the attribute name the submodule is bound to, or a unique generated name if it is not bound to an attribute.

Some arguments are already passed by default, of which the following cannot be changed with this option:

  • lib: The nixpkgs library.

  • config: The results of all options after merging the values from all modules together.

  • options: The options declared in all modules.

  • specialArgs: The specialArgs argument passed to evalModules.

  • All attributes of specialArgs

    Whereas option values can generally depend on other option values thanks to laziness, this does not apply to imports, which must be computed statically before anything else.

    For this reason, callers of the module system can provide specialArgs which are available during import resolution.

    For NixOS, specialArgs includes modulesPath, which allows you to import extra modules from the nixpkgs package tree without having to somehow make the module aware of the location of the nixpkgs or NixOS directories.

    { modulesPath, ... }: {
      imports = [
        (modulesPath + "/profiles/minimal.nix")
      ];
    }
    

For NixOS, the default value for this option includes at least this argument:

  • pkgs: The nixpkgs package set according to the nixpkgs.pkgs option.
Default: { }

boot.consoleLogLevel Link copied!

Type: signed integer

The kernel console loglevel. All Kernel Messages with a log level smaller than this setting will be printed to the console.

Default: 4

boot.devShmSize Link copied!

Type: string

Size limit for the /dev/shm tmpfs. Look at mount(8), tmpfs size option, for the accepted syntax.

Default: "50%"
Example: "256m"

boot.devSize Link copied!

Type: string

Size limit for the /dev tmpfs. Look at mount(8), tmpfs size option, for the accepted syntax.

Default: "5%"
Example: "32m"

boot.extraModulePackages Link copied!

Type: list of package

A list of additional packages supplying kernel modules.

Default: [ ]
Example: [ config.boot.kernelPackages.nvidia_x11 ]

boot.init.availableBackends Link copied!

Type: attribute set of (submodule)

List of available backends.

Default: { }

boot.init.availableBackends.<name>.executable Link copied!

Type: absolute path or string

Executable that stage 2 will hand off to as PID 1.

boot.init.availableBackends.<name>.extraFiles Link copied!

Type: attribute set of (submodule)

Extra files required by the init system, passed directly to environment.etc and uses the same syntax.

Default: [ ]

boot.init.availableBackends.<name>.extraFiles.<name>.enable Link copied!

Type: boolean

Whether this /etc file should be generated. This option allows specific /etc files to be disabled.

Default: true

boot.init.availableBackends.<name>.extraFiles.<name>.gid Link copied!

Type: signed integer

GID of created file. Only takes effect when the file is copied (that is, the mode is not 'symlink').

Default: 0

boot.init.availableBackends.<name>.extraFiles.<name>.group Link copied!

Type: string

Group name of file owner.

Only takes effect when the file is copied (that is, the mode is not symlink).

When services.userborn.enable, this option has no effect. You have to assign a gid instead. Otherwise this option takes precedence over gid.

Default: "+0"

boot.init.availableBackends.<name>.extraFiles.<name>.mode Link copied!

Type: string

If set to something else than symlink, the file is copied instead of symlinked, with the given file mode.

Default: "symlink"
Example: "0600"

boot.init.availableBackends.<name>.extraFiles.<name>.source Link copied!

Type: absolute path

Path of the source file.

boot.init.availableBackends.<name>.extraFiles.<name>.target Link copied!

Type: string

Name of symlink (relative to /etc). Defaults to the attribute name.

boot.init.availableBackends.<name>.extraFiles.<name>.text Link copied!

Type: null or strings concatenated with "\n"

Text of the file.

Default: null

boot.init.availableBackends.<name>.extraFiles.<name>.uid Link copied!

Type: signed integer

UID of created file. Only takes effect when the file is copied (that is, the mode is not 'symlink').

Default: 0

boot.init.availableBackends.<name>.extraFiles.<name>.user Link copied!

Type: string

User name of file owner.

Only takes effect when the file is copied (that is, the mode is not symlink).

When services.userborn.enable, this option has no effect. You have to assign a uid instead. Otherwise this option takes precedence over uid.

Default: "+0"

boot.init.availableBackends.<name>.name Link copied!

Type: string

Name of the init backend used after stage-2 activation.

boot.init.availableBackends.<name>.requiredPackages Link copied!

Type: list of package

Packages which are required for the backend to function.

Default: [ ]

boot.init.availableBackends.<name>.serviceBuilder Link copied!

Type: function

Function which takes config.micros.services as an input and outputs files to be appended to environment.etc.

boot.init.availableBackends.<name>.supportedFeatures Link copied!

Type: list of value "dependencies" (singular enum)

Extra features offered by the init backend, e.g. dependency management

Default: [ ]

boot.init.currentBackend Link copied!

Type: submodule

Init backend used after stage-2 activation has completed.

Default: { executable = "/nix/store/gmwg1y3hz8k8377iw8ll2d0xsf99c3fg-runit-2.3.1/bin/runit"; extraFiles = { "runit/1" = { enable = true; gid = 0; group = "+0"; mode = "symlink"; source = <derivation runit-stage-1>; target = "runit/1"; text = null; uid = 0; user = "+0"; }; "runit/2" = { enable = true; gid = 0; group = "+0"; mode = "symlink"; source = <derivation runit-stage-2>; target = "runit/2"; text = null; uid = 0; user = "+0"; }; "runit/3" = { enable = true; gid = 0; group = "+0"; mode = "symlink"; source = <derivation runit-stage-3>; target = "runit/3"; text = null; uid = 0; user = "+0"; }; "service/boot/run" = { enable = true; gid = 0; group = "+0"; mode = "symlink"; source = <derivation boot-manager-service>; target = "service/boot/run"; text = null; uid = 0; user = "+0"; }; }; name = "runit"; requiredPackages = [ <derivation runit-compat> <derivation runit-2.3.1> ]; serviceBuilder = <function>; supportedFeatures = [ "dependencies" ]; }

boot.init.currentBackend.executable Link copied!

Type: absolute path or string

Executable that stage 2 will hand off to as PID 1.

boot.init.currentBackend.extraFiles Link copied!

Type: attribute set of (submodule)

Extra files required by the init system, passed directly to environment.etc and uses the same syntax.

Default: [ ]

boot.init.currentBackend.extraFiles.<name>.enable Link copied!

Type: boolean

Whether this /etc file should be generated. This option allows specific /etc files to be disabled.

Default: true

boot.init.currentBackend.extraFiles.<name>.gid Link copied!

Type: signed integer

GID of created file. Only takes effect when the file is copied (that is, the mode is not 'symlink').

Default: 0

boot.init.currentBackend.extraFiles.<name>.group Link copied!

Type: string

Group name of file owner.

Only takes effect when the file is copied (that is, the mode is not symlink).

When services.userborn.enable, this option has no effect. You have to assign a gid instead. Otherwise this option takes precedence over gid.

Default: "+0"

boot.init.currentBackend.extraFiles.<name>.mode Link copied!

Type: string

If set to something else than symlink, the file is copied instead of symlinked, with the given file mode.

Default: "symlink"
Example: "0600"

boot.init.currentBackend.extraFiles.<name>.source Link copied!

Type: absolute path

Path of the source file.

boot.init.currentBackend.extraFiles.<name>.target Link copied!

Type: string

Name of symlink (relative to /etc). Defaults to the attribute name.

boot.init.currentBackend.extraFiles.<name>.text Link copied!

Type: null or strings concatenated with "\n"

Text of the file.

Default: null

boot.init.currentBackend.extraFiles.<name>.uid Link copied!

Type: signed integer

UID of created file. Only takes effect when the file is copied (that is, the mode is not 'symlink').

Default: 0

boot.init.currentBackend.extraFiles.<name>.user Link copied!

Type: string

User name of file owner.

Only takes effect when the file is copied (that is, the mode is not symlink).

When services.userborn.enable, this option has no effect. You have to assign a uid instead. Otherwise this option takes precedence over uid.

Default: "+0"

boot.init.currentBackend.name Link copied!

Type: string

Name of the init backend used after stage-2 activation.

boot.init.currentBackend.requiredPackages Link copied!

Type: list of package

Packages which are required for the backend to function.

Default: [ ]

boot.init.currentBackend.serviceBuilder Link copied!

Type: function

Function which takes config.micros.services as an input and outputs files to be appended to environment.etc.

boot.init.currentBackend.supportedFeatures Link copied!

Type: list of value "dependencies" (singular enum)

Extra features offered by the init backend, e.g. dependency management

Default: [ ]

boot.init.executable Link copied!

Type: absolute path or string

Executable that stage 2 will hand off to as PID 1.

Default: "/nix/store/gmwg1y3hz8k8377iw8ll2d0xsf99c3fg-runit-2.3.1/bin/runit"

boot.init.stage2Path Link copied!

Type: string

PATH value used by stage 2 before handing off to the init backend.

Default: "/run/booted-system/sw/bin"

boot.initrd.allowMissingModules Link copied!

Type: boolean

Whether the initrd can be built even though modules listed in boot.initrd.kernelModules or boot.initrd.availableKernelModules are missing from the kernel. This is useful when combining configurations that include a lot of modules, such as hardware.enableAllHardware, with kernels that don't provide as many modules as typical NixOS kernels.

Note that enabling this is discouraged. Instead, try disabling individual modules by setting e.g. boot.initrd.availableKernelModules.foo = lib.mkForce false;

Default: false

boot.initrd.availableKernelModules Link copied!

Type: (attribute set of boolean) or (list of string) convertible to it

The set of kernel modules in the initial ramdisk used during the boot process. This set must include all modules necessary for mounting the root device. That is, it should include modules for the physical device (e.g., SCSI drivers) and for the file system (e.g., ext3). The set specified here is automatically closed under the module dependency relation, i.e., all dependencies of the modules list here are included automatically. The modules listed here are available in the initrd, but are only loaded on demand (e.g., the ext3 module is loaded automatically when an ext3 filesystem is mounted, and modules for PCI devices are loaded when they match the PCI ID of a device in your system). To force a module to be loaded, include it in boot.initrd.kernelModules.

This can either be a list of modules, or an attrset. In an attrset, names that are set to true represent modules that will be included. Note that setting these names to false does not prevent the module from being loaded. For that, use boot.blacklistedKernelModules.

Default: { }
Example:
[
  "sata_nv"
  "ext3"
]

boot.initrd.compressor Link copied!

Type: string or function that evaluates to a(n) string

The compressor to use on the initrd image. May be any of:

  • The name of one of the predefined compressors, see pkgs/build-support/kernel/initrd-compressor-meta.nix for the definitions.
  • A function which, given the nixpkgs package set, returns the path to a compressor tool, e.g. pkgs: "${pkgs.pigz}/bin/pigz"
  • (not recommended, because it does not work when cross-compiling) the full path to a compressor tool, e.g. "${pkgs.pigz}/bin/pigz"

The given program should read data from stdin and write it to stdout compressed.

Default: `zstd` if the kernel supports it (5.9+), `gzip` if not
Example: "xz"

boot.initrd.compressorArgs Link copied!

Type: null or (list of string)

Arguments to pass to the compressor for the initrd image, or null to use the compressor's defaults.

Default: null

boot.initrd.enable Link copied!

Type: boolean

Whether to enable initrd.

Default: true
Example: true

boot.initrd.includeDefaultModules Link copied!

Type: boolean

This option, if set, adds a collection of default kernel modules to boot.initrd.availableKernelModules and boot.initrd.kernelModules.

Default: true

boot.initrd.kernelModules Link copied!

Type: (attribute set of boolean) or (list of string) convertible to it

Set of modules that are always loaded by the initrd.

This can either be a list of modules, or an attrset. In an attrset, names that are set to true represent modules that will be included. Note that setting these names to false does not prevent the module from being loaded. For that, use boot.blacklistedKernelModules.

Default: { }

boot.isContainer Link copied!

Type: boolean

Whether the image is a container.

Default: false

boot.kernel.enable Link copied!

Type: boolean

Whether to enable the Linux kernel. This is useful for systemd-like containers which do not require a kernel.

Default: true
Example: true

boot.kernel.randstructSeed Link copied!

Type: string

Provides a custom seed for the RANDSTRUCT security option of the Linux kernel. Note that RANDSTRUCT is only enabled in NixOS hardened kernels. Using a custom seed requires building the kernel and dependent packages locally, since this customization happens at build time.

Default: ""
Example: "my secret seed"

boot.kernel.sysctl Link copied!

Type: open submodule of attribute set of (sysctl option value)

Runtime parameters of the Linux kernel, as set by sysctl(8). Note that sysctl parameters names must be enclosed in quotes (e.g. "vm.swappiness" instead of vm.swappiness). The value of each parameter may be a string, integer, boolean, or null (signifying the option will not appear at all).

Default: { }
Example:
{ "net.ipv4.tcp_syncookies" = false; "vm.swappiness" = 60; }

boot.kernel.sysctl."net.core.rmem_max" Link copied!

Type: null or (unsigned integer, meaning >=0)

The maximum receive socket buffer size in bytes. In case of conflicting values, the highest will be used.

Default: null

boot.kernel.sysctl."net.core.wmem_max" Link copied!

Type: null or (unsigned integer, meaning >=0)

The maximum send socket buffer size in bytes. In case of conflicting values, the highest will be used.

Default: null

boot.kernelModules Link copied!

Type: (attribute set of boolean) or (list of string) convertible to it

The set of kernel modules to be loaded in the second stage of the boot process. Note that modules that are needed to mount the root file system should be added to boot.initrd.availableKernelModules or boot.initrd.kernelModules.

This can either be a list of modules, or an attrset. In an attrset, names that are set to true represent modules that will be included. Note that setting these names to false does not prevent the module from being loaded. For that, use boot.blacklistedKernelModules.

Default: { }

boot.kernelPackages Link copied!

Type: raw value

This option allows you to override the Linux kernel used by NixOS. Since things like external kernel module packages are tied to the kernel you're using, it also overrides those. This option is a function that takes Nixpkgs as an argument (as a convenience), and returns an attribute set containing at the very least an attribute kernel. Additional attributes may be needed depending on your configuration. For instance, if you use the NVIDIA X driver, then it also needs to contain an attribute nvidia_x11.

Please note that we strictly support kernel versions that are maintained by the Linux developers only. More information on the availability of kernel versions is documented in the Linux section of the manual.

Default: pkgs.linuxPackages
Example: pkgs.linuxKernel.packages.linux_5_10

boot.kernelParams Link copied!

Type: list of string, with spaces inside double quotes

Parameters added to the kernel command line.

Default: [ ]

boot.kernelPatches Link copied!

Type: list of (attribute set)

A list of additional patches to apply to the kernel.

Every item should be an attribute set with the following attributes:

{
  name = "foo";                 # descriptive name, required

  patch = ./foo.patch;          # path or derivation that contains the patch source
                                # (required, but can be null if only config changes
                                # are needed)

  structuredExtraConfig = {     # attrset of extra configuration parameters without the CONFIG_ prefix
    FOO = lib.kernel.yes;       # (optional)
  };                            # values should generally be lib.kernel.yes,
                                # lib.kernel.no or lib.kernel.module

  features = {                  # attrset of extra "features" the kernel is considered to have
    foo = true;                 # (may be checked by other NixOS modules, optional)
  };

  extraConfig = "FOO y";        # extra configuration options in string form without the CONFIG_ prefix
                                # (optional, multiple lines allowed to specify multiple options)
                                # (deprecated, use structuredExtraConfig instead)
}

There's a small set of existing kernel patches in Nixpkgs, available as pkgs.kernelPatches, that follow this format and can be used directly.

Default: [ ]
Example:
[
  {
    name = "foo";
    patch = ./foo.patch;
    structuredExtraConfig.FOO = lib.kernel.yes;
    features.foo = true;
  }
  {
    name = "foo-ml-mbox";
    patch = (fetchurl {
      url = "https://lore.kernel.org/lkml/19700205182810.58382-1-email@domain/t.mbox.gz";
      hash = "sha256-...";
    });
  }
]

boot.runSize Link copied!

Type: string

Size limit for the /run tmpfs. Look at mount(8), tmpfs size option, for the accepted syntax.

Default: "25%"
Example: "256m"

boot.specialFileSystems.<name>.depends Link copied!

Type: list of string (with check: non-empty without trailing slash)

List of paths that should be mounted before this one. This filesystem's device and mountPoint are always checked and do not need to be included explicitly. If a path is added to this list, any other filesystem whose mount point is a parent of the path will be mounted before this filesystem. The paths do not need to actually be the mountPoint of some other filesystem.

Default: [ ]
Example:
[
  "/persist"
]

boot.specialFileSystems.<name>.device Link copied!

Type: null or string (with check: non-empty)

Location of the device.

Default: null
Example: "/dev/sda"

boot.specialFileSystems.<name>.enable Link copied!

Type: boolean

Whether to enable the filesystem mount.

Default: true
Example: true

boot.specialFileSystems.<name>.fsType Link copied!

Type: string (with check: non-empty)

Type of the file system.

Default: "auto"
Example: "ext3"

boot.specialFileSystems.<name>.mountPoint Link copied!

Type: string (with check: non-empty without trailing slash)

Location of the mounted file system.

Example: "/mnt/usb"

boot.specialFileSystems.<name>.neededForBoot Link copied!

Type: boolean

Whether to mount filesystem in Stage 1

Default: false
Example: true

boot.specialFileSystems.<name>.options Link copied!

Type: non-empty (list of string (with check: non-empty))

Options used to mount the file system.

Default: [ "defaults" ]
Example:
[
  "data=journal"
]

boot.specialFileSystems.<name>.stratis.poolUuid Link copied!

Type: null or string

UUID of the stratis pool that the fs is located in

Default: null
Example: "04c68063-90a5-4235-b9dd-6180098a20d9"

boot.supportedFilesystems Link copied!

Type: (attribute set of boolean) or (list of string) convertible to it

Names of supported filesystem types, or an attribute set of file system types and their state. The set form may be used together with lib.mkForce to explicitly disable support for specific filesystems, e.g. to disable ZFS with an unsupported kernel.

Default: { }
Example:
{
  btrfs = true;
  zfs = lib.mkForce false;
}

boot.vesa Link copied!

Type: boolean

(Deprecated) This option, if set, activates the VESA 800x600 video mode on boot and disables kernel modesetting. It is equivalent to specifying [ "vga=0x317" "nomodeset" ] in the boot.kernelParams option. This option is deprecated as of 2020: Xorg now works better with modesetting, and you might want a different VESA vga setting, anyway.

Default: false

environment.binsh Link copied!

Type: absolute path

The shell executable that is linked system-wide to /bin/sh.

Default: "${config.system.build.binsh}/bin/sh"
Example: "${pkgs.dash}/bin/dash"

environment.etc Link copied!

Type: attribute set of (submodule)

Set of files that have to be linked in /etc.

Default: { }
Example:
{ example-configuration-file =
    { source = "/nix/store/.../etc/dir/file.conf.example";
      mode = "0440";
    };
  "default/useradd".text = "GROUP=100 ...";
}

environment.etc.<name>.enable Link copied!

Type: boolean

Whether this /etc file should be generated. This option allows specific /etc files to be disabled.

Default: true

environment.etc.<name>.gid Link copied!

Type: signed integer

GID of created file. Only takes effect when the file is copied (that is, the mode is not 'symlink').

Default: 0

environment.etc.<name>.group Link copied!

Type: string

Group name of file owner.

Only takes effect when the file is copied (that is, the mode is not symlink).

When services.userborn.enable, this option has no effect. You have to assign a gid instead. Otherwise this option takes precedence over gid.

Default: "+0"

environment.etc.<name>.mode Link copied!

Type: string

If set to something else than symlink, the file is copied instead of symlinked, with the given file mode.

Default: "symlink"
Example: "0600"

environment.etc.<name>.source Link copied!

Type: absolute path

Path of the source file.

environment.etc.<name>.target Link copied!

Type: string

Name of symlink (relative to /etc). Defaults to the attribute name.

environment.etc.<name>.text Link copied!

Type: null or strings concatenated with "\n"

Text of the file.

Default: null

environment.etc.<name>.uid Link copied!

Type: signed integer

UID of created file. Only takes effect when the file is copied (that is, the mode is not 'symlink').

Default: 0

environment.etc.<name>.user Link copied!

Type: string

User name of file owner.

Only takes effect when the file is copied (that is, the mode is not symlink).

When services.userborn.enable, this option has no effect. You have to assign a uid instead. Otherwise this option takes precedence over uid.

Default: "+0"

environment.extraInit Link copied!

Type: strings concatenated with "\n"

Shell script code called during global environment initialisation after all variables and profileVariables have been set. This code is assumed to be shell-independent, which means you should stick to pure sh without sh word split.

Default: ""

environment.extraOutputsToInstall Link copied!

Type: list of string

List of additional package outputs to be symlinked into /run/current-system/sw.

Default: [ ]
Example:
[
  "doc"
  "info"
  "docdev"
]

environment.extraSetup Link copied!

Type: strings concatenated with "\n"

Shell fragments to be run after the system environment has been created.

This should only be used for things that need to modify the internals of the environment, e.g. generating MIME caches. The environment being built can be accessed at $out.

Default: ""

environment.systemPackages Link copied!

Type: list of package

The set of packages that appear in /run/current-system/sw.

These packages are automatically available to all users, and are automatically updated every time you rebuild the system configuration. (The latter is the main difference with installing them in the default profile, /nix/var/nix/profiles/default.

Default: [ ]
Example: [ pkgs.firefox pkgs.thunderbird ]

fileSystems Link copied!

Type: attribute set of (submodule)

The file systems to be mounted. It must include an entry for the root directory (mountPoint = "/"). Each entry in the list is an attribute set with the following fields: mountPoint, device, fsType (a file system type recognised by mount; defaults to "auto"), and options (the mount options passed to mount using the -o flag; defaults to [ "defaults" ]).

Instead of specifying device, you can also specify a volume label (label) for file systems that support it, such as ext2/ext3 (see mke2fs -L).

Default: { }
Example:
{
  "/".device = "/dev/hda1";
  "/data" = {
    device = "/dev/hda2";
    fsType = "ext3";
    options = [ "data=journal" ];
  };
  "/bigdisk".label = "bigdisk";
}

fileSystems.<name>.autoFormat Link copied!

Type: boolean

If the device does not currently contain a filesystem (as determined by blkid), then automatically format it with the filesystem type specified in fsType. Use with caution.

Default: false

fileSystems.<name>.autoResize Link copied!

Type: boolean

If set, the filesystem is grown to its maximum size before being mounted. (This is typically the size of the containing partition.) This is currently only supported for ext2/3/4 filesystems that are mounted during early boot.

Default: false

fileSystems.<name>.depends Link copied!

Type: list of string (with check: non-empty without trailing slash)

List of paths that should be mounted before this one. This filesystem's device and mountPoint are always checked and do not need to be included explicitly. If a path is added to this list, any other filesystem whose mount point is a parent of the path will be mounted before this filesystem. The paths do not need to actually be the mountPoint of some other filesystem.

Default: [ ]
Example:
[
  "/persist"
]

fileSystems.<name>.device Link copied!

Type: null or string (with check: non-empty)

Location of the device.

Default: null
Example: "/dev/sda"

fileSystems.<name>.enable Link copied!

Type: boolean

Whether to enable the filesystem mount.

Default: true
Example: true

fileSystems.<name>.fsType Link copied!

Type: string (with check: non-empty)

Type of the file system.

Default: "auto"
Example: "ext3"

fileSystems.<name>.label Link copied!

Type: null or string (with check: non-empty)

Label of the device (if any).

Default: null
Example: "root-partition"

fileSystems.<name>.mountPoint Link copied!

Type: string (with check: non-empty without trailing slash)

Location of the mounted file system.

Example: "/mnt/usb"

fileSystems.<name>.neededForBoot Link copied!

Type: boolean

Whether to mount filesystem in Stage 1

Default: false
Example: true

fileSystems.<name>.noCheck Link copied!

Type: boolean

Disable running fsck on this filesystem.

Default: false

fileSystems.<name>.options Link copied!

Type: non-empty (list of string (with check: non-empty))

Options used to mount the file system.

Default: [ "defaults" ]
Example:
[
  "data=journal"
]

fileSystems.<name>.stratis.poolUuid Link copied!

Type: null or string

UUID of the stratis pool that the fs is located in

Default: null
Example: "04c68063-90a5-4235-b9dd-6180098a20d9"

hardware.firmware Link copied!

Type: list of package

Firmware packages

Default: [ ]

lib Link copied!

Type: attribute set of (attribute set)

This option allows modules to define helper functions, constants, etc.

Default: { }

meta.maintainers Link copied!

Type: list of lib.maintainers

List of maintainers of each module. This option should be defined at most once per module.

The option value is not a list of maintainers, but an attribute set that maps module file names to lists of maintainers.

Default: [ ]
Example: [ lib.maintainers.alice lib.maintainers.bob ]

meta.teams Link copied!

Type: list of lib.teams

List of team maintainers of each module. This option should be defined at most once per module.

Default: [ ]
Example: [ lib.teams.acme lib.teams.haskell ]

micros.services Link copied!

Type: attribute set of (submodule)

Init-backend-agnostic service definitions.

Default: { }

micros.services.<name>.confScript Link copied!

Type: null or strings concatenated with "\n"

Optional shell fragment available to init backends that support service configuration files.

Default: null

micros.services.<name>.dependencies Link copied!

Type: list of string

Other services to depend on. If they are not running, start them prior to starting this service.

Default: [ ]

micros.services.<name>.enable Link copied!

Type: boolean

Whether to enable Whether to enable this service. .

Default: true
Example: true

micros.services.<name>.finishScript Link copied!

Type: null or strings concatenated with "\n"

Optional shell script run by init backends that support service exit hooks.

Default: null

micros.services.<name>.name Link copied!

Type: string

Service name used by the selected init backend.

micros.services.<name>.startOnBoot Link copied!

Type: boolean

Whether to start automatically after boot

Default: false

micros.services.<name>.startScript Link copied!

Type: null or strings concatenated with "\n"

Shell script used to start the service.

Default: null

micros.services.<name>.type Link copied!

Type: one of "longrun", "oneshot"

Whether this service should be supervised continuously or run once.

Default: "longrun"

networking.dhcp.enable Link copied!

Type: boolean

Whether to enable DHCP globally. This is overrided by individual interface settings. Defaults to true

Default: true

networking.dhcp.overrideNameservers Link copied!

Type: boolean

Whether to use DHCP nameservers over configured ones. Defaults to false.

Default: false

networking.firewall.allowPing Link copied!

Type: boolean

Whether to respond to incoming ICMPv4 echo requests ("pings"). ICMPv6 pings are always allowed because the larger address space of IPv6 makes network scanning much less effective.

Default: true

networking.firewall.allowedTCPPortRanges Link copied!

Type: list of attribute set of 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Range of open TCP ports.

Default: [ ]
Example:
[
  {
    from = 32000;
    to = 32768;
  }
]

networking.firewall.allowedTCPPorts Link copied!

Type: list of 16 bit unsigned integer; between 0 and 65535 (both inclusive)

List of open TCP ports.

Default: [ ]
Example:
[
  22
]

networking.firewall.allowedUDPPortRanges Link copied!

Type: list of attribute set of 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Range of open UDP ports.

Default: [ ]
Example:
[
  {
    from = 32000;
    to = 32768;
  }
]

networking.firewall.allowedUDPPorts Link copied!

Type: list of 16 bit unsigned integer; between 0 and 65535 (both inclusive)

List of open UDP ports.

Default: [ ]
Example:
[
  53
]

networking.firewall.autoLoadConntrackHelpers Link copied!

Type: boolean

Whether to auto-load connection-tracking helpers. See the description at networking.firewall.connectionTrackingModules

(needs kernel 3.5+)

Default: false

networking.firewall.checkReversePath Link copied!

Type: boolean or one of "strict", "loose"

Performs a reverse path filter test on a packet. If a reply to the packet would not be sent via the same interface that the packet arrived on, it is refused.

If using asymmetric routing or other complicated routing, set this option to loose mode or disable it and setup your own counter-measures.

This option can be either true (or "strict"), "loose" (only drop the packet if the source address is not reachable via any interface) or false.

Default: `true` except if the iptables based firewall is in use and the kernel lacks rpfilter support
Example: "loose"

networking.firewall.connectionTrackingModules Link copied!

Type: list of string

List of connection-tracking helpers that are auto-loaded. The complete list of possible values is given in the example.

As helpers can pose as a security risk, it is advised to set this to an empty list and disable the setting networking.firewall.autoLoadConntrackHelpers unless you know what you are doing. Connection tracking is disabled by default.

Loading of helpers is recommended to be done through the CT target. More info: <https://home.regit.org/netfilter-en/secure-use-of-helpers/>

Default: [ ]
Example:
[
  "ftp"
  "irc"
  "sane"
  "sip"
  "tftp"
  "amanda"
  "h323"
  "netbios_sn"
  "pptp"
  "snmp"
]

networking.firewall.enable Link copied!

Type: boolean

Whether to enable firewall.

Default: false
Example: true

networking.firewall.extraForwardRules Link copied!

Type: strings concatenated with "\n"

Additional nftables rules to be appended to the forward-allow chain.

This option only works with the nftables based firewall.

Default: ""
Example: "iifname wg0 accept"

networking.firewall.extraInputRules Link copied!

Type: strings concatenated with "\n"

Additional nftables rules to be appended to the input-allow chain.

This option only works with the nftables based firewall.

Default: ""
Example: "ip6 saddr { fc00::/7, fe80::/10 } tcp dport 24800 accept"

networking.firewall.extraReversePathFilterRules Link copied!

Type: strings concatenated with "\n"

Additional nftables rules to be appended to the rpfilter-allow chain.

This option only works with the nftables based firewall.

Default: ""
Example: "fib daddr . mark . iif type local accept"

networking.firewall.filterForward Link copied!

Type: boolean

Enable filtering in IP forwarding.

This option only works with the nftables based firewall.

Default: false

networking.firewall.interfaces Link copied!

Type: attribute set of (submodule)

Interface-specific open ports.

Default: { }

networking.firewall.interfaces.<name>.allowedTCPPortRanges Link copied!

Type: list of attribute set of 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Range of open TCP ports.

Default: [ ]
Example:
[
  {
    from = 32000;
    to = 32768;
  }
]

networking.firewall.interfaces.<name>.allowedTCPPorts Link copied!

Type: list of 16 bit unsigned integer; between 0 and 65535 (both inclusive)

List of open TCP ports.

Default: [ ]
Example:
[
  22
]

networking.firewall.interfaces.<name>.allowedUDPPortRanges Link copied!

Type: list of attribute set of 16 bit unsigned integer; between 0 and 65535 (both inclusive)

Range of open UDP ports.

Default: [ ]
Example:
[
  {
    from = 32000;
    to = 32768;
  }
]

networking.firewall.interfaces.<name>.allowedUDPPorts Link copied!

Type: list of 16 bit unsigned integer; between 0 and 65535 (both inclusive)

List of open UDP ports.

Default: [ ]
Example:
[
  53
]

networking.firewall.logRefusedConnections Link copied!

Type: boolean

Whether to log rejected or dropped incoming connections. Note: The logs are found in the kernel logs, i.e. dmesg or journalctl -k.

Default: true

networking.firewall.logRefusedPackets Link copied!

Type: boolean

Whether to log all rejected or dropped incoming packets. This tends to give a lot of log messages, so it's mostly useful for debugging. Note: The logs are found in the kernel logs, i.e. dmesg or journalctl -k.

Default: false

networking.firewall.logRefusedUnicastsOnly Link copied!

Type: boolean

If networking.firewall.logRefusedPackets and this option are enabled, then only log packets specifically directed at this machine, i.e., not broadcasts or multicasts.

Default: true

networking.firewall.logReversePathDrops Link copied!

Type: boolean

Logs dropped packets failing the reverse path filter test if the option networking.firewall.checkReversePath is enabled.

Default: false

networking.firewall.pingLimit Link copied!

Type: null or strings concatenated with " "

If pings are allowed, this allows setting rate limits on them.

For the iptables based firewall, it should be set like "--limit 1/minute --limit-burst 5".

For the nftables based firewall, it should be set like "2/second" or "1/minute burst 5 packets".

Default: null
Example: "--limit 1/minute --limit-burst 5"

networking.firewall.rejectPackets Link copied!

Type: boolean

If set, refused packets are rejected rather than dropped (ignored). This means that an ICMP "port unreachable" error message is sent back to the client (or a TCP RST packet in case of an existing connection). Rejecting packets makes port scanning somewhat easier.

Default: false

networking.firewall.trustedInterfaces Link copied!

Type: list of string

Traffic coming in from these interfaces will be accepted unconditionally. Traffic from the loopback (lo) interface will always be accepted.

Default: [ ]
Example:
[
  "enp0s2"
]

networking.hostId Link copied!

Type: null or string

The 32-bit host ID of the machine, formatted as 8 hexadecimal characters.

You should try to make this ID unique among your machines. You can generate a random 32-bit ID using the following commands:

head -c 8 /etc/machine-id

(this derives it from the machine-id that systemd generates) or

head -c4 /dev/urandom | od -A none -t x4

The primary use case is to ensure when using ZFS that a pool isn't imported accidentally on a wrong machine.

Default: null
Example: "4e98920d"

networking.hostName Link copied!

Type: string matching the pattern ^$|^[[:alnum:]]([[:alnum:]_-]{0,61}[[:alnum:]])?$

The name of the machine. Leave it empty if you want to obtain it from a DHCP server (if using DHCP). The hostname must be a valid DNS label (see RFC 1035 section 2.3.1: "Preferred name syntax", RFC 1123 section 2.1: "Host Names and Numbers") and as such must not contain the domain part. This means that the hostname must start with a letter or digit, end with a letter or digit, and have as interior characters only letters, digits, and hyphen. The maximum length is 63 characters. Additionally it is recommended to only use lower-case characters. If (e.g. for legacy reasons) a FQDN is required as the Linux kernel network node hostname (uname --nodename) the option boot.kernel.sysctl."kernel.hostname" can be used as a workaround (but the 64 character limit still applies).

WARNING: Do not use underscores (_) or you may run into unexpected issues.

Default: "micros"

networking.interfaces Link copied!

Type: list of (submodule)

The list of interfaces to configure. By default, all network interfaces detected on startup are brought up with DHCP. Use this to manually configure interfaces and set static IPs.

Default: [ ]

networking.interfaces.*.dhcp Link copied!

Type: null or boolean

Whether to use DHCP for the interface. When null (default), DHCP is used if ipv4 has no manually configured addresses.

Default: null

networking.interfaces.*.enable Link copied!

Type: boolean

Whether to enable the interface. This determines if the interface will have an entry in the /etc/network/interfaces file.

Default: true

networking.interfaces.*.ipv4.address Link copied!

Type: null or string matching the pattern ^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]).){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])/([1-9]|[1-2][0-9]|3[0-2])$

IPV4 address given to the interface, with the subnet mask. Given as "x.x.x.x/xx".

Default: null

networking.interfaces.*.ipv4.gateway Link copied!

Type: null or string matching the pattern ^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]).){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$

IPV4 address used as the network gateway. Given as "x.x.x.x".

Default: null

networking.interfaces.*.ipv6.address Link copied!

Type: null or string matching the pattern (([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/([1-9]|[1-9][0-9]|1[01][0-9]|12[0-8])

IPV6 address given to the interface, with the subnet mask.

Default: null

networking.interfaces.*.ipv6.gateway Link copied!

Type: null or string matching the pattern (([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))

IPV6 address used as the network gateway.

Default: null

networking.interfaces.*.name Link copied!

Type: string

Name of the interface. This is used in the /etc/network/interfaces file and needs to be set to a valid network interface, e.g. eth0, ens1p0, wlp2s0, etc.

networking.interfaces.*.slaac Link copied!

Type: null or boolean

Whether to use SLAAC for configuring IPV6 on the interface. When null (default), SLAAC is used if ipv6 has no manually configured addresses.

Default: null

networking.nameservers Link copied!

Type: list of string matching the pattern (([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])

The list of nameservers used. This can be overrided by DHCP. Defaults to cloudflare DNS (1.1.1.1, 1.0.0.1).

Default: [ "1.1.1.1" "1.0.0.1" ]

networking.nftables.checkRuleset Link copied!

Type: boolean

Run nft check on the ruleset to spot syntax errors during build. Because this is executed in a sandbox, the check might fail if it requires access to any environmental factors or paths outside the Nix store. To circumvent this, the ruleset file can be edited using the preCheckRuleset option to work in the sandbox environment.

Default: true

networking.nftables.checkRulesetRedirects Link copied!

Type: attribute set of absolute path

Set of paths that should be intercepted and rewritten while checking the ruleset using pkgs.buildPackages.libredirect.

Default: { }

networking.nftables.enable Link copied!

Type: boolean

Whether to enable nftables and use nftables based firewall if enabled. nftables is a Linux-based packet filtering framework intended to replace frameworks like iptables.

Note that if you have Docker enabled you will not be able to use nftables without intervention. Docker uses iptables internally to setup NAT for containers. This module disables the ip_tables kernel module, however Docker automatically loads the module. Please see <https://github.com/NixOS/nixpkgs/issues/24318#issuecomment-289216273> for more information.

There are other programs that use iptables internally too, such as libvirt. For information on how the two firewalls interact, see <https://wiki.nftables.org/wiki-nftables/index.php/Troubleshooting#Question_4._How_do_nftables_and_iptables_interact_when_used_on_the_same_system.3F>.

Default: false

networking.nftables.extraDeletions Link copied!

Type: strings concatenated with "\n"

Extra deletion commands to be run on every firewall start, reload and after stopping the firewall.

Default: ""
Example:
''
  # this makes deleting a non-existing table a no-op instead of an error
  table inet some-table;
  
  delete table inet some-table;
''

networking.nftables.flattenRulesetFile Link copied!

Type: boolean

Use builtins.readFile rather than include to handle networking.nftables.rulesetFile. It is useful when you want to apply networking.nftables.preCheckRuleset to networking.nftables.rulesetFile.

Note

It is expected that networking.nftables.rulesetFile can be accessed from the build sandbox.

Default: false

networking.nftables.flushRuleset Link copied!

Type: boolean

Whether to enable flushing the entire ruleset on each reload.

Default: false
Example: true

networking.nftables.preCheckRuleset Link copied!

Type: strings concatenated with "\n"

This script gets run before the ruleset is checked. It can be used to create additional files needed for the ruleset check to work, or modify the ruleset for cases the build environment cannot cover.

Default: ""
Example:
sed 's/skgid meadow/skgid nogroup/g' -i ruleset.conf

networking.nftables.ruleset Link copied!

Type: strings concatenated with "\n"

The ruleset to be used with nftables. Should be in a format that can be loaded using "/bin/nft -f". The ruleset is updated atomically. Note that if the tables should be cleaned first, either:

  • networking.nftables.flushRuleset = true; needs to be set (flushes all tables)
  • networking.nftables.extraDeletions needs to be set
  • or networking.nftables.tables can be used, which will clean up the table automatically
Default: ""
Example:
''
  # Check out https://wiki.nftables.org/ for better documentation.
  # Table for both IPv4 and IPv6.
  table inet filter {
    # Block all incoming connections traffic except SSH and "ping".
    chain input {
      type filter hook input priority 0;
  
      # accept any localhost traffic
      iifname lo accept
  
      # accept traffic originated from us
      ct state {established, related} accept
  
      # ICMP
      # routers may also want: mld-listener-query, nd-router-solicit
      ip6 nexthdr icmpv6 icmpv6 type { destination-unreachable, packet-too-big, time-exceeded, parameter-problem, nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert } accept
      ip protocol icmp icmp type { destination-unreachable, router-advertisement, time-exceeded, parameter-problem } accept
  
      # allow "ping"
      ip6 nexthdr icmpv6 icmpv6 type echo-request accept
      ip protocol icmp icmp type echo-request accept
  
      # accept SSH connections (required for a server)
      tcp dport 22 accept
  
      # count and drop any other traffic
      counter drop
    }
  
    # Allow all outgoing connections.
    chain output {
      type filter hook output priority 0;
      accept
    }
  
    chain forward {
      type filter hook forward priority 0;
      accept
    }
  }
''

networking.nftables.rulesetFile Link copied!

Type: null or absolute path

The ruleset file to be used with nftables. Should be in a format that can be loaded using "nft -f". The ruleset is updated atomically.

Default: null

networking.nftables.tables Link copied!

Type: attribute set of (submodule)

Tables to be added to ruleset. Tables will be added together with delete statements to clean up the table before every update.

Default: { }
Example:
{
  filter = {
    content = ''
      # Check out https://wiki.nftables.org/ for better documentation.
      # Table for both IPv4 and IPv6.
      # Block all incoming connections traffic except SSH and "ping".
      chain input {
        type filter hook input priority 0;
      
        # accept any localhost traffic
        iifname lo accept
      
        # accept traffic originated from us
        ct state {established, related} accept
      
        # ICMP
        # routers may also want: mld-listener-query, nd-router-solicit
        ip6 nexthdr icmpv6 icmpv6 type { destination-unreachable, packet-too-big, time-exceeded, parameter-problem, nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert } accept
        ip protocol icmp icmp type { destination-unreachable, router-advertisement, time-exceeded, parameter-problem } accept
      
        # allow "ping"
        ip6 nexthdr icmpv6 icmpv6 type echo-request accept
        ip protocol icmp icmp type echo-request accept
      
        # accept SSH connections (required for a server)
        tcp dport 22 accept
      
        # count and drop any other traffic
        counter drop
      }
      
      # Allow all outgoing connections.
      chain output {
        type filter hook output priority 0;
        accept
      }
      
      chain forward {
        type filter hook forward priority 0;
        accept
      }
    '';
    family = "inet";
  };
}

networking.nftables.tables.<name>.content Link copied!

Type: strings concatenated with "\n"

The table content.

networking.nftables.tables.<name>.enable Link copied!

Type: boolean

Enable this table.

Default: true

networking.nftables.tables.<name>.family Link copied!

Type: one of "ip", "ip6", "inet", "arp", "bridge", "netdev"

Table family.

networking.timeServers Link copied!

Type: list of string

The set of NTP servers from which to synchronise.

Default: [ "0.nixos.pool.ntp.org" "1.nixos.pool.ntp.org" "2.nixos.pool.ntp.org" "3.nixos.pool.ntp.org" ]

nix.enable Link copied!

Type: boolean

Whether to enable Nix.

Disabling Nix makes the system hard to modify and the Nix programs and configuration will not be made available by NixOS itself.

Default: false

nix.nixPath Link copied!

Type: list of string

The default Nix expression search path, used by the Nix evaluator to look up paths enclosed in angle brackets (e.g. <nixpkgs>).

Default: [ ]

nix.package Link copied!

Type: package

This option specifies the Nix package instance to use throughout the system.

Default: pkgs.nix

nix.registry Link copied!

Type: attribute set of (submodule)

A system-wide flake registry.

Default: { }

nix.registry.<name>.exact Link copied!

Type: boolean

Whether the from reference needs to match exactly. If set, a from reference like nixpkgs does not match with a reference like nixpkgs/nixos-20.03.

Default: true

nix.registry.<name>.flake Link copied!

Type: null or (attribute set)

The flake input from is rewritten to.

Default: null
Example: nixpkgs

nix.registry.<name>.from Link copied!

Type: attribute set of (string or signed integer or boolean or absolute path or package)

The flake reference to be rewritten.

Default: { }
Example:
{
  id = "nixpkgs";
  type = "indirect";
}

nix.registry.<name>.to Link copied!

Type: attribute set of (string or signed integer or boolean or absolute path or package)

The flake reference from is rewritten to.

Default: { }
Example:
{
  owner = "my-org";
  repo = "my-nixpkgs";
  type = "github";
}

nixpkgs.buildPlatform Link copied!

Type: string or (attribute set)

Specifies the platform on which NixOS should be built. By default, NixOS is built on the system where it runs, but you can change where it's built. Setting this option will cause NixOS to be cross-compiled.

For instance, if you're doing distributed multi-platform deployment, or if you're building machines, you can set this to match your development system and/or build farm.

Ignored when nixpkgs.pkgs is set.

Default: config.nixpkgs.hostPlatform
Example:
{
  system = "x86_64-linux";
}

nixpkgs.config Link copied!

Type: nixpkgs config

Global configuration for Nixpkgs. The complete list of Nixpkgs configuration options is in the Nixpkgs manual section on global configuration.

Ignored when nixpkgs.pkgs is set.

Default: { }
Example:
{ allowBroken = true; allowUnfree = true; }

nixpkgs.crossSystem Link copied!

Type: null or (attribute set)

Systems with a recently generated hardware-configuration.nix may instead specify only nixpkgs.buildPlatform, or fall back to removing the nixpkgs.hostPlatform line from the generated config.

Specifies the platform for which NixOS should be built. Specify this only if it is different from nixpkgs.localSystem, the platform on which NixOS should be built. In other words, specify this to cross-compile NixOS. Otherwise it should be set as null, the default. See its description in the Nixpkgs manual for more details.

Ignored when nixpkgs.pkgs or hostPlatform is set.

Default: null
Example:
{
  system = "aarch64-linux";
}

nixpkgs.flake.setFlakeRegistry Link copied!

Type: boolean

Whether to pin nixpkgs in the system-wide flake registry (/etc/nix/registry.json) to the store path of the sources of nixpkgs used to build the NixOS system.

This is on by default for NixOS configurations built with flakes.

This option makes nix run nixpkgs#hello reuse dependencies from the system, avoid refetching nixpkgs, and have a consistent result every time.

Note that this option makes the NixOS closure depend on the nixpkgs sources, which may add undesired closure size if the system will not have any nix commands run on it.

Default: "config.nixpkgs.flake.source != null"

nixpkgs.flake.setNixPath Link copied!

Type: boolean

Whether to set NIX_PATH to include nixpkgs=flake:nixpkgs such that <nixpkgs> lookups receive the version of nixpkgs that the system was built with, in concert with nixpkgs.flake.setFlakeRegistry.

This is on by default for NixOS configurations built with flakes.

This makes nix-build '<nixpkgs>' -A hello work out of the box on flake systems.

Note that this option makes the NixOS closure depend on the nixpkgs sources, which may add undesired closure size if the system will not have any nix commands run on it.

Default: "config.nixpkgs.flake.source != null"

nixpkgs.flake.source Link copied!

Type: null or string or absolute path

The path to the nixpkgs sources used to build the system. This is automatically set up to be the store path of the nixpkgs flake used to build the system if using nixpkgs.lib.nixosSystem, and is otherwise null by default.

This can also be optionally set if the NixOS system is not built with a flake but still uses pinned sources: set this to the store path for the nixpkgs sources used to build the system, as may be obtained by builtins.fetchTarball, for example.

Note: the name of the store path must be "source" due to <https://github.com/NixOS/nix/issues/7075>.

Default: "if (using nixpkgsFlake.lib.nixosSystem) then self.outPath else null"
Example: "builtins.fetchTarball { name = \"source\"; sha256 = \"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"; url = \"https://github.com/nixos/nixpkgs/archive/somecommit.tar.gz\"; }"

nixpkgs.hostPlatform Link copied!

Type: string or (attribute set)

Specifies the platform where the NixOS configuration will run.

To cross-compile, set also nixpkgs.buildPlatform.

Ignored when nixpkgs.pkgs is set.

Example:
{
  system = "aarch64-linux";
}

nixpkgs.localSystem Link copied!

Type: attribute set

Systems with a recently generated hardware-configuration.nix do not need to specify this option, unless cross-compiling, in which case you should set only nixpkgs.buildPlatform.

If this is somehow not feasible, you may fall back to removing the nixpkgs.hostPlatform line from the generated config and use the old options.

Specifies the platform on which NixOS should be built. When nixpkgs.crossSystem is unset, it also specifies the platform for which NixOS should be built. If this option is unset, it defaults to the platform type of the machine where evaluation happens. Specifying this option is useful when doing distributed multi-platform deployment, or when building virtual machines. See its description in the Nixpkgs manual for more details.

Ignored when nixpkgs.pkgs or hostPlatform is set.

Default: config.nixpkgs.system
Example:
{
  system = "aarch64-linux";
}

nixpkgs.overlays Link copied!

Type: list of (nixpkgs overlay)

List of overlays to apply to Nixpkgs. This option allows modifying the Nixpkgs package set accessed through the pkgs module argument.

For details, see the Overlays chapter in the Nixpkgs manual.

If the nixpkgs.pkgs option is set, overlays specified using nixpkgs.overlays will be applied after the overlays that were already included in nixpkgs.pkgs.

Default: [ ]
Example:
[
  (self: super: {
    openssh = super.openssh.override {
      hpnSupport = true;
      kerberos = self.libkrb5;
    };
  })
]

nixpkgs.pkgs Link copied!

Type: An evaluation of Nixpkgs; the top level attribute set of packages

If set, the pkgs argument to all NixOS modules is the value of this option, extended with nixpkgs.overlays, if that is also set. Either nixpkgs.crossSystem or nixpkgs.localSystem will be used in an assertion to check that the NixOS and Nixpkgs architectures match. Any other options in nixpkgs.*, notably config, will be ignored.

If unset, the pkgs argument to all NixOS modules is determined as shown in the default value for this option.

The default value imports the Nixpkgs source files relative to the location of this NixOS module, because NixOS and Nixpkgs are distributed together for consistency, so the nixos in the default value is in fact a relative path. The config, overlays, localSystem, and crossSystem come from this option's siblings.

This option can be used by applications like NixOps to increase the performance of evaluation, or to create packages that depend on a container that should be built with the exact same evaluation of Nixpkgs, for example. Applications like this should set their default value using lib.mkDefault, so user-provided configuration can override it without using lib.

Note that using a distinct version of Nixpkgs with NixOS may be an unexpected source of problems. Use this option with care.

Default: import "${nixos}/.." { inherit (config.nixpkgs) config overlays localSystem crossSystem; }
Example: import <nixpkgs> {}

nixpkgs.system Link copied!

Type: string

This option does not need to be specified for NixOS configurations with a recently generated hardware-configuration.nix.

Specifies the Nix platform type on which NixOS should be built. It is better to specify nixpkgs.localSystem instead.

{
  nixpkgs.system = ..;
}

is the same as

{
  nixpkgs.localSystem.system = ..;
}

See nixpkgs.localSystem for more information.

Ignored when nixpkgs.pkgs, nixpkgs.localSystem or nixpkgs.hostPlatform is set.

Default: Traditionally `builtins.currentSystem`, but unset when invoking NixOS through `lib.nixosSystem`.
Example: "i686-linux"

runit.package Link copied!

Type: package

Package to use as the runit executable

Default: <derivation runit-2.3.1>

runit.stage-1.script Link copied!

Type: strings concatenated with "\n"

Runit's initial start script

Default: '' #!/nix/store/gw6fqdf6sd50az8lgwis0bzg5nk283db-busybox-1.37.0/bin/ash PATH=/run/booted-system/sw/bin # Link /bin/sh from environment.binsh, defaults to ash from buxybox. mkdir /bin ln -s /nix/store/gw6fqdf6sd50az8lgwis0bzg5nk283db-busybox-1.37.0/bin/ash /bin/sh # disable DPMS on tty's echo -ne "\033[9;0]" > /dev/tty0 touch /etc/runit/stopit chmod 0 /etc/runit/stopit ''

runit.stage-2.script Link copied!

Type: strings concatenated with "\n"

Runit's main service runner script

Default: '' #!/nix/store/gw6fqdf6sd50az8lgwis0bzg5nk283db-busybox-1.37.0/bin/ash cat /proc/uptime # Watch the /etc/service directory for files # used to configure a monitored service. mkdir -p /etc/service PATH=/run/wrappers/bin:/run/booted-system/sw/bin exec env - PATH=$PATH /nix/store/gmwg1y3hz8k8377iw8ll2d0xsf99c3fg-runit-2.3.1/bin/runsvdir -P /etc/service ''

runit.stage-3.script Link copied!

Type: strings concatenated with "\n"

Runit shutdown script

Default: '' #!/nix/store/gw6fqdf6sd50az8lgwis0bzg5nk283db-busybox-1.37.0/bin/ash echo Waiting for services to stop... /nix/store/gmwg1y3hz8k8377iw8ll2d0xsf99c3fg-runit-2.3.1/bin/sv force-stop /etc/service/* /nix/store/gmwg1y3hz8k8377iw8ll2d0xsf99c3fg-runit-2.3.1/bin/sv exit /etc/service/* echo Sending TERM signal to processes... /nix/store/gw6fqdf6sd50az8lgwis0bzg5nk283db-busybox-1.37.0/bin/pkill -TERM -v -s 0,1 sleep 1 echo Sending KILL signal to processes... /nix/store/gw6fqdf6sd50az8lgwis0bzg5nk283db-busybox-1.37.0/bin/pkill -KILL -v -s 0,1 echo Unmounting filesystems, disabling swap... swapoff -a umount -r -a -t nosysfs,noproc,nodevtmpfs,notmpfs echo Remounting rootfs read-only... mount -o remount,ro / sync ''

security.pam.enable Link copied!

Type: boolean

Whether to enable PAM.

Default: false
Example: true

security.wrappers Link copied!

Type: attribute set of (submodule)

This option effectively allows adding setuid/setgid bits, capabilities, changing file ownership and permissions of a program without directly modifying it. This works by creating a wrapper program in a directory (not configurable), which is then added to the shell PATH.

Default: { }
Example:
{
  # a setuid root program
  doas =
    { setuid = true;
      owner = "root";
      group = "root";
      source = "${pkgs.doas}/bin/doas";
    };

  # a setgid program
  locate =
    { setgid = true;
      owner = "root";
      group = "mlocate";
      source = "${pkgs.locate}/bin/locate";
    };

  # a program with the CAP_NET_RAW capability
  ping =
    { owner = "root";
      group = "root";
      capabilities = "cap_net_raw+ep";
      source = "${pkgs.iputils.out}/bin/ping";
    };
}

security.wrappers.<name>.capabilities Link copied!

Type: strings concatenated with ","

A comma-separated list of capability clauses to be given to the wrapper program. The format for capability clauses is described in the “TEXTUAL REPRESENTATION” section of the cap_from_text(3) manual page. For a list of capabilities supported by the system, check the capabilities(7) manual page.

Note

cap_setpcap, which is required for the wrapper program to be able to raise caps into the Ambient set is NOT raised to the Ambient set so that the real program cannot modify its own capabilities!! This may be too restrictive for cases in which the real program needs cap_setpcap but it at least leans on the side security paranoid vs. too relaxed.

Default: ""

security.wrappers.<name>.enable Link copied!

Type: boolean

Whether to enable the wrapper.

Default: true

security.wrappers.<name>.group Link copied!

Type: string

The group of the wrapper program.

security.wrappers.<name>.owner Link copied!

Type: string

The owner of the wrapper program.

security.wrappers.<name>.permissions Link copied!

Type: file mode string

The permissions of the wrapper program. The format is that of a symbolic or numeric file mode understood by chmod.

Default: "u+rx,g+x,o+x"
Example: "a+rx"

security.wrappers.<name>.program Link copied!

Type: null or string

The name of the wrapper program. Defaults to the attribute name.

Default: "‹name›"

security.wrappers.<name>.setgid Link copied!

Type: boolean

Whether to add the setgid bit the wrapper program.

Default: false

security.wrappers.<name>.setuid Link copied!

Type: boolean

Whether to add the setuid bit the wrapper program.

Default: false

security.wrappers.<name>.source Link copied!

Type: absolute path

The absolute path to the program to be wrapped.

services.chronyd.enable Link copied!

Type: boolean

Whether to enable Enable chronyd time server.

Default: true
Example: true

services.chronyd.package Link copied!

Type: package

The chrony package to use.

Default: pkgs.chrony

services.getty.enable Link copied!

Type: boolean

Whether to enable getty.

Default: false
Example: true

services.getty.terminal Link copied!

Type: string

Terminal to start getty in

Default: "/dev/ttyS0"

services.mdevd.enable Link copied!

Type: boolean

Whether to enable Enable mdevd device manager.

Default: true
Example: true

services.nix-daemon.enable Link copied!

Type: boolean

Whether to enable nix-daemon.

Default: false
Example: true

services.nix-daemon.package Link copied!

Type: package

The nix package to use.

Default: pkgs.nix

services.rngd.enable Link copied!

Type: boolean

Whether to enable rngd.

Default: false
Example: true

services.rngd.package Link copied!

Type: package

The rng-tools package to use.

Default: pkgs.rng-tools

services.sshd.authorizedKeysFiles Link copied!

Type: list of string

Specify the rules for which files to read on the host.

These are paths relative to the host root file system or home directories and they are subject to certain token expansion rules. See AuthorizedKeysFile in man sshd_config for details.

Default: [ "%h/.ssh/authorized_keys" "/etc/ssh/authorized_keys.d/%u" ]

services.sshd.enable Link copied!

Type: boolean

Whether to enable sshd.

Default: false
Example: true

services.sshd.hostKeys Link copied!

Type: list of (attribute set)

MicrOS can automatically generate SSH host keys. This option specifies the path, type and size of each key. See ssh-keygen(1) for supported types and sizes.

Default: [ { bits = 4096; path = "/etc/ssh/ssh_host_rsa_key"; type = "rsa"; } { path = "/etc/ssh/ssh_host_ed25519_key"; type = "ed25519"; } ]

services.sshd.package Link copied!

Type: package

The openssh package to use.

Default: pkgs.openssh

system.activationScripts Link copied!

Type: attribute set of (string or (submodule))

A set of shell script fragments that are executed when a NixOS system configuration is activated. Examples are updating /etc, creating accounts, and so on. Since these are executed every time you boot the system or run nixos-rebuild, it's important that they are idempotent and fast.

Default: { }
Example:
{
  stdio = {
    # Run after /dev has been mounted
    deps = [ "specialfs" ];
    text =
      ''
        # Needed by some programs.
        ln -sfn /proc/self/fd /dev/fd
        ln -sfn /proc/self/fd/0 /dev/stdin
        ln -sfn /proc/self/fd/1 /dev/stdout
        ln -sfn /proc/self/fd/2 /dev/stderr
      '';
  };
}

system.build Link copied!

Type: open submodule of lazy attribute set of unspecified value

Attribute set of derivations used to set up the system.

Default: { }

system.build.ociImage Link copied!

Type: absolute path

OCI compatible image.

system.etc.overlay.enable Link copied!

Type: boolean

Mount /etc as an overlayfs instead of generating it via a perl script.

Note: This is currently experimental. Only enable this option if you're confident that you can recover your system if it breaks.

Default: false

system.etc.overlay.mutable Link copied!

Type: boolean

Whether to mount /etc mutably (i.e. read-write) or immutably (i.e. read-only).

If this is false, only the immutable lowerdir is mounted. If it is true, a writable upperdir is mounted on top.

Default: true

system.logging.enable Link copied!

Type: boolean

Whether to enable Enable syslog daemon.

Default: true
Example: true

system.logging.syslogConfig Link copied!

Type: strings concatenated with "\n"

Contents of /etc/syslog.conf file

Default: '' # /etc/syslog.conf - Configuration file for syslogd(8) # # For information about the format of this file, see syslog.conf(5) # # # First some standard log files. Log by facility. # auth,authpriv.* /var/log/auth.log *.*;auth,authpriv.none -/var/log/syslog #cron.* /var/log/cron.log #daemon.* -/var/log/daemon.log kern.* -/var/log/kern.log #lpr.* -/var/log/lpr.log mail.* -/var/log/mail.log #user.* -/var/log/user.log # # Logging for the mail system. Split it up so that # it is easy to write scripts to parse these files. # #mail.info -/var/log/mail.info #mail.warn -/var/log/mail.warn mail.err /var/log/mail.err #mail.*;mail.!=info -/var/log/mail #mail,news.=info -/var/log/info # The tcp wrapper loggs with mail.info, we display all # the connections on tty12 # #mail.=info /dev/tty12 # # Some "catch-all" log files. # #*.=debug;\ # auth,authpriv.none;\ # news.none;mail.none -/var/log/debug *.=info;*.=notice;*.=warn;\ auth,authpriv.none;\ cron,daemon.none;\ mail,news.none -/var/log/messages # # Store all critical events, except kernel logs, in critical RFC5424 format. # Override global log rotation settings, rotate every 10MiB, keep 5 old logs, # #*.=crit;kern.none /var/log/critical ;rotate=10M:5,RFC5424 # Example of sending events to remote syslog server. # All events from notice and above, except auth, authpriv # and any kernel message are sent to server finlandia in # RFC5424 formatted output. # #*.notice;auth,authpriv.none;\ # kern.none @finlandia ;RFC5424 # Emergencies are sent to anyone logged in # *.=emerg * # Priority alert and above are sent to the operator # #*.alert root,joey # # Secure mode, same as -s, none(0), on(1), full(2). When enabled # only logging to remote syslog server possible, with full secure # mode, not even that is possible. We default to prevent syslogd # from opening UDP/514 and receiving messages from other systems. # secure_mode 1 # # Global log rotation, same as -r SIZE:COUNT, command line wins. # #rotate_size 1M #rotate_count 5 # # Include all config files in /etc/syslog.d/ # include /etc/syslog.d/*.conf ''

system.logging.syslogFlags Link copied!

Type: string

Flags passed to syslog executable.

Default: "-F -p /dev/log"

system.logging.syslogPackage Link copied!

Type: string or package

Syslog daemon to use for system logging. Defaults to busybox's syslog implementation. If the option is set to a derivation, lib.getExe is used to get the executable file. If the option is set to a string, it is executed directly.

Default: "/nix/store/9vhk64sqmmjqj3sxkxykpbc7zz0cn4rq-sysklogd-2.7.2/bin/syslogd"

system.name Link copied!

Type: string

The name of the system used in the system.build.toplevel derivation.

That derivation has the following name: "nixos-system-${config.system.name}-${config.system.nixos.label}"

Default: if config.networking.hostName == "" then "unnamed" else config.networking.hostName;

systemd.services Link copied!

Type: unspecified value

systemd.tmpfiles Link copied!

Type: unspecified value

systemd.user Link copied!

Type: unspecified value

users Link copied!

Type: attribute set of (submodule)

Attrset of users.

Default: { }

users.<name>.gid Link copied!

Type: null or signed integer

Account group ID

Default: null

users.<name>.home Link copied!

Type: absolute path

Account home directory

Default: "/home/‹name›"

users.<name>.name Link copied!

Type: string

Account Username

Default: ""

users.<name>.packages Link copied!

Type: list of package

User-wide package list

Default: [ ]

users.<name>.password Link copied!

Type: string

Hashed account password

Default: "!"

users.<name>.shell Link copied!

Type: null or package or absolute path

Account login shell

Default: "/run/booted-system/sw/bin/ash"

users.<name>.uid Link copied!

Type: null or signed integer

Account User ID

Default: null

virtualisation.cores Link copied!

Type: positive integer, meaning >0

Specify the number of cores the guest is permitted to use. The number can be higher than the available cores on the host system.

Default: 1

virtualisation.forwardPorts Link copied!

Type: list of (submodule)

When using the SLiRP user networking (default), this option allows to forward ports to/from the host/guest.

Warning

If the NixOS firewall on the virtual machine is enabled, you also have to open the guest ports to enable the traffic between host and guest.

Note

Currently QEMU supports only IPv4 forwarding.

Default: [ ]
Example:
[
  # forward local port 2222 -> 22, to ssh into the VM
  { from = "host"; host.port = 2222; guest.port = 22; }

  # forward local port 80 -> 10.0.2.10:80 in the VLAN
  { from = "guest";
    guest.address = "10.0.2.10"; guest.port = 80;
    host.address = "127.0.0.1"; host.port = 80;
  }
]

virtualisation.forwardPorts.*.from Link copied!

Type: one of "host", "guest"

Controls the direction in which the ports are mapped:

  • "host" means traffic from the host ports is forwarded to the given guest port.
  • "guest" means traffic from the guest ports is forwarded to the given host port.
Default: "host"

virtualisation.forwardPorts.*.guest.address Link copied!

Type: string

The IPv4 address on the guest VLAN.

Default: ""

virtualisation.forwardPorts.*.guest.port Link copied!

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

The guest port to be mapped.

virtualisation.forwardPorts.*.host.address Link copied!

Type: string

The IPv4 address of the host.

Default: ""

virtualisation.forwardPorts.*.host.port Link copied!

Type: 16 bit unsigned integer; between 0 and 65535 (both inclusive)

The host port to be mapped.

virtualisation.forwardPorts.*.proto Link copied!

Type: one of "tcp", "udp"

The protocol to forward.

Default: "tcp"

virtualisation.memorySize Link copied!

Type: positive integer, meaning >0

The memory size in megabytes of the virtual machine.

Default: 1024

virtualisation.networkingOptions Link copied!

Type: list of string

Networking-related command-line options that should be passed to qemu. The default is to use userspace networking (SLiRP). See the QEMU Wiki on Networking for details.

If you override this option, be advised to keep ${QEMU_NET_OPTS:+,$QEMU_NET_OPTS} (as seen in the example) to keep the default runtime behaviour.

Default: [ ]
Example:
[
  "-net nic,netdev=user.0,model=virtio"
  "-netdev user,id=user.0,\${QEMU_NET_OPTS:+,$QEMU_NET_OPTS}"
]