A modular NixOS configuration using the aspects pattern for composable system configuration.
.
├── flake.nix # Flake entry point
├── hosts/ # Host-specific configurations
│ ├── <hostname>/
│ │ ├── host.nix # Host config and aspect overrides
│ │ ├── fs.nix # Filesystem layout
│ │ ├── hardware.nix # Hardware configuration
│ │ └── user/ # User and home setup (hjem)
│ └── default.nix # Host definitions and aspect lists
├── modules/
│ ├── aspects/ # Reusable configuration modules
│ └── options/ # Custom option definitions
└── parts/ # Flake parts (lib, packages, modules)
Aspects are self-contained, composable configuration modules. Each aspect configures a specific feature of the system.
| Category | Aspects |
|---|---|
| boot-loader | grub, grub/efi, systemd-boot |
| console | fonts, theme |
| cpu | intel |
| desktopManager | gnome, plasma |
| displayManager | gdm, sddm, greetd/tuigreet-niri |
| gpu | intel-nvidia |
| kernel | latest, zen |
| localization | default |
| nix | settings |
| nixpkgs | default |
| programs | common, discord/*, firefox, ghostty, obs-studio, rmpc |
| quickshell | noctalia-shell |
| security | default, firewall |
| services | bluetooth, dbus, mpd, openssh, pipewire, power, printing, pulseaudio |
| shell | fish |
| system | network |
| virtualization | distrobox, docker, libvirt_qemu, podman |
| wayland | niri, swaybg |
In hosts/default.nix, add aspects to the host's aspect list:
seiren = mkNixosSystem {
hostname = "seiren";
username = "frenzfries";
system = "x86_64-linux";
modules = mkModulesFor "seiren" {
aspects = [
"boot-loader/grub"
"boot-loader/grub/efi"
"kernel/zen"
"services/pipewire"
"programs/firefox"
# ... add more aspects
];
};
};-
Create directory
hosts/<hostname>/ -
Add required files:
hosts/<hostname>/ ├── host.nix # Main config, imports, and overrides ├── fs.nix # Filesystem mounts ├── hardware.nix # Hardware-specific settings └── user/ # User configuration (optional) -
Add host definition in
hosts/default.nix:<hostname> = mkNixosSystem { hostname = "<hostname>"; username = "<username>"; system = "x86_64-linux"; modules = mkModulesFor "<hostname>" { aspects = [ # list your aspects here ]; }; };
-
Create
modules/aspects/<category>/<name>/default.nix:{ pkgs, config, lib, ... }: { # Your configuration here environment.systemPackages = [ pkgs.example ]; }
-
Use the aspect by adding
"<category>/<name>"to a host's aspect list.
Override aspect defaults in your host's host.nix:
{
imports = [ ./fs.nix ./hardware.nix ./user ];
# Override aspect options
nixify.aspect.programs.ghostty.font = "iosevka";
system.modules.shell.fish.features.integrations = ["eza" "git"];
# Standard NixOS options
time.timeZone = "Asia/Kathmandu";
system.stateVersion = "25.05";
}# Switch to configuration
sudo nixos-rebuild switch --flake .#<hostname>
# Test configuration
sudo nixos-rebuild test --flake .#<hostname>- flake-parts - Modular flake framework
- hjem - Home configuration (home-manager alternative)
MIT