| id | CLAUDE | |
|---|---|---|
| aliases |
|
|
| tags |
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a NixOS and nix-darwin flake configuration managing multiple machines including desktops, laptops (Framework and work), servers (storage, K8s, VPN gateway, KVM hypervisor), and macOS systems. The configuration uses home-manager for user-level configuration and supports both NixOS and Darwin systems.
All commands are managed via just (justfile). The system automatically uses nh if available, otherwise falls back to nixos-rebuild or darwin-rebuild:
# Build and switch immediately
just switch [extraargs]
just s # alias
# Build and set for next boot
just boot
just b # alias
# Build without activating
just build [hostname] [extraargs]
just B # alias
# Test temporarily (reverts on reboot)
just test [extraargs]
just t # alias
# Update flake inputs
just update
just u # alias
# Deploy to remote machines via deploy-rs
just deploy [extraargs]
# Build VM for testing
just test-build <hostname>
# Run built VM
just test-run <hostname>
# Build NixOS AMI image
just ami-build <hostname>
# Upload built AMI to AWS
just ami-upload <hostname> [region] [bucket]
# Build + upload AMI in one step
just ami <hostname> [region] [bucket]# Build specific host configuration
nix build ".#nixosConfigurations.<hostname>.config.system.build.toplevel"
# Check flake
nix flake check
# Show flake outputs
nix flake show
# Update specific input
nix flake lock --update-input <input-name>This repository uses the Dendritic Pattern with flake-parts + haumea for modular, auto-discovered configuration.
flake.nix: Minimal entry point (~50 lines of outputs logic). Defines inputs, uses haumea to auto-discover all flake-parts modules fromflake-modules/.flake-modules/: All flake output definitions, auto-discovered by haumea:overlays.nix: Exportsflake.overlaysfromoverlays/deploy.nix: deploy-rs node definitions and checksdev-shells.nix: Development shell (perSystem.devShells.default)templates.nix: Flake templatesnixos-modules.nix: Exports all NixOS modules asflake.nixosModules.*home-modules.nix: Exports home-manager modules asflake.homeModules.*hosts/: One directory per host configuration (NixOS, Darwin, standalone home-manager), each containingdefault.nix(the flake-parts module),hardware-configuration.nix(wrapped asflake.nixosModules.<hostname>-hardware), anddisko-config.nix(wrapped asflake.nixosModules.<hostname>-disko-config)
modules/: Reusable NixOS modules using the options system (options.*/config = mkIf cfg.enable):base/: Core system configuration (networking, boot, nix settings, impermanence, secure boot)desktop/: Desktop environment configurationsdevelopment/: Development tools and environments (e.g., web development)locale/: Localization settingslibvirtd/,vr/,rocm/,ollama/,servers/: Specialized functionality modulesdesktop-base/,desktop-1password/,desktop-aws-tools/,desktop-kubernetes/, etc.: Desktop feature modulesdesktop-greetd/,desktop-greetd-regreet/,desktop-sddm/: Display manager modulesdesktop-wm-plasma6/,desktop-wm-sway/: Window manager moduleshardware-fingerprint/,hardware-touchpad/: Hardware feature modulesk8s-master/,storage-server/: Server role modules
home/: Home-manager configurations:home-linux.nix,home-macos.nix,home-common.nix: Platform-specific and shared configsprograms/: Per-program home-manager configurations (zsh, neovim, tmux, git, etc.)wms/: Window manager configurations (river, plasma, etc.)
pkgs/: Custom packages and overridesoverlays/: System-independent nixpkgs overlays (accepts only{ inputs }, usesfinal.stdenv.hostPlatform.systeminternally)secrets/: SOPS-encrypted secrets (managed by sops-nix, configured in .sops.yaml)templates/: Flake templates (e.g., Rust development environment)
Each host is defined in its own flake-parts module directory at flake-modules/hosts/<hostname>/. These directories contain:
default.nix: The flake-parts module definingflake.nixosConfigurations.<hostname>(ordarwinConfigurations/homeConfigurations)hardware-configuration.nix: Wrapped as a flake-parts module exportingflake.nixosModules.<hostname>-hardwaredisko-config.nix: Wrapped as a flake-parts module exportingflake.nixosModules.<hostname>-disko-config
All custom modules are referenced via self.nixosModules.* (exported in nixos-modules.nix) and enabled with modules.<name>.enable = true. Home-manager modules are referenced via self.homeModules.* (exported in home-modules.nix). File paths for secrets/patches use self + "/path/to/file". No relative path imports (../../) are used — everything goes through flake outputs.
New flake-modules files are auto-discovered by haumea - just create a .nix file or directory in flake-modules/ and it will be imported automatically.
The modules/base module uses NixOS options under modules.base:
enable: Enable the base modulebootLoader: Boot loader selection — enum of"systemd-boot","grub", or"secure-boot"(Lanzaboote with TPM)pcr15Value: TPM PCR15 value for LUKS unlocking (required whenbootLoader = "secure-boot")enableImpermanence: Enable tmpfs root with persistenceimpermanencePersistencePath: Where to persist data (default:/persistence)enableCachyOSKernel: Enable CachyOS kernel overlay (for hosts using CachyOS kernel packages)enableOpenSSH,enableTailscale,enableIPv6,enableICMPPing: Feature togglessuspendState: Suspend state ("mem","standby","freeze", ornullfor auto-detect)hibernateMode: Hibernate mode ("platform"or"shutdown")timezone,consoleKeyMap: Locale settingsbeesdFilesystems: Btrfs dedup filesystem configuration
Overlays: The flake provides system-independent overlays for accessing different nixpkgs channels:
pkgs.stable: nixpkgs 25.11 stablepkgs.unstable: nixos-unstablepkgs.master: nixpkgs master branch
Configured in overlays/default.nix and exported via flake-modules/overlays.nix. Applied per-host in their flake-parts module files.
Impermanence: Several hosts use tmpfs root filesystems with selective persistence via the impermanence module. Persistence paths are configured per-host.
Secrets Management: Uses sops-nix with age encryption. Age keys are defined in .sops.yaml with path-based rules for different hosts/secrets.
Remote Deployment: The flake exports a deploy attribute using deploy-rs for remote system deployments, defined in flake-modules/deploy.nix.
Key configurations defined in the flake:
- Desktop/Laptop:
ali-desktop,ali-framework-laptop,ali-work-laptop - macOS:
Alisons-MacBook-Pro(Darwin configuration for work laptop) - Servers:
home-storage-server-1,home-kvm-hypervisor-1,home-k8s-master-1,home-k8s-server-1,home-vpn-gateway-1,download-server-1 - Dev/Test:
dev-vm(aarch64-linux VM) - Home-Manager Only:
ali(Arch Linux),deck(Steam Deck)
ali-neovim: Custom Neovim configuration flakehome-manager: User environment managementstylix: System-wide themingplasma-manager: KDE Plasma home-manager integrationsops-nix: Secrets managementdisko: Declarative disk partitioninglanzaboote: Secure Boot supportimpermanence: Tmpfs root persistencedeploy-rs: Remote deployment toolnixos-hardware: Hardware-specific configurations (e.g., Framework 16)nixos-cosmic: Alternative desktop environmentrust-overlay: Rust toolchain managementjovian-nixos: Steam Deck specific configurationsniks3: Self-hosted binary cache push tool
build-and-cache.yaml: Builds all nixosConfigurations on push to main and pushes to niks3 binary cache. Includes dry-run check to skip cached builds and parallel build+push via queue drain.update.yaml: Automated daily flake lock updates (2 AM UTC)ami-build-and-upload.yaml: Builds and uploads NixOS AMIs to AWS with retention cleanupclosure-report.yaml: Generates closure size reports for desktop/laptop configurations
The modules/niks3-cache-push module and GHA parallel push workflow are implemented but not yet enabled on hosts. To finish:
- Create
secrets/niks3-token.enc.yamlviasops secrets/niks3-token.enc.yamlwith keyniks3_token - Add ali-framework-laptop's server age key to
.sops.yaml(keys section + niks3-token creation rule) - Uncomment the
modules.niks3CachePushandsops.secrets.niks3-tokenblocks in:flake-modules/hosts/ali-desktop/default.nixflake-modules/hosts/ali-framework-laptop/default.nixflake-modules/hosts/ali-work-laptop/default.nix
When modifying configurations:
- Edit relevant files in
modules/,home/, orflake-modules/hosts/<hostname>/ - Test changes with
just testfor temporary activation - Use
just buildto build without activating (useful for checking for errors) - Commit with
just switchto activate and make permanent - For remote hosts, use
just deploy .#<hostname>after testing locally
When adding new hosts:
- Create a directory at
flake-modules/hosts/<hostname>/(auto-discovered by haumea) - Create
default.nixas a flake-parts module definingflake.nixosConfigurations.<hostname> - Create
hardware-configuration.nixwrapped as{ ... }: { flake.nixosModules.<hostname>-hardware = { ... }; } - Create
disko-config.nixwrapped as{ ... }: { flake.nixosModules.<hostname>-disko-config = { ... }; } - Reference custom modules via
self.nixosModules.*, home modules viaself.homeModules.*, secrets viaself + "/secrets/...", and overlays viaself.overlays.* - New files must be
git added beforenix eval/nix buildwill see them (flake git tracking)
When adding new NixOS modules (two-step process):
- Create the module in
modules/<name>/default.nixusing the options pattern - Export it in
flake-modules/nixos-modules.nix(add an entry toflake.nixosModules) - Reference it in host files via
self.nixosModules.<name> - New files in
modules/must begit added beforenix eval/nix buildwill see them (flake git tracking)
When adding new flake-modules:
- Create a
.nixfile inflake-modules/orflake-modules/hosts/ - The file will be auto-discovered by haumea - no need to update
flake.nix - Use the flake-parts module signature:
{ inputs, self, ... }: { flake = { ... }; }
When adding secrets:
- Add age keys to
.sops.yamlif needed - Create secret files in
secrets/orsecrets/<hostname>/ - Unencrypted Secrets should be named using the pattern
<name>.dec.yamlso that they are gitignored. Encrypted secrets get saved with the name pattern<name>.enc.yaml - Encrypt with
sopscommand - Reference in host configuration via
sops.secrets.<name>