# Flake: split into multiple files using module system

**URL:** https://discourse.nixos.org/t/flake-split-into-multiple-files-using-module-system/67612
**Category:** Nixpkgs Architecture
**Created:** [August 5, 2025, 1:54pm UTC](https://discourse.nixos.org/t/flake-split-into-multiple-files-using-module-system/67612 "2025-08-05T13:54:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mightyiam](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mightyiam/32/33998_2.png) [@mightyiam](https://discourse.nixos.org/u/mightyiam)
#### Post date: [August 5, 2025, 1:54pm UTC](https://discourse.nixos.org/t/flake-split-into-multiple-files-using-module-system/67612/1 "2025-08-05T13:54:17Z")

</div>

> <https://github.com/NixOS/nixpkgs/pull/431169>
>
> For a while I have wanted to do this thing, and recently did, in my own infra re…po,
> where NixOS configurations are defined by providing a value to a flake-parts option
> \`configurations.nixos.\<name\>.module\`. Here that is:
> https://github.com/mightyiam/infra/commit/edff6bfd1079241732e616d4281b449ec789dc90
> 
> I kind of have this vision of this flake-parts option being provided by Nixpkgs.
> I suppose it would be a precendent and should be discussed and that's not what this PR is about.
> But, when considering that, I noticed that our \`flake.nix\` seems to be a mixture of multiple concerns.
> 
> So, I took what I have learned from flake-parts and tried to apply here.
> The goal was to split \`flake.nix\` into multiple files. Ideally, each file is in a directory where it belongs.
> The means: the Nixpkgs module system. An added bonus, arguably: some type checking.
> 
> Compared with flake-parts, this implementation is simple. Especially the \`perSystem\` feature.
> And our usage is private, so I tried to avoid over-engineering anything, considering it can be changed as needed.
> 
> I have a slight improvement in mind, but overall I figured it's time to ask for some opinions.
> I might add some more thoughts via line comments after submitting.
> 
> 
> 
> \## Things done
> 
> 
> 
> \- Built on platform:
> - \[x\] x86\_64-linux
> - \[\] aarch64-linux
> - \[\] x86\_64-darwin
> - \[\] aarch64-darwin
> \- Tested, as applicable:
> - \[\] \[NixOS tests\] in \[nixos/tests\].
> - \[\] \[Package tests\] at \`passthru.tests\`.
> - \[\] Tests in \[lib/tests\] or \[pkgs/test\] for functions and "core" functionality.
> \- \[\] Ran \`nixpkgs-review\` on this PR. See \[nixpkgs-review usage\].
> \- \[\] Tested basic functionality of all binary files, usually in \`./result/bin/\`.
> \- Nixpkgs Release Notes
> - \[\] Package update: when the change is major or breaking.
> \- NixOS Release Notes
> - \[\] Module addition: when adding a new NixOS module.
> - \[\] Module update: when the change is significant.
> \- \[x\] Fits \[CONTRIBUTING.md\], \[pkgs/README.md\], \[maintainers/README.md\] and other READMEs.
> 
> \[NixOS tests\]: https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests
> \[Package tests\]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-tests
> \[nixpkgs-review usage\]: https://github.com/Mic92/nixpkgs-review#usage
> 
> \[CONTRIBUTING.md\]: https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md
> \[lib/tests\]: https://github.com/NixOS/nixpkgs/blob/master/lib/tests
> \[maintainers/README.md\]: https://github.com/NixOS/nixpkgs/blob/master/maintainers/README.md
> \[nixos/tests\]: https://github.com/NixOS/nixpkgs/blob/master/nixos/tests
> \[pkgs/README.md\]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md
> \[pkgs/test\]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/test
> 
> \---
> 
> Add a :+1: \[reaction\] to \[pull requests you find important\].
> 
> \[reaction\]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
> \[pull requests you find important\]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc
