Skip to content

Sandboxed Bootstrapping

You can try flake-file bootstrap command without having to change anything in your flake.

Just create a temporary directory where to experiment safely.

Terminal window
mkdir bootstrap
cd bootstrap

You can create a flake.nix from scratch — without running inside an existing flake — using a one-shot bootstrap command:

Terminal window
# Write a minimal flake-file.nix file (or copy a flake.nix of yours)
echo '{ inputs.flake-file.url = "github:vic/flake-file"; }' > flake-file.nix
# Generate flake.nix or unflake.nix or npins or nixlock from flake-file.nix
nix-shell https://github.com/vic/flake-file/archive/refs/heads/main.zip \
-A flake-file.sh --run write-flake --arg modules ./flake-file.nix
See also: all bootstrap command args

Replace write-flake with write-inputs, write-unflake, write-nixlock, or write-npins to target a different backend.

bootstrap.nix can also be a directory. All .nix files in it will be auto-imported using import-tree:

Terminal window
nix-shell https://github.com/vic/flake-file/archive/refs/heads/main.zip \
-A flake-file.sh --run write-flake --arg modules ./modules

This is useful when you already have module files and just need the initial flake.nix to be generated before Nix can evaluate the flake itself.

See the bootstrap command reference for more options.

Contribute Community Sponsor