# NixOS Config Base: A modularized base for NixOS configs

**URL:** https://discourse.nixos.org/t/nixos-config-base-a-modularized-base-for-nixos-configs/28171
**Category:** Announcements
**Created:** [May 14, 2023, 4:30pm UTC](https://discourse.nixos.org/t/nixos-config-base-a-modularized-base-for-nixos-configs/28171 "2023-05-14T16:30:06Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![jtojnar](https://discourse.nixos.org/user_avatar/discourse.nixos.org/jtojnar/32/70_2.png) [@jtojnar](https://discourse.nixos.org/u/jtojnar)
#### Post date: [May 14, 2023, 7:14pm UTC](https://discourse.nixos.org/t/nixos-config-base-a-modularized-base-for-nixos-configs/28171/2 "2023-05-14T19:14:13Z")

</div>

I want to split [configuration of my desktop PC](https://github.com/jtojnar/nixfiles/blob/b4150c848b6a408ba857e181f82416db243ca691/hosts/theo/configuration.nix) into multiple modules but I was not able to come up with a consistent system that makes sense. It is a hard problem.

I am not particularly convinced `system.nix` × `packages.nix` dichotomy is a good idea since the line between user space and system is bit blurry. For example, does `services.xserver.desktopManager.gnome.enable = true;` go to system? What about `environment.systemPackages = [pkgs.gnomeExtensions.dash-to-dock];`? And most software is distributed as a package, yet sometimes it needs to be installed using a module – like `programs.wireshark.enable = true;` which also creates the necessary user group.

The cleanest I have seen were concern-based categories (e.g. `desktop-environment.nix`, `development-tools.nix`…), rather than grouping by type (e.g. `services.nix`, `programs.nix`…).

It is a bit easier on servers, since there I can split the configuration [hierarchically based on domain name](https://github.com/jtojnar/nixfiles/blob/b4150c848b6a408ba857e181f82416db243ca691/hosts/azazel/configuration.nix#L14-L27). Although some services like nginx are still stuck in top-level `configuration.nix`.

# Related discussions

## Other templates

- [Nixos configuration template](https://discourse.nixos.org/t/nixos-configuration-template/22576) recommends [digga/examples/devos at main · divnix/digga · GitHub](https://github.com/divnix/digga/tree/main/examples/devos) and [~misterio/nix-config - My pretty nice NixOS/home-manager configuration - sourcehut git](https://git.sr.ht/~misterio/nix-config)
  - The latter points to [GitHub - Misterio77/nix-starter-configs: Simple and documented config templates to help you get started with NixOS + home-manager + flakes. All the boilerplate you need! · GitHub](https://github.com/Misterio77/nix-starter-configs)

- [DevOS: template repo for NixOS configurations using flakes!](https://discourse.nixos.org/t/devos-template-repo-for-nixos-configurations-using-flakes/5325)

## Organization discussions

- [NixOS Configuration File Organisation](https://discourse.nixos.org/t/nixos-configuration-file-organisation/19612)
- [Question Regarding configuration.nix](https://discourse.nixos.org/t/question-regarding-configuration-nix/1619)
- [How do you organize your configuration?](https://discourse.nixos.org/t/how-do-you-organize-your-configuration/7306)

---

_[View the full topic](https://discourse.nixos.org/t/nixos-config-base-a-modularized-base-for-nixos-configs/28171)._
