aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 91cc1f09cda1e4d58fe7a1a8f036dd86f5548a89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# NixOS Configuration

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

## Quick Start

```bash
# 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}/system.nix       # Rice system config
  ├─ Desktop (X11 + i3wm)
  └─ Stylix (theming)

home/mun/                          # User "mun" config
  └─ default.nix                   # User orchestrator
      ├─ programs/                 # git, ssh, zsh
      └─ (imports rice via specialArgs)

home/rices/                        # Desktop rices (home-manager)
  ├─ nord-blue/                    # Complete rice
  ├─ original/                     # Complete rice
  └─ cosmic/                       # WIP rice
```

## 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
        │   ├── system.nix         # Desktop + stylix config
        │   ├── default.nix        # Home-manager modules
        │   ├── i3.nix
        │   ├── alacritty.nix
        │   ├── nvim.nix
        │   ├── helix.nix
        │   ├── picom.nix
        │   └── fastfetch.nix
        │
        ├── original/              # Complete rice
        │   ├── system.nix         # Desktop + stylix config
        │   ├── default.nix        # Home-manager modules
        │   ├── variables.nix      # Color definitions
        │   ├── i3.nix
        │   ├── kitty.nix
        │   ├── polybar.nix
        │   ├── rofi.nix
        │   ├── dunst.nix
        │   ├── neovim.nix
        │   ├── nnn.nix
        │   ├── picom.nix
        │   ├── scripts.nix
        │   └── xdg.nix
        │
        └── cosmic/                # WIP rice
            ├── system.nix         # Desktop + stylix config
            ├── default.nix        # Home-manager modules
            └── fluxbox.nix
```

## 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 System Layer (`home/rices/*/system.nix`)
Desktop environment (X11 + i3wm) and stylix theming (colors, fonts, cursor). Imported at system level in flake.

### 4. User Layer (`home/mun/`)
User-specific programs: git, ssh, zsh config. Imports the active rice via specialArgs.

### 5. Rice Home Layer (`home/rices/*/`)
Desktop application configs: window manager, terminal, editor, compositor. Imported at home-manager level.

## 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 target rice directory (e.g., `home/rices/nord-blue/mymodule.nix`)
2. Add to that rice's `default.nix` imports

## 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` (desktop + stylix)
2. **Home-level**: `home/rices/${rice}` (app configs via specialArgs)

## Creating a New Rice

1. Create directory: `home/rices/my-rice/`
2. Create `system.nix` with desktop environment and stylix config
3. Create `default.nix` orchestrator (imports home-manager modules)
4. Add application configs (i3.nix, terminal, editor, etc.)
5. Optional: Create `variables.nix` for shared color variables
6. Assign to host in `flake.nix`: `myhost = mkSystem "myhost" "my-rice";`

## Machine-Specific Config

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

```nix
# 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
- `nixowos` - NixOS branding and theming (os-release customization)