76 KiB
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: https://git.faumaray.com/faumaray/NixOsConfig
(origin). GitHub (https://github.com/Faumaray/NixOsConfig, 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 is
a Catppuccin Wayland greeter with the Stylix wallpaper: there is no autologin,
you type the password at every boot and it also unlocks the keyring. Neovim is
configured by your own
nvimrepository, taken as a pinned flake input (see Neovim). - Stylix theming: Catppuccin Mocha, Monaspace Radon and Noto fonts, Bibata
cursor, Papirus icons and one wallpaper for GTK, Qt, the TTY, Hyprland,
Noctalia, the login screen, WezTerm, Obsidian, the command-line tools and every
other program Stylix supports (
autoEnable), all from one file. - Gaming: Steam with Proton-GE, gamescope, gamemode, MangoHud; Hyprland rules start Proton games fullscreen and float their launchers.
- Notes: Obsidian with a declarative vault (
~/Documents/Notes), pinned community plugins and git backup to Gitea, readable by Claude Code (see Obsidian). - Full AMD: AMD CPU, Radeon GPU (Mesa, LACT, optional ROCm).
- Network: proxy-suite (zapret, Telegram WebSocket proxy, and an
AmneziaWG split tunnel (global TProxy) that sends the Claude/Anthropic and
ChatGPT/OpenAI domains, plus a few other sites listed in
aiDomains, through the tunnel and everything else directly, except the networks zapret2 cannot unblock, which go through it as well; a manual full-tunnel profilevpnuses the same config and hands back to the split tunnel when it stops), AmneziaVPN, NetworkManager with the OpenVPN plugin. - Dev: composable dev shells for Rust (fenix), C/C++ (Clang or GCC) and
Vulkan, entered with
devor activated per directory by direnv; Docker (rootless and rootful), a Gitea Actions runner, nix-ld and AppImage support for binaries built for other distros, and Claude Code with the codebase-memory-mcp, Serena, REA, NixOS and Context7 MCP servers, the nil and rust-analyzer language servers, codebase-memory-mcp's skill and graph agents, the Context7 skill, hooks (rtk, nixfmt, notifications, codebase-memory-mcp and Serena), a status line, deny rules for secrets and caveman. - Disks via disko, btrfs, no encryption:
- NVMe: ESP (
/boot, 2G) + btrfsnixoswith@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.
- NVMe: ESP (
- 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(alsonix 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, dev shells (shells.nix),
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, AmneziaWG split tunnel and full-tunnel profile)
dev/ docker, gitea-runner, nix-ld (foreign binaries, AppImage),
dev-shells (the `dev` helper), shells/ (rust, cpp, vulkan, rust-cpp)
desktop/ hyprland (+ its Lua files), sddm (login screen), noctalia, audio, fonts,
wezterm, xdg, apps, obsidian
theme/ stylix: scheme, fonts, cursor, icons, wallpaper, targets switched off
cli/ shell, git, neovim (the nvim input)
gaming/ steam
ai/ claude-code (+ claude-statusline.sh, its status line, and codebase-memory/,
codebase-memory-mcp's skill and agents)
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,
dev-shell (the `dev` command)
patches/proxy-suite/ patches applied to the locked proxy-suite input (network/proxy-suite.nix)
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
.nixfile undermodules/is a flake-parts module.flake.nixonly declares inputs; itsoutputsisflake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules). import-tree imports every file belowmodules/(paths containing/_are skipped), so there are no import lists:git adda new file and it is part of the flake. - An aspect is one feature, published as
flake.modules.nixos.<name>(a NixOS module) and/orflake.modules.homeManager.<name>(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 noenableoptions. Alternatives are separate aspects (secure-bootorsystemd-boot).coreis the always-on basics, merged frommodules/core/*.nixand the agenix import inmodules/security/secrets.nix. - A host picks aspects.
modules/hosts/desktop/host.nixsetsconfigurations.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,stateVersions).hardware.nixanddisks.nixadd to the same module.modules/flake/nixos.nixturns everyconfigurations.nixos.<name>intonixosConfigurations.<name>andchecks.<system>.nixos-<name>. - A combined aspect attaches its home-manager half to the owner from its
NixOS half (
home-manager.users.<owner>.imports), so the host imports it once. Home-manager-only aspects (shell,git,neovim,wezterm,xdg,apps,obsidian,claude-code,dev-shells) are listed in the host'shome-manager.users.<owner>block.sddmis NixOS-only and sits in the host's NixOS list next tohyprland,noctaliaandtheme(it reads the Stylix palette, wallpaper, font and cursor, and asserts a Catppuccin scheme). - 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 inmodules/users/faumaray.nix) andmeta.secretsDir(default./secrets). A file reads them from the flake-partsconfig, bound in aletbefore any NixOS or home-manager module (inside{ config, ... }:of those,configis 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 inhost.nix. A home-manager half reads them, and everything else on the system side (osConfig.age.secrets, ...), throughosConfig, home-manager's handle on the NixOS configuration. - The only custom option left is the read-only
config.myinmodules/core/install-facts.nix, a compatibility view of the real configuration thatinstall-systemevaluates; 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'sdisks.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.<name>) only whenmeta.secretsDir + "/<name>.age"exists, with awarningsentry otherwise. Never put a secret value into a.nixfile.
Add an aspect
-
Create
modules/<area>/<name>.nixwith a header comment (what it does; for a combined aspect, what each half does). -
Define
flake.modules.nixos.<name>and/orflake.modules.homeManager.<name>. A combined aspect adds its home-manager half from the NixOS half:{ 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; }; } -
Stylix themes every program it supports on its own (
stylix.autoEnable = true), so nothing is needed for most. To keep one out, addstylix.targets.<program>.enable = false;tomodules/theme/stylix.nix(its home-manager half for user programs). A few targets need settings of their own (obsidian.vaultNames): set them there too. -
Add the name to the NixOS list (or the home-manager list) in
modules/hosts/<host>/host.nix. -
git addthe new file (flakes only see tracked files), runnix fmt, the host evaluation (nix eval .#nixosConfigurations.desktop.config.system.build.toplevel.drvPath) and thennix flake check --no-build.
Add a host
- Create
hosts/<new>/withdisk-ids.json({"system": "/dev/disk/by-id/nvme-CHANGE-ME", "data": "/dev/disk/by-id/ata-CHANGE-ME"}) and a placeholderhardware-configuration.nix(hosts/desktop/'s is a template).install-systemrewrites both and needs the directory to exist. - Copy
modules/hosts/desktop/tomodules/hosts/<new>/. In each file replaceconfigurations.nixos.desktopwithconfigurations.nixos.<new>and thehosts/desktop/paths; adjust the aspect lists, time zone and keyboard layouts, firewall, disks and thestateVersions. git addeverything, thennix run .#install -- --host <new>on the target. If a second host needs the same disk layout, liftdisks.nixinto a shared aspect at that point.
Flake outputs
| Output | Contents |
|---|---|
nixosConfigurations |
desktop, installer |
packages.x86_64-linux |
create-keys, dev-shell, 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, dev-shell, 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), rust, rust-nightly, cpp, cpp-gcc, vulkan, vulkan-gcc, rust-cpp (see Development shells) |
legacyPackages.x86_64-linux |
composeShells (the function behind dev a b -p pkg) |
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.<aspect>, homeManager.<aspect> |
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 six 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, the Telegram proxy is off and so are the
AmneziaWG tunnels, split and vpn (a warning each for the runner, the proxy and
AmneziaWG).
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 <name>.age -i <your key>.
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/<host>/ 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/<key> (modules/security/ssh.nix) |
gitea-runner-token.age |
one line TOKEN=<registration 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) |
amneziawg-ai.age |
the whole AmneziaWG client .conf (AWG 1.x to 3.x) | AmneziaWG split tunnel (amneziaWg.profiles.ai.configFile) and full-tunnel profile vpn (profiles.vpn.configFile), both in modules/network/proxy-suite.nix; without it no tunnel, no TProxy and no per-app routing, the proxy stays off |
gitea-runner-token.age and tg-ws-proxy-secret.age 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):
# Gitea runner: a fresh registration token from the Gitea runners page.
# The editor opens; type one line: TOKEN=<registration 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' '<registration token>' \
| 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.)
The AmneziaWG split tunnel (the Claude/Anthropic and ChatGPT/OpenAI domains, and
the few other sites in aiDomains, go through the tunnel, everything else stays
direct but for the networks zapret cannot unblock, below) takes the client .conf
that AmneziaVPN exports. It is a file that holds a private key, so keep it outside
the repository, encrypt it and delete the plaintext. secret-from-file runs
git add for you. Do not keep the AmneziaVPN desktop client connected with the
same peer at the same time:
nix run .#secret-from-file -- amneziawg-ai.age /path/to/client.conf -i ~/.ssh/id_ed25519
rm /path/to/client.conf
A plaintext copy must not stay in the repository: /WG.conf in the root is
gitignored, so git add and the .# flake references skip it, but it is still
a private key on disk, and a path: flake reference would copy it into the
world-readable Nix store. amneziawg-ai.age is the only copy needed.
The split mode is the proxy-suite global TProxy (proxy.autostart = "tproxy"):
nftables hands this host's own TCP and UDP connections to public addresses, DNS
lookups included, to sing-box (loopback, private and LAN ranges, replies and
proxy-suite's own traffic stay out). It sends the AI domains (and Anthropic's
published inbound range 160.79.104.0/23) through the ai tunnel and everything
else directly, where zapret works.
It is TProxy and not TUN because proxy-suite hands zapret2's fallback lists only
to the config that serves TProxy (proxy-suite-socks): zapret-cutoff (networks
that cut TLS off at about 16 KB: Cloudflare, AWS, Hetzner...) and
zapret-unfixable (addresses no strategy fixed: CDN77, G-Core, OVH, Fastly,
Akamai...) go to outbound proxy, which here is the ai tunnel too. Under TUN
they went direct and timed out. What TProxy costs:
- Only this host's own connections are taken (dockerd's and rootless Docker's user-mode networking among them), not forwarded ones. Rootful containers (the Gitea runner's jobs) and VMs behind a bridge go out directly, through zapret but with neither the split nor the fallback lists.
- Blocked CDNs and cut-off networks now leave through the AmneziaWG server, which carries their traffic.
- They have no direct fallback: while
aiis down they do not load at all (cache.nixos.org, behind Fastly, among them).
Two local fixes to proxy-suite. The module is built from the locked
proxy-suite input with the patches in patches/proxy-suite/, applied with
applyPatches; the module factory is then called with the same inputs upstream's
flake.nix passes for nixosModules.default. Evaluation builds that patched tree
first (import from derivation): a small local build whose tools may need
cache.nixos.org, reachable only through ai. system.extraDependencies keeps the
tree in the system closure, so the weekly garbage collection leaves it and
evaluation needs neither a build of it nor cache.nixos.org once a switch has put it
there; a fresh clone or a nix flake update still builds it. nix flake check --no-build is read-only: it
fails with ...-proxy-suite-flake-patched.drv is not valid whenever the store
lacks the tree's .drv (a fresh clone or machine, a nix flake update that moves
nixpkgs or proxy-suite, an edited patch, a garbage collection). That error means:
run the host evaluation first
(nix eval .#nixosConfigurations.desktop.config.system.build.toplevel.drvPath
builds the tree), then the check.
0001-tproxy-let-zapret-desync-packets-past.patch: TProxy's output chain took zapret's own desync packets (fakes and split segments) back into the proxy, which dropped them, so every connection zapret desyncs stalled (YouTube, Discord...). nfqws2 marks those packets with its desync mark OR'd with the mark of the packet they derive from (0x40000002 for a proxy-marked one), so the patch tests the mark bits and lets every packet with a zapret desync bit past. The kill switch matches its zapret marks by exact value and would miss 0x40000002 (probably an upstream bug of its own; it is off here). The patch header describes it for an upstream report.- The
aiwatchdog checks the tunnel withcurl --interface awg-ai, which TProxy marked for the proxy and itsmisroutedguard dropped: three misses, and the watchdog reset the peer every five minutes. The NixOS tableproxy-suite-ai-probe(networking.nftables.tables, inproxy-suite.nix) gives packets leaving throughawg-aithe proxy's own mark, just ahead of TProxy's output chain, which lets that mark past. Drop the table once upstream marks the watchdog's probe.
When upstream has the first fix, drop the patch: delete the file, and in
modules/network/proxy-suite.nix import inputs.proxy-suite.nixosModules.default
again in place of proxySuiteModule (and remove proxySuiteSource with the
patches directory). A patch that no longer applies after nix flake update proxy-suite fails evaluation, which is the reminder.
The same file also backs a full-tunnel profile vpn: a normal VPN for all
traffic, never started at boot.
proxy-ctl awg on vpn # connect (or: systemctl start proxy-suite-awg-vpn)
proxy-ctl awg off # disconnect, back to the split mode
Starting it stops TProxy, zapret and the ai tunnel (one global mode at a time,
and both profiles hold the same peer, which accepts one endpoint). Stopping it
starts TProxy (which pulls ai in) and zapret again, within seconds; a restart
keeps the full tunnel, and so does a shutdown. The hook starts both whatever you
had switched off by hand before (proxy-ctl zapret off, proxy-ctl proxy tproxy off). zapret is started by the hook and not wanted by TProxy, so proxy-ctl zapret off holds until the next full tunnel stop, boot or switch (a switch starts zapret
and TProxy again).
A full tunnel that fails to start (no handshake) falls back to the split mode the
same way, with a rough edge: the hook's start of TProxy, which conflicts with
proxy-suite-awg-vpn, cancels the unit's running start job, so proxy-ctl awg on vpn prints Job ... canceled instead of the real error (read it with
journalctl -u proxy-suite-awg-vpn). The unit ends up failed, and the system
reports degraded until systemctl reset-failed proxy-suite-awg-vpn.
A switch (nix run .#switch) starts the active targets again, which starts every
unit wanted at boot that is not running, TProxy, zapret and ai among them. Each
of them stops the full tunnel, so a switch made with the full tunnel up ends in the
split mode: run proxy-ctl awg on vpn again afterwards, from a terminal outside
the tools that depend on the tunnel. For the same reason a switch does not restart
the vpn unit when it changed (restartIfChanged = false): that would bounce
between the two modes.
A second peer (vpn with a client config of its own: another secret and
profiles.vpn.configFile) would only keep ai up beside the full tunnel, and only
once the unconditional conflicts and after of proxy-suite-awg-vpn on awg-ai
in proxy-suite.nix are dropped; TProxy and zapret stop either way.
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
-
Boot the official NixOS ISO (minimal or graphical, e.g. with Ventoy), connect to the network (
nmtui). -
Mount the stick that holds the repository and
keys/. Not below/mnt, that is where the new system is mounted:sudo -i mkdir -p /media/usb && mount /dev/disk/by-label/<LABEL> /media/usb -
Run the installer from the repository:
cd /media/usb/nixos-config nix --extra-experimental-features 'nix-command flakes' run --accept-flake-config .#installIf Nix complains about the repository ownership or a read-only stick, copy it first:
cp -r /media/usb/nixos-config /root/ && cd /root/nixos-config.The private
nviminput (see Neovim) is fetched over SSH, and the live system's store does not have it yet: root needs your login key (the one Gitea knows) and the Gitea host key.keys/holds only the machine's keys, but the host key can decrypt your login key, which is stored insecrets/. In the repository directory, as root, before the command above:mkdir -p -m 700 /root/.ssh age -d -i keys/desktop/ssh_host_ed25519_key secrets/ssh-id_ed25519.age \ > /root/.ssh/id_ed25519 chmod 600 /root/.ssh/id_ed25519 ssh-keyscan git.faumaray.ru >> /root/.ssh/known_hosts # compare the fingerprint if in doubtinstall-systemevaluates the whole system before it touches a disk, so a missing key stops it there with an explanation. Path B needs none of this: its ISO already carries every input.
Path B: the custom ISO
nix build .#iso # result/iso/nixos-*.iso, this repository included
sudo dd if=result/iso/nixos-*.iso of=/dev/sdX bs=4M status=progress conv=fsync
(check sdX with lsblk first; or just copy the file to a Ventoy stick).
Boot it, then:
nmtui # if you need Wi-Fi
sudo mkdir -p /media/keys && sudo mount /dev/disk/by-label/<LABEL> /media/keys # stick with keys/
sudo install-system
The ISO ships the flake in /etc/nixos-config (read-only; install-system
works on a copy) and finds keys/ on mounted sticks. Point at it explicitly
with --keys-dir /media/keys/keys. If you changed secrets after building the
ISO, use Path A or rebuild the ISO. Building it fetches the private nvim input
(see Neovim) with your SSH key; the ISO then carries every input, the installing
machine needs no key.
What install-system does
- Checks root, UEFI and the flake; copies it to
/root/nixos-configif it is read-only or not a usable git repository (keys/is never copied into a flake, it would end up in the world-readable Nix store). - If
hosts/desktop/disk-ids.jsonstill hasCHANGE-ME(or a disk does not exist), lists the disks and asks for the system NVMe and the data SSD. The live USB is skipped. The choice is written todisk-ids.json. - Evaluates the whole system, which fetches every flake input (the private
nvimone over SSH), so a missing input stops it before any disk is touched. Then it shows both disks (model, size) and wipes them only after you type the host name.--yesskips this prompt. - Runs disko, writes
hosts/desktop/hardware-configuration.nixfrom the real hardware (nixos-generate-config --no-filesystems). - Installs the host key, checks that it can decrypt
secrets/*.age; if not it stops before installing and explains how to fix it. - Puts the Secure Boot keys into
/mnt/var/lib/sbctl. nixos-install --flake .#desktop, asks for a login password if there is no password secret, and copies the repository to~/nixos-configof the new system.
Useful options: --host, --flake DIR, --keys-dir DIR, --select-disks,
--disko-mode mount (re-run after a failure without wiping anything), --help.
After the installation
Reboot, remove the stick. SDDM shows its login screen (modules/desktop/sddm.nix:
Catppuccin Mocha with the lavender accent, the Stylix wallpaper). There is no
autologin: type the login password at every boot; the keyboard layouts are the
host's (us,ru, Alt+Shift switches). Hyprland (UWSM) is preselected and SDDM
remembers the session you used last. The same password unlocks the GNOME keyring
(the sddm PAM service substacks login), and it is also for sudo and the
TTYs. The greeter runs on Weston, which is not configured per monitor, so with
two monitors it appears on one of them.
Secure Boot (lanzaboote). The keys exist but the firmware does not trust them yet:
-
Enter the firmware setup and put Secure Boot into Setup Mode ("Reset to Setup Mode" / clear the Platform Key; keep the factory db/dbx).
-
Boot NixOS (Secure Boot still off or in Setup Mode), then:
sudo sbctl enroll-keys --microsoft -
Reboot, enable Secure Boot in the firmware, and check:
bootctl status | grep -i "secure boot" # Secure Boot: enabled (user) sudo sbctl status
--microsoft keeps Microsoft's keys so firmware option ROMs (GPU) still work.
Steam: Settings > Storage > add ~/Games/SteamLibrary (on the data SSD).
Proton-GE appears under the compatibility tool list. Proton games (window class
steam_app_<id>) start fullscreen and their launchers, installers and error
dialogs float in the middle of the screen (modules/desktop/hyprland/rules.lua).
The rules tell them apart by window title when the window maps, so a launcher
that sets its title later still counts as a game, and native Linux games are not
covered.
Noctalia starts with the session (a systemd user service). Super+Space
launcher, Super+S control center, Super+, settings, Super+W wallpaper
panel. Its colours come from Stylix (see Theming). Changes made in the settings
window are stored by Noctalia and override modules/desktop/noctalia.nix; move
what you want to keep into that file. How it fits into the session
(modules/desktop/noctalia.nix):
- Start-up. The service waits (at most 15 s) until Hyprland answers
hyprctl statusand has a workspace. Started earlier, Noctalia could miss that the config is Lua and the workspace buttons in the bar would do nothing after login. The wrapper also exportsXDG_SESSION_ID(a user service is not part of the login session), which Noctalia needs for its lock-session handling and the brightness lookup. - Apps. Apps from the launcher, dock and taskbar start through
uwsm-app -- $CMD(launch_apps_as_systemd_servicesis off), as scopes inapp-graphical.slice. UWSM stops that slice before the compositor, so apps close cleanly at logout (Firefox saves its session), and restarting the shell does not kill them. TheSuper+ReturnandSuper+Ebinds useuwsm-apptoo.Terminal=trueentries open WezTerm through theTERMINALwrapper the service gets, also as a scope of their own. - Wallpaper. Stylix's image (see Theming) is linked at
~/.local/share/wallpapers/wallpaper.<ext>and Noctalia is pointed at that link, so a new image does not change the path. Noctalia keeps the path it was given in its runtime state (~/.local/state/noctalia/settings.toml); on every start the service looks at it and, when a file there no longer exists (for example after a garbage collection of an older Stylix image), points Noctalia at the link again. A wallpaper you picked in Noctalia stays as long as its file exists.
Session environment. The Wayland toolkit variables (NIXOS_OZONE_WL,
ELECTRON_OZONE_PLATFORM_HINT, GDK_BACKEND, QT_QPA_PLATFORM,
SDL_VIDEODRIVER, CLUTTER_BACKEND) are defined once, in
modules/desktop/hyprland/default.nix, and written to
~/.config/uwsm/env-hyprland. UWSM sources that file before the compositor
starts, so every app of the Hyprland session gets them and nothing outside it
does (a TTY shell or another session does not). An old SDL game that breaks on
Wayland needs SDL_VIDEODRIVER=x11 for itself. The cursor variables
(XCURSOR_SIZE, XCURSOR_THEME, HYPRCURSOR_SIZE) are set in settings.lua
with hl.env(..., true), which also exports them to the systemd user manager and
D-Bus, so apps started by Noctalia, the portals or D-Bus activation use the same
cursor. EDITOR and VISUAL (nvim, from the neovim aspect) are exported to the
systemd user session as well, so programs outside a shell see them; they apply
from the next login.
Firefox has no declared profile, only enterprise policies
(modules/desktop/apps.nix): it reopens the windows and tabs of the last session
and websites default to the dark appearance. Both are defaults, not locks;
about:preferences can still change them.
Obsidian needs a few steps in the app itself, once (community plugins, spellcheck languages, the first push): see Obsidian.
Commit the files the installer generated:
hosts/desktop/disk-ids.json and hosts/desktop/hardware-configuration.nix
(and flake.lock if it changed).
Theming (Stylix)
One palette for the whole desktop, applied by Stylix.
Everything is set in modules/theme/stylix.nix: the NixOS half holds the scheme,
fonts, cursor, icons, wallpaper and the system-wide targets, the home-manager half
the per-program targets.
| Setting | Value |
|---|---|
| Scheme | Catppuccin Mocha (16 colours inline, so the scheme needs no import-from-derivation), polarity dark |
| Fonts | monospace and sans Monaspace Radon, serif Noto Serif, emoji Noto Color Emoji; Noctalia keeps Monaspace Krypton for the shell through a per-target override |
| Cursor | Bibata-Modern-Classic, 24 |
| Icons | Papirus-Dark (Papirus-Light for a light scheme) |
| Wallpaper | stylix.image, the one knob: the Catppuccin Mocha wallpaper of nixos-artwork. Noctalia draws it (see Noctalia) and the SDDM login screen shows it |
Targets are opt-out (stylix.autoEnable = true): Stylix themes every program it
supports, so it also writes GNOME, KDE, X resources, gedit, gdu, Blender, ...
configs and rebuilds gtksourceview through an overlay. The file lists the targets
this desktop is built around and switches off the ones that clash with it:
- NixOS (on through
autoEnableanyway, listed for what each is for):console(TTY palette),fontconfig,font-packages,gtk,qt. - home-manager:
gtk(without Flatpak overrides),qt(qt5ct/qt6ct + Kvantum),hyprland,noctalia,wezterm,bat,btop,fzf,starship,mpv,zathuraandobsidian(for the vaultNotes). - Switched off on purpose, each with its reason in the file:
hyprland.hyprpaper,gnome.image,kde.useWallpaper: withstylix.imageset they would start hyprpaper and write the wallpaper into GNOME's and KDE's settings; Noctalia is the only one that draws it.neovim: themed by thenvimrepository (see below).firefox: needs a declared profile (see below).rofi: not installed, and the pinned Stylix target would warn at every evaluation (a renamed option).
How to change it:
- Turn a target off: set
stylix.targets.<name>.enable = false;in the matching half ofmodules/theme/stylix.nix, like the lines above. This is also the way back for one program if you dislike the new look. Deleting a target's line does not turn it off any more:autoEnableturns it on. To go back to opting in, setautoEnable = falseand list what you want. - Change the scheme: edit the
base16Schemecolours, or point it at a packaged scheme,"${pkgs.base16-schemes}/share/themes/<name>.yaml"(that is import-from-derivation: evaluation then builds it). For a light scheme also setstylix.polarity, and changegtk.colorSchemeand the dconfcolor-scheme(both fixed to dark in the home-manager half). The SDDM theme is Catppuccin and follows the palette's flavour (latte, frappe, macchiato, mocha): with any other scheme an assertion stops the evaluation until you pick another theme inmodules/desktop/sddm.nix. - Change the wallpaper: point
stylix.imageat another image, a file next tostylix.nix(./wallpaper.png) or apkgs.fetchurl { url; hash; }. The colours do not follow it, the scheme is explicit. The switch restarts Noctalia and the login screen shows the new image. - Noctalia follows the palette: Stylix's
noctaliatarget writes a custom palettestylix(~/.config/noctalia/palettes/stylix.json) and selects it. Its opacity part is off, so Noctalia keeps its own panel opacities, and the shell font stays Monaspace Krypton. Settings changed in Noctalia's own window still override the file. - Hyprland: Stylix sets the border, group, shadow and background colours
after
settings.luais loaded, so the colour literals in that file no longer take effect; disable thehyprlandtarget to use your own. - Neovim is themed by its own repository. The
nviminput (modules/cli/neovim.nix) picks its colorscheme (silkcircuit), so it does not follow the Stylix palette; Stylix's neovim target would add mini.base16 on top of it and stays off. - Firefox is not themed: Stylix needs a profile declared in home-manager, which would hide your existing one. Its settings are enterprise policies instead (see After the installation).
- Obsidian is themed by Stylix's
obsidiantarget: a CSS snippet with the palette and the fonts, written into the vaults listed invaultNames(see Obsidian).
Visible changes compared with the configuration before Stylix:
- The TTY uses the Catppuccin palette.
- GTK apps use
adw-gtk3with Stylix CSS and Monaspace Radon 12 (wasadw-gtk3-dark); the default serif font is Noto Serif (was DejaVu Serif). - No autologin: SDDM shows a Catppuccin login screen, and both it and the desktop show the Stylix wallpaper.
- Qt apps (Dolphin, Telegram, TeamSpeak) use Kvantum with the palette (was adwaita-dark).
- Hyprland borders, groups and shadows use the palette (blue/surface; they were the Hyprland default cyan/grey).
- Noctalia uses the
stylixpalette and WezTerm the generatedstylixscheme; bat, btop, fzf, starship, mpv and zathura follow the palette.
Obsidian
modules/desktop/obsidian.nix is a home-manager-only aspect (obsidian, listed
in host.nix): the app and one vault, configured through home-manager's
programs.obsidian. The vault is ~/Documents/Notes (Documents is a btrfs
subvolume on the data SSD), a git repository with the remote
gitea@git.faumaray.ru:faumaray/Notes.git (created empty on Gitea; the first
push by obsidian-git fills it).
What is declared. Everything under .obsidian/ comes from Nix and is not
committed (the vault's .gitignore lists it): app.json, appearance.json,
core-plugins.json, community-plugins.json, the core plugin files and Stylix's
CSS snippet are links into the store. Obsidian cannot write to them, so a
setting changed in its settings window does not stick: change it in the file.
The exception is data.json of the plugins that get settings in the file
(obsidian-git, templater-obsidian, calendar): a plain file, merged on every
switch, where the declared keys win and anything else the plugin keeps survives.
Plugins that have no settings in the file keep their own data.json.
-
Notes: new notes go to
Inbox/, pasted files toAttachments/, links are updated when a note is renamed or moved, Vim keybindings, readable line length, spellcheck on. Daily notes:Daily/YYYY-MM-DD.mdfromTemplates/Daily.md. The light or dark base scheme follows the Stylix polarity; colours and fonts come from Stylix'sobsidiantarget. -
Core plugins: files, search, quick switcher, backlinks, outgoing links, outline, graph, bookmarks, tags, page preview, properties, note composer, command palette, status bar, word count, daily notes, canvas and file recovery. The core Templates plugin is off; Templater replaces it.
-
Community plugins, pinned GitHub release assets (none is in nixpkgs):
Plugin id For dataviewqueries over notes (tables and lists from frontmatter) templater-obsidiantemplates with logic calendarmonth calendar next to the daily notes (weeks start on Monday) obsidian-tasks-plugintasks across the vault, due dates, queries obsidian-excalidraw-plugindrawings stored as Markdown ( Excalidraw/)table-editor-obsidianAdvanced Tables: Tab/Enter move between cells and reformat obsidian-linterformatter for notes (YAML, headings, spacing) shiki-highlightersyntax highlighting of fenced code blocks obsidian-gitbackup and sync of the vault with git -
Git:
obsidian-gitpulls when the vault opens (once the first push has given the branch an upstream) and, every 10 minutes, commits any changes, pulls and pushes; the commit message isvault backup: <host> <date>, <n> file(s). The remote is SSH, so the key is the one of thenviminput (~/.ssh/id_ed25519, installed fromsecrets/ssh-id_ed25519.age); accept the host key ofgit.faumaray.ruonce by hand (ssh -T gitea@git.faumaray.ru), so that the first push does not stop at the host-key prompt. -
First switch: the vault does not exist yet, so the switch creates it once, only if
~/Documents/Notes/.gitis missing: the foldersInbox/,Daily/andTemplates/, a.gitignore(.obsidian/,.trash/, OS junk),CLAUDE.md(conventions for Claude Code) andTemplates/Daily.md, thengit init -b mainand the remote. It never pushes, and an existing repository is left alone. On a second machine the vault already exists on Gitea: clone it into place before the first switch, or rungit fetch && git checkout -f -B main origin/mainin the new vault to replace the files written here.
After the first switch (what is not in the vault, so it cannot be declared):
- Start Obsidian and open the vault
Notes(~/Documents/Notes). The first time it asks "Turn on community plugins": accept, otherwise none of the plugins above loads. The choice is kept in Obsidian's own browser storage. - Settings > Editor > Spellcheck languages: add English and Russian. Also a per-device setting.
- Optional: Templater's
<% %>syntax runs in new files only if "Trigger Templater on new file creation" is on in its settings, also per device. The daily template uses the core variables ({{title}},{{date}}) and does not depend on it. - Let
obsidian-gitmake the first push (the first automatic backup after 10 minutes, or commit and push from the command palette), which gives the branch its upstream.
Update a plugin: change its version in the plugins set, put lib.fakeHash in
its hashes, and copy the real hashes from the build error (or
nix store prefetch-file <asset url>). The build checks that manifest.json
carries the plugin id, and each release's minAppVersion must stay at or below
the Obsidian in nixpkgs. A second vault: add it to programs.obsidian.vaults
and its name to stylix.targets.obsidian.vaultNames in modules/theme/stylix.nix
(the aspect asserts that its vault is listed there). Claude Code reads the
vault without a prompt, see below.
Claude Code tools
modules/ai/claude-code.nix is a home-manager-only aspect (claude-code, listed
in host.nix; the status line script modules/ai/claude-statusline.sh sits next
to it). It installs and configures, for the owner (user scope):
| What | Details |
|---|---|
claude |
Claude Code from nixpkgs (unfree, allowed in core) |
MCP codememory |
codebase-memory-mcp (DeusData), a code knowledge graph; the CLI is on PATH, indexes live in ~/.cache/codebase-memory-mcp. auto_index is checked at every switch and switched on if off (codebase-memory-mcp config set auto_index true, each call limited to 20 s), so the first session in a project indexes it (up to 50000 files) and the watcher keeps the index fresh. To use another server, replace this one mcpServers entry. Plus what its install command sets up for Claude Code (nixpkgs patches that command out): the skill codebase-memory, the read-only graph agents codebase-memory-scout, codebase-memory and codebase-memory-auditor (kept in modules/ai/codebase-memory/, rendered from release 0.11.0) and its hooks (below) |
MCP serena |
Serena, semantic code retrieval and editing; the serena flake input pinned to a release tag, started per project (--project-from-cwd; the dashboard is started but not opened in a browser, and listens only on 127.0.0.1). Plus the four hooks Serena's documentation recommends for Claude Code (below); serena setup claude-code itself only registers the server |
MCP rea |
REA (Reverse Engineer Anything), npx --yes rea-agents@<pinned version> mcp; wrapper rea on PATH, plus REA's skill reverse-engineer-anything from the same npm release |
MCP nixos |
mcp-nixos (nixpkgs): search of NixOS and Home Manager options and packages; stdio, queries search.nixos.org and the Home Manager docs when a tool is called |
MCP context7 |
context7-mcp (nixpkgs): current library documentation; stdio, works without an API key (a key only raises the rate limit), queries context7.com when a tool is called. Plus its skill context7-mcp (the one ctx7 setup --claude installs, taken from the package; its rule file is not installed), which tells Claude when to use the server |
| Gitea | no entry here: use the claude.ai account's Gitea connector (mcp__claude_ai_gitea__*). An HTTP entry for mcp.faumaray.com cannot log in from Claude Code, because the Gitea OAuth server has no dynamic client registration |
| LSP | nil for .nix (lspServers; it also reports diagnostics after edits of .nix files) and the official plugin rust-analyzer-lsp for .rs. The plugin runs the bare rust-analyzer, so it works inside dev rust (the fenix toolchain brings the rust-analyzer of the compiler's release) and not outside it; pkgs.rust-analyzer is not installed on purpose, it would analyse against the wrong sysroot |
plugin caveman |
skills, commands, agents and hooks (JuliusBrussee/caveman at a pinned tag); default mode manual: off until /caveman turns it on for a session |
| official plugins | claude-md-management (CLAUDE.md audit skill and /revise-claude-md) and security-guidance (see below), next to rust-analyzer-lsp. They are enabled in the settings and fetched from the claude-plugins-official marketplace after a session starts: run /reload-plugins or restart once |
| hooks | rtk before Bash commands, nixfmt after edits of .nix files, a desktop notification when Claude waits for you, codebase-memory-mcp's graph context and Serena's reminders (below) |
| status line | <model> · <directory> · <git branch> · ctx <used>%, the percentage green below 50, yellow below 80, red from 80; read from the session JSON, no network |
command /check |
runs git status --short, the desktop host evaluation and then nix flake check --no-build (the check needs the patched proxy-suite tree that the evaluation builds) and reports the outcomes; typed by you only (disable-model-invocation), never switches or commits, flake references .#... only |
Where it lands in the home:
~/.claude/settings.json: merged on every switch and still writable (mutableSettings): a declared key wins, a key the aspect does not declare is kept, and every list (permission rules, the hooks of one event) is replaced as a whole. So a hand-added deny rule or hook under an event declared here is dropped at the next switch, one under another event stays, and deleting a declaration from the.nixfile does not remove it fromsettings.json: set it to its empty form ([ ]orfalse) first. Model and effort are not set, so a repository's own.claude/settings.jsonapplies as before. What the aspect declares is listed under Settings below.~/.claude/skills/claude-code-home-manager(home-manager's generated plugin that carries the five MCP servers and thenillanguage server; their tools are namedmcp__plugin_hm_<server>__<tool>),~/.claude/skills/caveman,~/.claude/skills/reverse-engineer-anything,~/.claude/skills/codebase-memory,~/.claude/skills/context7-mcp,~/.claude/agents/codebase-memory{-scout,,-auditor}.md,~/.claude/commands/check.mdand~/.claude/rules/rtk.md(rtk's note to the model: its output is condensed on purpose,rtk bypass <cmd>runs a command unfiltered).~/.serena/hook_data/<session>/: the counters of Serena'sremindhook (the main session's calls only), deleted again when the session ends.~/.config/rtk/config.toml, a read-only link (see rtk below).~/.config/caveman/config.json={"defaultMode": "manual"}, written once if missing (caveman only reads it): every session starts with caveman off. Afullleft by an earlier version of this aspect is rewritten tomanual; any other value is yours and stays.- On PATH:
codebase-memory-mcp,serena,rea,node(caveman's hooks need it),ghidra(Ghidra, packageghidra-bin),rtk,ccusage(usage and cost from the session logs:ccusage daily,ccusage blocks),ast-grep(ast-grep run -p 'pattern') andpython3(the security-guidance hooks run it).~/.claude.json(Claude Code's own state) is not touched.
Settings the aspect declares:
env:MCP_TIMEOUT=60000(Serena can start slowly),MAX_MCP_OUTPUT_TOKENS=10000(cap on what one MCP result puts into the context) andCLAUDE_CODE_SUBAGENT_MODEL=sonnet, the model of a subagent for which neither its frontmatter nor the spawning call picks one. A frontmattermodel:still wins, so this repository'smao-*agents keep their own models; do not addCLAUDE_CODE_SUBAGENT_MODEL_FORCE, which would make the variable win. AlsobashOutputMaxChars = 15000(default 30000): the rest of a long Bash result goes to a file with a preview.enabledPlugins: off areserena@synced(the claude.ai account's own Serena plugin starts a second, broken copy of the server throughuvx, which is not installed),design@syncedandproduct-management@synced(a dozen remote MCP servers that are not used); on are the three official plugins above. Other synced plugins are left as they are, andclaude plugin enableon a declared one is undone at the next switch.permissions.deny:Read(~/.ssh/**),Read(~/.gnupg/**),Read(./keys/**),Read(./.env),Read(./WG.conf),Read(//run/agenix/**). A Read rule also blocks Edit and Write on the path and covers Grep, Glob,@mentions and the file commands Claude Code recognises in Bash (cat,head,sed, ...), but not a script that opens the file itself: it is no sandbox../...is relative to the session's directory, so it protects sessions started in the repository;//run/agenixneeds the double slash, a single one anchors at~/.claude.permissions.additionalDirectories: the Obsidian vaults (see below).hooks.PreToolUse(Bash):rtk, see below.hooks.PostToolUse(Edit, Write, MultiEdit): runsnixfmton the edited file when it is a.nixfile (not the generatedhardware-configuration.nix); on a syntax error the file stays as it is and the reason goes to Claude as additional context; any other failure is silent, a tool call never fails because of the hook.hooks.Notification: a desktop notification (notify-send, shown by Noctalia) for permission prompts, the idle prompt and MCP dialogs, with the project directory in the summary.- codebase-memory-mcp's hooks, the entries its installer writes, all
codebase-memory-mcp hook-augment(context only, never blocking, 5 s limit): before Grep, Glob and grep-like Bash commands the graph symbols matching the pattern (PreToolUse), after a Read a note when the graph covers that file only in part (PostToolUse), and at session start (SessionStart) and for every subagent (SubagentStart) whether the project is indexed and how to use the graph. - Serena's hooks (
serena-hooks <command> --client=claude-code, behind a wrapper that always exits 0, 10 s limit):remindon every tool call of the main session (PreToolUse): on the 3rd Grep call, the 3rd read of a source file or the 4th call of either in a row without a Serena tool, it denies that call once with a note to use Serena's tools, then stays quiet for 2 minutes (a subagent has its parent's session id, so the deny could land on one without Serena tools, such as mao-helper, the reviewers or the codebase-memory agents, and the wrapper skipsremindfor every call made inside a subagent);auto-approveon Serena's tools (PreToolUse): in theacceptEditsmode it approves them, in theautomode Claude Code passes that allow to its auto-mode classifier (deny and ask rules still apply);activate(SessionStart): asks Claude to read Serena's instructions manual;cleanup(SessionEnd): deletes the session's hook data. statusLine: the script above; it reads the session JSON and.git/HEAD, and calls neither the network nor ccusage.
rtk (Rust Token Killer) rewrites a Bash command it has a compact form for
(git status becomes rtk git status; also ls, grep, cargo, cat, ...)
so that its output costs fewer tokens. It honours the permission rules (a command
a deny rule matches is not rewritten). The hook is a fail-open wrapper: while
rtk is not on PATH (a session that started before the switch) every command
passes unchanged. ~/.config/rtk/config.toml is read-only on purpose, so
rtk telemetry enable or rtk config ... fail: edit claude-code.nix. It
excludes git commit, git push and git -C from the rewrite, because the
security-guidance commit review starts from the plain command text, and it keeps
telemetry off (this build cannot send any). For one command: RTK_DISABLED=1 git status. To turn rtk off delete its PreToolUse entry in claude-code.nix and
switch, then remove rules.rtk, the package and the config. Any other hook goes
the same way; if that leaves an event with no entries, keep it as [ ] for one
switch.
What is not hermetic or worth knowing:
- REA runs from npm: the first start downloads the pinned version and its
dependencies into
~/.npm(needs network; the dependency tree is not pinned). Standalone executables shipped by npm packages rely on thenix-ldaspect;.nodeadd-ons loaded by the Nix-builtnodedo not. REA's skill and caveman are fetched with fixed hashes. - Serena writes
.serena/into every project it activates (it is in this repository's.gitignore). It is built locally from its lock file, not downloaded from a binary cache, so the first switch takes longer. - security-guidance costs tokens and disk. Besides pattern warnings on edits
it runs an LLM review (the newest Opus, through your sign-in) of the diff at the
end of a turn and of commits and pushes. Its SessionStart hook builds a Python
venv of about 340 MB in
~/.claude/securityand pip-installs the Agent SDK once (network, about 30 s). Parts are turned off with environment variables:ENABLE_STOP_REVIEW=0,ENABLE_COMMIT_REVIEW=0,ENABLE_CODE_SECURITY_REVIEW=0(both reviews),SECURITY_GUIDANCE_DISABLE=1(all of it). - Plugins run code: caveman's hooks run
nodescripts and security-guidance's runpython3, in every session. - The codebase-memory-mcp and Serena hooks cost time and now and then a retry.
codebase-memory-mcp's hook takes about 1 s per call, with or without a daemon
and at most 2 s: before every grep-like Bash command (and Grep or Glob, where a
session has those tools), after every Read, and at the start of a session and of
each subagent, whether or not it has anything to add (other Bash commands are
not slowed). It asks the daemon the MCP server runs, and that daemon stops when
its last client disconnects, so a session started while no other one is open
usually gets no codebase-memory context at its start (the hook runs before the
MCP server) and may show a note that no daemon runs (at most every 15 minutes).
Serena's
reminddenies the call that completes a burst of searches or source-file reads (.nixfiles do not count) in the main session; Claude can repeat the call. Each of these hooks is one entry inclaude-code.nix, with how to remove it. - codebase-memory-mcp's skill and agents are copies. They are C strings in
the binary, so
modules/ai/codebase-memory/holds them as rendered from release 0.11.0, with the agents' tool names changed tomcp__plugin_hm_codememory__*. When nixpkgs updates codebase-memory-mcp, evaluation warns until they are rendered again (seeclaude-code.nix). - The first switch moves existing files at these paths to
*.hm-backup(notsettings.json, which is merged).home-manager.overwriteBackup = true(modules/core/home-manager.nix) lets later switches replace an older*.hm-backupinstead of stopping. - The Obsidian vault is readable without a prompt. Every enabled vault of the
obsidianaspect (~/Documents/Notes) is inpermissions.additionalDirectories(absolute paths), so Claude can read and search the notes from any project; edits still follow the permission mode. The vault has its ownCLAUDE.mdwith the conventions (see Obsidian). There is no Obsidian MCP server: nixpkgs has none, and the popular ones need the Local REST API plugin and an API key. - The
claudealias skips permission prompts. In zshclaudeexpands toclaude --dangerously-skip-permissions(modules/cli/shell.nix); runcommand claudefor the plain command.
Bump a pin:
- Serena: change the tag of the
serenainput inflake.nix, thennix flake update serena. - REA: change
reaVersioninmodules/ai/claude-code.nix, thennix store prefetch-file --unpack --hash-type sha256 https://registry.npmjs.org/rea-agents/-/rea-agents-<version>.tgzand put the printed hash intohash. - caveman: change
tag, thennix flake prefetch github:JuliusBrussee/caveman/<tag>and put its hash intohash.
Development shells
modules/dev/shells/ holds the shells: each file sets shells.<name>, and
modules/flake/shells.nix turns them into devShells.<system>.<name> (plus the
legacyPackages.<system>.composeShells function). The dev-shells aspect puts
the dev command (pkgs/dev-shell) on the owner's PATH. default stays the
repository's own shell (modules/flake/dev.nix).
| Shell | Contents |
|---|---|
rust |
stable Rust from fenix: rustc, cargo, clippy, rustfmt, rust-src, llvm-tools and the rust-analyzer of the same release; cargo-nextest, cargo-expand, cargo-edit, bacon; lldb, gdb; pkg-config and openssl, dav1d, libvpx, libopus, alsa-lib, fontconfig and pipewire for -sys crates |
rust-nightly |
the same on fenix's latest nightly |
cpp |
Clang/LLVM (CC=clang, CXX=clang++): CMake, Ninja, Meson, pkg-config, clangd, clang-format, clang-tidy, lldb, gdb, cppcheck, valgrind, GoogleTest; hardening flags off (sanitizers and -O0 builds behave as on other distributions), CMAKE_EXPORT_COMPILE_COMMANDS=ON |
cpp-gcc |
the same tools with GCC (CC=gcc, CXX=g++) |
vulkan, vulkan-gcc |
the cpp tools on Clang or GCC plus Vulkan: headers, loader, validation layers (VK_LAYER_PATH, VULKAN_SDK set), lunarg tools, memory allocator, glslang, shaderc, Slang, GLFW, freetype, libarchive, openssl, libsodium and sqlite |
rust-cpp |
cpp and rust together on Clang, plus bindgen's libclang (FFI, cxx, -sys crates built with CMake) |
Every shell except default sets DEV_SHELL=<name>; inside one the prompt shows
dev:<name>.
dev # list the shells
dev rust # a subshell ($SHELL) with the Rust toolchain
dev rust -c cargo test # run one command in it and come back
dev rust cpp-gcc -p python3 # merge shells and nixpkgs packages into one ad hoc shell
nix develop ~/nixos-config#rust # the same, without the helper
dev takes the flake from --flake DIR, else $DEV_FLAKE, else $NH_FLAKE
(set system-wide by programs.nh.flake, modules/core/nix.nix: the checkout in
~/nixos-config). It insists on the top directory of a git checkout and reads
it as git+file://, so only tracked files count and an untracked keys/ is
never copied into the store. One shell goes through nix develop; a
combination goes through composeShells (nix develop --impure --expr, about
4-5 s, no evaluation cache).
Per project (direnv). dev init writes the project's .envrc and runs
direnv allow; from then on entering the directory enters the shell:
cd ~/src/project
dev init rust # one shell; -f replaces an existing .envrc
The file is two comment lines and three directives (shown for the checkout in
~/nixos-config):
# Written by 'dev init rust': direnv enters the "rust" dev shell of
# /home/faumaray/nixos-config here. Editing the shells (modules/dev/shells/) reloads it.
watch_dir "/home/faumaray/nixos-config/modules/dev/shells"
watch_file "/home/faumaray/nixos-config/modules/flake/shells.nix"
use flake "/home/faumaray/nixos-config#rust"
nix-direnv (modules/cli/shell.nix) caches the environment in .direnv/, a
garbage-collection root; this repository's .gitignore already lists it, add it
to the project's. Editing a shell file reloads the environment (the two watch
lines). The .envrc holds an absolute path of this machine's checkout, so do
not commit it to a shared repository.
Add a shell. Create modules/dev/shells/<name>.nix, git add it (no switch
needed: dev <name> and nix develop .#<name> see it at once):
{
perSystem =
{ pkgs, ... }:
{
shells.go = {
description = "Go: compiler, gopls, delve";
packages = [
pkgs.go
pkgs.gopls
pkgs.delve
];
env.GOFLAGS = "-mod=readonly";
shellHook = ''
echo "go shell: $(go version)"
'';
};
};
}
extends = [ "cpp" "rust" ]; merges other shells by name into this one. The
shells are linearized (dependencies first, each one once, this shell last) and
merged in that order: packages, hooks and hardening switches add up, a later
environment value wins, and the stdenv is the last one set.
modules/dev/shells/rust-cpp.nix is the example. dev init takes a single
shell, so a combination you want in a project is a shell of its own. The names
list, ls, init (commands of dev) and default (the repository shell)
are reserved; evaluation rejects them.
Knobs:
- Rust channel: the argument of
rustShellinmodules/dev/shells/rust.nixis a fenix channel,"stable","beta"or"latest"(nightly, therust-nightlyshell). A project pinned by arust-toolchain.tomlis better served by a flake of its own (fenix.packages.<system>.fromToolchainFile). - LLVM release:
llvminmodules/dev/shells/cpp.nix(clang, clangd, lldb). The bindgen hook ofrust-cppfollows nixpkgs' default LLVM instead. - clangd in
cpp-gccmay report warnings that only Clang does not know. If it does, addenv.CLANGD_FLAGS = "--query-driver=/nix/store/*-gcc-wrapper-*/bin/*";to that shell (documented, not set).
Costs and limits:
- The closures are large:
rustabout 3.3 GiB,cppandcpp-gccabout 2.4 GiB,rust-cppabout 3.7 GiB. fenix follows this flake's nixpkgs, so its binary cache on cachix does not apply and the firstdev rustunpacks the toolchain locally (a few minutes). - A shell entered with
devornix developis not a garbage-collection root; a collection may remove it and the next entry rebuilds it. direnv's.direnv/is a root. - Neovim started inside a shell (or inside a direnv directory) finds the shell's clangd, rust-analyzer and compilers first, because the editor's own tools are appended to PATH. A Neovim server started elsewhere, such as a shared daemon that Neovide attaches to, does not see them.
Neovim
Neovim is nixpkgs' (0.12) and its configuration is your own repository
faumaray/nvim: the flake input nvim (plain files, pinned in flake.lock)
wired up by modules/cli/neovim.nix. Its URL is
git+ssh://gitea@git.faumaray.ru/faumaray/nvim.git: the repository is private
and Nix has no credentials for HTTPS, so Nix fetches it over SSH with the key of
the user who runs it (~/.ssh/id_ed25519, installed from
secrets/ssh-id_ed25519.age; the host key of git.faumaray.ru, the Gitea
behind git.faumaray.com, must be in ~/.ssh/known_hosts). Once the input is in
the store it is reused, also by root. A machine or CI runner without that key
cannot evaluate the desktop host: give it a key, or override the input with
--override-input nvim path:<directory>.
How it lands in the home:
~/.config/nvimis a real directory whose files are read-only links into a filtered copy of the pinned repository (*-nvim-configin the store, without the lockfile;recursive), so the configuration cannot drift. Plugins may still add files there (cd-project.nvim writescd-project.nvim.json).nvim-pack-lock.jsonis the exception:vim.packrewrites it whenever it installs, repairs or updates a plugin and stops withEROFSon a read-only file (the pinned lockfile also lags behind the plugin specs). It is a writable copy, reset to the pinned one by the switch when the pinned one changes; the old copy is kept asnvim-pack-lock.json.prev.- Plugins are not managed by Nix, on purpose.
init.luabootstraps zpack.nvim with Neovim's ownvim.pack, which clones the plugins on the first start into~/.local/share/nvim/site/pack/core/optat the revisions of the lockfile. That needs git and network, asks for confirmation once and takes about a minute: start Neovim in a terminal for the first time, not fromgit commit. zpack'sbuild = "make"hook runs:makein the current directory, so start it somewhere harmless such as~. - A new pin also empties
vim.loader's bytecode cache (~/.cache/nvim/luac): store files all have the same modification time, so an edit that keeps a file's size would keep running the old code.
Change the configuration:
# edit the nvim repository, commit and push; then, here:
nix flake update nvim
nh os switch
# in Neovim, once: :ZRestore (plugins to the revisions of the new lockfile)
To try changes live without a switch, and to update plugins, give Neovim a second configuration that is a clone of the repository:
git clone gitea@git.faumaray.ru:faumaray/nvim.git ~/.config/nvim-dev
NVIM_APPNAME=nvim-dev nvim
Plugin updates belong there: :ZUpdate rewrites the lockfile of Neovim's config
directory (stdpath('config')), here the clone, so commit and push that file,
then run the steps above. Run in ~/.config/nvim it only changes the writable
copy; copy ~/.config/nvim/nvim-pack-lock.json into the checkout before
committing if you did. vim.pack prints "Repaired corrupted lock data" once when
a plugin directory exists on disk without an entry in the lockfile, for example
after the copy was reset to an older pinned lockfile; :ZClean removes plugins
that the specs no longer list. zpack 2.x renamed :ZRestore, :ZUpdate and
:ZClean to :ZPack restore, :ZPack update and :ZPack clean; the pinned
lockfile has zpack 1.x today, which has the names used here.
Who brings which tool. One rule: whatever is tied to a project's toolchain comes from the dev shell, whatever the editor needs everywhere comes with the editor.
- Neovim's wrapper (appended to PATH, so a dev shell's tools win): git, curl, gnumake, gcc, tree-sitter, ripgrep, fd, fzf, lua-language-server, stylua, codespell, neocmakelsp, cmake-format, devcontainer and codelldb (from the VS Code extension, which is in the binary cache; the standalone adapter package is not).
- The dev shells: compilers, cargo, rustc, clippy, rustfmt and rust-analyzer (fenix), clangd, clang-format and clang-tidy, cmake, ninja, meson, gdb, lldb.
- Not installed: nixd and nixfmt (the repository never enables them; they are
in this repository's
nix develop), gopls (there is no Go shell) and lazygit.
Known problems of the repository, not fixed here:
- The debug adapter is
/usr/bin/lldb-dap, which does not exist on NixOS. Usecodelldb, which the wrapper provides, or change the repository to plainlldb-dap, which the C/C++ shells provide. - gopls is enabled in the LSP configuration but not installed.
lua/overseer/template/cmake_cpp_modules_provider.luahardcodes-DCMAKE_CXX_COMPILER=/usr/bin/clang++, which does not exist on NixOS.- telescope-fzf-native's
build = "make"is run by zpack as:makein the current directory, not in the plugin's: the native sorter is never built, and in a project directory the command could run that project's Makefile.
Day-2
nh os switch # rebuild + activate (flake: ~/nixos-config); also nh os boot | nh os test
nix run .#switch # the same through the repo helper switch-system (-- boot | test)
nix flake update # new inputs, then switch (one input: nix flake update stylix)
nix flake update nvim # the newest commit of your nvim repository, then switch (see Neovim)
dev # list the dev shells; dev rust, dev rust cpp -p python3, dev init rust (see Development shells)
nix fmt # nixfmt over the whole tree
nix eval .#nixosConfigurations.desktop.config.system.build.toplevel.drvPath # first: builds the patched proxy-suite tree
nix flake check --no-build # evaluates every check, including the whole desktop host
nix build .#checks.x86_64-linux.nixos-desktop # builds the whole system without activating it
nix flake check --no-build is read-only: it builds nothing but the patched
proxy-suite tree, when that tree's .drv already exists, and it fails with
...-proxy-suite-flake-patched.drv is not valid when it does not (a fresh clone
or machine, a nix flake update, an edited patch, a garbage collection). Run the
nix eval above first and the error does not appear. A failure that only shows at
build time (for example Noctalia validating its generated config.toml) appears
in the nixos-desktop build or in the switch itself. After nix flake update
build first.
Roll back: pick an older generation in the boot menu, or
sudo nixos-rebuild switch --rollback.
Add a folder on the SSD later (example Projects):
sudo mkdir -p /mnt/data
sudo mount -o subvolid=5 /dev/disk/by-label/data /mnt/data # top level of the data fs
sudo btrfs subvolume create /mnt/data/@projects
sudo umount /mnt/data
then add Projects = { }; to homeFolders in modules/hosts/desktop/disks.nix
(subvolume name defaults to @projects) and switch.
Change a secret: cd secrets && agenix -e faumaray-password.age -i ~/.ssh/id_ed25519
(or run set-password / secret-from-file again with --force), git add, switch.
Foreign binaries (nix-ld, AppImage)
The nix-ld aspect (modules/dev/nix-ld.nix) runs programs built for other
Linux distributions. nix-ld gives plain ELF binaries a dynamic linker and a broad
library set (NIX_LD, NIX_LD_LIBRARY_PATH); .AppImage files run directly
through appimage-run (binfmt). When a binary stops with error while loading shared libraries: libfoo.so.N, add the package that ships it to
programs.nix-ld.libraries in that file and switch. AppImages do not use
nix-ld: give them extra libraries through programs.appimage.package.
Verify in a fresh session
From the repository root of a fresh clone or shell (new files must be
git added first), these confirm that the configuration evaluates:
nix eval --raw .#nixosConfigurations.desktop.config.system.build.toplevel.drvPath # first: builds the patched proxy-suite tree
nix flake check --no-build # ends with: all checks passed!
nix eval --raw .#packages.x86_64-linux.iso.drvPath
nix build .#checks.x86_64-linux.formatting # nixfmt check, same formatter as `nix fmt`
nix eval --json .#devShells.x86_64-linux --apply builtins.attrNames # the dev shells
nix flake show # the outputs listed under "Flake outputs"
The first evaluation on a machine fetches the private nvim input over SSH as
you (see Neovim); without a usable key it stops with an SSH error (see
Troubleshooting).
The two nix eval lines print a /nix/store/...-nixos-system-desktop-26.11...drv
and the ISO's .drv, without evaluation warnings once secrets/gitea-runner-token.age,
secrets/tg-ws-proxy-secret.age and secrets/amneziawg-ai.age exist. Until
then there is one warning each for the runner, the Telegram proxy and the
AmneziaWG tunnels. nix flake check adds one message of its own, unknown flake output 'modules' (the flake-parts modules output).
Troubleshooting
- The PC does not boot after enabling Secure Boot. Disable Secure Boot in
the firmware and boot. To go back to plain systemd-boot replace
secure-bootwithsystemd-bootin theimportslist ofmodules/hosts/desktop/host.nixand runnh os boot(ornix run .#switch -- boot); the installer's closing hint gives the same instruction.sbctl enroll-keysrefusing to run means the firmware is not in Setup Mode. - Secrets do not decrypt (no password, no
~/.ssh/id_ed25519). The host key insecrets/secrets.nixmust match/etc/ssh/ssh_host_ed25519_key.pubon the machine. Test:sudo age -d -i /etc/ssh/ssh_host_ed25519_key secrets/<name>.age. Fixsecrets.nix, re-encrypt (agenix -r -i <your key>),git add, switch. Meanwhile log in withchangeme(when no password secret is defined) and runpasswd. - The Gitea runner, the Telegram proxy or the AmneziaWG tunnels are gone after a switch. The service secrets do not exist yet; see "Secrets" under First-time setup. The evaluation warning names the missing file.
- The SSD is missing or fails. Its mounts use
nofailand a 10 s timeout, so the system still boots from the NVMe. Files written to~/Gamesmeanwhile land on the NVMe and are hidden once the SSD is mounted again. - A new file is "not found" by Nix. Flakes only see git-tracked files:
git addit. - Fetching
nvimfails withPermission denied (publickey)orHost key verification failed. Nix runssshas the user who runs it: checkssh -T gitea@git.faumaray.ruas that user (the key is~/.ssh/id_ed25519; connect once by hand to accept the host key). Undersudothere is no such key and the input must already be in the store, so build as yourself (nh os switchdoes). nvim-pack-lock.jsonfails withEROFSorEACCES. It must be a writable regular file in~/.config/nvim. A switch repairs a symlink or a missing file but leaves a read-only regular copy alone (its recorded hash matches): delete~/.config/nvim/nvim-pack-lock.jsonand switch, and the activation step installs a fresh one.- A change to the Neovim configuration has no effect. Neovim may be running
cached bytecode:
find ~/.cache/nvim/luac -mindepth 1 -delete, then restart (a switch with a new pin does this itself). - The installer stopped halfway. Run it again with
--disko-mode mount(and the same--flake); partitions and the already installed host key are reused. - Slow first build / compiling Hyprland, Noctalia or Serena. The binary caches in
flake.nix(nixConfig) must be accepted; use--accept-flake-config. Serena is always built locally. - A switch stops at an existing
*.hm-backupfile. Home-manager moves files it now manages (GTK/Qt/Kvantum configs,~/.claude/skills, commands and rules, the vault's.obsidian/files) to*.hm-backup.home-manager.overwriteBackup = true(modules/core/home-manager.nix) replaces an older backup, so this should only happen if that setting was removed: look at the backup, then delete it. Files such as~/.config/gtk-3.0/gtk.cssor~/.config/qt6ct/qt6ct.confcan be rewritten by Noctalia's GTK template or the qt*ct tools; the next switch backs the rewritten file up again. - WezTerm starts with default colours or fonts after an update. WezTerm drops
its whole config silently when a value does not parse (Stylix writes the
palette).
WEZTERM_LOG=debug wezterm show-keysmust logReloaded configuration.