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
: TheperSystem
submodule 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.
Type: lazy attribute set of raw value
Declared by:
- flake-parts/extras/flakeModules.nix
- 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.<name>.<name>.program
A path to an executable or a derivation with meta.mainProgram
.
Type: string or package convertible to it
Declared by:
flake.apps.<name>.<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.flakeModule
Alias of flakeModules.default
.
Type: submodule
Declared by:
flake.flakeModules
flake-parts modules for use by other flakes.
If the flake defines only one module, it should be flakeModules.default
.
You can not read this option in defining the flake’s own imports
. Instead, you can
put the module in question into its own file or let binding and reference
it both in imports
and export it with this option.
See Dogfood a Reusable Module for details and an example.
Type: lazy attribute set of module
Default:
{ }
Declared by:
flake.formatter
An attribute set of per system a package used by nix fmt
.
Type: lazy attribute set of 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 unspecified value
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/extras/easyOverlay.nix
- 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>
.
Type: lazy attribute set of package
Default:
{ }
Declared by:
perSystem.apps
Programs runnable with nix run <name>
.
Type: lazy attribute set of (submodule)
Default:
{ }
Example:
{
default.program = "${config.packages.hello}/bin/hello";
}
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
Declared by:
perSystem.devShells
An attribute set of packages to be used as shells.
nix develop .#<name>
will run devShells.<name>
.
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>
.
Type: lazy attribute set of raw value
Default:
{ }
Declared by:
perSystem.overlayAttrs
Attributes to add to overlays.default
.
The overlays.default
overlay will re-evaluate perSystem
with
the “prev” (or “super”) overlay argument value as the pkgs
module
argument. The easyOverlay
module also adds the final
module
argument, for the result of applying the overlay.
When not in an overlay, final
defaults to pkgs
plus the generated
overlay. This requires Nixpkgs to be re-evaluated, which is more
expensive than setting pkgs
to a Nixpkgs that already includes
the necessary overlays that are required for the flake itself.
See Overlays.
Type: lazy attribute set of raw value
Default:
{ }
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
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: