The outputs Function
What is flake-file.outputs?
Section titled “What is flake-file.outputs?”The flake-file.outputs option is a literal Nix string that is placed verbatim as the outputs attribute in the generated flake.nix:
# generated flake.nix (simplified){ outputs = <your flake-file.outputs value here>;}The Default
Section titled “The Default”The default value is:
inputs: import ./outputs.nix inputsThis is deliberately minimal — it delegates all logic to outputs.nix, keeping flake.nix as a pure dependency manifest.
Why Keep the Default?
Section titled “Why Keep the Default?”flake.nix is a generated file. If you embed complex Nix logic in flake-file.outputs, you are putting business logic in a string option, which is hard to read, impossible to type-check, and easy to break.
The recommended split:
flake.nix— generated, declares inputs and nixConfig only.outputs.nix— hand-written, contains all your Nix logic.
Overriding for a One-liner
Section titled “Overriding for a One-liner”The only reasonable case for overriding outputs is a legitimate one-liner — for example, the dendritic module sets:
flake-file.outputs = "inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules)";This is still a single expression with no embedded logic.
What You Cannot Do
Section titled “What You Cannot Do”You cannot assign a Nix function value to flake-file.outputs. A Nix function cannot be serialised to a string. This option exists only for a literal code string.
# WRONG — this will failflake-file.outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } { };Always set it to a string:
# Correctflake-file.outputs = ''inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } { }'';