aboutsummaryrefslogtreecommitdiff

NixOS Configuration

A modular NixOS flake configuration for managing multiple machines (kronos, herra, mystra) with a layered architecture and swappable desktop rices.

Quick Start

# Apply configuration
sudo nixos-rebuild switch

# Build for specific host
sudo nixos-rebuild switch --flake .#kronos
sudo nixos-rebuild switch --flake .#herra
sudo nixos-rebuild switch --flake .#mystra

# Test without applying
sudo nixos-rebuild test

# Validate syntax
nix flake check

# Preview changes
sudo nixos-rebuild dry-run

# Update flake inputs
nix flake update

Architecture

flake.nix                          # Entry point - assigns rices to hosts
  ↓
hosts/{kronos,herra,mystra}/       # Per-machine configs
  ├─ configuration.nix             # Machine identity + overrides
  └─ hardware-configuration.nix    # Hardware (autogenerated)

system/                            # System-wide base config
  └─ default.nix                   # Orchestrator (base modules only)
      ├─ boot.nix, audio.nix, bluetooth.nix
      ├─ networking.nix, graphics.nix
      ├─ packages.nix, programs.nix, services.nix
      └─ users.nix, nix.nix

home/rices/{rice}/                 # Rice configs (self-contained)
  ├─ default.nix                   # Exports {system, home}
  ├─ system.nix                    # NixOS: Desktop + Stylix
  └─ home.nix                      # HM: imports program configs

home/mun/                          # User "mun" config
  └─ default.nix                   # User orchestrator
      └─ programs/                 # git, ssh, zsh

home/rices/                        # Desktop rices
  ├─ nord-blue/                    # Complete rice (i3wm)
  ├─ original/                     # Complete rice (i3wm)
  └─ plasma6/                      # Complete rice (KDE Plasma)

Directory Structure

.
├── flake.nix                      # Flake inputs/outputs
├── flake.lock                     # Reproducibility lock
│
├── hosts/
│   ├── kronos/                    # Machine 1
│   │   ├── configuration.nix
│   │   └── hardware-configuration.nix
│   ├── herra/                     # Machine 2 (desktop, dual-boot, Zen kernel)
│   │   ├── configuration.nix
│   │   ├── hardware-configuration.nix
│   │   ├── packages.nix
│   │   ├── audio.nix
│   │   └── drivers.nix
│   └── mystra/                    # Machine 3
│       ├── configuration.nix
│       └── hardware-configuration.nix
│
├── system/                        # System-wide base modules
│   ├── default.nix                # Imports all base system modules
│   ├── nix.nix                    # Nix settings, flakes
│   ├── boot.nix                   # Bootloader, kernel
│   ├── audio.nix                  # Pipewire
│   ├── bluetooth.nix              # Bluetooth
│   ├── networking.nix             # NetworkManager
│   ├── graphics.nix               # GPU drivers
│   ├── packages.nix               # System packages
│   ├── programs.nix               # System programs
│   ├── services.nix               # System services
│   └── users.nix                  # User accounts
│
└── home/
    ├── mun/                       # User "mun"
    │   ├── default.nix            # User orchestrator
    │   └── programs/
    │       ├── git.nix
    │       ├── ssh.nix
    │       └── zsh.nix
    │
    └── rices/                     # Desktop themes
        ├── nord-blue/             # Complete rice (i3wm)
        │   ├── default.nix        # Exports {system, home}
        │   ├── system.nix         # NixOS: Desktop + stylix
        │   ├── home.nix           # HM: imports all configs
        │   ├── i3.nix
        │   ├── alacritty.nix
        │   ├── nvim.nix
        │   ├── helix.nix
        │   ├── picom.nix
        │   └── fastfetch.nix
        │
        ├── original/              # Complete rice (i3wm)
        │   ├── default.nix        # Exports {system, home}
        │   ├── system.nix         # NixOS: Desktop + stylix
        │   ├── home.nix           # HM: imports all configs
        │   ├── variables.nix      # Color definitions
        │   ├── i3.nix
        │   ├── kitty.nix
        │   ├── polybar.nix
        │   ├── rofi.nix
        │   ├── dunst.nix
        │   ├── neovim.nix
        │   ├── nnn.nix
        │   ├── picom.nix
        │   ├── scripts.nix
        │   └── xdg.nix
        │
        └── plasma6/               # Complete rice (KDE Plasma)
            ├── default.nix        # Exports {system, home}
            ├── system.nix         # NixOS: Plasma + stylix
            ├── home.nix           # HM: Plasma configs
            └── variables.nix      # Wallpaper path

Configuration Layers

1. System Layer (system/)

Base system config applied to all machines: boot, networking, audio, graphics, packages, services, users. Does NOT include desktop or stylix (moved to rice layer).

2. Machine Layer (hosts/)

Per-machine identity (hostname), hardware configuration, and optional machine-specific overrides (e.g., herra uses Zen kernel).

3. Rice Layer (home/rices/*/)

Self-contained desktop environment configs. Each rice exports {system, home}:

  • system.nix: NixOS-level (desktop environment, system packages, stylix theming)
  • home.nix: Home-manager level (imports program configs like i3, terminal, editor)
  • default.nix: Exports both modules for flake consumption

4. User Layer (home/mun/)

User-specific shared programs: git, ssh, zsh config. Only contains configs shared across all rices.

Adding Configurations

New system package:

# system/packages.nix
environment.systemPackages = with pkgs; [
  # add here
];

New system module:

  1. Create system/mymodule.nix
  2. Add to system/default.nix imports

New user program:

  1. Create home/mun/programs/myprogram.nix
  2. Add to home/mun/default.nix imports

New rice module:

  1. Create file in target rice directory (e.g., home/rices/nord-blue/mymodule.nix)
  2. Add to that rice's home.nix imports

Switching Rices

Rices are assigned per-host in flake.nix. Edit the nixosConfigurations section:

nixosConfigurations = {
  kronos = mkSystem "kronos" "nord-blue";    # Laptop uses nord-blue
  herra = mkSystem "herra" "plasma6";        # Desktop uses plasma6
  mystra = mkSystem "mystra" "nord-blue";    # Another machine uses nord-blue
};

Then rebuild: sudo nixos-rebuild switch

Each rice exports {system, home} from its default.nix:

  1. system: Imported by mkSystem (NixOS modules - desktop, stylix)
  2. home: Imported by mkHomeManagerModule (HM modules - program configs)

Creating a New Rice

  1. Create directory: home/rices/my-rice/
  2. Create system.nix with NixOS-level configs:
    {pkgs, ...}: {
      services.xserver = {
        enable = true;
        windowManager.i3.enable = true;
        # ... desktop environment config
      };
    
      stylix = {
        enable = true;
        # ... theming config
      };
    }
    
  3. Create home.nix with home-manager imports:
    {...}: {
      imports = [
        ./i3.nix
        ./terminal.nix
        ./editor.nix
        # ... program configs
      ];
    }
    
  4. Create default.nix to export both modules:
    {
      system = import ./system.nix;
      home = import ./home.nix;
    }
    
  5. Add application configs (i3.nix, terminal, editor, etc.)
  6. Optional: Create variables.nix for shared variables
  7. Assign to host in flake.nix: myhost = mkSystem "myhost" "my-rice";

Machine-Specific Config

Each host has minimal configuration - hostname, hardware, and optional overrides:

# hosts/kronos/configuration.nix (minimal)
{
  imports = [ ./hardware-configuration.nix ];
  networking.hostName = "kronos";
}

# hosts/herra/configuration.nix (with overrides)
{
  imports = [
    ./hardware-configuration.nix
    ./packages.nix
    ./audio.nix
    ./drivers.nix
  ];
  networking.hostName = "herra";
  boot.loader.grub.useOSProber = true;  # Dual-boot with Windows
  boot.kernelPackages = lib.mkForce pkgs.linuxPackages_zen;  # Gaming kernel
}

All shared config lives in system/ and home/.

Flake Inputs

  • nixpkgs - NixOS 25.11 (stable)
  • nixpkgs-unstable - Rolling release, accessible via pkgs.unstable.*
  • home-manager - 25.11 (user environment manager)
  • stylix - System-wide theming framework (base16 colors, fonts, cursor)
  • fenix - Rust toolchain manager (provides latest stable/nightly Rust)
  • crane - Nix build system for Rust projects