# NixOS flake: Hyprland + Noctalia gaming desktop Declarative NixOS for one AMD desktop (`desktop`, user `faumaray`), installable from a USB stick with a single command. The canonical remote is Gitea: (`origin`). GitHub (, remote `github`) is a secondary remote. ## Features - **Flake** in the dendritic layout (flake-parts + import-tree) with home-manager, agenix, disko, lanzaboote, nixos-hardware and Stylix. - **Hyprland** (from its own flake, current git) under UWSM with the **Noctalia v5** shell, WezTerm, Neovim, zsh + starship and Dolphin. SDDM logs the user straight into the session (autologin). - **Stylix theming**: Catppuccin Mocha, Monaspace and Inter fonts, Bibata cursor and Papirus icons for GTK, Qt, the TTY, Hyprland, Noctalia, WezTerm and the command-line tools, all from one file. - **Gaming**: Steam with Proton-GE, gamescope, gamemode, MangoHud. - **Full AMD**: AMD CPU, Radeon GPU (Mesa, LACT, optional ROCm). - **Network**: proxy-suite (zapret, Telegram WebSocket proxy), AmneziaVPN, NetworkManager with the OpenVPN plugin. - **Dev**: Docker (rootless and rootful), a Gitea Actions runner, **nix-ld** and AppImage support for binaries built for other distros, and **Claude Code** with codebase-memory-mcp, Serena, REA and caveman. - **Disks via disko, btrfs, no encryption**: - NVMe: ESP (`/boot`, 2G) + btrfs `nixos` with `@root @home @nix @log @swap` (16G swapfile). - SATA SSD: btrfs `data`, one subvolume per folder, mounted into the home: `~/Games ~/Downloads ~/Documents ~/Music ~/Pictures ~/Videos ~/Storage`. - **Secure Boot** with lanzaboote (keys in `/var/lib/sbctl`). - **Secrets** with agenix, decrypted by the machine's SSH host key (`/etc/ssh/ssh_host_ed25519_key`). Every secret is optional. - **Installer**: `install-system` (also `nix run .#install`) and a bootable ISO with this repository baked in (`nix build .#iso`). ## Layout ``` flake.nix inputs and nixConfig; outputs = flake-parts over import-tree of modules/ flake.lock pinned inputs (committed) modules/ every .nix file below is a flake-parts module (import-tree) flake/ glue: systems, meta (shared data), hosts -> nixosConfigurations, overlays, packages, apps, dev shell, formatter, checks users/ meta.owner: the user's identity (faumaray.nix) core/ the `core` aspect every host imports: nix, boot, locale, networking, users, home-manager, facts for install-system boot/ secure-boot (lanzaboote) or systemd-boot hardware/ amd (CPU, GPU, LACT), rocm (optional, not imported by desktop) security/ secrets (agenix), ssh (server and client) network/ vpn (AmneziaVPN), proxy-suite (zapret, Telegram proxy) dev/ docker, gitea-runner, nix-ld (foreign binaries, AppImage) desktop/ hyprland (+ its Lua files), noctalia, audio, fonts, wezterm, xdg, apps theme/ stylix: scheme, fonts, cursor, icons, target list cli/ shell, git, neovim gaming/ steam ai/ claude-code installer/ the installer ISO hosts/desktop/ host.nix (aspects + host-only values), hardware.nix, disks.nix hosts/desktop/ written by install-system: hardware-configuration.nix, disk-ids.json (not modules) pkgs/ install-system, create-keys, set-password, secret-from-file, switch-system secrets/ secrets.nix (recipients) and the encrypted *.age files keys/ PRIVATE keys, gitignored, lives only on your USB stick .claude/, CLAUDE.md project settings and instructions for Claude Code sessions ``` ### How it is organised (dendritic) - **Every `.nix` file under `modules/` is a flake-parts module.** `flake.nix` only declares inputs; its `outputs` is `flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules)`. import-tree imports every file below `modules/` (paths containing `/_` are skipped), so there are no import lists: `git add` a new file and it is part of the flake. - **An aspect is one feature**, published as `flake.modules.nixos.` (a NixOS module) and/or `flake.modules.homeManager.` (a home-manager module). One file can define both halves, e.g. `modules/security/ssh.nix` (server and client). Importing an aspect turns the feature on: there are no `enable` options. Alternatives are separate aspects (`secure-boot` or `systemd-boot`). `core` is the always-on basics, merged from `modules/core/*.nix` and the agenix import in `modules/security/secrets.nix`. - **A host picks aspects.** `modules/hosts/desktop/host.nix` sets `configurations.nixos.desktop.module`: the list of NixOS aspects, the owner's home-manager aspects and the values that belong to this machine only (time zone, locale, keyboard layouts, firewall, `stateVersion`s). `hardware.nix` and `disks.nix` add to the same module. `modules/flake/nixos.nix` turns every `configurations.nixos.` into `nixosConfigurations.` and `checks..nixos-`. - **A combined aspect attaches its home-manager half to the owner** from its NixOS half (`home-manager.users..imports`), so the host imports it once. Home-manager-only aspects (`shell`, `git`, `neovim`, `wezterm`, `xdg`, `apps`, `claude-code`) are listed in the host's `home-manager.users.` block. - **Shared data** is two typed top-level flake-parts options (schema in `modules/flake/meta.nix`, not a flake output): `meta.owner` (name, full name, e-mail, uid, SSH keys; the values are in `modules/users/faumaray.nix`) and `meta.secretsDir` (default `./secrets`). A file reads them from the flake-parts `config`, bound in a `let` *before* any NixOS or home-manager module (inside `{ config, ... }:` of those, `config` is the NixOS or home-manager configuration), so both halves get the values by closure. - **Host values are plain NixOS options** (`time.timeZone`, `services.xserver.xkb`, ...), set in `host.nix`. A home-manager half reads them, and everything else on the system side (`osConfig.age.secrets`, ...), through `osConfig`, home-manager's handle on the NixOS configuration. - The only custom option left is the read-only `config.my` in `modules/core/install-facts.nix`, a compatibility view of the real configuration that `install-system` evaluates; aspects never read it. Rules of thumb: - A third-party module is imported by exactly one aspect (agenix and home-manager: `core`; lanzaboote: `secure-boot`; Stylix: `theme`; disko: the host's `disks.nix`). Importing it twice declares its options twice. - A dynamic attribute such as `users.users.${owner.name}` may appear only once per attribute set: put everything for the owner into one block. - A secret is declared (`age.secrets.`) only when `meta.secretsDir + "/.age"` exists, with a `warnings` entry otherwise. Never put a secret value into a `.nix` file. #### Add an aspect 1. Create `modules//.nix` with a header comment (what it does; for a combined aspect, what each half does). 2. Define `flake.modules.nixos.` and/or `flake.modules.homeManager.`. A combined aspect adds its home-manager half from the NixOS half: ```nix { config, ... }: let # flake-parts' config: read shared values here, before the `config` argument # of a NixOS or home-manager module shadows the name. inherit (config.meta) owner; hmFoo = config.flake.modules.homeManager.foo; in { flake.modules.nixos.foo = { pkgs, ... }: { environment.systemPackages = [ pkgs.hello ]; home-manager.users.${owner.name}.imports = [ hmFoo ]; }; flake.modules.homeManager.foo = { osConfig, ... }: { programs.git.settings.user.email = owner.email; home.sessionVariables.KB_LAYOUT = osConfig.services.xserver.xkb.layout; }; } ``` 3. If Stylix supports the program, add `stylix.targets..enable = true;` to `modules/theme/stylix.nix` (its home-manager half for user programs). 4. Add the name to the NixOS list (or the home-manager list) in `modules/hosts//host.nix`. 5. `git add` the new file (flakes only see tracked files), run `nix fmt` and `nix flake check --no-build`. #### Add a host 1. Create `hosts//` with `disk-ids.json` (`{"system": "/dev/disk/by-id/nvme-CHANGE-ME", "data": "/dev/disk/by-id/ata-CHANGE-ME"}`) and a placeholder `hardware-configuration.nix` (`hosts/desktop/`'s is a template). `install-system` rewrites both and needs the directory to exist. 2. Copy `modules/hosts/desktop/` to `modules/hosts//`. In each file replace `configurations.nixos.desktop` with `configurations.nixos.` and the `hosts/desktop/` paths; adjust the aspect lists, time zone and keyboard layouts, firewall, disks and the `stateVersion`s. 3. `git add` everything, then `nix run .#install -- --host ` on the target. If a second host needs the same disk layout, lift `disks.nix` into a shared aspect at that point. ### Flake outputs | Output | Contents | |---|---| | `nixosConfigurations` | `desktop`, `installer` | | `packages.x86_64-linux` | `create-keys`, `install-system`, `iso`, `secret-from-file`, `set-password`, `switch-system` | | `apps.x86_64-linux` | `create-keys`, `install`, `secret-from-file`, `set-password`, `switch` | | `checks.x86_64-linux` | `create-keys`, `formatting`, `install-system`, `nixos-desktop`, `secret-from-file`, `set-password`, `switch-system` | | `devShells.x86_64-linux` | `default` (`nix develop`: agenix, disko, age, ssh-to-age, sbctl, git, nixfmt, nixd, shellcheck) | | `formatter.x86_64-linux` | `nix fmt` (nixfmt; skips the generated `hosts/*/hardware-configuration.nix`) | | `overlays` | `hyprland`, `noctalia`, `additions`, `modifications`, and `default`, which composes the four | | `modules` | `nixos.`, `homeManager.` | `checks.x86_64-linux.nixos-desktop` is the host's toplevel: with `--no-build`, `nix flake check` evaluates the whole host down to its derivation, without it the host is built. `formatting` is the nixfmt check; the five tools are checks too (their shellcheck runs when they are built). ## First-time setup (on your current machine) Everything here is **optional**. Without it the system still installs; the login password then is `changeme` (with a warning), there is no SSH key, the Gitea runner is not configured and the Telegram proxy is off (a warning each). ```sh git clone https://git.faumaray.com/faumaray/NixOsConfig nixos-config && cd nixos-config # 1. Host SSH key (the agenix identity) and Secure Boot keys -> keys/desktop/ nix run .#create-keys # 2. Open secrets/secrets.nix and replace the two placeholder keys: # host = the public key create-keys printed # faumaray = your own public key (cat ~/.ssh/id_ed25519.pub) # 3. Login password (asks twice, stores secrets/faumaray-password.age) nix run .#set-password -- -i ~/.ssh/id_ed25519 # 4. Your SSH key, installed as ~/.ssh/id_ed25519 on the new system nix run .#secret-from-file -- ssh-id_ed25519.age ~/.ssh/id_ed25519 -i ~/.ssh/id_ed25519 cp ~/.ssh/id_ed25519.pub secrets/ssh-id_ed25519.pub # 5. Commit. Flakes only see tracked files; keys/ is gitignored on purpose. git add -A && git commit -m "Add secrets" ``` `-i` is only a check: it proves your private key can decrypt what was just written. Edit secrets later with `cd secrets && agenix -e .age -i `. Copy the whole directory, **including `keys/`**, to the USB stick (and back `keys/` up: it holds the host key and the Secure Boot keys). `keys//` contains `ssh_host_ed25519_key(.pub)` and `sbctl/{keys,GUID}`. The installer copies them to `/etc/ssh` and `/var/lib/sbctl`; if they are missing it generates new ones and saves them back to the stick. ### Secrets | File in `secrets/` | Content | Consumer | |---|---|---| | `faumaray-password.age` | hashed login password (`mkpasswd -m yescrypt`; `set-password`) | the user account (`modules/core/users.nix`) | | `ssh-id_ed25519.age`, `ssh-id_ed25519_work.age` | private SSH keys (+ optional plain `.pub` files) | linked to `~/.ssh/` (`modules/security/ssh.nix`) | | `gitea-runner-token.age` | one line `TOKEN=` | Gitea runner `performance`, `tokenFile` (`modules/dev/gitea-runner.nix`) | | `tg-ws-proxy-secret.age` | the hex secret (32 hex digits, generated below) | Telegram proxy, `secretFile` (`modules/network/proxy-suite.nix`) | The last two are new: the runner token and the Telegram secret used to be plaintext in the Nix files. Create them the same way as the others (the recipients are already listed in `secrets/secrets.nix`; `secret-from-file` runs `git add` for you): ```sh # Gitea runner: a fresh registration token from the Gitea runners page. # The editor opens; type one line: TOKEN= (cd secrets && agenix -e gitea-runner-token.age -i ~/.ssh/id_ed25519) # or without an editor (the token lands in your shell history): printf 'TOKEN=%s\n' '' \ | nix run .#secret-from-file -- gitea-runner-token.age - -i ~/.ssh/id_ed25519 # Telegram proxy: a new secret; note it, the Telegram clients need it in the proxy link s=$(od -An -N16 -tx1 /dev/urandom | tr -d ' \n') && [ "${#s}" -eq 32 ] && echo "$s" \ && printf '%s\n' "$s" | nix run .#secret-from-file -- tg-ws-proxy-secret.age - -i ~/.ssh/id_ed25519 unset s git add secrets/gitea-runner-token.age secrets/tg-ws-proxy-secret.age # agenix -e does not ``` (`-` reads the plaintext from stdin, so no plaintext file is left behind; add `--force` to replace an existing file. Show a stored secret again with `age -d -i ~/.ssh/id_ed25519 secrets/tg-ws-proxy-secret.age`.) **Rotate the old values.** They are in the git history, so treat them as leaked: create a new runner registration token in Gitea and a new MTProto secret, and update the Telegram clients with the new proxy link. Until the two files exist a switch removes the runner instance and turns the Telegram proxy off, each with an evaluation warning. ## Install from USB Needs a UEFI PC and network. **The NixOS installer image is not Secure Boot signed: disable Secure Boot in the firmware while installing** (you enable it again afterwards, see below). `install-system` erases the two chosen disks. ### Path A: official NixOS ISO + this repository on a stick 1. Boot the official NixOS ISO (minimal or graphical, e.g. with Ventoy), connect to the network (`nmtui`). 2. Mount the stick that holds the repository and `keys/`. **Not below `/mnt`**, that is where the new system is mounted: ```sh sudo -i mkdir -p /media/usb && mount /dev/disk/by-label/