Skip to content

With a traditional flake

Terminal window
mv flake.nix flake-file.nix
nix-shell https://github.com/vic/flake-file/archive/main.tar.gz -A flake-file.sh --run bootstrap

You will notice your new flake.nix has your same meta-data: inputs, description, nixConfig. Only the outputs function was changed.

And the outputs function treats your flake-file.nix - your original flake.nix file - as an ordinary Nix module. No changes required on your existing Nix logic.

Your inputs and all other flake meta-data are now module options (flake-file.inputs, etc).

flake.nix is a generated static asset intended for code distribution.

Your outputs are now freeform types but can also be validated by output schemas.

And they work with any Nix implementation: Lix, CppNix, DetSys, etc.

Add the following flake-file.outputs-schema to your flake-file.nix and then run nix flake check, then try replacing mundo by world.

No extra check-derivation was needed, no custom nix-implementation, the checks are by the Nix module system as normal.

flake-file.nix
{
outputs = inputs: { hello = "mundo"; };
flake-file.outputs-schema = { lib, ... }: {
options.hello = lib.mkOption {
type = lib.types.enum [ "mundo" ];
};
};
}

You can run the bootstrap command whenever you want.

When your input changes, run it again to propagate your input changes into the static flake.nix.

Terminal window
nix-shell https://github.com/vic/flake-file/archive/main.zip -A flake-file.sh --run bootstrap
Contribute Community Sponsor