Migration Guide
Prerequisites
Section titled “Prerequisites”Your project must already use flake-parts. If it doesn’t, migrate to flake-parts first.
1. Add the flake-file input
Section titled “1. Add the flake-file input”In your current flake.nix, add:
flake-file.url = "github:vic/flake-file";2. Move outputs to outputs.nix
Section titled “2. Move outputs to outputs.nix”Copy the body of your outputs function into a new file ./outputs.nix:
inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } { imports = [ ./modules/inputs.nix # Add more modules here as you split things up. ];}3. Create inputs.nix
Section titled “3. Create inputs.nix”Copy your current flake.nix input declarations into a flake-parts module:
{ inputs, ... }: { imports = [ inputs.flake-file.flakeModules.default ];
flake-file = { description = "Your flake description"; inputs = { flake-file.url = "github:vic/flake-file"; # ... all your original inputs here }; nixConfig = { }; # if you had any };}Important: Run
git addso that the new files are visible to Nix.
4. Back up and regenerate
Section titled “4. Back up and regenerate”cp flake.nix flake.nix.baknix run .#write-flake5. Verify
Section titled “5. Verify”cat flake.nix # inspect the generated filenix flake check # verify everything is in syncrm flake.nix.bak # clean up if happySplitting inputs across modules
Section titled “Splitting inputs across modules”Once migrated, you can distribute input declarations to the modules that use them:
{ inputs, lib, ... }: { flake-file.inputs.my-tool.url = lib.mkDefault "github:owner/my-tool"; imports = lib.optionals (inputs ? my-tool) [ inputs.my-tool.flakeModule ];}Remove the entry from modules/inputs.nix and regenerate. The result is the same flake.nix, but each module is self-contained.