Core Options
These options are provided by default. They reflect what Nix expects,
plus a small number of helpful options, notably perSystem.
Options
debug
Whether to add the attributes debug, allSystems and currentSystem
to the flake output. When true, this allows inspection of options via
nix repl.
$ nix repl
nix-repl> :lf .
nix-repl> currentSystem._module.args.pkgs.hello
«derivation /nix/store/7vf0d0j7majv1ch1xymdylyql80cn5fp-hello-2.12.1.drv»
Each of debug, allSystems.<system> and currentSystem is an
attribute set consisting of the config attributes, plus the extra
attributes _module, config, options, extendModules. So note that
these are not part of the config parameter, but are merged in for
debugging convenience.
debug: The top-level optionsallSystems: TheperSystemsubmodule applied to the configuredsystems.currentSystem: Shortcut intoallSystems. Only available in impure mode. Works for arbitrary system values.
See Expore and debug option values for more examples.
Type: boolean
Default:
false
Declared by:
flake
Raw flake output attributes. Any attribute can be set here, but some attributes are represented by options, to provide appropriate configuration merging.
Further processing may be applied to these attributes. See processedFlake for more information.
Type: open submodule of lazy attribute set of raw value
Declared by:
- flake-parts/modules/packages.nix
- flake-parts/modules/overlays.nix
- flake-parts/modules/nixosModules.nix
- flake-parts/modules/nixosConfigurations.nix
- flake-parts/modules/legacyPackages.nix
- flake-parts/modules/formatter.nix
- flake-parts/modules/flake.nix
- flake-parts/modules/devShells.nix
- flake-parts/modules/checks.nix
- flake-parts/modules/apps.nix
flake.packages
See perSystem.packages for description and examples.
Type: lazy attribute set of lazy attribute set of package
Default:
{ }
Declared by:
flake.apps
See perSystem.apps for description and examples.
Type: lazy attribute set of lazy attribute set of (submodule)
Default:
{ }
Declared by:
flake.apps.<system>.<name>.meta
Metadata information about the app. Standardized in Nix at https://github.com/NixOS/nix/pull/11297.
Note: nix flake check is only aware of the description attribute in meta.
Type: lazy attribute set of raw value
Default:
{ }
Declared by:
flake.apps.<system>.<name>.program
A path to an executable or a derivation with meta.mainProgram.
Type: string or package convertible to it
Declared by:
flake.apps.<system>.<name>.type
A type tag for apps consumers.
Type: value “app” (singular enum)
Default:
"app"
Declared by:
flake.checks
See perSystem.checks for description and examples.
Type: lazy attribute set of lazy attribute set of package
Default:
{ }
Declared by:
flake.devShells
See perSystem.devShells for description and examples.
Type: lazy attribute set of lazy attribute set of package
Default:
{ }
Declared by:
flake.formatter
An attribute set of per system a package used by nix fmt.
Type: lazy attribute set of (null or package)
Default:
{ }
Declared by:
flake.legacyPackages
See perSystem.legacyPackages for description and examples.
Type: lazy attribute set of lazy attribute set of raw value
Default:
{ }
Declared by:
flake.nixosConfigurations
Instantiated NixOS configurations. Used by nixos-rebuild.
nixosConfigurations is for specific machines. If you want to expose
reusable configurations, add them to nixosModules
in the form of modules (no lib.nixosSystem), so that you can reference
them in this or another flake’s nixosConfigurations.
Type: lazy attribute set of raw value
Default:
{ }
Example:
{
my-machine = inputs.nixpkgs.lib.nixosSystem {
# system is not needed with freshly generated hardware-configuration.nix
# system = "x86_64-linux"; # or set nixpkgs.hostPlatform in a module.
modules = [
./my-machine/nixos-configuration.nix
config.nixosModules.my-module
];
};
}
Declared by:
flake.nixosModules
NixOS modules.
You may use this for reusable pieces of configuration, service modules, etc.
Type: lazy attribute set of module
Default:
{ }
Declared by:
flake.overlays
An attribute set of overlays.
Note that the overlays themselves are not mergeable. While overlays
can be composed, the order of composition is significant, but the
module system does not guarantee sufficiently deterministic
definition ordering, across versions and when changing imports.
Type: lazy attribute set of function that evaluates to a(n) function that evaluates to a(n) lazy attribute set of unspecified value
Default:
{ }
Example:
{
default = final: prev: {};
}
Declared by:
perInput
A function that pre-processes flake inputs.
It is called for users of perSystem such that inputs'.${name} = config.perInput system inputs.${name}.
This is used for inputs' and self'.
The attributes returned by the perInput function definitions are merged into a single namespace (per input),
so each module should return an attribute set with usually only one or two predictable attribute names. Otherwise,
the inputs' namespace gets polluted.
Type: function that evaluates to a(n) function that evaluates to a(n) lazy attribute set of unspecified value
Declared by:
perSystem
A function from system to flake-like attributes omitting the <system> attribute.
Modules defined here have access to the suboptions and some convenient module arguments.
Type: module
Declared by:
- flake-parts/modules/withSystem.nix
- flake-parts/modules/perSystem.nix
- flake-parts/modules/packages.nix
- flake-parts/modules/legacyPackages.nix
- flake-parts/modules/formatter.nix
- flake-parts/modules/devShells.nix
- flake-parts/modules/debug.nix
- flake-parts/modules/checks.nix
- flake-parts/modules/apps.nix
perSystem.packages
An attribute set of packages to be built by nix build.
nix build .#<name> will build packages.<name>.
You can also build attributes of a package using . to access nested attributes:
.#foo.tests.simple builds the simple attribute in foo.tests.
This is a Nixpkgs convention (packages having “passthru” attributes like tests) which gets no special treatment in Flakes.
Attribute names containing special characters like . must be doubly quoted when used in installable arguments:
nix build '.#"example.com"'
Consider using : or / as separators instead (e.g., foo:bar) for better command-line usability.
Type: lazy attribute set of package
Default:
{ }
Declared by:
perSystem.apps
An attribute set of programs runnable with nix run.
nix run .#<name> will run apps.<name>.
Attribute names containing special characters like . must be doubly quoted when used in installable arguments:
nix run '.#"example.com"'
Consider using : or / as separators instead (e.g., foo:bar) for better command-line usability.
Type: lazy attribute set of (submodule)
Default:
{ }
Example:
{
default.program = "${config.packages.hello}/bin/hello";
}
Declared by:
perSystem.apps.<name>.meta
Metadata information about the app. Standardized in Nix at https://github.com/NixOS/nix/pull/11297.
Note: nix flake check is only aware of the description attribute in meta.
Type: lazy attribute set of raw value
Default:
{ }
Declared by:
perSystem.apps.<name>.program
A path to an executable or a derivation with meta.mainProgram.
Type: string or package convertible to it
Declared by:
perSystem.apps.<name>.type
A type tag for apps consumers.
Type: value “app” (singular enum)
Default:
"app"
Declared by:
perSystem.checks
Derivations to be built by nix flake check.
Type: lazy attribute set of package
Default:
{ }
Declared by:
perSystem.debug
Values to return in e.g. allSystems.<system> when
debug = true.
Type: lazy attribute set of raw value
Default:
{ }
Declared by:
perSystem.devShells
An attribute set of packages to be used as shells.
nix develop .#<name> will run devShells.<name>.
Attribute names containing special characters like . must be doubly quoted when used in installable arguments:
nix develop '.#"example.com"'
Consider using : or / as separators instead (e.g., foo:bar) for better command-line usability.
Type: lazy attribute set of package
Default:
{ }
Example:
{
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ wget bat cargo ];
};
}
Declared by:
perSystem.formatter
A package used by nix fmt.
Type: null or package
Default:
null
Declared by:
perSystem.legacyPackages
An attribute set of unmergeable values. This is also used by nix build .#<attrpath>.
legacyPackages supports nested attribute sets. Use . to access nested attributes:
.#foo.bar refers to the bar attribute in foo.
Attribute names that literally contain special characters like . must be doubly quoted when used in installable arguments:
nix build '.#"example.com"'
Consider using : or / as separators instead (e.g., foo:bar) for better command-line usability.
Type: lazy attribute set of raw value
Default:
{ }
Declared by:
processedFlake
The final flake output, as returned by mkFlake.
This separates two concerns:
flake: the internal representation, where all attributes are available for use by other modules, regardless of whether they evaluate successfully for all configurations.processedFlake: the external output, which may have attributes removed or transformed to satisfy tools likenix flake check.
By default, processedFlake equals flake (no processing).
Import a module such as flakeModules.touchup to define it, or set it directly.
Type: raw value (read only)
Declared by:
systems
All the system types to enumerate in the flake output subattributes.
In other words, all valid values for system in e.g. packages.<system>.foo.
Type: list of string
Default:
[ ]
Declared by:
transposition
A helper that defines transposed attributes in the flake outputs.
When you define transposition.foo = { };, definitions are added to the effect of (pseudo-code):
flake.foo.${system} = (perSystem system).foo;
perInput = system: inputFlake: inputFlake.foo.${system};
Transposition is the operation that swaps the indices of a data structure. Here it refers specifically to the transposition between
perSystem: .${system}.${attribute}
outputs: .${attribute}.${system}
It also defines the reverse operation in perInput.
Type: lazy attribute set of (submodule)
Declared by:
transposition.<name>.adHoc
Whether to provide a stub option declaration for perSystem.<name>.
The stub option declaration does not support merging and lacks
documentation, so you are recommended to declare the perSystem.<name>
option yourself and avoid adHoc.
Type: boolean
Default:
false
Declared by: