The Telegram secret recipes no longer depend on openssl (the host does not install it): they read 16 bytes from /dev/urandom with od and check the length before anything is encrypted, so a failure cannot store an empty secret. README, secrets/README.md and the proxy-suite header and warning agree. README: Serena's dashboard is started but not opened and listens on 127.0.0.1 only; the nix-ld note for REA now distinguishes standalone npm executables from .node add-ons; the Serena pin notes mention the stdenv.isLinux/isDarwin warnings. home-manager.overwriteBackup = true so a rewritten gtk.css or qt6ct.conf does not make a later switch fail on an existing .hm-backup. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JZ16yf4acmaSiHq81vyQ6Z
594 lines
30 KiB
Markdown
594 lines
30 KiB
Markdown
# 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 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.<name>` (a
|
|
NixOS module) and/or `flake.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 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.<name>` into `nixosConfigurations.<name>` and
|
|
`checks.<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`, `claude-code`) are listed in the host's `home-manager.users.<owner>`
|
|
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.<name>`) only when
|
|
`meta.secretsDir + "/<name>.age"` exists, with a `warnings` entry otherwise.
|
|
Never put a secret value into a `.nix` file.
|
|
|
|
#### Add an aspect
|
|
|
|
1. Create `modules/<area>/<name>.nix` with a header comment (what it does; for a
|
|
combined aspect, what each half does).
|
|
2. Define `flake.modules.nixos.<name>` and/or `flake.modules.homeManager.<name>`.
|
|
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.<program>.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>/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/<new>/` 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/<new>/`. In each file replace
|
|
`configurations.nixos.desktop` with `configurations.nixos.<new>` 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 <new>` 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.<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 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 <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`) |
|
|
|
|
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=<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`.)
|
|
|
|
**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/<LABEL> /media/usb
|
|
```
|
|
|
|
3. Run the installer from the repository:
|
|
|
|
```sh
|
|
cd /media/usb/nixos-config
|
|
nix --extra-experimental-features 'nix-command flakes' run --accept-flake-config .#install
|
|
```
|
|
|
|
If 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`.
|
|
|
|
### Path B: the custom ISO
|
|
|
|
```sh
|
|
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:
|
|
|
|
```sh
|
|
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.
|
|
|
|
### What `install-system` does
|
|
|
|
1. Checks root, UEFI and the flake; copies it to `/root/nixos-config` if 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).
|
|
2. If `hosts/desktop/disk-ids.json` still has `CHANGE-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 to `disk-ids.json`.
|
|
3. Shows both disks (model, size) and wipes them only after you type the host
|
|
name. `--yes` skips this prompt.
|
|
4. Runs disko, writes `hosts/desktop/hardware-configuration.nix` from the real
|
|
hardware (`nixos-generate-config --no-filesystems`).
|
|
5. Installs the host key, checks that it can decrypt `secrets/*.age`; if not it
|
|
stops **before** installing and explains how to fix it.
|
|
6. Puts the Secure Boot keys into `/mnt/var/lib/sbctl`.
|
|
7. `nixos-install --flake .#desktop`, asks for a login password if there is no
|
|
password secret, and copies the repository to `~/nixos-config` of 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 logs `faumaray` in automatically and starts
|
|
Hyprland (UWSM session); the login password is for `sudo` and the TTYs.
|
|
|
|
**Secure Boot** (lanzaboote). The keys exist but the firmware does not trust them yet:
|
|
|
|
1. Enter the firmware setup and put Secure Boot into **Setup Mode** ("Reset to
|
|
Setup Mode" / clear the Platform Key; keep the factory db/dbx).
|
|
2. Boot NixOS (Secure Boot still off or in Setup Mode), then:
|
|
|
|
```sh
|
|
sudo sbctl enroll-keys --microsoft
|
|
```
|
|
|
|
3. Reboot, enable Secure Boot in the firmware, and check:
|
|
|
|
```sh
|
|
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.
|
|
|
|
**Noctalia** starts with the session (a systemd user service). `Super+Space`
|
|
launcher, `Super+S` control center, `Super+,` settings. 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.
|
|
|
|
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](https://github.com/nix-community/stylix).
|
|
Everything is set in `modules/theme/stylix.nix`: the NixOS half holds the scheme,
|
|
fonts, cursor, icons and the system-wide targets, the home-manager half the
|
|
per-program targets.
|
|
|
|
| Setting | Value |
|
|
|---|---|
|
|
| Scheme | Catppuccin Mocha (16 colours inline, so evaluation needs no import-from-derivation), polarity dark |
|
|
| Fonts | monospace Monaspace Radon, sans Inter, serif Noto Serif, emoji Noto Color Emoji; WezTerm and Noctalia keep Monaspace Krypton through a per-target override |
|
|
| Cursor | Bibata-Modern-Classic, 24 |
|
|
| Icons | Papirus-Dark (Papirus-Light for a light scheme) |
|
|
| Wallpaper | none: Noctalia draws it |
|
|
|
|
Targets are opt-in (`stylix.autoEnable = false`), so Stylix touches only what is
|
|
listed:
|
|
|
|
- NixOS: `console` (TTY palette), `fontconfig`, `font-packages`, `gtk`.
|
|
- home-manager: `gtk`, `qt` (qt5ct/qt6ct + Kvantum), `hyprland`, `noctalia`,
|
|
`wezterm`, `bat`, `btop`, `fzf`, `starship`, `mpv`, `zathura`.
|
|
- Everything else is off, `neovim` and `firefox` on purpose (see below).
|
|
|
|
How to change it:
|
|
|
|
- **Turn a target off**: set `stylix.targets.<name>.enable = false;` (or delete
|
|
the line) in the matching half of `modules/theme/stylix.nix`. This is also the
|
|
way back for one program if you dislike the new look.
|
|
- **Change the scheme**: edit the `base16Scheme` colours, 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
|
|
set `stylix.polarity`, and change `gtk.colorScheme` and the dconf
|
|
`color-scheme` (both fixed to dark in the home-manager half).
|
|
- **Noctalia follows the palette**: Stylix's `noctalia` target writes a custom
|
|
palette `stylix` (`~/.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.lua` is loaded, so the colour literals in that file no longer
|
|
take effect; disable the `hyprland` target to use your own.
|
|
- **Neovim keeps catppuccin on purpose.** `modules/cli/neovim/init.lua` sets its
|
|
own colorscheme and lualine theme; Stylix's neovim target would append
|
|
mini.base16 after it and clear the highlight groups they created. The palette
|
|
is Catppuccin Mocha either way, so the look matches.
|
|
- Firefox is not themed: Stylix needs a profile declared in home-manager, which
|
|
would hide your existing one.
|
|
|
|
Visible changes compared with the configuration before Stylix:
|
|
|
|
- The TTY uses the Catppuccin palette.
|
|
- GTK apps use `adw-gtk3` with Stylix CSS and Inter 12 (was `adw-gtk3-dark`);
|
|
the default serif font is Noto Serif (was DejaVu Serif).
|
|
- 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 `stylix` palette and WezTerm the generated `stylix` scheme;
|
|
bat, btop, fzf, starship, mpv and zathura follow the palette.
|
|
|
|
## Claude Code tools
|
|
|
|
`modules/ai/claude-code.nix` is a home-manager-only aspect (`claude-code`, listed
|
|
in `host.nix`). It installs, 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`. To use another server, replace this one `mcpServers` entry |
|
|
| 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) |
|
|
| 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 |
|
|
| plugin `caveman` | skills, commands, agents and hooks (JuliusBrussee/caveman at a pinned tag); its default mode is off, `/caveman` turns it on per session |
|
|
|
|
Where it lands in the home:
|
|
|
|
- `~/.claude/settings.json`: merged on every switch and still writable
|
|
(`mutableSettings`); the aspect only sets `env.MCP_TIMEOUT`. It sets no model,
|
|
effort, permissions or hooks, so a repository's own `.claude/settings.json`
|
|
applies as before.
|
|
- `~/.claude/skills/claude-code-home-manager` (home-manager's generated plugin
|
|
that carries the three MCP servers; their tools are named
|
|
`mcp__plugin_hm_<server>__<tool>`), `~/.claude/skills/caveman` and
|
|
`~/.claude/skills/reverse-engineer-anything`.
|
|
- `~/.config/caveman/config.json` = `{"defaultMode": "off"}`, written once if
|
|
missing (caveman may change it later).
|
|
- On PATH: `codebase-memory-mcp`, `serena`, `rea` and `node` (caveman's hooks need
|
|
it). `~/.claude.json` (Claude Code's own state) is not touched.
|
|
|
|
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 the `nix-ld` aspect;
|
|
`.node` add-ons loaded by the Nix-built `node` do 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.
|
|
- Plugins run code: caveman's hooks run `node` scripts in every session.
|
|
- The first switch moves existing files at these paths to `*.hm-backup` (not
|
|
`settings.json`, which is merged). `home-manager.overwriteBackup = true`
|
|
(`modules/core/home-manager.nix`) lets later switches replace an older
|
|
`*.hm-backup` instead of stopping.
|
|
|
|
Bump a pin:
|
|
|
|
- Serena: change the tag of the `serena` input in `flake.nix`, then
|
|
`nix flake update serena`. Serena v1.7.0's own flake uses the deprecated
|
|
`stdenv.isLinux` / `stdenv.isDarwin` (the two warnings seen at every
|
|
evaluation); a future nixpkgs update may remove them and require bumping the
|
|
`serena` input.
|
|
- REA: change `reaVersion` in `modules/ai/claude-code.nix`, then
|
|
`nix store prefetch-file --unpack --hash-type sha256 https://registry.npmjs.org/rea-agents/-/rea-agents-<version>.tgz`
|
|
and put the printed hash into `hash`.
|
|
- caveman: change `tag`, then `nix flake prefetch github:JuliusBrussee/caveman/<tag>`
|
|
and put its hash into `hash`.
|
|
|
|
## Day-2
|
|
|
|
```sh
|
|
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 fmt # nixfmt over the whole 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` builds nothing, so 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`):
|
|
|
|
```sh
|
|
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 add`ed first), these confirm that the configuration evaluates:
|
|
|
|
```sh
|
|
nix flake check --no-build # ends with: all checks passed!
|
|
nix eval --raw .#nixosConfigurations.desktop.config.system.build.toplevel.drvPath
|
|
nix eval --raw .#packages.x86_64-linux.iso.drvPath
|
|
nix build .#checks.x86_64-linux.formatting # nixfmt check, same formatter as `nix fmt`
|
|
nix flake show # the outputs listed under "Flake outputs"
|
|
```
|
|
|
|
The two `nix eval` lines print a `/nix/store/...-nixos-system-desktop-26.11...drv`
|
|
and the ISO's `.drv`. The only warnings to expect are `stdenv.isLinux is
|
|
deprecated` and `stdenv.isDarwin is deprecated` (Serena's pinned uv2nix and
|
|
another input), `unknown flake output 'modules'` (the flake-parts `modules`
|
|
output), and, until `secrets/gitea-runner-token.age` and
|
|
`secrets/tg-ws-proxy-secret.age` exist, one warning each for the runner and the
|
|
Telegram proxy.
|
|
|
|
## 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-boot`
|
|
with `systemd-boot` in the `imports` list of `modules/hosts/desktop/host.nix`
|
|
and run `nh os boot` (or `nix run .#switch -- boot`); the installer's closing
|
|
hint gives the same instruction.
|
|
`sbctl enroll-keys` refusing to run means the firmware is not in Setup Mode.
|
|
- **Secrets do not decrypt** (no password, no `~/.ssh/id_ed25519`). The host key
|
|
in `secrets/secrets.nix` must match `/etc/ssh/ssh_host_ed25519_key.pub` on the
|
|
machine. Test: `sudo age -d -i /etc/ssh/ssh_host_ed25519_key secrets/<name>.age`.
|
|
Fix `secrets.nix`, re-encrypt (`agenix -r -i <your key>`), `git add`, switch.
|
|
Meanwhile log in with `changeme` (when no password secret is defined) and
|
|
run `passwd`.
|
|
- **The Gitea runner or the Telegram proxy is gone after a switch.** The two
|
|
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 `nofail` and a 10 s timeout, so
|
|
the system still boots from the NVMe. Files written to `~/Games` meanwhile 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 add` it.
|
|
- **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-backup` file.** Home-manager moves files
|
|
it now manages (GTK/Qt/Kvantum configs, `~/.claude/skills/*`) 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.css` or `~/.config/qt6ct/qt6ct.conf` can 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-keys` must log `Reloaded configuration`.
|