How to migrate to flake-parts?

This is my flake config: GitHub - god464/NeoDotfile
As you can see, this config structure is confusing. So I wan to use flake-parts + flake-utils to maintain the configuration better. But I didn’t find relevant getting started articles, and there is no relatively clear example reference (I tried to refer to some famous user configurations, but they were too complicated for me). Do you have any good suggestions?

1 Like

There is no point in using flake-parts + flake-utils. Flake-parts covers flake-utils functionality.

I don’t really want to turn this into an Arch Linux support thread and say RTFM but that’s basically what you need to do. In general, you can just wrap your existing flake.nix outputs inside flake-parts.lib.mkFlake function and then you can extend on it

You might going to find this helpful:


it is really simple but as previously said flake-parts replaces flake-utils.

  1. add flake parts as a input.

  2. remove everything from outputs and store for later.

  3. make your outputs a function with a @-pattern named inputs returning flake-parts.lib.mkFlake {inherit inputs;} {}

  4. use your stored outputs from earlier in the flake attibute of the second record passed as argument to mkFlake. you’ve succesfully migrated but aren’t using everything from flake-parts.

  5. to migrate the devShells, packages or anything else made per system you need to add a systems attibute to the last record on outputs it is a list containing which systems you want to support like x86_64-linux or aarch64-darwin.

  6. make a module on the last record called perSystem receiving as argument {system, self’, inputs’, pkgs} which returns a record containing everything which is system dependent without using a system enumeration so devShells.x86_64-linux.default and devShells.aarch64-darwin.default becomes devShells.default.

  7. actually read the flake parts documentation for even more useful stuff like treefmt-nix or devenv

1 Like