Sandboxed Bootstrapping
The Bootstrap Command
Section titled “The Bootstrap Command”You can try flake-file bootstrap command without having to change anything in your flake.
Just create a temporary directory where to experiment safely.
mkdir bootstrapcd bootstrapYou can create a flake.nix from scratch — without running inside an existing flake — using a one-shot bootstrap command:
# 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.nixnix-shell https://github.com/vic/flake-file/archive/refs/heads/main.zip \ -A flake-file.sh --run write-flake --arg modules ./flake-file.nixSee also: all bootstrap command args
Replace write-flake with write-inputs, write-unflake, write-nixlock, or write-npins to target a different backend.
Using a modules directory
Section titled “Using a modules directory”bootstrap.nix can also be a directory. All .nix files in it will be auto-imported using import-tree:
nix-shell https://github.com/vic/flake-file/archive/refs/heads/main.zip \ -A flake-file.sh --run write-flake --arg modules ./modulesThis 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.
Next Steps
Section titled “Next Steps”See the bootstrap command reference for more options.