this post was submitted on 07 Oct 2025
21 points (100.0% liked)

Nix / NixOS

2485 readers
1 users here now

Main links

Videos

founded 2 years ago
MODERATORS
top 2 comments
sorted by: hot top controversial new old
[โ€“] river_in_the_sky@lemmy.blahaj.zone 4 points 1 week ago (1 children)

Does anyone know of any examples of flake-parts being used in a NixOS/home-manager configuration that one could learn from?

I think I still did not understand how flake-parts works by the end of the video or even what it is attempting to solve. I'm not sure how to apply this to my NixOS configuration or whether it's even useful for my type of setup (a small multi-user and multi-system setup for a couple personal machines and a home server).

[โ€“] hallettj@leminal.space 4 points 1 week ago

I haven't gotten much into flake-parts, but my understanding is that it creates a module system very similar to NixOS modules and Home Manager modules. Except that instead of defining a system configuration, flake-parts modules define flake outputs.

So I don't think you would use it in your NixOS configuration. If your configuration uses a flake there might be use cases for using it at the flake level. For example your flake defines a nixosConfigurations output, which is a set with an attribute for each host. If you had some unusually complicated code in that flake output you might use flake-parts to modularize it.

Or I suppose flake-parts is largely aimed at simplifying per-system outputs like packages and devShells. Once again, if you wanted to split those definitions over multiple files flake-parts can do that. Or you can use it just to get flake-parts' eachDefaultSystem helper if you don't want to use equivalent functionality from flake-utils, or the built-in genAttrs function.

Although I love the NixOS module system, I haven't used flake-parts because I haven't had a case where I want reusable modules in the context of flake outputs. Usually my flakes are a pretty uncomplicated combination of genAttrs, basic devShells, basic overlays, and package expressions that I build with callPackage.