# NixOS Configuration A modular NixOS flake configuration for managing multiple machines (kronos laptop, herra desktop) with a layered architecture and swappable desktop rices. ## Quick Start ```bash # Apply configuration sudo nixos-rebuild switch # Test without applying sudo nixos-rebuild test # Validate syntax nix flake check # Preview changes sudo nixos-rebuild dry-run ``` ## Architecture ``` flake.nix # Entry point, defines inputs ↓ hosts/{kronos,herra}/ # Per-machine configs ├─ configuration.nix # Machine identity └─ hardware-configuration.nix # Hardware (autogenerated) system/ # System-wide config └─ default.nix # Orchestrator ├─ boot.nix, audio.nix, bluetooth.nix ├─ networking.nix, graphics.nix ├─ packages.nix, programs.nix, services.nix ├─ users.nix, nix.nix ├─ desktop.nix # X11 + i3wm └─ stylix.nix # Theming home/mun/ # User "mun" config └─ default.nix # User orchestrator ├─ programs/ # git, ssh, zsh └─ (imports active rice) home/rices/ # Desktop rices ├─ nord-blue/ # Current active rice └─ original/ # Alternative rice ``` ## Directory Structure ``` . ├── flake.nix # Flake inputs/outputs ├── flake.lock # Reproducibility lock │ ├── hosts/ │ ├── kronos/ # Laptop │ │ ├── configuration.nix │ │ └── hardware-configuration.nix │ └── herra/ # Desktop (dual-boot) │ ├── configuration.nix │ └── hardware-configuration.nix │ ├── system/ # System-wide modules │ ├── default.nix # Imports all 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 │ ├── desktop.nix # X11 + i3wm │ └── stylix.nix # Theme framework │ └── home/ ├── mun/ # User "mun" │ ├── default.nix # User orchestrator │ └── programs/ │ ├── git.nix │ ├── ssh.nix │ └── zsh.nix │ └── rices/ # Desktop themes ├── nord-blue/ # Active rice │ ├── default.nix │ ├── variables.nix # Colors, wallpaper │ ├── i3.nix │ ├── alacritty.nix │ ├── nvim.nix │ ├── helix.nix │ ├── picom.nix │ ├── fastfetch.nix │ └── wallpapers/ │ └── original/ # Alternative rice ├── default.nix ├── variables.nix ├── i3.nix ├── kitty.nix ├── polybar.nix ├── rofi.nix ├── dunst.nix ├── neovim.nix ├── nnn.nix ├── picom.nix ├── scripts.nix └── xdg.nix ``` ## Configuration Layers ### 1. System Layer (`system/`) Applied to all machines. Contains boot, networking, audio, graphics, packages, services, users, and desktop environment setup. ### 2. Machine Layer (`hosts/`) Per-machine identity (hostname) and hardware configuration. ### 3. User Layer (`home/mun/`) User-specific programs: git, ssh, zsh config, and imports the active rice. ### 4. Rice Layer (`home/rices/`) Desktop theming: window manager config, terminal, editor, status bar, colors. ## Adding Configurations **New system package:** ```nix # 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 the active rice directory 2. Add to that rice's `default.nix` imports ## Switching Rices Edit `home/mun/default.nix`: ```nix imports = [ ./programs/git.nix ./programs/ssh.nix ./programs/zsh.nix # Change rice here: ../rices/nord-blue # current # ../rices/original # alternative ]; ``` Then rebuild: `sudo nixos-rebuild switch` ## Creating a New Rice 1. Create directory: `home/rices/my-rice/` 2. Create `default.nix` orchestrator 3. Create `variables.nix` with colors 4. Add application configs (i3.nix, terminal, etc.) 5. Import in `home/mun/default.nix` ## Machine-Specific Config Each host has minimal configuration - just hostname and hardware: ```nix # hosts/kronos/configuration.nix { imports = [ ./hardware-configuration.nix ]; networking.hostName = "kronos"; } ``` All shared config lives in `system/` and `home/`. ## Flake Inputs - `nixpkgs` - NixOS 25.11 - `nixpkgs-unstable` - Latest packages via `pkgs.unstable.*` - `home-manager` - 25.11 - `stylix` - Theming framework - `fenix` - Rust toolchain