diff options
| author | Natasha Moongrave <natasha@256phi.eu> | 2026-03-31 12:31:08 +0200 |
|---|---|---|
| committer | Natasha Moongrave <natasha@256phi.eu> | 2026-03-31 12:31:08 +0200 |
| commit | a9d265475915636393b89edca99ddf2ba3fde2eb (patch) | |
| tree | 54d0c8bc0ca13d81de9ad0dcd8942ee86afcd78b /README.md | |
| parent | 59be3fbd673d64c12a1a831081b40f4ae888c939 (diff) | |
Fixed up documentation
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 674 |
1 files changed, 144 insertions, 530 deletions
@@ -1,581 +1,195 @@ -# NixOS Configuration Guide +# NixOS Configuration -This NixOS configuration repository uses a modular, hierarchical import structure to manage system and home-manager configurations across multiple environments and desktop setups. +A modular NixOS flake configuration for managing multiple machines (kronos laptop, herra desktop) with a layered architecture and swappable desktop rices. -## Table of Contents +## Quick Start -1. [Architecture Overview](#architecture-overview) -2. [Directory Structure](#directory-structure) -3. [How Import Wranglers Work](#how-import-wranglers-work) -4. [Switching Environments](#switching-environments) -5. [Configuration Layers](#configuration-layers) -6. [Modifying Configurations](#modifying-configurations) - ---- - -## Architecture Overview - -The configuration follows a **layered orchestrator pattern**: - -``` -flake.nix (entry point) - ↓ -configuration.nix (system orchestrator) - ├─ hardware-configuration.nix (hardware specifics) - ├─ modules/nixos/base/ (system-wide config) - │ └─ default.nix (orchestrator) - │ ├─ nix.nix - │ ├─ boot.nix - │ ├─ networking.nix - │ ├─ users.nix - │ ├─ services.nix - │ ├─ programs.nix - │ ├─ graphics.nix - │ └─ packages.nix - └─ modules/nixos/{i3wm,hyprland}/ (environment-specific) - -mun.nix (home-manager orchestrator) - ├─ modules/home/i3wm/default.nix (orchestrator) - │ ├─ dunst.nix - │ ├─ i3.nix - │ ├─ kitty.nix - │ ├─ neovim.nix - │ ├─ nnn.nix - │ ├─ picom.nix - │ ├─ polybar.nix - │ ├─ rofi.nix - │ ├─ scripts.nix - │ └─ xdg.nix - └─ modules/home/hyprland/default.nix (orchestrator) - └─ chernobyl/default.nix (orchestrator) - ├─ dunst.nix - ├─ fastfetch.nix - ├─ hyprland.nix - └─ kitty.nix -``` - ---- - -## Directory Structure - -``` -. -├── flake.nix # Flake inputs/outputs definition -├── flake.lock # Lock file for reproducibility -├── configuration.nix # Main system config (thin orchestrator) -├── hardware-configuration.nix # Hardware-specific config (generated) -├── mun.nix # Home-manager user config (orchestrator) -├── modules/ -│ ├── nixos/ -│ │ ├── base/ # Base system config (split modules) -│ │ │ ├── default.nix # Orchestrator: imports all base modules -│ │ │ ├── nix.nix # Nix settings, flakes, substituters -│ │ │ ├── boot.nix # Boot loader, kernel, Plymouth -│ │ │ ├── networking.nix # Hostname, NetworkManager, Bluetooth -│ │ │ ├── users.nix # User definitions -│ │ │ ├── services.nix # System services (SSH, Pipewire, Printing, Ly) -│ │ │ ├── programs.nix # System programs (Firefox, Zsh, Steam) -│ │ │ ├── graphics.nix # GPU drivers, hardware acceleration -│ │ │ └── packages.nix # System-wide packages -│ │ ├── i3wm/ -│ │ │ └── default.nix # X11, i3 window manager config -│ │ └── hyprland/ -│ │ └── default.nix # Wayland, Hyprland config -│ └── home/ -│ ├── i3wm/ -│ │ ├── default.nix # Orchestrator: imports all i3wm home modules -│ │ ├── dunst.nix # Notification daemon (i3 config) -│ │ ├── i3.nix # i3 window manager config (keybinds, layout) -│ │ ├── kitty.nix # Terminal emulator (i3 config) -│ │ ├── neovim.nix # Text editor with LazyVim setup -│ │ ├── nnn.nix # File browser -│ │ ├── picom.nix # X11 compositor -│ │ ├── polybar.nix # Status bar (i3 specific) -│ │ ├── rofi.nix # Application launcher -│ │ ├── scripts.nix # Custom shell scripts -│ │ └── xdg.nix # XDG MIME type defaults -│ └── hyprland/ -│ ├── default.nix # Orchestrator: imports Hyprland rices -│ └── chernobyl/ # "Chernobyl" Hyprland rice -│ ├── default.nix # Orchestrator for chernobyl rice -│ ├── dunst.nix # Notification daemon (Hyprland config) -│ ├── fastfetch.nix # System info display -│ ├── hyprland.nix # Hyprland window manager config -│ └── kitty.nix # Terminal emulator (Hyprland config) -``` - ---- - -## How Import Wranglers Work - -An "import wrangler" is a `default.nix` file that acts as a **local aggregator**, collecting all related configurations into one place for easy management. This pattern appears at multiple levels: - -### Level 1: Base System Configuration - -**File:** `modules/nixos/base/default.nix` - -```nix -{ ... }: - -{ - imports = [ - ./nix.nix - ./boot.nix - ./networking.nix - ./users.nix - ./services.nix - ./programs.nix - ./graphics.nix - ./packages.nix - ]; - - system.stateVersion = "25.11"; -} -``` - -**Purpose:** Groups all foundational system configurations (boot, networking, users, services, packages) into a single import point. When you need to add a base system feature, you either: -- Add it to an existing module file -- Create a new module (e.g., `firewall.nix`) and add it to this import list - -**Benefits:** -- Single import in `configuration.nix`: `./modules/nixos/base` -- All base modules are in one place; easy to see what's included -- New base modules are simply added to the imports list - -### Level 2: Environment-Specific System Configuration - -**Files:** `modules/nixos/i3wm/default.nix`, `modules/nixos/hyprland/default.nix` - -These are currently thin wrappers but follow the same pattern. To extend them (e.g., add environment-specific services or packages), you would create sub-modules: - -```nix -# Example expansion of modules/nixos/i3wm/default.nix -{ ... }: - -{ - imports = [ - ./xserver.nix # X11-specific settings - ./i3.nix # i3 window manager - ./keyboard.nix # Czech keyboard layout - ]; -} -``` - -### Level 3: Home-Manager Orchestration - -**File:** `modules/home/i3wm/default.nix` - -```nix -{ ... }: - -{ - imports = [ - ./dunst.nix - ./i3.nix - ./kitty.nix - ./neovim.nix - ./nnn.nix - ./picom.nix - ./polybar.nix - ./rofi.nix - ./scripts.nix - ./xdg.nix - ]; -} -``` - -**Purpose:** All i3wm-specific home-manager modules (dunst, i3 keybinds, polybar, etc.) are collected here. This is imported once in `mun.nix`, rather than importing 10 separate files. - -**Benefits:** -- One line in `mun.nix`: `./modules/home/i3wm/default.nix` -- All i3 home configs are clearly grouped -- Easy to switch entire environments with a single comment/uncomment - -### Level 4: Multi-Rice Support (Hyprland) +```bash +# Apply configuration +sudo nixos-rebuild switch -**File:** `modules/home/hyprland/default.nix` +# Test without applying +sudo nixos-rebuild test -```nix -{ ... }: +# Validate syntax +nix flake check -{ - imports = [ - #./default.nix # main hyprland rice (future) - ./chernobyl/default.nix # chernobyl hyprland rice - ]; -} +# Preview changes +sudo nixos-rebuild dry-run ``` -**File:** `modules/home/hyprland/chernobyl/default.nix` +## Architecture -```nix -{ ... }: - -{ - imports = [ - ./dunst.nix - ./fastfetch.nix - ./hyprland.nix - ./kitty.nix - ]; -} ``` +flake.nix # Entry point, defines inputs + ↓ +hosts/{kronos,herra}/ # Per-machine configs + ├─ configuration.nix # Machine identity + └─ hardware-configuration.nix # Hardware (autogenerated) -**Purpose:** Supports multiple visual rices/themes for the same window manager. The parent orchestrator selects which rice to use. - -**Benefits:** -- Scale to many rices easily (add `./cyberpunk/default.nix`, `./nord/default.nix`, etc.) -- Each rice has its own folder with consistent structure -- Switch rices by commenting/uncommenting in the parent orchestrator - ---- - -## Switching Environments - -### Switch from i3wm to Hyprland - -Edit **two files**: +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 -#### 1. System Configuration (`configuration.nix`) +home/mun/ # User "mun" config + └─ default.nix # User orchestrator + ├─ programs/ # git, ssh, zsh + └─ (imports active rice) -```nix -{ config, lib, pkgs, ... }: - -{ - imports = [ - ./hardware-configuration.nix - ./modules/nixos/base - - # === Environment Choice === - # Uncomment one of the following to select your environment: - #./modules/nixos/i3wm # ← comment this - ./modules/nixos/hyprland # ← uncomment this - ]; -} +home/rices/ # Desktop rices + ├─ nord-blue/ # Current active rice + └─ original/ # Alternative rice ``` -#### 2. Home-Manager Configuration (`mun.nix`) - -```nix -{ config, lib, pkgs, ... }: +## Directory Structure -{ - imports = [ - #./modules/home/i3wm/default.nix # ← comment this - ./modules/home/hyprland/default.nix # ← uncomment this - ]; - - # ... rest of mun.nix -} ``` - -#### 3. Rebuild - -```bash -sudo nixos-rebuild switch +. +├── 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 -The configuration is organized in **four distinct layers**: - -### 1. **System-Wide Base (`modules/nixos/base/`)** - -Applied to **all environments**. - -**Includes:** -- Nix settings (flakes, substituters) -- Boot configuration (GRUB, EFI, kernel) -- Networking (hostname, NetworkManager, Bluetooth) -- Users (mun user definition) -- System services (SSH, Pipewire, Printing, Ly display manager) -- System programs (Firefox, Zsh, Steam) -- Graphics drivers (Intel VAAPI, hardware acceleration) -- System packages (Neovim, Git, TeX Live, RetroArch, etc.) - -**Modify by:** Editing existing files in `base/` or creating new ones and adding them to `base/default.nix`. - -### 2. **Environment-Specific System (`modules/nixos/{i3wm,hyprland}/`)** - -Applied to **one environment at a time** (X11 vs Wayland). - -**i3wm includes:** -- X11 enable -- i3 window manager -- Keyboard layout (Czech) -- Display manager session +### 1. System Layer (`system/`) +Applied to all machines. Contains boot, networking, audio, graphics, packages, services, users, and desktop environment setup. -**Hyprland includes:** -- X11 disable -- Hyprland enable -- XDG portal for Wayland -- Qt6 Wayland support -- Keyboard layout (Czech) +### 2. Machine Layer (`hosts/`) +Per-machine identity (hostname) and hardware configuration. -**Modify by:** Editing the respective `default.nix` or creating sub-modules. +### 3. User Layer (`home/mun/`) +User-specific programs: git, ssh, zsh config, and imports the active rice. -### 3. **Home-Manager User-Wide Config (`mun.nix`)** +### 4. Rice Layer (`home/rices/`) +Desktop theming: window manager config, terminal, editor, status bar, colors. -Configuration applied to user `mun` only. - -**Includes:** -- SSH setup -- Shell configuration (Zsh with oh-my-zsh) -- Environment variables -- Gnome-keyring service -- User packages (Rust tools, Discord, utilities) -- Environment-specific home-manager orchestrator import - -**Modify by:** Editing `mun.nix` directly or adding packages to the `packages` list. - -### 4. **Environment-Specific Home-Manager (`modules/home/{i3wm,hyprland}/`)** - -Applied to **one environment at a time**. - -**i3wm includes:** -- i3 keybindings and layout -- Polybar status bar -- Dunst notifications -- Picom compositor -- Rofi launcher -- NeoVim with LazyVim -- Kitty terminal -- Custom scripts -- XDG MIME type defaults - -**Hyprland (chernobyl rice) includes:** -- Hyprland config -- Dunst notifications -- Kitty terminal -- Fastfetch system info - -**Modify by:** Editing the respective module files or adding new ones to the orchestrator `default.nix`. - ---- - -## Modifying Configurations - -### Add a New System Package - -**File:** `modules/nixos/base/packages.nix` +## Adding Configurations +**New system package:** ```nix +# system/packages.nix environment.systemPackages = with pkgs; [ - # ... existing packages ... - my-new-package # ← add here + # add here ]; ``` -### Add a New Base System Service +**New system module:** +1. Create `system/mymodule.nix` +2. Add to `system/default.nix` imports -**File:** `modules/nixos/base/services.nix` or create `modules/nixos/base/firewall.nix` +**New user program:** +1. Create `home/mun/programs/myprogram.nix` +2. Add to `home/mun/default.nix` imports -If adding firewall rules, create a new file: +**New rice module:** +1. Create file in the active rice directory +2. Add to that rice's `default.nix` imports -```nix -# modules/nixos/base/firewall.nix -{ config, lib, pkgs, ... }: - -{ - networking.firewall.allowedTCPPorts = [ 80 443 ]; -} -``` +## Switching Rices -Then add to orchestrator: +Edit `home/mun/default.nix`: ```nix -# modules/nixos/base/default.nix -{ ... }: - -{ - imports = [ - ./nix.nix - ./boot.nix - ./networking.nix - ./users.nix - ./services.nix - ./programs.nix - ./graphics.nix - ./packages.nix - ./firewall.nix # ← add here - ]; - - system.stateVersion = "25.11"; -} -``` - -### Add an i3wm Home-Manager Module - -**File:** `modules/home/i3wm/my-new-config.nix` - -```nix -{ config, pkgs, ... }: - -{ - # Your home-manager config here -} -``` - -Then add to orchestrator: - -```nix -# modules/home/i3wm/default.nix -{ ... }: - -{ - imports = [ - ./dunst.nix - ./i3.nix - # ... other modules ... - ./my-new-config.nix # ← add here - ]; -} +imports = [ + ./programs/git.nix + ./programs/ssh.nix + ./programs/zsh.nix + # Change rice here: + ../rices/nord-blue # current + # ../rices/original # alternative +]; ``` -### Add a New Hyprland Rice - -Create a new directory: - -```bash -mkdir modules/home/hyprland/cyberpunk -``` +Then rebuild: `sudo nixos-rebuild switch` -Add files: +## Creating a New Rice -```nix -# modules/home/hyprland/cyberpunk/default.nix -{ ... }: +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` -{ - imports = [ - ./dunst.nix - ./hyprland.nix - ./kitty.nix - ]; -} -``` +## Machine-Specific Config -Update parent orchestrator: +Each host has minimal configuration - just hostname and hardware: ```nix -# modules/home/hyprland/default.nix -{ ... }: - +# hosts/kronos/configuration.nix { - imports = [ - #./default.nix - ./chernobyl/default.nix - #./cyberpunk/default.nix # ← uncomment to use - ]; + imports = [ ./hardware-configuration.nix ]; + networking.hostName = "kronos"; } ``` ---- - -## Rebuilding Your System - -After making changes: - -```bash -# Switch to new system configuration -sudo nixos-rebuild switch - -# Or, test first (doesn't activate) -sudo nixos-rebuild test - -# Show what changed -sudo nixos-rebuild dry-run -``` - -To edit and rebuild in one step: - -```bash -# If you have the 'edit' alias from mun.nix -edit -sudo nixos-rebuild switch -``` - ---- - -## Key Principles - -1. **One Import Per Layer:** Each `default.nix` orchestrator imports related modules, reducing clutter in parent files. - -2. **Separation of Concerns:** System config (nixos/) is separate from user config (home/); base is separate from environment-specific. - -3. **Easy Environment Switching:** Change environments by commenting one line in `configuration.nix` and `mun.nix`. - -4. **Scalability:** Adding new features (base services, home modules, rices) follows a consistent pattern of creating a file + adding it to the orchestrator. - -5. **Clarity:** Each file has a clear purpose; finding where to modify something is straightforward. - ---- - -## Example Workflow - -### Goal: Add Firefox configuration to i3wm - -1. Create `modules/home/i3wm/firefox.nix`: - ```nix - { config, pkgs, ... }: - - { - programs.firefox = { - enable = true; - profiles.mun = { - settings = { - "browser.startup.homepage" = "about:home"; - }; - }; - }; - } - ``` - -2. Add to orchestrator in `modules/home/i3wm/default.nix`: - ```nix - imports = [ - ./dunst.nix - ./firefox.nix # ← add here - ./i3.nix - # ... rest - ]; - ``` - -3. Rebuild: - ```bash - sudo nixos-rebuild switch - ``` - -Done! Firefox is now configured for the i3wm environment. - ---- - -## Troubleshooting - -### "Module not found" error - -Check that all imports in `default.nix` files reference correct file paths. Use absolute paths from the module directory: -- `./nix.nix` ✓ (correct) -- `../base/nix.nix` ✓ (correct, relative to parent) -- `/absolute/path/nix.nix` ✗ (avoid; use relative) - -### Environment not loading after switch - -Ensure **both** `configuration.nix` and `mun.nix` have the same environment enabled (not one i3wm and one hyprland). - -### Syntax errors in .nix files - -Use `nix flake check` to validate: -```bash -nix flake check -``` - ---- +All shared config lives in `system/` and `home/`. -## References +## Flake Inputs -- [NixOS Manual - Configuration](https://nixos.org/manual/nixos/stable/) -- [Home Manager Manual](https://nix-community.github.io/home-manager/) -- [Nix Language](https://nixos.wiki/wiki/Nix_language) +- `nixpkgs` - NixOS 25.11 +- `nixpkgs-unstable` - Latest packages via `pkgs.unstable.*` +- `home-manager` - 25.11 +- `stylix` - Theming framework +- `fenix` - Rust toolchain |
