mirror of
https://github.com/nickolaj-jepsen/nixos.git
synced 2026-01-22 08:06:50 +01:00
3.1 KiB
3.1 KiB
NixOS Configuration - Copilot Instructions
Architecture Overview
This is a NixOS flake-based configuration using flake-parts, managing multiple hosts (desktop, laptop, work, homelab, desktop-wsl, bootstrap). The configuration uses a custom module system under fireproof.* options.
Key Structural Patterns
- Host definitions:
hosts/<hostname>/default.nixsetsfireproof.hostname,fireproof.username, and feature flags - Module organization:
modules/contains themed directories (base/,desktop/,programs/,homelab/,system/,scripts/) - Host configuration flow:
hosts/default.nixdefinesmkSystemwhich imports all module directories plus the specific host
The fireproof Options System
All custom options live under fireproof.*. Key options:
fireproof.hostname = "desktop"; # Required per host
fireproof.username = "nickolaj"; # Required per host
fireproof.desktop.enable = true; # Enables niri + desktop modules
fireproof.homelab.enable = true; # Enables server services
fireproof.work.enable = true; # Work-related tools
fireproof.dev.enable = true; # Development tools
Home Manager Integration
Use fireproof.home-manager instead of home-manager.users.<username>:
# Correct pattern (from modules/programs/ghostty.nix)
fireproof.home-manager.programs.ghostty.enable = true;
# NOT: home-manager.users.nickolaj.programs...
Theme System
Colors are defined in modules/base/theme.nix under config.fireproof.theme.colors.*. Access them as:
let c = config.fireproof.theme.colors;
in {
background = c.bg; # No # prefix in the option
border = "#${c.accent}"; # Add # when needed
}
Developer Workflow
Use just for all operations:
just switch # Rebuild current host
just switch desktop <IP> # Rebuild specific host
just update nixpkgs # Update single input
just diff # Preview changes before switching
nix fmt # Format with alejandra, deadnix, statix
Secret Management
Secrets use agenix + agenix-rekey with YubiKey master identity:
- Global secrets:
secrets/*.age - Per-host secrets:
secrets/hosts/<hostname>/ - Host keys are in
secrets/hosts/<hostname>/id_ed25519.{pub,age} - Rekey after adding hosts/secrets:
just secret-rekey
Adding New Features
- New program: Create
modules/programs/<name>.nix, guard withlib.mkIf config.fireproof.desktop.enableor similar - New homelab service: Create
modules/homelab/<name>.nix, add tomodules/homelab/default.niximports - New host: Run
just new-host <hostname> <username>, then add tohosts/default.nix
Common Patterns
Conditional Module Loading
{config, lib, ...}: {
config = lib.mkIf config.fireproof.desktop.enable {
# Desktop-only configuration
};
}
Using Unstable Packages
pkgsUnstable is available via specialArgs when packages need bleeding-edge versions.
Hardware Config
Use facter.reportPath = ./facter.json; in host config; generate with just factor <hostname>.