# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Project Overview NixOS flake configuration for multiple machines (kronos, herra, mystra) using NixOS 25.11 and Home Manager 25.11. Features a layered architecture with swappable desktop rices. ## Common Commands ```bash # Apply configuration (full rebuild and activation) sudo nixos-rebuild switch # Test configuration without making it the default boot option sudo nixos-rebuild test # Validate flake syntax and check for errors nix flake check # Preview what changes would be made sudo nixos-rebuild dry-run # Update flake inputs to latest versions nix flake update # Update specific input (e.g., nixpkgs) nix flake lock --update-input nixpkgs # Build for specific host sudo nixos-rebuild switch --flake .#kronos sudo nixos-rebuild switch --flake .#herra sudo nixos-rebuild switch --flake .#mystra ``` ## Architecture ``` flake.nix # Entry point - assigns rices to hosts ↓ hosts/{kronos,herra,mystra}/ # Per-machine (hostname + hardware) ↓ system/ # System-wide config (base only) └─ boot, audio, bluetooth, networking, graphics packages, programs, services, users, nix ↓ home/rices/{rice}/system.nix # Rice-level system config └─ desktop.nix (X11 + i3wm) # Desktop environment stylix.nix (theming) # Colors, fonts, cursor ↓ home/mun/ # User config ├─ programs/ # git, ssh, zsh └─ (imports rice via specialArgs) ↓ home/rices/{rice}/default.nix # Rice home-manager modules └─ alacritty, i3, nvim, helix, picom, etc. ``` ## Key Files - `flake.nix` - Entry point: defines inputs and outputs, assigns rices to hosts in `nixosConfigurations` (e.g., `kronos = mkSystem "kronos" "nord-blue"`) - `hosts/*/configuration.nix` - Per-machine config (hostname, hardware imports, machine-specific overrides) - `hosts/herra/configuration.nix` - Desktop: dual-boot with Windows 11 (GRUB OS prober), Zen kernel override - `system/default.nix` - System module orchestrator (imports base system modules only, no desktop/stylix) - `system/packages.nix` - System-wide packages - `home/mun/default.nix` - User orchestrator: imports user programs and rice via `${rice}` specialArg - `home/rices/*/system.nix` - Rice-level system config (desktop environment + stylix theming) - `home/rices/*/default.nix` - Rice home-manager modules orchestrator - `home/rices/*/variables.nix` - Rice color definitions (optional, some rices use system.nix for colors) ## Adding Configurations **New system package:** Add to `system/packages.nix` under `environment.systemPackages` **New user package:** Add to `home/mun/default.nix` under `home.packages` (supports fenix Rust toolchain, TeX Live combinations, RetroArch cores) **New system module:** Create in `system/`, add to `system/default.nix` imports **New user program:** Create in `home/mun/programs/`, add to `home/mun/default.nix` imports **New rice module:** Create in target rice directory (e.g., `home/rices/nord-blue/mymodule.nix`), add to that rice's `default.nix` imports **New rice:** 1. Create `home/rices/my-rice/` directory 2. Create `system.nix` with desktop environment and stylix config 3. Create `default.nix` (imports home-manager modules) 4. Create app-specific configs (i3.nix, terminal.nix, etc.) 5. Optional: create `variables.nix` for shared color variables ## Switching Rices Rices are assigned per-host in `flake.nix`. Edit the `nixosConfigurations` section: ```nix nixosConfigurations = { kronos = mkSystem "kronos" "nord-blue"; # Laptop uses nord-blue herra = mkSystem "herra" "cosmic"; # Desktop uses cosmic mystra = mkSystem "mystra" "nord-blue"; # Another machine uses nord-blue }; ``` Then rebuild: `sudo nixos-rebuild switch` Each rice is imported twice: 1. **System-level**: `home/rices/${rice}/system.nix` imported in flake (desktop + stylix) 2. **Home-level**: `home/rices/${rice}` imported in `home/mun/default.nix` via specialArgs (app configs) ## Important Architecture Details **Overlays:** Flake provides `pkgs.unstable.*` for accessing bleeding-edge packages from nixpkgs-unstable while staying on stable 25.11 **NixOwOs Integration:** Enabled in `home/mun/default.nix` for NixOS branding/theming (os-release customization, overlays) **Machine Separation:** Host configs are intentionally minimal (hostname + hardware-configuration import + optional overrides). All shared system config lives in `system/`, all shared user config in `home/mun/` **Rice Architecture:** Rices span both system and home-manager: - `system.nix` in each rice configures desktop environment (X11 + i3wm) and stylix theming - `default.nix` in each rice imports home-manager modules (terminal, editor, compositor, etc.) - System-level desktop/stylix was moved from `system/` to per-rice to allow different DEs per rice **Stylix:** System-level theming framework imported at flake level, configured in each rice's `system.nix` (base16 colors, fonts, cursor, opacity, wallpaper) **mkSystem Helper:** The `mkSystem` function in flake.nix takes (hostname, rice) and: 1. Imports host config from `hosts/${hostname}/configuration.nix` 2. Imports base system modules from `system/` 3. Imports rice system config from `home/rices/${rice}/system.nix` 4. Passes rice name to home-manager via specialArgs for user-level rice import **Available Rices:** - `nord-blue` - Complete: alacritty, i3, nvim, helix, picom, fastfetch - `original` - Complete: kitty, i3, polybar, rofi, dunst, neovim, nnn, picom - `cosmic` - Minimal/incomplete: only fluxbox.nix (work in progress)