With a traditional flake
The bootstrap magic step.
Section titled “The bootstrap magic step.”mv flake.nix flake-file.nixnix-shell https://github.com/vic/flake-file/archive/main.tar.gz -A flake-file.sh --run bootstrapThe new flake.nix (static Nix)
Section titled “The new flake.nix (static Nix)”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 flake-file.nix (non-static real Nix)
Section titled “Your flake-file.nix (non-static real Nix)”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.
Output Schemas
Section titled “Output Schemas”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.
{ outputs = inputs: { hello = "mundo"; };
flake-file.outputs-schema = { lib, ... }: { options.hello = lib.mkOption { type = lib.types.enum [ "mundo" ]; }; };}Update flake.nix
Section titled “Update flake.nix”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.
nix-shell https://github.com/vic/flake-file/archive/main.zip -A flake-file.sh --run bootstrap