Compare commits

..
40 Commits
Author SHA1 Message Date
ryan4yin | 二花 835b7f6df1 feat(shoukei): pin home Wi-Fi to a static IPv4 & adjust networking.nix (#407) 2026-10-07 21:27:34 +08:00
Ryan Yin e9d706aa96 fix(apparmor): correct the sudo profile comment's conclusion
The abort needs havePrivateMountNs == false AND /nix/store still ro:
remountReadOnlyWritable() returns early while the store is writable. Nix
<= 2.34 left it rw until reboot; 2.35 remounts in a private namespace, so
only a freshly booted host hits it. The repro command also uses an open-only
exec 7<..., since cat fails on the read even when the open succeeds.

While here, trim the comments and drop the disabled default_deny/nix
policies plus the explicit killUnconfinedConfinables=false (nixpkgs
default). 82 -> 34 lines.
2026-10-07 20:22:43 +08:00
Ryan Yin 124bcd8490 docs: drop the stale "just test exit code" caveat
`just test` has enforced the suite result since #350: the recipe raises unless
`evalTests` is `true`, so a zero exit already means pass. Update the places that
still described the old raw-`nix eval` behaviour: AGENTS.md, README.md,
SECURITY.md, outputs/README.md, and the nix-config-debug / nix-config-new-host /
nix-config-update skills.

The exit-0 caveat is kept only where the raw `nix eval .#evalTests` command is
documented, because that command genuinely exits 0 even on `false`.
2026-10-07 19:54:32 +08:00
ryan4yin | 二花 6f136b50e4 fix(shoukei): mitigate brcmfmac wifi auth failures, document duplicate-profile bug (#406)
BCM4378/brcmfmac intermittently fails Wi-Fi association (ASSOC-REJECT /
authentication timeout) on this laptop. NetworkManager misreads the failure
as a bad key and re-prompts; whichever client reconnects (Noctalia, nmtui,
nmcli) then saves the answer as a duplicate "<SSID> 1" profile. The problem
predates the Noctalia v5 shell and is driven by the driver, not the shell.

- disable Wi-Fi powersave on shoukei, a common source of brcmfmac auth timeouts
- WORKAROUNDS.md WA-024: the powersave mitigation and its removal condition
- WORKAROUNDS.md WA-025: the pending upstream brcmfmac port_authorized fix
- document how to recover a wedged supplicant without rebooting, and that
  deleting an active NM profile is what turned a reconnect into a dead link

Refs: https://patchew.org/linux/20260915-brcmfmac-4way-handshake-offload-authenticated-event-v2-1-fbb9cc7ac177@jannau.net/
2026-10-07 19:52:57 +08:00
Ryan Yin 0d800c4d9c fix(apparmor): attach disconnected paths in the sudo profile
Nix 2.35's root nix-env -- used by nixos-rebuild to set the system profile --
calls saveMountNamespace(), which opens /proc/self/ns/mnt before remounting
the read-only /nix/store writable. Those magic links have no connected path,
so AppArmor cannot match them against any rule and denies the open with
EACCES even in complain mode. The private mount namespace is then never
created and nixos-rebuild aborts with:

  cannot remount "/nix/store" writable: not in a private mount namespace

Adding flags=(attach_disconnected) lets AppArmor re-root those paths on / so
the existing `file /**` rule matches. This also fixes any other sudo'd tool
that needs namespaces (unshare, nsenter, bwrap, ...).

Rolling this out to a host that already has the old profile loaded needs one
deploy with --no-reexec, so the current system's Nix performs nix-env --set
instead of the new system's; after that generation is active, plain
`just niri` works and the Nix version is never rolled back.
2026-10-07 19:39:42 +08:00
Ryan Yin 94312fc2e5 ci: bound and retry the Gitee mirror push
Gitee's SSH gateway intermittently accepts the connection and key, then never
answers the initial git-receive-pack and drops the session ~100s later with
"the remote end hung up upon initial contact". The same failure mode shows up
sporadically since 2026-10-02 and spiked on 2026-10-07 (9 of 14 runs failed).

Bound each push attempt with `timeout`, retry up to six times with exponential
backoff, and add ssh connect/keepalive timeouts. Serialize runs (a push to main
and a tag on the same commit used to race for Gitee's per-repo push lock), cap
the job at 30 minutes, and allow manual workflow_dispatch reruns.
2026-10-07 19:02:46 +08:00
ryan4yin | 二花 8f065f24bc feat(nix): use Nix 2.35 via nixVersions.latest (#405)
Nix 2.35 brings lazy flake source copying, mimalloc (5-12% faster
evaluation), lower nix-daemon memory use, HTTP/3 support, and jittered
transfer retries with Retry-After.
2026-10-07 18:32:09 +08:00
ryan4yin | 二花 b64adc4c20 docs(security): correct the M3 pod-to-node control #403 2026-10-07 17:58:54 +08:00
ryan4yin | 二花 df6f9b8d6d feat(k3s): disable kube-proxy for Cilium eBPF replacement (#404) 2026-10-07 17:58:33 +08:00
ryan4yin | 二花 2af97e37b9 feat(shoukei): x86 emulation via muvm+FEX, drop pkgs-x64 (#394)
* feat(shoukei): run x86/x86_64 apps and games via muvm+FEX

Apple Silicon's 16K pages mean FEX cannot run natively and qemu-user cannot
run complex x86_64 binaries. Wire the maintained rowanG077/nix-x86-on-aarch64
runtime (FEX inside a 4K muvm microVM) into shoukei so games, Steam, Wine and
other x86/x86_64 programs work, and let the module own the x86 ELF handlers
instead of qemu-user.

The input is pinned to our fork (ryan4yin/nix-x86-on-aarch64) at the reviewed
commit. Dropping boot.binfmt.emulatedSystems also removes x86_64 from
nix.settings.extra-platforms, so the qemu-user/uncached-x86-build gap is
recorded as WA-022.

- flake.nix: add nix-x86-on-aarch64 input (WA-021)
- hosts/12kingdoms-shoukei/game/: programs.x86-on-arm + steam/wine, 6 GiB VM
- hardware-configuration.nix: drop emulatedSystems/preferStaticEmulators
- apple-silicon.nix: drop the now-redundant box64
- docs: WA-012 resolved; WA-021 and WA-022 added; host README updated

* refactor(nixpkgs): drop the repo-wide pkgs-x64 package set

Every remaining pkgs-x64 consumer runs only on x86_64-linux hosts, where the
native pkgs already carries the same allowUnfree config
(modules/nixos/base/nix.nix) and overlays (modules/base/overlays.nix), so
replace the references with pkgs and drop the extra nixpkgs instantiation
(which also removes an eval on aarch64-darwin).

media.nix keeps the native Zoom app on x86_64 hosts only, since zoom-us has
no aarch64 Linux build.
2026-10-07 16:03:59 +08:00
Ryan Yin 13fe324507 refactor(nixpkgs): drop the repo-wide pkgs-x64 package set
Every remaining pkgs-x64 consumer runs only on x86_64-linux hosts, where the
native pkgs already carries the same allowUnfree config
(modules/nixos/base/nix.nix) and overlays (modules/base/overlays.nix), so
replace the references with pkgs and drop the extra nixpkgs instantiation
(which also removes an eval on aarch64-darwin).

media.nix keeps the native Zoom app on x86_64 hosts only, since zoom-us has
no aarch64 Linux build.
2026-10-07 15:56:58 +08:00
Ryan Yin 3e4e093869 feat(shoukei): run x86/x86_64 apps and games via muvm+FEX
Apple Silicon's 16K pages mean FEX cannot run natively and qemu-user cannot
run complex x86_64 binaries. Wire the maintained rowanG077/nix-x86-on-aarch64
runtime (FEX inside a 4K muvm microVM) into shoukei so games, Steam, Wine and
other x86/x86_64 programs work, and let the module own the x86 ELF handlers
instead of qemu-user.

The input is pinned to our fork (ryan4yin/nix-x86-on-aarch64) at the reviewed
commit. Dropping boot.binfmt.emulatedSystems also removes x86_64 from
nix.settings.extra-platforms, so the qemu-user/uncached-x86-build gap is
recorded as WA-022.

- flake.nix: add nix-x86-on-aarch64 input (WA-021)
- hosts/12kingdoms-shoukei/game/: programs.x86-on-arm + steam/wine, 6 GiB VM
- hardware-configuration.nix: drop emulatedSystems/preferStaticEmulators
- apple-silicon.nix: drop the now-redundant box64
- docs: WA-012 resolved; WA-021 and WA-022 added; host README updated
2026-10-07 15:55:55 +08:00
ryan4yin | 二花 f5a111c638 feat(backup): hourly read-only snapshots and per-backup integrity checks (#402)
* feat(restic): verify the repository after each backup

* feat(youko): snapshot the restic store hourly

* docs(backup): document the snapshot and check layers
2026-10-07 15:26:57 +08:00
ryan4yin | 二花 3694961e74 fix(postgres,darwin): close the loopback superuser path and scope agenix ownership (#401)
* fix(postgres): require a password for superuser over TCP

* test: assert the postgres loopback auth rules

* fix(darwin): keep root-only agenix secrets root-only

* docs(security): record the local auth boundaries and retire WA-015
2026-10-07 15:22:03 +08:00
ryan4yin | 二花 3acb5d4ee5 fix(nfs,libvirt): restrict the golden export and bind VNC to loopback (#400)
* fix(nfs): restrict the golden export to its real clients

* fix(libvirt): bind VNC consoles to loopback

* fix(firewall): drop VNC ports on every host

* docs(security): record the NFS and VNC boundaries
2026-10-07 15:10:52 +08:00
ryan4yin | 二花 43f39e8e9f fix(k3s): deny credential-bearing host ports to pod sources (#399)
* fix(k3s): deny credential-bearing host ports to pod sources

* test: assert the k3s pod firewall drops sensitive ports

* docs(security): record the pod firewall boundary
2026-10-07 15:03:56 +08:00
ryan4yin | 二花 b79c5807ae ci: harden workflows and run the runtime firewall VM test (#398)
* ci: pin actions, scope tokens, run the runtime security VM test

* test: add a just recipe for the runtime firewall VM test
2026-10-07 14:57:34 +08:00
ryan4yin | 二花 5f6a1dadf4 docs: fix stale claims and AI-flavored prose (#397) 2026-10-07 14:48:36 +08:00
Ryan Yin fabccbafda fix(monitoring): ignore openapi discovery in apiserver latency alert
KubernetesApiServerLatency fired continuously on the p99 of
apiserver_request_duration_seconds_bucket. Every firing series was
verb="GET", subresource="openapi/v3" (kubelet, kube-controller-manager,
kube-scheduler, apiserver) at ~8s, while real verbs (POST/LIST/DELETE)
stay around 0.2s.

openapi/v3 is a streaming discovery endpoint, like WATCH, so exclude
subresource=~"^openapi/" from the rule.
2026-10-07 13:21:43 +08:00
ryan4yin | 二花 76c4566e9b fix(k8s): pass inputs to the MicroVM guests (#396)
Host builds have been broken since #375 - function called without argument inputs
2026-10-07 13:20:08 +08:00
ryan4yin | 二花 95b849420e feat(gaming): declarative Proton and dGPU game rendering (#393) 2026-10-07 13:14:42 +08:00
ryan4yin | 二花 90bbe8bc4f fix(monitoring): stop recurring false alerts (#395)
The Telegram channel was dominated by alerts that can never be actionable:

- DriveTemperatureHigh/Critical did not filter temperature_type, so
  max(smartctl_device_temperature) picked the drive's rated
  op_limit_max/critical_limit_max instead of the actual reading. ai reported
  95 C and youko 130 C while the drives actually ran at 40-48 C.
- HostPhysicalComponentTooHot excluded label!="tctl", but the AMD k10temp
  hwmon sensor labels itself Tctl, so the CPU control temperature (up to
  ~100 C under load) tripped the alert on every AMD host.
- MicroVM guests share the host's read-only /nix/store, so their
  nix-gc.service always failed and tripped HostSystemdServiceCrashed on all
  six k3s guests. Disable automatic GC in the guest; the host's nix.gc
  reclaims the shared store.

The remaining k3s alert noise comes from workloads running on the masters
that belong on the workers; that is fixed in k8s-gitops, not by resizing
the control-plane VMs.
2026-10-07 12:51:30 +08:00
Ryan Yin a7cc474a50 docs(hosts): update the idols-ai memory notes for 1.28 V
The bring-up runs at the default 1.25 V; afterwards Gear mode is set to
Gear2 and VDD/VDDQ are raised to 1.28 V, changing nothing else. 1.29 V and
up do not train. Also record that the 1.25 V config passed stressapptest
but still hard-froze under a real llama.cpp load, so a passing test is not
proof of stability.
2026-10-07 07:38:52 +08:00
Ryan Yin a091fe1aca docs(hosts): refresh the ai screenshots and correct its hardware notes
- replace the btop screenshot with the 2026-10-06 annotated capture
  (btop + fastfetch + the strata/llama.cpp serving logs); the old
  2026-10-01 file is gone, so the README link moves to the new name
- drop the Helix/AI-agents screenshot and its README reference
- fix stale hardware descriptions: the hosts/README.md inventory row and
  the idols-ai header comment still said i5-13600KF, and the zswap pool
  comment sized its percentages against the old 96G of RAM (now 128G)
- record the hardware history: the platform was rebuilt on 2026-04-27
  (PR #257/#258) onto the Colorful CVN Z890 ARK FROZEN + Core Ultra 7
  270K Plus, replacing the MSI board and i5-13600KF the host was added
  with in 2023-05; the 2x48G kit predates that rebuild, the 2x16G kit
  was added 2026-10-06
- make the DIMM bring-up order mandatory and record its failure mode:
  with the 48G pair in first, or all four DIMMs from the start, the
  board does not POST
- gloss the Chinese BIOS labels in English, marked as translations of
  the labels rather than the firmware's own English wording

Left alone on purpose: the 96G swapfile in hosts/idols-ai/disko-fs.nix.
It was grown from 20G to 1x-RAM on 2026-10-02 (a26ab3be), when the host
still had 96G; resizing it again means re-running disko on the machine,
so that stays a separate decision.
2026-10-06 22:32:34 +08:00
ryan4yin | 二花 e653ec3306 docs(hosts): add mixed-memory notes for idols-ai (#391)
Document the 4-DIMM kit mix (2×48G JUHOR + 2×16G GLOWY) on the Colorful
CVN Z890 ARK FROZEN V20:

- hardware (CPU, board, and both kits)
- the install order that trains (16G pair first)
- the only stable settings (XMP off, DDR5-4800 @ 1.25 V)
- the stress-test recipe and results
- the XMP @ 5600 failure and how to recover a board that will not POST
- re-enrolling the LUKS TPM unlock after a BIOS change
2026-10-06 21:39:23 +08:00
Ryan Yin 87e87aad7d fix(agents): perserve dsh data 2026-10-06 17:00:01 +08:00
ryan4yin | 二花 dc65254511 fix(ssh): make sandboxed ssh work on Linux (#390) 2026-10-06 15:20:53 +08:00
ryan4yin | 二花 187577b2da docs(agents): fix the dsh private model route recipe (#389)
`dsh-llm-pi-ai` registers its built-in providers once, so a second instance
in the profile patch fails on mount with `provider "..." is already declared`.
Extend the base `llm-pi-ai` row instead.
2026-10-06 14:10:54 +08:00
ryan4yin | 二花 28e0b156ce refactor(agents): link dsh shared policy as a home-layer patch (#388)
dsh rewrites a profile's cordis.patch.yml at runtime, so linking the web
profile put GUI state in the checkout and let runtime writes clobber manual
edits. Link the stable policy as the $DSH_HOME home layer instead: dsh applies
it after every profile and only reads it.

The host-plane compaction-basic row is disabled on the web surface and each
agent preset owns its own copy, so the top-level override was inert. Drop it;
the model contextWindow/maxTokens are the effective knobs.

- add home/base/tui/agents/dsh/cordis.patch.yml, linked from default.nix
- drop the ~/.dsh/profiles/web link and the tracked web/ profile
- keep runtime state and private/local model routes in the profile patch
- update the eval test and README
2026-10-06 14:04:55 +08:00
ryan4yin | 二花 205f7c622b feat(agents): version the dsh web profile and add a proxied launcher #387 2026-10-06 00:54:30 +08:00
Ryan Yin 975d2668a8 feat(idols-ai): back up the dsh state directory (~/.dsh) with restic
dsh keeps its session transcripts, workspace storages, and profiles in
DSH_HOME=~/.dsh, which was outside the backup allowlist. Exclude its
.credentials.yaml like the module's other credential paths.
2026-10-05 23:46:04 +08:00
Ryan Yin 2e77458766 feat(noctalia): add 10s confirm countdown to session menu actions
Explicit session action lists replace the built-in defaults, so re-declare all
five actions; lock stays immediate, logout/suspend/reboot/shutdown arm a 10 s
countdown that a second press runs immediately.
2026-10-05 23:33:15 +08:00
Ryan Yin d7e169d56c docs(rime): reload the rime addon via busctl instead of fcitx5-remote 2026-10-05 23:27:03 +08:00
Ryan Yin 9cc5d92451 fix(desktop): restore dynamic light/dark for Qt apps
QT_QPA_PLATFORMTHEME=gtk3 (from #386) made Qt derive its color scheme
from GTK3, which has no dynamic dark/light signal, so Telegram and other Qt
apps were stuck on the light palette after Noctalia's theme mode changed.

Use the portal theme instead: Qt then follows
org.gnome.desktop.interface color-scheme, which Noctalia writes. The trade-off
is Qt's built-in "Sans Serif" 9pt font, which a font-providing platform theme
would be needed to change.
2026-10-05 23:14:28 +08:00
Ryan Yin a52e9dbbd7 fix(noctalia): drop the duplicate Now Playing OSD
go-musicfox posts its own desktop notification on every track change and both popups sit at bottom_right, so the media OSD was a second, redundant popup.
2026-10-05 22:46:13 +08:00
ryan4yin | 二花 85c51f5769 feat(rime): share the Rime config and user dictionary across Linux and macOS (#385)
* feat(rime): share the Rime config and user dictionary across Linux and macOS

Move the Rime data, preferences, and user dictionary into home/base/gui/rime so fcitx5-rime and Squirrel read the same files.

* feat(vinput): open the command palette with right Ctrl

Pin keyd's right-hand modifiers (rightcontrol/rightshift/rightmeta) to their own keycodes; keyd otherwise folds them into the left keys. Set Vinput's MenuKey to right Ctrl and clear CommandKeys, which would shadow it.

* feat(fcitx5): switch CN/EN with Ctrl+Space and right Shift

Clear AltTriggerKeys, whose Shift_L default toggled on left Shift. Left Shift is now a plain modifier and right Shift switches through the shared Rime config.
2026-10-05 22:43:20 +08:00
Ryan Yin 9442a82d91 feat(fcitx5): switch CN/EN with Ctrl+Space and right Shift
Clear AltTriggerKeys, whose Shift_L default toggled on left Shift. Left Shift is now a plain modifier and right Shift switches through the shared Rime config.
2026-10-05 22:41:49 +08:00
Ryan Yin 8e3f12aa19 feat(vinput): open the command palette with right Ctrl
Pin keyd's right-hand modifiers (rightcontrol/rightshift/rightmeta) to their own keycodes; keyd otherwise folds them into the left keys. Set Vinput's MenuKey to right Ctrl and clear CommandKeys, which would shadow it.
2026-10-05 22:41:48 +08:00
Ryan Yin 5e5707dd13 feat(rime): share the Rime config and user dictionary across Linux and macOS
Move the Rime data, preferences, and user dictionary into home/base/gui/rime so fcitx5-rime and Squirrel read the same files.
2026-10-05 22:41:48 +08:00
ryan4yin | 二花 0ec5b8032c fix(desktop): align Qt app fonts with GTK (#386)
* fix(desktop): align Qt app fonts with GTK

Qt apps kept their built-in default font ("Sans Serif" 9) while GTK apps use
`gtk-font-name` (Noto Sans 11), so Telegram and other Qt apps rendered
noticeably smaller than GTK apps like Firefox. Set
QT_QPA_PLATFORMTHEME=gtk3; the plugin ships with qtbase, so it needs no
extra package and also gives Qt apps GTK file dialogs.

* chore(desktop): drop unused Xft.dpi from the Wayland GTK profile

Xft.dpi/ *.dpi are X11 X-resource settings. This file is only imported by
the niri (Wayland) hosts, where xwayland-satellite sets its own Xft.dpi
(96 x output scale, currently 144), and the i3 hosts are headless 1080p
computer-use sessions that do not import it. So the setting had no effect
anywhere; remove it instead of keeping a misleading knob.
2026-10-05 20:01:51 +08:00
119 changed files with 1648 additions and 603 deletions

No files matched your search

+3 -2
View File
@@ -26,7 +26,7 @@ bump, and the commands that destroy rollback points are in the `nix-config-updat
| Layer | Symptom | Look with |
| ------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| eval | `just test` prints `false`, an eval error | `just eval-host <host>` (already passes `--show-trace`) |
| eval | `just test` fails, an eval error | `just eval-host <host>` (already passes `--show-trace`) |
| build | build error, hash mismatch, "marked as broken" | `just build-host <host>`, then `nix log <drv>` |
| activation | the deploy fails after building | the deploy output; `journalctl -u home-manager-$USER -b` for Home Manager |
| runtime | a unit is failed or restarting | `just list-failed`, `systemctl status <unit>`, `journalctl -u <unit> -b` |
@@ -39,7 +39,8 @@ bump, and the commands that destroy rollback points are in the `nix-config-updat
## 2. Read the evaluated value
When `just test` prints `false`, re-run the suite directly to get the trace:
When `just test` fails, re-run the suite directly to get the trace (`nix eval` exits 0 even when the
suite returns `false`, so read its output):
```bash
nix eval .#evalTests --show-trace
+1 -1
View File
@@ -79,7 +79,7 @@ check every configuration and which list hosts by name:
- `security-*`, `kernel`, `nix-system-features`: apply to every configuration automatically.
- `home-manager`, `btrbk`, and the other host-listing tests: add the host if it should be covered.
`just test` must print `true`; an exit code of `0` with `false` is a failure.
`just test` fails (non-zero) unless the suite returns `true`.
## 4. Install and deploy
+1 -1
View File
@@ -75,7 +75,7 @@ Treat an update as a supply-chain event.
Run these before any host is touched:
- `just test` — must print `true`. An exit code of `0` with `false` is a failed suite.
- `just test` — fails (non-zero) unless the suite returns `true`.
- `just eval-host <host>` — fast, evaluation only.
- `just build-host <host>` — builds the full system closure and catches broken packages or build
failures that eval misses.
+28 -2
View File
@@ -18,6 +18,9 @@ on:
- "**.nu"
- "Justfile"
permissions:
contents: read
jobs:
checks:
name: Check expressions
@@ -25,9 +28,9 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
- name: Install nix
uses: cachix/install-nix-action@v31
uses: cachix/install-nix-action@13d8dd58da0234aa297dedd986986ccb8e7f3e24 # v31
with:
install_url: https://nixos.org/nix/install
extra_nix_config: |
@@ -40,3 +43,26 @@ jobs:
# `nix eval` prints the suite result but still exits 0 on failure, so
# compare the JSON boolean explicitly to fail the job.
test "$(nix eval .#evalTests --json --show-trace)" = "true"
runtime-security:
name: Runtime security VM tests
runs-on: ubuntu-latest
needs: checks
steps:
- name: Checkout repository
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
- name: Install nix
uses: cachix/install-nix-action@13d8dd58da0234aa297dedd986986ccb8e7f3e24 # v31
with:
install_url: https://nixos.org/nix/install
extra_nix_config: |
experimental-features = nix-command flakes
# Hosted runners have /dev/kvm but the runner user cannot open it. This
# udev rule hands the group mode to everyone for the job's lifetime.
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Run the firewall VM test
run: nix build --no-link --print-build-logs .#checks.x86_64-linux.security-exporters
+47 -4
View File
@@ -5,15 +5,35 @@ on:
- main
tags:
- "*"
workflow_dispatch:
permissions:
contents: read
# A push to main and a tag on the same commit each trigger a run. Queue them so
# two runs never race for Gitee's per-repo push lock.
concurrency:
group: mirror-to-gitee
cancel-in-progress: false
jobs:
mirror:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
fetch-depth: 0
- name: Pin the Gitee host key
run: |
mkdir -p ~/.ssh
cat > ~/.ssh/known_hosts <<'HOSTS'
gitee.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEKxHSJ7084RmkJ4YdEi5tngynE8aZe2uEoVVsB/OvYN
gitee.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDMzG3r+88lWSDK9fyjcZmYsWGDBDmGoAasKMAmjoFloGt9HRQX2Qp4f9FY2XK/hsHYinvoh5Xytl9iaUNUWMfYR8q6VEMtOO87DgoAFcfKZHt0/nbAg9RoNTKYt6v8tPwYpr7N0JP/01nE4LFsNDnstr6H0bXSAzbKWCETLZfdPV4l2uSpRn3bU0ugoZ0aSKz5Dc/IloBfGCTvkSsxUydMRd/Chpjt6VxncDbp+Fa6pzsseK8OQzrg6Fgc5783EN3EQqZ2skqyCwExtx95BJlfx1B3luZnWfpkwNDnrZRT/Qx0OrWqyf0q6f9uQr+UG1S8qDcUn3e/9onq3rwBri8/
HOSTS
chmod 600 ~/.ssh/known_hosts
- name: Mirror repo to Gitee
id: mirror-to-gitee
shell: bash
@@ -23,10 +43,33 @@ jobs:
run: |
set -eu
mkdir -p ~/.ssh
echo "$INPUT_SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
export GIT_SSH_COMMAND="ssh -v -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no"
export GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=$HOME/.ssh/known_hosts -o ConnectTimeout=20 -o ServerAliveInterval=20 -o ServerAliveCountMax=3"
git remote add mirror "$INPUT_TARGET_REPO_URL"
git push --tags --force --prune mirror "refs/remotes/origin/*:refs/heads/*"
# Gitee's SSH gateway intermittently accepts the connection and key,
# then never answers the initial git-receive-pack and drops the
# session about 100s later ("the remote end hung up upon initial
# contact"). Bound each attempt so a stuck session cannot hang the
# job, and retry with backoff.
attempts=6
for attempt in $(seq 1 "$attempts"); do
echo "::group::Mirror attempt $attempt/$attempts"
if timeout --kill-after=15s 120s \
git push --tags --force --prune mirror "refs/remotes/origin/*:refs/heads/*"; then
echo "::endgroup::"
echo "Mirrored to Gitee on attempt $attempt"
exit 0
fi
echo "::endgroup::"
if [ "$attempt" -lt "$attempts" ]; then
delay=$((15 * 2 ** (attempt - 1)))
echo "Attempt $attempt failed; retrying in ${delay}s"
sleep "$delay"
fi
done
echo "::error::failed to mirror to Gitee after $attempts attempts" >&2
exit 1
+5
View File
@@ -6,3 +6,8 @@ vercel.json
cache
temp
.temp
# dsh writes its profile files itself (the Settings UI and `dsh plugin`), and
# its YAML dumper wraps prose differently from prettier; formatting them here
# would be undone on the next write.
home/base/tui/agents/dsh/web
+1 -1
View File
@@ -11,7 +11,7 @@ extend-exclude = [
"rime-data/",
# small-duck flypy user dictionary: entries are pinyin codes ("delt", "juli"),
# not English words, so the spell checker flags every one of them
"overlays/fcitx5/flypy_user.txt",
"home/base/gui/rime/flypy_user.txt",
]
[default]
+4 -3
View File
@@ -38,8 +38,9 @@ deployments. Keep repository guidance here; reusable global rules live in `agent
`nixfmt` with width 100.
- For supported non-Nix files, use `prettier --write <file>` and `prettier --check <file>`;
configuration lives in `.prettierrc.yaml`. Spelling checks use `typos` and `.typos.toml`.
- Run `just test` for configuration changes. It evaluates `.#evalTests` across Linux and Darwin; the
output must be `true`. Exit code zero with `false` is a failed suite.
- Run `just test` for configuration changes; it evaluates `.#evalTests` across Linux and Darwin and
exits non-zero unless the result is `true`. The bare `nix eval .#evalTests` exits 0 even on
`false`, so run `just test` or compare its `--json` output yourself.
- Eval tests are `expr.nix` / `expected.nix` pairs under `outputs/<system>/tests/`. Update focused
cases when changing behavior covered by those tests.
- Use `nix flake check` for broader flake checks. A host build can validate changes beyond eval:
@@ -125,7 +126,7 @@ repository, and cross-link them — no need to be told.
change.
- `~/codes/nix-secrets` — the private agenix store behind `secrets/` and the `mysecrets` input:
ciphertext and recipient rules for the secrets declared here.
- `wallpapers`, `nur-packages`, `pyclipsync`, `nu_scripts` — flake inputs; bump with
- `wallpapers`, `nur-ryan4yin`, `pyclipsync`, `nu_scripts` — flake inputs; bump with
`just upp <input>` after their source changes, do not edit them from here.
## Further Context
+14 -9
View File
@@ -4,12 +4,12 @@ How this fleet is backed up, where the data lives, and how to restore it.
## What protects against what
| Threat | Defence |
| ----------------------------- | ------------------------------------------------------------------ |
| accidental deletion, bad edit | btrbk: local btrfs snapshots |
| disk or host loss | restic: encrypted copies on youko |
| a compromised backup server | desktop repositories use a password youko never holds |
| a compromised host | not defended yet: the immutable cloud copy (planned) is that layer |
| Threat | Defence |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| accidental deletion, bad edit | btrbk: local btrfs snapshots |
| disk or host loss | restic: encrypted copies on youko |
| a compromised backup server | desktop repositories use a password youko never holds |
| a compromised host | youko takes hourly read-only btrfs snapshots of the REST store, which a desktop cannot reach; the immutable cloud copy (planned) is still the offsite layer |
## Layers
@@ -22,7 +22,10 @@ How this fleet is backed up, where the data lives, and how to restore it.
with `--private-repos`, authenticated by htpasswd, published behind caddy as
`restic.writefor.fun`. Deliberately not append-only: a desktop holds both the plaintext and the
repository password, so blocking deletion there protects little while denying the client the
automatic retention it needs.
automatic retention it needs. A compromised desktop can still `forget --prune` its own repository
through the REST API, so youko also snapshots `/data/backups` hourly into a read-only btrfs
subvolume the desktop cannot reach (see
`hosts/12kingdoms-youko/homelab-services/restic-server-snapshots.nix`).
3. **cloud copy** (planned). youko will copy the homelab repositories with `restic copy` (it holds
that password). Desktops copy their own: youko does not hold the desktop password. This layer is
what protects history against a compromised host, so the target should be immutable or versioned
@@ -61,6 +64,7 @@ collisions.
| ---------------- | ----------------------------------- |
| 01:30 + 15m | desktops push to youko |
| 02:30 + 15m | youko backs itself up |
| hourly | youko snapshots the REST store |
| 03:45:20 Tue/Sat | btrbk local snapshots |
| 06:00 (planned) | youko copies homelab repos to cloud |
@@ -123,7 +127,8 @@ Restoring a btrbk snapshot (offline; stop writers first):
## Verifying
- Units: `systemctl status restic-backups-homelab`, `systemctl list-timers 'restic-backups*'`.
- Repository integrity (where the password is): `restic check`.
- Repository integrity (where the password is): `restic check`, which runs after every backup via
`modules.restic-backup.checkOpts` (a 5% data read, `1/20`, by default).
- Server side, ciphertext only: repository directories under `/data/backups/rest-server/<user>/`,
with no leftover files in `locks/` and no stale `.tmp` files.
- `restic-rest-server`'s log must not print `Invalid htpasswd entry`: that means the client's REST
@@ -144,7 +149,6 @@ Restoring a btrbk snapshot (offline; stop writers first):
- **Cloud copy**: youko copies the homelab repositories with `restic copy`; desktops copy their own.
The target must not live in the homelab, and should be immutable or versioned (object lock) — that
is the layer which survives a compromised host.
- **`restic check` timer**: periodic integrity verification, on the host that holds the password.
## Components
@@ -153,6 +157,7 @@ Restoring a btrbk snapshot (offline; stop writers first):
| [`modules/nixos/base/restic-backup.nix`](./modules/nixos/base/restic-backup.nix) | client module: repository, paths, excludes, schedule |
| [`modules/nixos/base/btrbk.nix`](./modules/nixos/base/btrbk.nix) | local btrfs snapshots |
| `hosts/12kingdoms-youko/default.nix` | the REST server and youko's own backup |
| `hosts/12kingdoms-youko/homelab-services/restic-server-snapshots.nix` | hourly read-only snapshots of the REST store |
| `hosts/12kingdoms-youko/homelab-services/caddy.nix` | the `restic.writefor.fun` vhost |
| `secrets/nixos.nix` | which secret is defined on which host |
| `hosts/idols-ai/restic.nix`, `hosts/12kingdoms-youko/default.nix` | per-host backup configuration |
+29
View File
@@ -23,6 +23,12 @@ default:
test:
let result = (nix eval .#evalTests --json --show-trace --print-build-logs --verbose | str trim); if $result != "true" { error make { msg: $"eval tests failed: evalTests returned ($result)" } }
# Build and run the runtime security VM test (needs /dev/kvm; not run by just test)
[linux]
[group('nix')]
test-vm:
nix build --no-link --print-build-logs .#checks.x86_64-linux.security-exporters
# Evaluate a NixOS host configuration without building it.
[group('nix')]
eval-host host:
@@ -151,6 +157,12 @@ niri mode="switch" verbosity="normal":
use {{utils_nu}} *;
nixos-switch $"(hostname)-niri" {{mode}} {{verbosity}}
# Pin shoukei's home Wi-Fi to a static IPv4 (run once; the profile persists).
[linux]
[group('desktop')]
shoukei-home-wifi:
sudo nu {{absolute_path("scripts/shoukei-home-wifi-static.nu")}}
############################################################################
#
# Darwin related commands
@@ -254,6 +266,23 @@ kana mode="switch":
k3s-test mode="switch":
colmena apply {{mode}} --on '@k3s-test-*' --verbose --show-trace
# =================================================
#
# AI agent commands
#
# =================================================
# Start the dsh web UI without opening a browser, proxied via mihomo's mixed port.
[group('agents')]
dsh-web:
#!/usr/bin/env nu
# dsh's web fetch refuses a DNS answer it does not call public, and a fake-ip
# resolver answers with 198.18.0.0/15. A proxied hop lets mihomo resolve the
# origin instead, which skips that check and leaves fake-ip acceleration
# intact. The policy reaches every Node fetch the harness makes, so mihomo
# becomes a dependency for LLM, web search and HTTP MCP traffic too.
with-env { HTTPS_PROXY: "http://127.0.0.1:7897", HTTP_PROXY: "http://127.0.0.1:7897" } { ^dsh web --no-open }
# =================================================
#
# Other useful commands
+2 -4
View File
@@ -82,9 +82,7 @@ Wallpapers: https://github.com/ryan4yin/wallpapers
![desktop](./_img/2026-10-02_niri-noctalia_desktop.webp)
![btop monitoring and system information](./_img/2026-10-01_btop-monitoring-system-info.webp)
![Helix and AI agents in a terminal workspace](./_img/2026-10-02_helix-ai-agents.webp)
![btop, fastfetch, and llama.cpp serving logs](./_img/2026-10-06_btop-monitoring-system-info.webp)
## Editors / IDE
@@ -161,7 +159,7 @@ of the same flake, e.g. `just col <tag>`, `just k3s-test`, `just lab`.
`nix develop` provides the formatters and linters used by the repository. The most useful commands:
```bash
just test # eval tests across Linux & Darwin; the output must be `true`
just test # eval tests across Linux & Darwin (fails unless the result is `true`)
just fmt # format all Nix files with nixfmt
just --list # all recipes
+43 -24
View File
@@ -44,7 +44,7 @@ small, reversible controls and narrow exceptions; benchmark before adopting expe
| Desktop apps | Selected apps use nixpak/bubblewrap; Podman is rootless | Rules and shared directories vary per app; user namespaces are needed for these sandboxes |
| Secrets | agenix declarations here, encrypted data in the private nix-secrets repository | Recipients and plaintext file permissions must be reviewed; root on a recipient can read its decrypted secrets |
| Supply chain | Locked flake inputs; explicit binary-cache trust keys; normal user is not a Nix trusted-user | A trusted cache or imported Nix module can supply code executed as root; a lock file is not a security audit |
| Recovery | NixOS generations, btrbk/restic and documented backup procedures | A rollback does not undo compromised data or secrets; backup configuration alone does not prove restore works |
| Recovery | NixOS generations, btrbk/restic, hourly read-only snapshots of the REST store, and documented backup procedures | A rollback does not undo compromised data or secrets; backup configuration alone does not prove restore works; the offsite immutable copy is still planned |
Sources: [host layout](hosts/README.md), [k3s deployment](hosts/k8s/README.md),
[firewall](modules/nixos/base/networking/firewall.nix), [SSH](modules/nixos/base/ssh.nix),
@@ -109,8 +109,8 @@ See [application hardening](hardening/README.md) for wrapper details.
1. Check the advisory and affected package/kernel; prioritize active exploitation and reachable
attack paths. Review changed inputs and cache trust instead of treating updates as inherently
safe.
2. Run `just test` (must return `true`), build affected systems/runners and review closure
differences. Evaluate tests cannot prove runtime enforcement or workload compatibility.
2. Run `just test` (must pass), build affected systems/runners and review closure differences.
Evaluate tests cannot prove runtime enforcement or workload compatibility.
3. Record the old system generation/runner and ensure backups and recovery access exist. Use `boot`
mode for bridge/network-stack changes or broad VM-host updates.
4. Deploy MicroVM closures to the **physical host**, not the guest's read-only store. Install the
@@ -194,10 +194,25 @@ checks remain necessary after deployment.
privileges are intentional for cluster reconciliation; Git write access and controller credentials
therefore remain administration boundaries. This inventory is not a complete effective-access or
privilege-escalation analysis.
- **NFS:** the golden store is `0755 root:root`, exported read-write to the entire home LAN with
`sec=sys,no_root_squash`. File mode 0755 does not contain an allowed client with root privileges;
such a client can act as server root within this export. The network allowlist and client trust
are therefore material boundaries, not merely filesystem permissions.
- **NFS:** the golden store is `0755 root:root`, exported read-write to an explicit client list (the
k3s nodes and the VM hosts) with `sec=sys,no_root_squash`. The client list stops other LAN devices
reaching the export, but a root user on an allowed client still has server-root write access.
`root_squash` is deferred: the existing PVC subdirectories are root-owned (observed
`drwxr-xr-x root root` and `drwxrwsr-x root 107`), so enabling it needs a one-time ownership
migration and a maintenance window. See WORKAROUNDS.md.
- **Remote consoles:** the libvirt VNC consoles listen on `127.0.0.1` only, and the shared firewall
drops 5900-5910 on every host. Reach a console through an SSH tunnel.
- **Pod-to-host firewall:** two independent layers deny pod access to the credential-bearing host
ports (SSH, NFS, Postgres, restic, VNC, Immich, exporter/monitoring). The
`deny-pod-to-node-admin-ports` `CiliumClusterwideNetworkPolicy` in
[k8s-gitops#52](https://github.com/ryan4yin/k8s-gitops/pull/52) denies pod egress to
`host`/`remote-node` on those ports at the pod's own node; the k3s nodes' nftables rule drops the
same ports for pod CIDR sources (`10.0.0.0/8`, `fd00::/104`). The nftables rule only matches when
the pod IP survives to the destination, which requires Cilium's eBPF datapath: kube-proxy's
iptables masquerade rewrote pod -> node traffic to the source node IP and defeated it. That is why
k3s runs `--disable-kube-proxy` ([#404](https://github.com/ryan4yin/nix-config/pull/404)) and
Cilium runs `kubeProxyReplacement` with `bpf.masquerade`. Verified live on all nodes: pod ->
node:22 is dropped while kubelet, ingress (80/443 stay open), ClusterIP and DNS keep working.
Only selected pod security fields, RBAC rules/binding metadata, listeners and export metadata were
queried. Secret contents and raw kubeconfigs were not inspected. No live access policy, workload,
@@ -224,9 +239,13 @@ export, credential, DNS record or firmware configuration was changed during the
desktops. Same-user agents are not isolated from these credentials by Unix file permissions. Mode
`0000` also does not stop privileged root. Other host/runtime ownership checks and recipient
membership were not completed; no private recipient repository or secret value was inspected.
- Darwin's activation has a blanket `chown` over `/etc/agenix/*`; on symlink targets this can
override declared root ownership. Runtime ownership and consumer requirements must be verified
before replacing it with explicit per-file ownership. Track this source concern as WA-015.
- Darwin's activation now re-applies each secret's declared ownership explicitly instead of a
blanket `chown` over `/etc/agenix/*`, so the root-only `rclone.conf` stays root-owned. Runtime
ownership (`ls -l /etc/agenix`) on each Darwin host still needs a check after the next activation.
- PostgreSQL's loopback TCP listener still trusts application roles by password (Immich and the
exporter use it), but `postgres` and replication now require `scram-sha-256`, closing the
local-superuser path. Provisioning per-role passwords for full loopback `scram-sha-256` is the
follow-up (the Grafana datasource file already tracks this as its item 1.5).
### Sandbox and agent boundaries
@@ -294,20 +313,20 @@ separate verification.
## Remaining prioritized TODOs
| Priority | Work | Acceptance / constraints |
| -------- | -------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| P1 | Roll out and verify the implemented baseline/exporter rules | Runtime sysctl readback, allowed IPv4 scrape and denied IPv6/non-monitoring scrape tests; preserve Nix/Podman/Cilium/NFS functionality |
| P1 | Review router mappings and tailnet ACLs; narrow service exposure where warranted | Audit was limited to sampled host listeners; test intended and denied access without locking out deployment |
| P1 | Review NFS client scope and root identity requirements | Restrict to required VM hosts/CSI nodes where practical; test provisioning, permissions and existing PVCs before changing squash semantics |
| P1 | Narrow operator/secret access where justified; finish permission checks | Selected effective probes and ai/youko modes audited; validate broad secret-reader needs, remaining hosts, recipient scope and Darwin per-file ownership |
| P1 | Adopt the documented cadence and verify the booted kernel after rollouts | Routine documented; compare booted and selected kernel paths and recheck API/workloads after reboot; no automated metric is deployed |
| P1 | Exercise backup restore and credential rotation | Use an approved isolated restore target and recovery access; never overwrite live data for a drill |
| P2 | Promote selected AppArmor profiles to enforce; harden exposed systemd services | Per-app positive/negative tests, store-path coverage, reviewed capabilities and reversible rollout |
| P2 | Maintain ai boot integrity and assess other host roles | Review sbctl configuration migration, recovery boot and signed custom/NVIDIA modules; ai Secure Boot state already verified |
| P2 | Review unused-module deny list against real workloads and verified advisories | Check loaded/built-in modules and autoload dependencies; do not block required filesystems, WiFi, VM or Cilium/NFS functionality |
| P2 | Evaluate stronger controls only against a concrete threat | Account for hibernation, crash recovery, applications and performance; no blanket io_uring/SMT/userns ban or hardened-kernel switch |
| P2 | Validate narrower sandbox/agent boundaries where needed | Source and selected SSH/journal metadata audited; use disposable data/socket probes and preserve core-desktop diagnosis, browserpass and Homelab root workflows |
| P3 | Improve security-event alerts and configuration drift checks | Actionable redacted alerts and periodic runtime control readback |
| Priority | Work | Acceptance / constraints |
| -------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| P1 | Roll out and verify the implemented baseline/exporter rules | Runtime sysctl readback, allowed IPv4 scrape and denied IPv6/non-monitoring scrape tests; preserve Nix/Podman/Cilium/NFS functionality |
| P1 | Review router mappings and tailnet ACLs; narrow service exposure where warranted | Audit was limited to sampled host listeners; test intended and denied access without locking out deployment |
| P1 | Review NFS client scope and root identity requirements | Restrict to required VM hosts/CSI nodes where practical; test provisioning, permissions and existing PVCs before changing squash semantics |
| P1 | Narrow operator/secret access where justified; finish permission checks | Selected effective probes and ai/youko modes audited; validate broad secret-reader needs, remaining hosts and recipient scope; Darwin per-file ownership is now explicit and needs a runtime check |
| P1 | Adopt the documented cadence and verify the booted kernel after rollouts | Routine documented; compare booted and selected kernel paths and recheck API/workloads after reboot; no automated metric is deployed |
| P1 | Exercise backup restore and credential rotation | Use an approved isolated restore target and recovery access; never overwrite live data for a drill |
| P2 | Promote selected AppArmor profiles to enforce; harden exposed systemd services | Per-app positive/negative tests, store-path coverage, reviewed capabilities and reversible rollout |
| P2 | Maintain ai boot integrity and assess other host roles | Review sbctl configuration migration, recovery boot and signed custom/NVIDIA modules; ai Secure Boot state already verified |
| P2 | Review unused-module deny list against real workloads and verified advisories | Check loaded/built-in modules and autoload dependencies; do not block required filesystems, WiFi, VM or Cilium/NFS functionality |
| P2 | Evaluate stronger controls only against a concrete threat | Account for hibernation, crash recovery, applications and performance; no blanket io_uring/SMT/userns ban or hardened-kernel switch |
| P2 | Validate narrower sandbox/agent boundaries where needed | Source and selected SSH/journal metadata audited; use disposable data/socket probes and preserve core-desktop diagnosis, browserpass and Homelab root workflows |
| P3 | Improve security-event alerts and configuration drift checks | Actionable redacted alerts and periodic runtime control readback |
Record temporary exceptions in [WORKAROUNDS.md](WORKAROUNDS.md) with a removal condition. Revisit
this architecture after a new exposed service, network/storage change, host addition or significant
+36 -23
View File
@@ -16,48 +16,61 @@ obsolete workarounds get rolled back instead of lingering.
A version or revision pinned for a reason that can go away.
| ID | What & where | Why | Removal condition | Added | Revisit | Status |
| ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | ---------- | ---------------------- | ------ |
| WA-001 | smartctl_exporter pinned to upstream `6274decc`, which carries PR [#329](https://github.com/prometheus-community/smartctl_exporter/pull/329) — `overlays/smartctl-exporter/` | `/metrics` returns HTTP 500 once a device becomes readable after startup ([#305](https://github.com/prometheus-community/smartctl_exporter/issues/305), [#326](https://github.com/prometheus-community/smartctl_exporter/issues/326)) | Drop once nixpkgs provides a version containing the #329 fix | 2026-10-03 | next nixpkgs bump | active |
| WA-002 | `nixpkgs-2505` — `flake.nix`; consumer `home/base/tui/container.nix` | `kubernetes-helm` regressed in newer nixpkgs | Drop the input and its consumer once helm works again in current nixpkgs | 2025-12-03 | when helm is revisited | active |
| WA-003 | `rust-overlay` follow — `flake.nix` | lanzaboote v1.1.0's pinned rust-overlay uses the deprecated `stdenv.isLinux`/`stdenv.isDarwin` | Drop the follow once lanzaboote updates its pin (or we drop the lanzaboote pin) | 2026-09-25 | on lanzaboote bump | active |
| WA-004 | `catppuccin` on `main` — `flake.nix` | `main` carries the nodejs→nodejs-slim deprecation fix, which is not in a release | Switch to a release tag once it includes the fix | 2026-09-25 | on catppuccin release | active |
| WA-005 | `tuios` input — `flake.nix`; `home/base/tui/tuios/` | nixpkgs lags behind upstream | Use nixpkgs' `tuios` once it is recent enough | 2026-10-03 | on nixpkgs bump | active |
| WA-006 | `nixpkgs-blender` — `flake.nix` | Blender 5.2 LTS + CUDA/OptiX pin; keeps `just up` from triggering a full source rebuild | Bump deliberately when needed; drop the pin if the current nixpkgs build is acceptable | 2026-07-24 | deliberate | active |
| WA-007 | WeChat from `nixpkgs-master` — `hardening/bwraps/default.nix` | newest builds; the pinned channel lags | Fall back to the stable channel once it has a good build | 2026-10-03 | on nixpkgs bump | active |
| ID | What & where | Why | Removal condition | Added | Revisit | Status |
| ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ---------- | -------------------------- | ------ |
| WA-001 | smartctl_exporter pinned to upstream `6274decc`, which carries PR [#329](https://github.com/prometheus-community/smartctl_exporter/pull/329) — `overlays/smartctl-exporter/` | `/metrics` returns HTTP 500 once a device becomes readable after startup ([#305](https://github.com/prometheus-community/smartctl_exporter/issues/305), [#326](https://github.com/prometheus-community/smartctl_exporter/issues/326)) | Drop once nixpkgs provides a version containing the #329 fix | 2026-10-03 | next nixpkgs bump | active |
| WA-002 | `nixpkgs-2505` — `flake.nix`; consumer `home/base/tui/container.nix` | `kubernetes-helm` regressed in newer nixpkgs | Drop the input and its consumer once helm works again in current nixpkgs | 2025-12-03 | when helm is revisited | active |
| WA-003 | `rust-overlay` follow — `flake.nix` | lanzaboote v1.1.0's pinned rust-overlay uses the deprecated `stdenv.isLinux`/`stdenv.isDarwin` | Drop the follow once lanzaboote updates its pin (or we drop the lanzaboote pin) | 2026-09-25 | on lanzaboote bump | active |
| WA-004 | `catppuccin` on `main` — `flake.nix` | `main` carries the nodejs→nodejs-slim deprecation fix, which is not in a release | Switch to a release tag once it includes the fix | 2026-09-25 | on catppuccin release | active |
| WA-005 | `tuios` input — `flake.nix`; `home/base/tui/tuios/` | nixpkgs lags behind upstream | Use nixpkgs' `tuios` once it is recent enough | 2026-10-03 | on nixpkgs bump | active |
| WA-006 | `nixpkgs-blender` — `flake.nix` | Blender 5.2 LTS + CUDA/OptiX pin; keeps `just up` from triggering a full source rebuild | Bump deliberately when needed; drop the pin if the current nixpkgs build is acceptable | 2026-07-24 | deliberate | active |
| WA-007 | WeChat from `nixpkgs-master` — `hardening/bwraps/default.nix` | newest builds; the pinned channel lags | Fall back to the stable channel once it has a good build | 2026-10-03 | on nixpkgs bump | active |
| WA-020 | `fcitx5-vinput` pinned to release tag `v2.4.0` — `flake.nix`; consumer `home/linux/gui/base/vinput/default.nix` | Tracks a release tag instead of a branch, so `just up` stays on that release | Bump to a newer release tag when its changes are wanted | 2026-10-04 | on vinput release | active |
| WA-021 | `nix-x86-on-aarch64` input — our fork of rowanG077's patched FEX + muvm runtime — `flake.nix`; `hosts/12kingdoms-shoukei/game/` | FEX does not support 16K pages, so x86/x86_64 apps and games on shoukei need this pinned flake's 4K-page microVM runtime; our fork lets upstream changes be reviewed before use | Drop once FEX supports 16K pages directly, or nixpkgs/nixos-apple-silicon ships an equivalent runtime | 2026-10-07 | on FEX/nixpkgs/muvm update | active |
| WA-023 | `nix.package = pkgs.nixVersions.latest` — `modules/nixos/base/nix.nix` | NixOS is opted into Nix 2.35 (2.35.2), which nixpkgs ships as `nixVersions.latest`, while `nixVersions.stable` is still 2.34 | Drop the override and fall back to the default `pkgs.nix` once `nixVersions.stable` is 2.35 or newer | 2026-10-07 | next nixpkgs bump | active |
## Workarounds
A setting that works around a bug or a hardware quirk.
| ID | What & where | Why | Removal condition | Added | Revisit | Status |
| ------ | ------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ---------- | ------------------------------------------- | ------ |
| WA-008 | Relaxed NVMe APST (`nvme_core.default_ps_max_latency_us=100000`) — `hosts/idols-ai/hardware-configuration.nix` | the KINGBANK KP260 (DRAM-less QLC) froze on slow APST wake-ups | Drop the override once kernel/firmware fixes or replacement hardware make default APST reliable | 2026-10-03 | watch NVMe timeout/reset/AER in the journal | active |
| WA-009 | USB-SATA bridge mitigations (`usbcore.autosuspend=-1`, `usb-storage.delay_use=10`) — `hosts/12kingdoms-youko/default.nix` | flaky JMicron JMS567 resets with UDMA-CRC and I/O errors | Drop once the bridge/controller is replaced; the signal is smartctl CRC/media errors | 2026-09-21 | on hardware change or CRC errors | active |
| WA-010 | Insta360 Link USB reset on S3 resume — `hosts/idols-ai/default.nix` | the camera stays enumerated with a stalled UVC endpoint after resume | Drop after the Insta360 firmware or the kernel `uvcvideo` fixes it | 2026-08-01 | on kernel or firmware change | active |
| WA-011 | Kernel module blacklist (`esp4`, `esp6`, `rxrpc`) — `hardening/kernel-hardening.nix` | attack surface for the Dirty Frag LPE (CVE-2026-43284 / CVE-2026-43500) | Kept as defence in depth; drop only if something needs those modules | 2026-10-03 | rarely | active |
| ID | What & where | Why | Removal condition | Added | Revisit | Status |
| ------ | ------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ---------- | ------------------------------------------------------------------------------ | ------ |
| WA-008 | Relaxed NVMe APST (`nvme_core.default_ps_max_latency_us=100000`) — `hosts/idols-ai/hardware-configuration.nix` | the KINGBANK KP260 (DRAM-less QLC) froze on slow APST wake-ups | Drop the override once kernel/firmware fixes or replacement hardware make default APST reliable | 2026-10-03 | watch NVMe timeout/reset/AER in the journal | active |
| WA-009 | USB-SATA bridge mitigations (`usbcore.autosuspend=-1`, `usb-storage.delay_use=10`) — `hosts/12kingdoms-youko/default.nix` | flaky JMicron JMS567 resets with UDMA-CRC and I/O errors | Drop once the bridge/controller is replaced; the signal is smartctl CRC/media errors | 2026-09-21 | on hardware change or CRC errors | active |
| WA-010 | Insta360 Link USB reset on S3 resume — `hosts/idols-ai/default.nix` | the camera stays enumerated with a stalled UVC endpoint after resume | Drop after the Insta360 firmware or the kernel `uvcvideo` fixes it | 2026-08-01 | on kernel or firmware change | active |
| WA-011 | Kernel module blacklist (`esp4`, `esp6`, `rxrpc`) — `hardening/kernel-hardening.nix` | attack surface for the Dirty Frag LPE (CVE-2026-43284 / CVE-2026-43500) | Kept as defence in depth; drop only if something needs those modules | 2026-10-03 | rarely | active |
| WA-017 | keyd right-hand modifier passthrough — `modules/nixos/desktop/peripherals.nix` | keyd folds right Ctrl/Shift/Meta into their left keys | Drop once keyd or fcitx5 keeps right-hand modifiers distinct | 2026-10-05 | on keyd bump | active |
| WA-018 | user-owned `~/.ssh/config` + disabled systemd ssh-proxy include — `home/base/tui/ssh.nix`, `modules/nixos/base/ssh.nix` | bwrap exposes root-owned store files as `nobody` | Drop once sandboxes preserve store ownership | 2026-10-06 | when sandbox layout changes | active |
| WA-019 | programs.steam.extraCompatPackages = [ pkgs.dwproton-bin pkgs.proton-ge-bin ] — modules/nixos/desktop/gaming.nix | ACE games fail on GE/mainline Proton, work with DW-Proton | Drop once mainline or GE-Proton runs these games (GE-Proton#433) | 2026-10-07 | on Proton/GE bump | active |
| WA-024 | Wi-Fi power saving disabled (`networking.networkmanager.wifi.powersave = false`) — `hosts/12kingdoms-shoukei/apple-silicon.nix` | On this BCM4378/brcmfmac laptop, powersave is a common source of intermittent ASSOC-REJECT / authentication-timeout failures; NetworkManager then mistakes the failure for a bad key, re-prompts, and the client (Noctalia, nmtui, nmcli) saves the answer as a duplicate `<SSID> 1` profile | Drop once the kernel carries the brcmfmac `port_authorized` fix (WA-025) and no association failures remain | 2026-10-07 | watch `journalctl -u wpa_supplicant` for ASSOC-REJECT / authentication timeout | active |
If WA-008 freezes recur, the fallback is to restore
`nvme_core.default_ps_max_latency_us=0 nvme_core.io_timeout=4294967295 pcie_aspm=off`; this is a
recovery procedure, not its removal condition.
If Wi-Fi wedges after a failed association, restart the stack instead of rebooting:
`sudo systemctl restart wpa_supplicant`, then `sudo systemctl restart NetworkManager`. Deleting an
_active_ NetworkManager profile wedges the supplicant as well; switch to another profile first, and
only delete inactive duplicates.
## Known issues
A known limitation with no fix yet.
| ID | What & where | Why | Removal condition | Added | Revisit | Status |
| ------ | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | ---------- | -------------------------------------- | ------ |
| WA-012 | `muvm` (x86_64 apps/games via microVM) disabled — `hosts/12kingdoms-shoukei/apple-silicon.nix` | Apple Silicon's 16k page size means x86_64 apps need `muvm`; it is off because it does not build/run on nixos-apple-silicon yet ([nixos-apple-silicon#237](https://github.com/nix-community/nixos-apple-silicon/issues/237)) | Re-enable once `muvm` builds and works | — | on nixos-apple-silicon or muvm updates | active |
| WA-015 | Darwin secret ownership — `secrets/darwin.nix` | Blanket `chown /etc/agenix/*` can override declared root ownership through symlinks; source concern, not a verified runtime leak | Verify consumers/runtime ownership, replace blanket ownership with explicit per-file ownership, and recheck target modes | 2026-10-03 | next Darwin activation review | active |
| WA-016 | subscription rule snapshots — `modules/nixos/desktop/networking/mihomo/` (`rules_from:`) | mihomo's `proxy-providers` imports proxies only, so the `rules` and `proxy-groups` a subscription ships with are dropped by the core; the generator re-imports them from a local YAML copy that has to be refreshed by hand when the provider changes its routing policy | Drop the snapshots once mihomo can import rules from a proxy-provider, or the providers publish their rules as rule-providers | 2026-10-04 | when mihomo gains rule import | active |
| ID | What & where | Why | Removal condition | Added | Revisit | Status |
| ------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | ---------- | -------------------------------------------------------------- | ------ |
| WA-016 | subscription rule snapshots — `modules/nixos/desktop/networking/mihomo/` (`rules_from:`) | mihomo's `proxy-providers` imports proxies only, so the `rules` and `proxy-groups` a subscription ships with are dropped by the core; the generator re-imports them from a local YAML copy that has to be refreshed by hand when the provider changes its routing policy | Drop the snapshots once mihomo can import rules from a proxy-provider, or the providers publish their rules as rule-providers | 2026-10-04 | when mihomo gains rule import | active |
| WA-022 | qemu-user binfmt removed — `hosts/12kingdoms-shoukei/hardware-configuration.nix` | the x86-on-arm module owns the x86 ELF handlers and this host does not need riscv64, but dropping `boot.binfmt.emulatedSystems` also drops `nix.settings.extra-platforms` and qemu-user, so `podman run --platform=linux/amd64`, x86 chroots and local builds of uncached x86 derivations need a remote x86_64 builder | Restore `boot.binfmt.emulatedSystems` (without x86_64/i686, which the module asserts against) if such a workload is needed | 2026-10-07 | when an amd64 container/chroot or uncached x86 build is needed | active |
| WA-025 | brcmfmac 4-way-handshake offload authentication — upstream kernel/wpa_supplicant, no code in this repo | Since hostap commit 416386060, wpa_supplicant 2.11+ expects `NL80211_CMD_PORT_AUTHORIZED` from drivers that offload the 4-way handshake; brcmfmac never reports it, so authentication intermittently fails on Apple Silicon (BRCM4378/4387/4388). nixpkgs already carries the Broadcom revert in wpa_supplicant 2.12; the proper fix, Janne Grunau's `wifi: brcmfmac: cfg80211: Report port_authorized for 4-way HS offload` (2026-09), is still under review. Entering the key again after such a failure only creates a duplicate profile, so cancel and retry instead | Fix lands via a nixpkgs kernel update (or by carrying the patch through `nixpkgs-patched`) | 2026-10-07 | on every kernel bump | active |
## WIP
An unfinished feature or gap.
| ID | What & where | Why | Removal condition | Added | Revisit | Status |
| ------ | --------------------------------- | -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | ---------- | --------- | ------ |
| WA-013 | NixOS tests — `outputs/README.md` | tests rebuild custom packages (no private cache) and hosts need their own ssh host key to decrypt agenix | Resolve when a private cache exists and tests can run per-service | 2024-03-13 | quarterly | active |
| ID | What & where | Why | Removal condition | Added | Revisit | Status |
| ------ | --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | ---------- | ----------------------- | ------ |
| WA-013 | NixOS tests — `outputs/README.md` | full-host tests still rebuild custom packages (no private cache) and need the host ssh key to decrypt agenix; the shared-firewall security-exporters VM test now runs in CI (KVM) | Resolve when a private cache exists and tests can run per-service | 2024-03-13 | quarterly | active |
| WA-020 | NFS golden store `no_root_squash` — `hosts/12kingdoms-youko/nfs-golden.nix` | the existing PVC subdirectories are root-owned, so enabling `root_squash` would break running workloads until they are migrated; the CSI node plugin is hostNetwork and sources from the allowlisted node IPs | Drop when the PVC subdirectories are migrated and `root_squash` is enabled | 2026-10-07 | next maintenance window | active |
## Related
Binary file not shown.

Before

Width:  |  Height:  |  Size: 509 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 526 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 623 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 243 KiB

After

Width:  |  Height:  |  Size: 243 KiB

+1 -5
View File
@@ -1,4 +1,4 @@
# agents
# Agents
Portable agent resources shared across projects: the global baseline rules, behavioral scenarios for
those rules, and reference snippets for external tooling.
@@ -75,7 +75,3 @@ Ideas worth adopting once a concrete need appears; nothing here is implemented y
- Keep files portable and reviewable.
- Keep secrets and machine-specific credentials out of this directory.
- Keep guidance generic enough to reuse across multiple agent environments.
## Goal
Maintain one reusable source of truth for agent setup that stays simple to sync and easy to evolve.
Generated
+25 -3
View File
@@ -732,6 +732,27 @@
"type": "github"
}
},
"nix-x86-on-aarch64": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1790210091,
"narHash": "sha256-ZM9kDVJNjFHVHR1Osx+6SdG2Lufnfx2Ek0Wcxc3KX00=",
"owner": "ryan4yin",
"repo": "nix-x86-on-aarch64",
"rev": "5d69793a1c8b31d724fccd9b6acaa33587c923b3",
"type": "github"
},
"original": {
"owner": "ryan4yin",
"repo": "nix-x86-on-aarch64",
"rev": "5d69793a1c8b31d724fccd9b6acaa33587c923b3",
"type": "github"
}
},
"nixos-apple-silicon": {
"inputs": {
"flake-compat": "flake-compat_4",
@@ -941,11 +962,11 @@
]
},
"locked": {
"lastModified": 1791100543,
"narHash": "sha256-DsuozPwOkBqrobxHGRdAkIJ/XH4RlkklDAdCRZPspIc=",
"lastModified": 1791202937,
"narHash": "sha256-80qCd/nbv2E2SybjMwzu9nQNXEkU14skcWj4tBpM/wo=",
"owner": "ryan4yin",
"repo": "nur-packages",
"rev": "f7b563dd38adf37579465b28bfa5f34305cb59f3",
"rev": "ff5441119f114a934578f8c092bd6d1d01696ae8",
"type": "github"
},
"original": {
@@ -1050,6 +1071,7 @@
"mysecrets": "mysecrets",
"nix-darwin": "nix-darwin",
"nix-gaming": "nix-gaming",
"nix-x86-on-aarch64": "nix-x86-on-aarch64",
"nixos-apple-silicon": "nixos-apple-silicon",
"nixpak": "nixpak",
"nixpkgs": "nixpkgs_2",
+18 -1
View File
@@ -21,6 +21,7 @@
# https://hydra.nixos.org/jobset/nixpkgs/unstable
# update via nix flake update nixpkgs --override-input nixpkgs github:NixOS/nixpkgs/<commit-hash>
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# Pinned to release tag v2.4.0 (not a branch); bump deliberately when needed.
fcitx5-vinput = {
url = "github:xifan2333/fcitx5-vinput/v2.4.0";
inputs.nixpkgs.follows = "nixpkgs";
@@ -31,7 +32,9 @@
# input together with that consumer.
nixpkgs-2505.url = "github:nixos/nixpkgs/nixos-25.05";
# nixpkgs with some custom patches, including the NPU-capable sherpa-onnx package.
# ryan4yin/nixpkgs fork for the `.agents/skills/nixpkgs-patched` workflow. It
# currently carries no patches (see WORKAROUNDS.md), but `pkgs-patched` is
# wired in outputs/default.nix so a temporary carry needs no flake edit.
nixpkgs-patched.url = "github:ryan4yin/nixpkgs/nixos-unstable-patched";
# get some latest packages from the master branch
nixpkgs-master.url = "github:nixos/nixpkgs/master";
@@ -149,6 +152,20 @@
inputs.nixpkgs.follows = "nixpkgs";
};
# x86/x86_64 emulation on 16K-page ARM64 (Apple Silicon). FEX cannot run
# natively with 16K pages, so this wraps FEX in a 4K-page muvm microVM and
# exposes an `x86pkgs` set plus Steam/Wine launchers. Used by shoukei; see
# hosts/12kingdoms-shoukei and WORKAROUNDS.md (WA-021).
#
# Pinned to our fork of rowanG077/nix-x86-on-aarch64 at the reviewed commit
# 5d69793a. To update, fetch upstream into the fork, review the new commits,
# then bump the rev here deliberately. Do not track the fork's default branch:
# a GitHub "Sync fork" fast-forward would pull unreviewed changes.
nix-x86-on-aarch64 = {
url = "github:ryan4yin/nix-x86-on-aarch64/5d69793a1c8b31d724fccd9b6acaa33587c923b3";
inputs.nixpkgs.follows = "nixpkgs";
};
######################## Some non-flake repositories #########################################
nu_scripts = {
+1 -1
View File
@@ -12,7 +12,7 @@ for temporary exceptions and known gaps, see [`WORKAROUNDS.md`](../WORKAROUNDS.m
1. Such as browser cookies, SSH keys, etc.
- **Per-App Level**: Prevent untrusted applications(such as closed-source apps) from:
1. Accessing files they shouldn't.
- Such as a malicious application accessing your browser's cookies, SSH Keys, etc.
- Such as a malicious application accessing your browser's cookies, SSH keys, etc.
1. Accessing the network when they don't need to.
1. Accessing hardware devices they don't need.
+21 -45
View File
@@ -1,61 +1,37 @@
{
config,
pkgs,
...
}:
{
# AppArmor: activate the LSM + load policies. Roll out in complain mode first
# (log violations, never block) so nothing can break; promote profiles to
# "enforce" individually once stable.
# AppArmor in complain mode: log violations instead of blocking.
services.dbus.apparmor = "enabled";
security.apparmor = {
enable = true;
# Do not SIGTERM running unconfined-but-confinable processes yet.
# Safe to flip to true later now that no global default-deny profile is active.
killUnconfinedConfinables = false;
# Packages contributing to AppArmor's include path (abstractions).
# NOTE: these abstractions are FHS-oriented and reference FHS paths. nixpkgs does NOT
# provide a broad FHS->store alias layer (only /run/current-system, /usr/bin/env and
# /bin/sh are created), so some referenced paths do not resolve on NixOS and the
# resulting profiles are incomplete. They are safe only because they run in complain
# mode (log-only, no blocking); see hardening/README.md.
# FHS-oriented abstractions, incomplete on NixOS; only safe in complain mode.
packages = [ pkgs.apparmor-profiles ];
policies = {
# Global default-deny scaffold. DANGEROUS to enable: `/**` matches every binary and
# the empty block allows nothing. Keep disabled until per-app profiles exist.
"default_deny" = {
state = "disable";
profile = "profile default_deny /** { }";
};
policies.sudo = {
state = "complain";
profile = ''
abi <abi/4.0>,
include <tunables/global>
# Confine sudo; complain mode so a missing rule logs instead of blocking.
"sudo" = {
state = "complain";
profile = ''
abi <abi/4.0>,
include <tunables/global>
# NOTE: exec must use the `ix` (inherit) modifier here: abstractions/base
# pulls in nested rules like `rix` on specific binaries (via xdg-open etc.),
# and AppArmor 5.0's parser rejects merged rules with conflicting exec
# modifiers ("profile has merged rule with conflicting x modifiers") when a
# broad rule uses Ux over those paths.
profile ${pkgs.sudo}/bin/sudo {
include <abstractions/base>
file /** rwlkix,
}
'';
};
# nix runs unconfined (no restriction); inert, kept disabled.
"nix" = {
state = "disable";
profile = "profile ${config.nix.package}/bin/nix { unconfined, }";
};
# Confine sudo (complain). `attach_disconnected` lets Nix 2.35's
# nixos-rebuild set the profile; `ix` keeps the parser happy.
#
# /proc/self/ns/mnt has no connected path, so AppArmor denies the open even in
# complain mode; Nix 2.35's root nix-env opens it in saveMountNamespace(), and
# nixos-rebuild aborts only while /nix/store is ro (<= 2.34 left it rw until
# reboot, 2.35 remounts in a namespace).
# abstractions/base has nested rix rules, and Ux makes AppArmor 5.0 reject
# the merged rules.
profile ${pkgs.sudo}/bin/sudo flags=(attach_disconnected) {
include <abstractions/base>
file /** rwlkix,
}
'';
};
};
}
+1
View File
@@ -70,6 +70,7 @@ appimageTools.wrapAppImage {
"--setenv GTK_IM_MODULE fcitx"
];
chdirToPwd = false;
# WeChat needs outbound network; everything else is unshared
unshareNet = false;
unshareIpc = true;
unsharePid = true;
+1 -1
View File
@@ -30,7 +30,7 @@ home/
2. **linux**: Linux-specific configuration
- Desktop environments (Noctalia Shell, Niri compositor)
- Headless computer-use session (see `gui/i3/README.md`)
- Headless computer-use session (see `linux/gui/i3/README.md`)
- Linux-specific GUI applications
- System integration tools
+3 -4
View File
@@ -27,6 +27,7 @@ systems.
- **dev-tools.nix**: Misc development and network tools (mitmproxy, wireshark)
- **media.nix**: Media players and utilities
- **zed-editor.nix**: Zed editor configuration (primary GUI editor)
- **rime/**: Rime (flypy) customisation shared by fcitx5-rime (Linux) and Squirrel (macOS)
- **terminal/**: Terminal emulator configurations
- **ghostty.nix**: Ghostty terminal (default)
- **kitty.nix**: Kitty terminal
@@ -57,10 +58,8 @@ All configurations in this directory are designed to work across:
- **Linux**: All distributions with Nix and Home Manager
- **macOS**: Darwin systems with Home Manager
- **WSL**: Windows Subsystem for Linux
## Usage
These base configurations provide the foundation for both Linux and Darwin systems, ensuring
consistent environments across different platforms while allowing for platform-specific
customizations.
These base configurations provide the foundation for both Linux and Darwin systems while allowing
for platform-specific customizations.
+3 -3
View File
@@ -52,7 +52,7 @@ tuios shortcuts used often (leader is `Ctrl + B`; same idea as in the Neovim not
In Helix, `|` / `!` and variants pipe or insert shell output on selections (see **Changes**).
This flake’s Helix Home Manager module keeps **almost all default keys** but adds several
This flake's Helix Home Manager module keeps **almost all default keys** but adds several
normal-mode remaps: **`Ctrl+Shift+o`** → jump backward (leaving `Ctrl+o` free for the shell),
`Space Space` → `:reload-all`, `Space w` / `Space q` → `:w` / `:q`, `Esc` → collapse selection, and
`$` / `0` line jumps (see `home/base/core/editors/helix/default.nix`).
@@ -206,7 +206,7 @@ Some bindings need an **LSP** or **tree-sitter** grammar; see notes on the keyma
1. Neovim has a huge plugin ecosystem.
1. Helix is newer; a stable plugin system is still evolving:
<https://github.com/helix-editor/helix/pull/8675>
1. Neovim has an integrated terminal (similar in spirit to VS Code’s).
1. Neovim has an integrated terminal (similar in spirit to VS Code's).
1. Helix does not ship one; use tuios / tmux / terminal features instead.
1. <https://github.com/helix-editor/helix/issues/1976#issuecomment-1091074719>
1. <https://github.com/helix-editor/helix/pull/4649>
@@ -215,7 +215,7 @@ Some bindings need an **LSP** or **tree-sitter** grammar; see notes on the keyma
1. Global substitution is weaker in Helix; run replacements in another pane (tuios) or an external
tool when needed.
1. <https://github.com/helix-editor/helix/issues/196>
1. Neovim’s `:s` with preview remains strong for interactive refactors; external tools (e.g.
1. Neovim's `:s` with preview remains strong for interactive refactors; external tools (e.g.
<https://github.com/ms-jpq/sad>) can fill gaps in Helix-centric flows.
1. Complexity vs batteries-included tradeoffs:
<https://github.com/helix-editor/helix/discussions/6356>
+1 -1
View File
@@ -135,7 +135,7 @@ Advanced patterns:
Notes:
- `\v` — “very magic”, less backslash noise in the pattern.
- `\v` — "very magic", less backslash noise in the pattern.
- `\1` — first capture group.
### Specific line ranges
-9
View File
@@ -23,10 +23,6 @@
lfs.enable = true;
signing.format = "openpgp";
# signing = {
# key = "xxx";
# signByDefault = true;
# };
includes = [
{
@@ -55,9 +51,6 @@
"ssh://git@github.com/ryan4yin" = {
insteadOf = "https://github.com/ryan4yin";
};
# "ssh://git@bitbucket.com/ryan4yin" = {
# insteadOf = "https://bitbucket.com/ryan4yin";
# };
};
alias = {
@@ -98,8 +91,6 @@
diff-so-fancy = true;
line-numbers = true;
true-color = "always";
# features => named groups of settings, used to keep related settings organized
# features = "";
};
};
+47
View File
@@ -0,0 +1,47 @@
# Rime (flypy) customisation
Personal Rime setup for the [flypy](https://flypy.com/) (小鹤音形) schema, shared by fcitx5-rime
(Linux) and Squirrel (macOS) so both behave the same.
## Files
- `flypy.custom.yaml`: the preferences, layered by Rime on top of the shared rime-data.
- `flypy_user.txt`: the user dictionary (custom phrases, symbols, missing characters).
- `default.nix`: per-platform wiring (see that file for the details).
The schema data comes from the `rime-data-flypy` package in `nur-ryan4yin` and stays untouched, so
updates survive. Personal preferences and the dictionary live here. On macOS the shared data
includes an empty `flypy_user.txt`, so the user files set `home.fileOverlapResolution = "override"`
to win over it.
## Preferences
- Right Shift switches CN/EN. Left Shift stays a plain modifier; Ctrl+Space also switches (fcitx5 on
Linux, the system input-source shortcut on macOS).
- Shift+Space does not toggle full/half width.
- `[ ] { }` produce corner brackets `「」『』`.
These sit in a schema-level patch rather than `default.custom.yaml` so they also override the
`default` preset and flypy's own bindings, and to avoid colliding with the `default.custom.yaml`
that ships in Squirrel's user directory.
## Hotkeys
The flypy schema brings its own bindings. Two worth remembering:
- Ctrl+J toggles simplified/traditional Chinese (简繁).
- Ctrl+. toggles Chinese/ASCII punctuation (中英标点).
## Applying changes
`flypy.custom.yaml` is a store symlink with an epoch mtime, so Rime does not notice when it changes.
Remove `build/` and reload the Rime addon:
```sh
# Linux: reload the Rime addon (`fcitx5-remote -r` only reloads fcitx5's own config)
rm -rf ~/.local/share/fcitx5/rime/build
busctl --user call org.fcitx.Fcitx5 /controller org.fcitx.Fcitx.Controller1 ReloadAddonConfig s rime
# macOS: remove build/, then restart Squirrel
rm -rf ~/Library/Rime/build
```
+42
View File
@@ -0,0 +1,42 @@
{
inputs,
lib,
pkgs,
...
}:
let
# flypy (小鹤音形) rime data from nur-ryan4yin (`pkgs/rime-data-flypy`). The
# package stays pristine; personal preferences live in flypy.custom.yaml.
rime-data-flypy = inputs.nur-ryan4yin.packages.${pkgs.stdenv.hostPlatform.system}.rime-data-flypy;
# Personal Rime customisation, layered by Rime on top of the shared rime-data.
custom = ./flypy.custom.yaml;
# Manually maintained user dictionary (custom phrases, symbols, missing
# characters); Rime reads it from the user directory.
user-dict = ./flypy_user.txt;
in
lib.mkMerge [
# Linux: fcitx5-rime, with its user directory in ~/.local/share/fcitx5/rime.
(lib.mkIf pkgs.stdenv.hostPlatform.isLinux {
# Chinese: flypy (小鹤音形) data instead of the default rime-data.
i18n.inputMethod.fcitx5.addons = [
(pkgs.fcitx5-rime.override { rimeDataPkgs = [ rime-data-flypy ]; })
];
xdg.dataFile."fcitx5/rime/flypy.custom.yaml".source = custom;
xdg.dataFile."fcitx5/rime/flypy_user.txt".source = user-dict;
})
# macOS: Squirrel reads shared data from ~/Library/Rime, so link the data there.
# Its `flypy_user.txt` template overlaps our dictionary, so the regular files
# below must win. This is the only recursive link in the configuration.
(lib.mkIf pkgs.stdenv.hostPlatform.isDarwin {
home.fileOverlapResolution = "override";
home.file."Library/Rime" = {
source = "${rime-data-flypy}/share/rime-data";
recursive = true;
# overwrite possible existing data dynamically generated by squirrel
force = true;
};
home.file."Library/Rime/flypy.custom.yaml".source = custom;
home.file."Library/Rime/flypy_user.txt".source = user-dict;
})
]
+52
View File
@@ -0,0 +1,52 @@
# Personal Rime customisation for the flypy (小鹤音形) schema, layered on top of
# the shared rime-data by Rime's <schema>.custom.yaml mechanism. See README.md.
patch:
# Right Shift switches CN/EN; left Shift stays a plain modifier. The stock
# flypy schema switches on Shift_L, so keep the explicit noop. Ctrl+Space also
# switches (fcitx5 on Linux; the system input-source shortcut on macOS).
ascii_composer/switch_key/Shift_L: noop
ascii_composer/switch_key/Shift_R: commit_code
# Disable the stock `Shift+space -> toggle full_shape` binding. flypy declares
# its own copy after the one imported from `default`, so the override must be a
# schema-level `bindings/+` (appended last, highest priority) with `unset_option`.
key_binder/bindings/+:
- { when: always, accept: "Shift+space", unset_option: full_shape }
# Prefer corner brackets over the upstream `【】{}` for [ ] { }.
"punctuator/full_shape/[":
- 「
- 【
- 〔
- [
"punctuator/full_shape/]":
- 」
- 】
- 〕
- ]
"punctuator/full_shape/{":
- 『
- 〖
- {
"punctuator/full_shape/}":
- 』
- 〗
- }
"punctuator/half_shape/[":
- 「
- 【
- 〔
- [
"punctuator/half_shape/]":
- 」
- 】
- 〕
- ]
"punctuator/half_shape/{":
- 『
- 〖
- {
"punctuator/half_shape/}":
- 』
- 〗
- }
File renamed without changes.
+2 -3
View File
@@ -1,8 +1,7 @@
# Terminal Emulators
I used to spend a lot of time on terminal emulators, to make them match my taste, but now I found
that it's not worth it, **tuios can provide a user-friendly and unified user experience for all
terminal emulators! without any pain**!
I used to spend a lot of time tweaking terminal emulators to match my taste. Now **tuios gives me a
consistent experience across all of them**.
Currently, I only use the most basic features of terminal emulators, such as true color, graphics
protocol, etc. Other features such as tabs, scrollback buffer, select/search/copy, etc, are all
-1
View File
@@ -21,7 +21,6 @@
pkgs.ghostty;
enableBashIntegration = false;
installBatSyntax = false;
# installVimSyntax = true;
settings = {
font-family = "Maple Mono NF CN";
font-size = 13;
+2 -3
View File
@@ -13,6 +13,8 @@ Nix dependency; this module only wires it into place.
- `packages.nix`: agent CLIs (`codex`, `opencode2`, `pi`) from the `llm-agents` flake input, plus
`pkgs.mcp-grafana` for the Grafana MCP server.
- `env.nix`: telemetry and auto-update opt-outs for the agents.
- `dsh/`: the shared dsh home-layer patch linked to `~/.dsh/cordis.patch.yml`. See
[dsh/README.md](./dsh/README.md) for why the shared layer is linked and the profile patch is not.
## Deployed rule targets
@@ -30,6 +32,3 @@ Out-of-store means an edit to `agents/AGENTS.md` takes effect on the next agent
Home Manager switch. The trade-off is that the rules stay writable in the checkout; use a store
symlink (`home.file.<target>.source = ../../../../agents/AGENTS.md`) if immutability matters more
than fast iteration.
The module is imported through `home/base/tui`, so it applies to every host that imports
`home/linux/gui.nix` or the macOS `home/darwin` stack. Core-only servers do not get it.
+63
View File
@@ -0,0 +1,63 @@
# dsh
Shared dsh (DeepSeek Harness) policy, linked into `~/.dsh/cordis.patch.yml`.
## Layers
dsh composes a profile from bundle patches, the profile's own `cordis.patch.yml`, then
`$DSH_HOME/cordis.patch.yml` (the "home" layer) and `--patch` overlays. The home layer is the only
one shared by every profile and surface, so the stable policy lives here.
| Layer | Path | Writer | Tracked |
| ------- | ----------------------------------------- | ----------------------------- | ------- |
| home | `~/.dsh/cordis.patch.yml` | nix-config; dsh only reads it | yes |
| profile | `~/.dsh/profiles/<name>/cordis.patch.yml` | dsh, at runtime | no |
dsh writes the profile patch but only reads the home layer, so linking the home layer is safe while
linking the profile patch would put runtime state in the checkout. Declared settings are edited
here, not in the Settings UI.
## Which hosts deploy it
A host only gets this link by importing the module. `home/linux/gui.nix` and `home/darwin` pull it
in through `home/base/tui`, so core-only servers miss it — `idols-ruby` installs dsh from
`environment.systemPackages` and imports `home/base/tui/agents/dsh` from its own home module. A new
host that ships dsh needs one of those two wirings.
## Default model route
`cordis.patch.yml` pins `agent-default-model` to the API-key route (`deepseek-official`). The
account route (`deepseek-account`) never falls back to an API key, so a host holding only
`DEEPSEEK_API_KEY` fails every freshly created session with `ACCOUNT_SIGN_IN_REQUIRED`. A host that
signs in instead can select an account model per session.
## Compaction
The web and desktop surfaces give each agent preset its own compaction service, so a top-level
`compaction-basic` row here never reaches a session. The effective knobs are the model
`contextWindow` and `maxTokens`: the `400000`/`32000` values set here place the first compaction
near 300k tokens.
## Private and local model routes
Endpoints that must not enter this repository — LAN/self-hosted servers and staging gateways — do
not belong in the home layer. Extend the base `llm-pi-ai` row from the profile patch instead:
```yaml
# ~/.dsh/profiles/<name>/cordis.patch.yml
- id: llm-pi-ai
name: "@deepseek-ai/dsh-llm-pi-ai"
config:
providers: { ... }
```
`dsh-llm-pi-ai` registers its built-in providers once, so mount only one instance — a second one
fails with `provider "..." is already declared`.
## Running it
`just dsh-web` starts the harness without opening a browser and routes its outbound HTTP through
mihomo's mixed port. dsh's web fetch refuses a DNS answer it does not call public, and a fake-ip
resolver answers with `198.18.0.0/15`; a proxied hop lets mihomo resolve the origin instead, which
skips that check and leaves fake-ip acceleration intact. The policy reaches every Node fetch the
harness makes, so mihomo becomes a dependency for LLM, web search and HTTP MCP traffic too.
+70
View File
@@ -0,0 +1,70 @@
# Shared dsh policy. Linked to ~/.dsh/cordis.patch.yml and applied as the
# $DSH_HOME ("home") layer, after each profile's own patch, so it covers every
# profile and surface. dsh only reads it — keep runtime preferences and local
# model routes in the profile patch (see README.md).
- id: agent-default-model
name: "@deepseek-ai/dsh-agent-default-model"
config:
provider: deepseek-official
model: deepseek-flash
reasoningEffort: high
- id: locale
name: "@deepseek-ai/dsh-client-locale"
config:
preference: zh
- id: agent-preset-registry
name: "@deepseek-ai/dsh-agent-preset-registry"
config:
default: standard
selectedDefault: ptc
- id: llm-deepseek
name: "@deepseek-ai/dsh-llm-deepseek-api-key"
config:
models:
- id: deepseek-flash
name: DeepSeek-V41-Flash
inputModalities:
- text
- image
systemPromptUpdate: in-history
toolUpdate: addition-only
contextWindow: 400000
maxTokens: 32000
- id: deepseek-v4-pro
name: DeepSeek-V4-Pro
description:
Stronger agentic coding, knowledge, and difficult reasoning; suited to complex or
quality-critical tasks at higher cost.
contextWindow: 500000
inputModalities:
- text
- id: llm-deepseek-account
name: "@deepseek-ai/dsh-llm-deepseek-account"
config:
models:
- id: deepseek-flash
name: DeepSeek-V41-Flash
inputModalities:
- text
- image
systemPromptUpdate: in-history
toolUpdate: addition-only
contextWindow: 400000
maxTokens: 32000
- id: deepseek-v4-pro
name: DeepSeek-V4-Pro
description:
Stronger agentic coding, knowledge, and difficult reasoning; suited to complex or
quality-critical tasks at higher cost.
contextWindow: 500000
inputModalities:
- text
- id: agent-loop
name: "@deepseek-ai/dsh-agent-loop"
config:
agents: []
maxParallelToolCalls: 8
- id: subagent
name: "@deepseek-ai/dsh-subagent"
config:
maxActiveSubagents: 3
+12
View File
@@ -0,0 +1,12 @@
{
config,
...
}:
let
# Out-of-store so repo edits apply without a rebuild (see README.md).
sharedPatch = "${config.home.homeDirectory}/nix-config/home/base/tui/agents/dsh/cordis.patch.yml";
in
{
# The shared dsh policy, read as $DSH_HOME/cordis.patch.yml.
home.file.".dsh/cordis.patch.yml".source = config.lib.file.mkOutOfStoreSymlink sharedPatch;
}
+5 -6
View File
@@ -37,8 +37,7 @@ Currently I use both age & GnuPG:
## Practical Cryptography for Developers
To use GnuGP without seamlessly, Some Practical Cryptography knowledge is required, here is dome
tutorials:
To use GnuPG seamlessly, some Practical Cryptography knowledge is required, here are some tutorials:
- English version: <https://github.com/nakov/Practical-Cryptography-for-Developers-Book>
- Chinese version: <https://thiscute.world/tags/cryptography/>
@@ -49,7 +48,7 @@ tutorials:
> ArchWiki's GnuPG page: <https://wiki.archlinux.org/title/GnuPG>
### 0. How GnuGP generate & protect your keypair?
### 0. How does GnuPG generate & protect your keypair?
Related Docs:
@@ -549,12 +548,12 @@ gpg --verify <file> <signature-file>
```bash
# Encrypt a file via recipient's public key, sign it via your private key for signing, and output cleartext.
# so that the reciiptent can decrypt it via his/her private key.
# so that the recipient can decrypt it via his/her private key.
gpg --armor --sign --encrypt --recipient ryan4yin@linux.com <file>
# or use this short version
gpg -aser ryan4yin@linux.com <file>
# Descrypt a file via your private key, and verify the signature via the sender's public key.
# Decrypt a file via your private key, and verify the signature via the sender's public key.
gpg --decrypt <file>
# or
gpg -d <file>
@@ -630,7 +629,7 @@ sub cv25519/0x9E78E897B6490D6B 2024-01-09 [E]
# encrypt some file before revoke the keypair
› gpg -are test@test.t README.md > README.md.asc
# try to decrypt the file, it should works
# try to decrypt the file, it should work
› gpg -d README.md.asc
gpg: encrypted with cv25519 key, ID 0x9E78E897B6490D6B, created 2024-01-09
"test <test@test.t>"
+6 -2
View File
@@ -5,7 +5,7 @@
- <https://github.com/gopasspw/gopass>: reimplement in go, with more features.
- Clients
- Android: <https://github.com/android-password-store/Android-Password-Store>
- Brosers(Chrome/Firefox): <https://github.com/browserpass/browserpass-extension>
- Browsers(Chrome/Firefox): <https://github.com/browserpass/browserpass-extension>
## How to change the gpg key of the pass password store?
@@ -31,6 +31,7 @@ To ensure security, we should change the GPG key every two or three years. Here
# then pass will re-encrypt all the passwords with the new key
pass init <new-key-id>
```
If `pass init` fails, fix the error and run it again before continuing.
6. Check if the key is changed:
```bash
# check which key is used by pass
@@ -38,7 +39,10 @@ To ensure security, we should change the GPG key every two or three years. Here
# check which key is really used to encrypt the password
gpg --list-packets path/to/any/password.gpg
```
7. Delete the old GPG key pair:
If `.gpg-id` still lists the old key, `pass init` did not apply the change. Re-run it from the
password store directory and confirm `.gpg-id` contains the new key.
7. Delete the old GPG key pair, but only after both checks in step 6 show the new key. Files still
encrypted to the old key cannot be decrypted after you delete it.
```bash
# delete the old key pair
gpg --delete-secret-keys <old-key-id>
+19
View File
@@ -1,5 +1,7 @@
{
config,
lib,
pkgs,
mysecrets,
...
}:
@@ -41,4 +43,21 @@
};
};
};
# Keep ~/.ssh/config a real, user-owned file rather than a /nix/store symlink.
#
# OpenSSH accepts a config owned by root or the invoking user, but
# bubblewrap-based sandboxes (`--unshare-user`) expose root-owned store files
# as `nobody`, which trips the check (`Bad owner or permissions`). Disabling
# the home.file entry keeps Home Manager's linker out of the way; `install`
# writes a fresh 0600 copy on each activation.
#
# Linux only: macOS' Seatbelt sandbox keeps store ownership intact, so the
# normal symlink is fine there.
home.file.".ssh/config".enable = lib.mkIf pkgs.stdenv.hostPlatform.isLinux false;
home.activation.sshConfigRegularFile = lib.mkIf pkgs.stdenv.hostPlatform.isLinux (
lib.hm.dag.entryAfter [ "linkGeneration" ] ''
run install -D -m 600 ${config.home.file.".ssh/config".source} "$HOME/.ssh/config"
''
);
}
-2
View File
@@ -9,8 +9,6 @@ This directory contains macOS-specific Home Manager configurations for Darwin sy
- **default.nix**: Entry point that imports all Darwin configurations
- **shell.nix**: Shell configurations and environment settings
- **terminal.nix**: Sets a 15px font size across Ghostty and Kitty
- **rime-squirrel.nix**: [Rime Squirrel](https://github.com/rime/squirrel) input method
configuration
### Network Configuration
-12
View File
@@ -1,12 +0,0 @@
{ pkgs, ... }:
{
# Squirrel Input Method
home.file."Library/Rime" = {
# my custom squirrel data (flypy input method)
source = "${pkgs.flypy-squirrel}/share/rime-data";
recursive = true;
# overwrite possible existing data dynamically generated by squirrel
# https://github.com/nix-community/home-manager/blob/release-23.05/modules/lib/file-type.nix#L101-L111
force = true;
};
}
+2 -2
View File
@@ -11,7 +11,7 @@ This directory contains host-specific Home Manager entry modules.
1. Each host output should reference only one file under `home/hosts/...`.
2. Shared home module imports should be handled in the host file itself.
- Linux hosts usually import `../../linux/core.nix` or `../../linux/gui.nix`.
- Darwin hosts import `../../darwin`.
- Linux hosts usually import `../linux/core.nix` or `../linux/gui.nix`.
- Darwin hosts import `../darwin`.
3. Host-specific overrides (SSH keys, desktop toggles, host-local config links) live in the same
host file.
+5
View File
@@ -2,6 +2,11 @@
imports = [
../../linux/core.nix
../../linux/gui/i3
# Ruby installs the dsh CLI system-wide from `hosts/idols-ruby/packages.nix`
# while running the core home stack, so it misses the agents module that the
# GUI hosts pull in through `home/linux/gui.nix`. Import just the dsh
# profile, which keeps its Settings-owned configuration in this repository.
../../base/tui/agents/dsh
];
# Headless X11/i3 session for computer use.
+2 -4
View File
@@ -1,13 +1,12 @@
# Home Manager's Linux Submodules
This directory contains Linux-specific Home Manager configurations organized for different use
cases.
This directory contains Linux-specific Home Manager configurations.
## Configuration Modules
### Core Configurations
- **core.nix**: Essential Linux-specific configurations and settings
- **core.nix**: Linux-specific configurations
- **base/**: Base Linux configurations including shell, tools, and utilities
- `shell.nix`: Shell configurations and aliases
- `tools.nix`: Essential command-line tools and utilities
@@ -29,4 +28,3 @@ cases.
- **Lightweight/Terminal**: Use `core.nix` or `tui.nix` for terminal-focused setups
- **Desktops**: Use `gui.nix` for full desktop environments with Noctalia Shell and Niri compositor
- **Custom**: Mix and match configurations as needed for your specific use case
+10 -11
View File
@@ -1,21 +1,20 @@
# Base Desktop Environment Configuration
This directory contains base configurations for Linux desktop environments, providing essential
components for a complete Wayland desktop experience.
This directory contains base configurations for Linux desktop environments.
## Overview
The configuration is organized into modular components that can be selectively enabled:
The configuration is split into modules:
- **Desktop Shell**: Noctalia Shell for unified desktop environment
- **Applications**: Desktop tools, browsers, editors, media players, etc.
- **Development Tools**: IDEs and development utilities
- **System Integration**: Input methods, theming, XDG specifications, GPU settings
- Desktop shell: Noctalia Shell
- Applications: desktop tools, browsers, editors, media players
- Development tools: IDEs and development utilities
- System integration: input methods, theming, XDG specifications, GPU settings
## Noctalia
**Noctalia** (v5) is a native C++/Wayland all-in-one desktop shell that replaces multiple separate
tools with a single, unified solution. It is installed through the upstream
**Noctalia** (v5) is a native C++/Wayland desktop shell that replaces multiple separate tools. It is
installed through the upstream
[`programs.noctalia`](https://docs.noctalia.dev/noctalia/getting-started/nixos/) Home Manager
module.
@@ -62,9 +61,9 @@ Noctalia consolidates functionality that previously required multiple tools:
- **[`noctalia/config/config.toml`](./noctalia/config/config.toml)**: declarative baseline (v5
TOML), tracked in the repo and hot-reloaded
Key features: bar and widgets, control center, desktop widgets, night light, wallpaper, session
Covers the bar and widgets, control center, desktop widgets, night light, wallpaper, session
panel, screenshots with annotation, system monitor, audio/volume, brightness, calendar/weather,
color schemes, dock, notifications, OSD, clipboard, and more.
color schemes, dock, notifications, OSD, and clipboard.
- **[`hypridle/`](./hypridle/)**: Idle management
+8 -1
View File
@@ -7,6 +7,14 @@
"MOZ_WEBRENDER" = "1";
# enable native Wayland support for most Electron apps
"ELECTRON_OZONE_PLATFORM_HINT" = "auto";
# Make Qt apps follow the system light/dark live. Noctalia's theme mode
# writes org.gnome.desktop.interface color-scheme, and this platform theme
# (shipped by qtbase) reads it over the XDG desktop portal.
# Do not switch to `gtk3`: it would align Qt's font with `gtk-font-name`
# (Noto Sans 11), but GTK3 has no dynamic dark/light signal, so Qt apps like
# Telegram would be stuck on the light palette. Qt's default font stays
# "Sans Serif" 9; only a font-providing theme can change that size.
"QT_QPA_PLATFORMTHEME" = "xdgdesktopportal";
# misc
"_JAVA_AWT_WM_NONREPARENTING" = "1";
"QT_WAYLAND_DISABLE_WINDOWDECORATION" = "1";
@@ -31,6 +39,5 @@
# auto mount usb drives
services = {
udiskie.enable = true;
# syncthing.enable = true;
};
}
+14 -1
View File
@@ -2,11 +2,24 @@
fcitx5 is enabled in `default.nix` with the [flypy](https://flypy.com/) Rime schema (Chinese),
`fcitx5-mozc-ut` (Japanese), and `fcitx5-hangul` (Korean), alongside the US keyboard layouts. The
Rime data ships in the [`overlays/fcitx5`](../../../../../overlays/fcitx5/) overlay.
Rime data comes from the `rime-data-flypy` package in `nur-ryan4yin` (`pkgs/rime-data-flypy`); the
whole Rime configuration, including the `fcitx5-rime` addon and the user customisation shared with
macOS, lives in `home/base/gui/rime/` (see its README).
## Available Configurations
- `fcitx5/config` (global config) → `~/.config/fcitx5/config`; pins `AltTriggerKeys` (see below).
- `profile` → Symlink will be created at: `~/.config/fcitx5/profile`
- `mozc-config1.db` (Mozc config) → Symlink will be created at: `~/.config/mozc/config1.db`
- Main changes from the defaults: use half-width for all alphabets, numbers, and punctuation.
- https://github.com/google/mozc/blob/2.30.5544.102/docs/configurations.md
## Shift keys
- Right Shift: switch CN/EN, through Rime.
- Left Shift: plain modifier.
- Ctrl+Space: switch CN/EN (fcitx5's `TriggerKeys`).
fcitx5's `AltTriggerKeys` (the "temporarily toggle input method" hotkey) defaults to `Shift_L`, so
it would toggle on left Shift; it is empty here. The Rime side, `Shift_R` as `commit_code` and
`Shift_L` as `noop`, is in `home/base/gui/rime/flypy.custom.yaml` (shared with macOS).
+18 -10
View File
@@ -1,4 +1,8 @@
{ config, pkgs, ... }:
{
config,
pkgs,
...
}:
{
catppuccin.fcitx5.enable = false;
xdg.configFile = {
@@ -8,16 +12,20 @@
# so we need to force replace it in every rebuild to avoid file conflict.
force = true;
};
# `AltTriggerKeys` (the "temporarily toggle input method" hotkey) would
# toggle on left Shift, its default being Shift_L. Keep it empty so only
# right Shift (through Rime) and Ctrl+Space switch CN/EN. force = true
# because fcitx5 rewrites this file at runtime, like `profile`.
"fcitx5/config" = {
text = ''
[Hotkey/AltTriggerKeys]
'';
force = true;
};
"mozc/config1.db".source =
config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/nix-config/home/linux/gui/base/fcitx5/mozc-config1.db";
};
xdg.dataFile."fcitx5/rime/default.custom.yaml".text = ''
patch:
ascii_composer/switch_key/Shift_L: noop
ascii_composer/switch_key/Shift_R: commit_code
'';
i18n.inputMethod = {
enable = true;
type = "fcitx5";
@@ -26,9 +34,9 @@
qt6Packages.fcitx5-configtool # GUI for fcitx5
fcitx5-gtk # gtk im module
# Chinese
fcitx5-rime # for flypy chinese input method
# fcitx5-chinese-addons # we use rime instead
# Chinese: the flypy (小鹤音形) fcitx5-rime addon is wired in
# home/base/gui/rime/default.nix, which is also where the rime-data-flypy
# package is resolved. fcitx5-chinese-addons is not used.
# Japanese
# ctrl-i / F7 - convert to takakana
+6 -7
View File
@@ -1,6 +1,5 @@
{
pkgs,
pkgs-x64,
osConfig,
config,
lib,
@@ -44,12 +43,12 @@ in
# required by some games to fix problems
bbe
])
++ (with pkgs-x64; [
++ (with pkgs; [
# Heroic Games Launcher - primarily for Epic Games & GOG
# https://heroicgameslauncher.com/
(heroic.override {
extraPkgs = _pkgs: [
pkgs.gamescope # aarch64
pkgs.gamescope
];
})
]);
@@ -60,13 +59,13 @@ in
# https://lutris.net/games?ordering=-popularity
programs.lutris = {
enable = true;
defaultWinePackage = pkgs-x64.proton-ge-bin;
defaultWinePackage = pkgs.proton-ge-bin;
steamPackage = osConfig.programs.steam.package;
protonPackages = [ pkgs-x64.proton-ge-bin ];
winePackages = with pkgs-x64; [
protonPackages = [ pkgs.proton-ge-bin ];
winePackages = with pkgs; [
wineWow64Packages.full
];
extraPackages = with pkgs-x64; [
extraPackages = with pkgs; [
winetricks
gamescope
gamemode
-8
View File
@@ -17,14 +17,6 @@
size = 24;
};
# set dpi for 4k monitor
xresources.properties = {
# dpi for Xorg's font
"Xft.dpi" = 150;
# or set a generic dpi
"*.dpi" = 150;
};
# gtk's theme settings, generate files:
# 1. ~/.gtkrc-2.0
# 2. ~/.config/gtk-3.0/settings.ini
+20 -17
View File
@@ -1,29 +1,32 @@
{
pkgs,
pkgs-x64,
lib,
...
}:
# media - control and enjoy audio/video
{
home.packages = with pkgs; [
# audio control
pavucontrol
playerctl
pulsemixer
imv # simple image viewer
home.packages =
with pkgs;
[
# audio control
pavucontrol
playerctl
pulsemixer
imv # simple image viewer
# music
go-musicfox # TUI NetEase Cloud Music client; plays through mpv (configured below)
# music
go-musicfox # TUI NetEase Cloud Music client; plays through mpv (configured below)
# video/audio tools
libva-utils
vdpauinfo
vulkan-tools
mesa-demos
nvitop
# video/audio tools
libva-utils
vdpauinfo
vulkan-tools
mesa-demos
nvitop
]
# Zoom: Settings > Share Screen > Advanced > Screen Capture Mode on Wayland > PipeWire Mode.
(pkgs-x64.zoom-us)
];
# zoom-us ships only an x86_64 Linux client, so the aarch64 host skips it.
++ lib.optionals pkgs.stdenv.hostPlatform.isx86_64 [ pkgs.zoom-us ];
programs.mpv = {
enable = true;
@@ -21,11 +21,43 @@ setup_wizard_enabled = false
annotate = true
directory = "~/Pictures/Screenshots"
# Session (power) menu: any explicit action list replaces the built-in defaults,
# so re-declare all five default actions. Everything except lock gets a 10 s
# confirm countdown: first press arms it, press again to run now, Esc or moving away cancels.
[[shell.session.actions]]
action = "lock"
shortcut = "1"
[[shell.session.actions]]
action = "logout"
shortcut = "2"
countdown_seconds = 10
[[shell.session.actions]]
action = "lock_and_suspend"
shortcut = "3"
countdown_seconds = 10
[[shell.session.actions]]
action = "reboot"
shortcut = "4"
countdown_seconds = 10
[[shell.session.actions]]
action = "shutdown"
shortcut = "5"
variant = "destructive"
countdown_seconds = 10
# On-screen display popups: the input-method/keyboard-layout OSD shows on every
# IM change (e.g. focusing an input box), so keep it clear of the top bar in the
# bottom-right corner. Also moves volume, brightness, and the other OSD kinds.
[osd]
position = "bottom_right"
# go-musicfox posts its own desktop notification on every track change, so the
# MPRIS media OSD would be a second popup.
[osd.kinds]
media = false
# Desktop notification toasts (separate from the OSD above); same bottom-right
# corner so transient popups no longer sit under the top bar.
+12 -3
View File
@@ -1,8 +1,17 @@
# Fcitx5 Vinput
On `ai` and `shoukei`, install a Sherpa-ONNX model, then hold and release **right Alt** to dictate.
**Right Shift** toggles Chinese/English; **left Shift** remains a normal modifier. Open Vinput from
the application launcher for settings.
Voice input on `ai` and `shoukei`, backed by a Sherpa-ONNX model. Open Vinput from the application
launcher for settings.
## Key bindings
- Right Alt: record. Hold and release to dictate.
- Right Ctrl: open the command palette (`/model /asr /scene /proc`).
Vinput resolves `TriggerKey` > `CommandKeys` > `MenuKey`. `TriggerKey` is right Alt by default; the
config sets `MenuKey` to right Ctrl and clears `CommandKeys`, which otherwise defaults to right Ctrl
and would shadow `MenuKey`. The addon reads list options as `[Option]` plus `0=`, not the
`[Trigger]` shorthand in upstream's `vinput-config(5)` man page.
## One-time setup (CLI)
+9 -2
View File
@@ -15,11 +15,18 @@ in
config = lib.mkIf cfg.enable {
i18n.inputMethod.fcitx5.addons = [ vinput ];
# MenuKey opens the command palette; set it to right Ctrl. `CommandKeys`
# (voice command on the selection) defaults to right Ctrl and outranks
# `MenuKey`, so clear it or the palette never opens. List options use
# fcitx5's `[Option]` + `0=` form, not upstream's `[Trigger]` shorthand.
xdg.configFile."fcitx5/conf/vinput.conf" = {
text = ''
[Trigger]
MenuKey=Super_R
[MenuKey]
0=Control_R
[CommandKeys]
'';
# fcitx5 rewrites this file at runtime, like `profile` and `config`.
force = true;
};
+4 -5
View File
@@ -1,6 +1,5 @@
{
pkgs,
pkgs-x64,
config,
lib,
...
@@ -58,7 +57,7 @@ let
${lib.optionalString cfg.cuaDriver ''
# cua-driver sends content-free telemetry by default; turn it off.
${pkgs-x64.cua-driver}/bin/cua-driver telemetry disable >/dev/null 2>&1 || true
${pkgs.cua-driver}/bin/cua-driver telemetry disable >/dev/null 2>&1 || true
''}
'';
in
@@ -84,10 +83,10 @@ in
]
++ [
# MCP server / CLI that drives the desktop (see overlays/computer-use-linux.nix).
pkgs-x64.computer-use-linux
pkgs.computer-use-linux
]
++ lib.optional cfg.vnc pkgs.x11vnc
++ lib.optional cfg.cuaDriver pkgs-x64.cua-driver;
++ lib.optional cfg.cuaDriver pkgs.cua-driver;
# Headless X server.
systemd.user.services.xvfb = {
@@ -202,7 +201,7 @@ in
"DISPLAY=${display}"
"XDG_SESSION_TYPE=x11"
];
ExecStart = "${pkgs-x64.cua-driver}/bin/cua-driver serve";
ExecStart = "${pkgs.cua-driver}/bin/cua-driver serve";
Restart = "always";
RestartSec = 2;
};
+3
View File
@@ -4,6 +4,7 @@
mylib,
agenix,
mysecrets,
inputs,
...
}:
{
@@ -15,6 +16,7 @@
restartIfChanged = true;
specialArgs = {
inherit
inputs
myvars
mylib
agenix
@@ -29,6 +31,7 @@
restartIfChanged = true;
specialArgs = {
inherit
inputs
myvars
mylib
agenix
+23 -2
View File
@@ -2,8 +2,29 @@
This is NixOS's configuration for my Macbook Pro 2022 M2, 16G RAM.
This laptop joins untrusted networks and uses DHCP instead of a static IP, so it has no entry in
`vars/networking.nix`.
This laptop joins untrusted networks and uses DHCP by default. On the home Wi-Fi
(`shadow_light_ryan`) run `just shoukei-home-wifi` to pin `192.168.5.108`; the recipe calls
[`scripts/shoukei-home-wifi-static.nu`](../../scripts/shoukei-home-wifi-static.nu), and
`vars/networking.nix` records the address with `homeOnly = true`.
## x86/x86_64 applications
The M2 uses 16 KiB pages, and FEX does not emulate 4 KiB guest pages, so x86/x86_64 binaries cannot
run directly on this kernel. [`game/`](./game/default.nix) enables `programs.x86-on-arm` from
[our fork](https://github.com/ryan4yin/nix-x86-on-aarch64) of
[rowanG077/nix-x86-on-aarch64](https://github.com/rowanG077/nix-x86-on-aarch64), which runs FEX
inside a 4 KiB `muvm` microVM and registers both ELF handlers:
- run an x86/x86_64 ELF directly, or use `x86-arm run <program>`;
- `nix-shell -p x86pkgs.hello --run hello` for the x86 package set;
- `steam` and `x86-arm-wine` for games and Windows programs.
The microVM is capped at 6 GiB (`memoryMiB`) on this 16 GiB machine, and needs `/dev/kvm` plus a
running systemd user session. See [WORKAROUNDS.md](../../WORKAROUNDS.md) WA-021.
Because the host no longer registers qemu-user binfmt, `podman run --platform=linux/amd64`, x86
chroots, and local builds of uncached x86 derivations need a remote x86_64 builder (see
[WORKAROUNDS.md](../../WORKAROUNDS.md) WA-022).
Related:
+7 -15
View File
@@ -14,6 +14,7 @@
# without any authentication whenever the session exits, e.g. logout from the lock
# screen would bypass it entirely). Keep tuigreet from modules/nixos/desktop.nix.
# 16G machine: more compressed swap than the 50% default
zramSwap.memoryPercent = lib.mkForce 75;
nix.settings = {
@@ -25,20 +26,15 @@
];
};
environment.systemPackages = with pkgs; [
box64 # Linux Userspace x86 and x86_64 Emulator, run x86_64 apps(such as games, gui apps) on aarch64.
# https://asahilinux.org/2024/12/muvm-x11-bridging/
# https://github.com/nix-community/nixos-apple-silicon/issues/237
# muvm # run x86_64 Apps/Games in a microVM, used as a workaround of apple silicon's 16k page size.
];
# networking.wireless.iwd = {
# enable = true;
# settings.DriverQuirks.DefaultInterface = true;
# };
# configures the network interface(include wireless) via `nmcli` & `nmtui`
networking.networkmanager.enable = true;
# BCM4378/brcmfmac: disable Wi-Fi power saving. Powersave is a common source
# of intermittent association failures / authentication timeouts, which NM
# mistakes for a bad key, re-prompts, and lets the client (Noctalia, nmtui,
# nmcli) save as a duplicate "<SSID> 1" profile. See WORKAROUNDS.md WA-024/025.
networking.networkmanager.wifi.powersave = false;
# Specify path to peripheral firmware files.
hardware.asahi = {
enable = true;
@@ -258,8 +254,4 @@
};
};
# For ` to < and ~ to > (for those with US keyboards)
# boot.extraModprobeConfig = ''
# options hid_apple iso_layout=0
# '';
}
+4 -1
View File
@@ -14,11 +14,14 @@ in
{
imports = [
./hardware-configuration.nix
./game
# shoukei reuses ai's preservation layout; no host-specific overrides yet
../idols-ai/preservation.nix
];
# disable sunshine for securrity
# disable sunshine for security
services.sunshine.enable = lib.mkForce false;
# battery-first: override the profile default
services.tuned.ppdSettings.main.default = lib.mkForce "power-saver";
# Laptop joins untrusted networks and is never scraped (see youko's
+17
View File
@@ -0,0 +1,17 @@
# x86/x86_64 applications and games on this Apple Silicon host.
#
# FEX cannot run on the 16K pages this machine boots with, so
# nix-x86-on-aarch64 runs FEX inside a 4K-page muvm microVM and owns the
# x86_64/i686 ELF handlers. Pinned to our fork; see WORKAROUNDS.md WA-021.
{ nix-x86-on-aarch64, ... }:
{
imports = [ nix-x86-on-aarch64.nixosModules.default ];
programs.x86-on-arm = {
enable = true;
steam.enable = true;
wine.enable = true;
# 16 GiB machine: cap what the guest may demand instead of muvm's 80% default.
memoryMiB = 6144;
};
}
@@ -23,14 +23,9 @@ in
# depending on how you configured your disk mounts, change this to /boot or /boot/efi.
boot.loader.efi.efiSysMountPoint = "/boot";
# Enable binfmt emulation of aarch64-linux, this is required for cross compilation.
boot.binfmt.emulatedSystems = [
"x86_64-linux"
"riscv64-linux"
];
# This enables the kernel to preload the emulator binaries when the binfmt registrations are added,
# obviating the need to make the emulator binaries available inside chroots and chroot-like sandboxes.
boot.binfmt.preferStaticEmulators = true; # required to work with podman
# Foreign-architecture emulation is not used on this host: x86/x86_64 programs
# run through `./game` (FEX inside a muvm microVM), which owns the x86_64/i686
# ELF handlers, and qemu-user cannot run them on 16K pages anyway.
nixpkgs.overlays = [
(final: previous: {
# https://github.com/NixOS/nixpkgs/issues/392673
+5 -2
View File
@@ -4,6 +4,7 @@
mylib,
agenix,
mysecrets,
inputs,
...
}:
{
@@ -15,6 +16,7 @@
restartIfChanged = true;
specialArgs = {
inherit
inputs
myvars
mylib
agenix
@@ -29,6 +31,7 @@
restartIfChanged = true;
specialArgs = {
inherit
inputs
myvars
mylib
agenix
@@ -39,8 +42,8 @@
};
# Attach the guest's tap to the VM bridge, the same way the physical NIC is
# attached. The tap name is derived from the guest IP (192.168.5.116 -> vm116,
# 192.168.5.113 -> vm113), as IFNAMSIZ caps interface names at 15 characters.
# attached. The name is vm<last IP octet> from lib/genMicrovmGuestModule.nix:
# 192.168.5.116 -> vm116, 192.168.5.113 -> vm113.
systemd.network.networks."20-vm116" = {
matchConfig.Name = [ "vm116" ];
networkConfig = {
@@ -9,20 +9,30 @@ retired `idols-aquamarine` guest):
## Features
Services:
### Storage and data
1. caddy: Reverse proxy / TLS front end and the `file.writefor.fun` file server.
1. gitea: Self-hosted git service.
1. sftpgo: SFTP / WebDAV server.
1. transmission: BitTorrent client.
1. postgresql: Database for the homelab services.
1. restic: Encrypted backups; hosts the REST server the desktops push to.
1. victoriametrics + vmalert + alertmanager + grafana: Monitor the metrics of my homelab.
1. homepage + uptime-kuma: Service dashboard and uptime checks.
1. immich: Photo and video library with ML search.
1. jellyfin: Media server.
1. rustfs: S3-compatible object storage (Loki chunks and Terraform state).
1. valkey: Redis-compatible cache for Immich.
1. gitea: Self-hosted git service (`gitea.nix`).
1. sftpgo: SFTP / WebDAV server (`sftpgo.nix`).
1. postgresql: Database for the homelab services (`postgresql.nix`).
1. valkey: Redis-compatible cache for Immich (`valkey.nix`).
### Backups and object storage
1. restic: Encrypted backups; hosts the REST server the desktops push to (`../default.nix`).
1. rustfs: S3-compatible object storage (Loki chunks and Terraform state) (`rustfs.nix`).
### Media
1. immich: Photo and video library with ML search (`immich/`).
1. jellyfin: Media server (`jellyfin.nix`).
1. transmission: BitTorrent client (`transmission.nix`).
### Network and observability
1. caddy: Reverse proxy / TLS front end and the `file.writefor.fun` file server (`caddy.nix`).
1. victoriametrics + vmalert + alertmanager + grafana: Monitor the metrics of my homelab
(`monitoring/`).
1. homepage + uptime-kuma: Service dashboard and uptime checks (`oci-containers/`).
All the services assume a reverse proxy in front: they listen on localhost, and a caddy service
listens on the local network interface and proxies requests to them. The exception is transmission,
@@ -100,14 +100,13 @@ document is the agreed design and the rationale.
tmpfiles).
3. `../caddy.nix`: the `immich.writefor.fun` vhost.
4. `../oci-containers/homepage/config/services.yaml`: dashboard entry.
5. Preview and deploy: `colmena apply dry-activate --on '@youko'`, then
`colmena apply switch --on '@youko'`.
5. Preview and deploy: `just youko dry-activate`, then `just youko`.
6. Register the first user (becomes admin), disable open signup, add the external library, trigger a
scan.
## Validation
- `just fmt`; `just test` -> `true`; `nix build` the youko toplevel.
- `just fmt`; `just test` passes; `nix build` the youko toplevel.
- Postgres: `\dx` lists `vectorchord`/`pgvector`; `SHOW shared_preload_libraries` includes
`vchord.so`; the `immich` DB exists.
- Units: `immich-server`, `immich-machine-learning`, `redis-shared`, `postgresql` are active.
@@ -422,7 +422,7 @@ groups:
- alert: KubernetesApiServerLatency
expr:
'histogram_quantile(0.99,
sum(rate(apiserver_request_duration_seconds_bucket{subresource!="log",verb!~"^(?:CONNECT|WATCHLIST|WATCH|PROXY)$"}
sum(rate(apiserver_request_duration_seconds_bucket{subresource!="log",subresource!~"^openapi/",verb!~"^(?:CONNECT|WATCHLIST|WATCH|PROXY)$"}
[10m])) WITHOUT (instance, resource)) > 1'
for: 2m
labels:
@@ -307,8 +307,8 @@ groups:
- alert: HostPhysicalComponentTooHot
expr:
'((node_hwmon_temp_celsius * ignoring(label) group_left(instance, job, node, sensor)
node_hwmon_sensor_label{label!="tctl"} > 75)) * on(instance) group_left (nodename)
node_uname_info{nodename=~".+"}'
node_hwmon_sensor_label{label!~"(?i)^(tctl|tccd|tdie)$"} > 75)) * on(instance) group_left
(nodename) node_uname_info{nodename=~".+"}'
for: 5m
labels:
severity: warning
@@ -70,8 +70,11 @@ groups:
description: "{{ $value }} unrecovered data-integrity errors recorded."
# Drive temperature (SSD/HDD). Consumer M.2 NVMe throttles around 70-80 C.
# The metric carries the drive's rated `op_limit_max`/`critical_limit_max`
# alongside `current`; without `temperature_type="current"` the max() alerts on
# those constant limits (e.g. youko's 120/130 C) instead of the real reading.
- alert: DriveTemperatureHigh
expr: max by (host, device) (smartctl_device_temperature) > 70
expr: max by (host, device) (smartctl_device_temperature{temperature_type="current"}) > 70
for: 15m
labels:
severity: warning
@@ -80,7 +83,7 @@ groups:
description: "Drive temperature above 70 C; NVMe throttles around 70-80 C."
- alert: DriveTemperatureCritical
expr: max by (host, device) (smartctl_device_temperature) > 80
expr: max by (host, device) (smartctl_device_temperature{temperature_type="current"}) > 80
for: 5m
labels:
severity: critical
@@ -95,16 +95,20 @@ in
# "local" is for Unix domain socket connections only
local all all peer map=superuser_map
# IPv4 local connections:
# TCP loopback: application roles may still connect without a password
# (Immich, the exporter), but the superuser and replication may not. That
# is the path a compromised local service would take. No password is set
# for postgres, so these lines deny it over TCP.
host all postgres 127.0.0.1/32 scram-sha-256
host all postgres ::1/128 scram-sha-256
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
# Replication connections from loopback require a password too.
local replication all peer map=superuser_map
host replication all 127.0.0.1/32 scram-sha-256
host replication all ::1/128 scram-sha-256
# Other Remote Access - allow access only the database with the same name as the user
host sameuser all ${myvars.networking.lanCidr} scram-sha-256
@@ -0,0 +1,53 @@
{
pkgs,
...
}:
let
# The restic REST server store, and a directory on the sibling @snapshots
# subvolume (same btrfs pool), so the snapshots are real subvolumes the
# desktop has no path to.
source = "/data/backups";
snapshotRoot = "/data/apps-snapshots/restic";
keepDays = 14;
in
{
# The REST server is deliberately not append-only: the desktop holds both the
# data and its repository password and still needs to run retention. That
# leaves the repository deletable by anyone holding the desktop's REST
# credentials. A read-only snapshot the desktop cannot reach makes a
# `forget --prune` recoverable without giving up retention.
systemd.tmpfiles.rules = [
"d ${snapshotRoot} 0700 root root -"
];
systemd.services.restic-server-snapshot = {
description = "Read-only btrfs snapshot of the restic server store";
serviceConfig = {
Type = "oneshot";
User = "root";
};
path = [
pkgs.btrfs-progs
pkgs.coreutils
pkgs.findutils
];
script = ''
set -euo pipefail
stamp=$(date +%Y%m%d%H%M%S)
btrfs subvolume snapshot -r ${source} ${snapshotRoot}/backups.$stamp
# Drop snapshots older than ${toString keepDays} days. The desktop cannot
# reach this tree, so it cannot shorten the window.
find ${snapshotRoot} -mindepth 1 -maxdepth 1 -type d -mtime +${toString keepDays} -print0 |
xargs -0 -r -n1 btrfs subvolume delete
'';
unitConfig.RequiresMountsFor = source;
};
systemd.timers.restic-server-snapshot = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "hourly";
Persistent = true;
};
};
}
+5 -2
View File
@@ -4,6 +4,7 @@
mylib,
agenix,
mysecrets,
inputs,
...
}:
{
@@ -15,6 +16,7 @@
restartIfChanged = true;
specialArgs = {
inherit
inputs
myvars
mylib
agenix
@@ -31,6 +33,7 @@
restartIfChanged = true;
specialArgs = {
inherit
inputs
myvars
mylib
agenix
@@ -41,8 +44,8 @@
};
# Attach the guest's tap to the VM bridge, the same way the physical NIC is
# attached. The tap name is derived from the guest IP (192.168.5.115 -> vm115,
# 192.168.5.112 -> vm112), as IFNAMSIZ caps interface names at 15 characters.
# attached. The name is vm<last IP octet> from lib/genMicrovmGuestModule.nix:
# 192.168.5.115 -> vm115, 192.168.5.112 -> vm112.
systemd.network.networks."20-vm115" = {
matchConfig.Name = [ "vm115" ];
networkConfig = {
+23 -11
View File
@@ -1,19 +1,29 @@
{
myvars,
lib,
...
}:
let
# Shared golden-image store for the VM cluster. It is exported over
# NFSv4 so the cluster's NFS CSI driver can hand out RWX volumes to every
# node, and VM disks are cloned from it into local-path.
# Shared golden-image store for the VM cluster. It is exported over NFSv4 so
# the cluster's NFS CSI driver can hand out RWX volumes to every node, and VM
# disks are cloned from it into local-path.
#
# It lives on the encrypted btrfs pool (/persistent), which has plenty of
# free space on this host.
goldenDir = "/persistent/nfs/golden";
# Only the homelab LAN may mount the export; the VM hosts and the k3s nodes
# (which run the NFS-CSI node plugin) are all on it. The store is not
# sensitive, so the whole LAN is fine rather than an explicit client list.
clientCidr = "192.168.5.0/24";
# Only the hosts that actually mount the export may reach it: every k3s node
# runs the NFS CSI node plugin, and the VM hosts clone golden disks by hand.
# The rest of the LAN is not a client.
k3sNodes = lib.filterAttrs (name: _: lib.hasPrefix "k3s-test-1-" name) myvars.networking.hostsAddr;
clients = [
myvars.networking.hostsAddr.shoryu.ipv4
myvars.networking.hostsAddr.shushou.ipv4
myvars.networking.hostsAddr.youko.ipv4
]
++ lib.mapAttrsToList (_: v: v.ipv4) k3sNodes;
exportOpts = "rw,sync,no_subtree_check,fsid=0,no_root_squash";
in
{
# Make sure the export directory exists before the NFS server starts.
@@ -22,10 +32,12 @@ in
];
services.nfs.server.enable = true;
services.nfs.server.exports = ''
${goldenDir} ${clientCidr}(rw,sync,no_subtree_check,fsid=0,no_root_squash)
'';
services.nfs.server.exports = lib.concatStringsSep "\n" (
map (client: "${goldenDir} ${client}(${exportOpts})") clients
);
# NFSv4 only needs 2049/tcp (no rpcbind/mountd/statd). The export is limited
# to the LAN, and the shared firewall trusts the LAN.
# to the hosts above, not the whole LAN. `no_root_squash` stays until the
# existing root-owned PVC subdirectories are migrated for `root_squash`; see
# SECURITY.md.
}
+26 -8
View File
@@ -10,13 +10,31 @@ This directory contains all host-specific configurations for my NixOS and macOS
Named after characters from "Oshi no Ko":
| Host | Platform | Hardware | Purpose | Status |
| ------------ | --------------- | --------------------- | --------------------- | ----------- |
| `ai` | NixOS | i5-13600KF + RTX 4090 | Gaming & Daily Use | ✅ Active |
| `aquamarine` | NixOS (libvirt) | Virtual | Monitoring & Services | ⚪ Not Used |
| `kana` | NixOS (libvirt) | Virtual | Run AI Agents | ✅ Active |
| `ruby` | NixOS (libvirt) | Virtual | Run AI Agents | ✅ Active |
| `akane` | NixOS (aarch64) | Virtual (UTM) | aarch64 test VM | ✅ Active |
| Host | Platform | Hardware | Purpose | Status |
| ------- | --------------- | --------------------------------------- | ------------------ | --------- |
| `ai` | NixOS | Ultra 7 270K Plus + RTX 4090, 128G DDR5 | Gaming & Daily Use | ✅ Active |
| `kana` | NixOS (libvirt) | Virtual | Run AI Agents | ✅ Active |
| `ruby` | NixOS (libvirt) | Virtual | Run AI Agents | ✅ Active |
| `akane` | NixOS (aarch64) | Virtual (UTM) | aarch64 test VM | ✅ Active |
On 2026-04-27 `ai` was rebuilt on a new platform. The MSI board and i5-13600KF it was added with in
2023-05 (the host was originally named `msi-rtx4090`) gave way to the Colorful CVN Z890 ARK FROZEN +
Intel Core Ultra 7 270K Plus. The traces in the history are PR #257 (the NIC moved from `enp5s0` to
`enp130s0`) and PR #258 (Niri output names renamed, `hardware-intel.nix` added with the Arrow Lake
NPU, kernel moved to `linuxPackages_latest`). The 2×48G DDR5 kit was already in place at that point;
the repo has no record of when it went in.
On 2026-10-06 `ai` grew from 2×48G (96G) to 2×48G + 2×16G (128G) across all four DIMM slots, at
DDR5-4800 with XMP off — the only stable setting with four DIMMs on this board. The 16G pair must be
installed first; with the 48G pair in first the board does not POST. The bring-up order, the BIOS
settings, the stress-test recipe, and how to recover a board that will not POST are in
[`idols-ai/MIXED-MEMORY.md`](./idols-ai/MIXED-MEMORY.md).
##### Retired
| Host | Platform | Hardware | Purpose | Status |
| ------------ | --------------- | -------- | --------------------- | ---------- |
| `aquamarine` | NixOS (libvirt) | Virtual | Monitoring & Services | ⚪ Retired |
`aquamarine` is retired; its services now run directly on `youko`
(`hosts/12kingdoms-youko/homelab-services/`).
@@ -125,7 +143,7 @@ cool!
[Oshi no Ko 【推しの子】 - Wikipedia](https://en.wikipedia.org/wiki/Oshi_no_Ko):
![](../_img/idols-famaily.webp) ![](../_img/idols-ai.webp)
![](../_img/idols-family.webp) ![](../_img/idols-ai.webp)
[The Rolling Girls【ローリング☆ガールズ】 - Wikipedia](https://en.wikipedia.org/wiki/The_Rolling_Girls):
+139
View File
@@ -0,0 +1,139 @@
# Mixed memory on idols-ai
Notes from adding a 2×16G kit to the existing 2×48G kit on this desktop.
## Hardware
### CPU
- Intel Core Ultra 7 270K Plus (Arrow Lake-S Refresh, socket LGA1851)
- 24 cores / 24 threads: 8 P-cores up to 5.5 GHz + 16 E-cores up to 4.7 GHz
- 36 MB L3, 40 MB L2, 125 W PL1 / 250 W PL2, 4-core Xe iGPU
### Motherboard
- Colorful CVN Z890 ARK FROZEN V20 (Intel Z890, LGA1851, ATX), BIOS version 1013
- 4× DDR5 DIMM slots, officially up to 192 GB (48 GB max per slot), DDR5-8400(OC) and slower
### Memory
| Kit | Capacity | XMP rating | Timings | Voltage | Rank | Part number |
| ----- | -------- | --------------------- | ------------- | ------- | ---- | --------------------- |
| JUHOR | 2×48G | DDR5-5600 (PC5-44800) | CL46-45-45-90 | 1.25 V | 2R | `JHE5600U4648JG` |
| GLOWY | 2×16G | DDR5-6400 (PC5-51200) | CL32-38-38-90 | 1.35 V | 1R | `VGM5UH64C32AG-DTACW` |
- When they went in: the 2×16G GLOWY kit was added 2026-10-06; the 2×48G JUHOR kit was already in
place when the platform was rebuilt 2026-04-27 (before that the host was an MSI LGA1700 board with
an i5-13600KF — see the `hosts/README.md` inventory notes).
- Channel A/B, DIMM0 = 48G (2R), DIMM1 = 16G (1R) → 64G per channel, 128G total.
- With XMP off both kits run at JEDEC DDR5-4800; the board exposes one XMP profile per kit
(`XMP 模块一` / `XMP 模块二`, XMP profile 1 / profile 2).
## Bring-up order (install the 16G pair first)
The order is mandatory. Starting from the 2×48G, or from all four DIMMs, does not POST: no BIOS
entry and nothing to change in setup — pull the 48G pair and start from step 1.
1. Insert **only the 2×16G**, in the board's primary slots (the first-populate pair the manual
marks; the working layout has them in `ChannelA-DIMM1` / `ChannelB-DIMM1`).
2. Boot to BIOS; confirm `内存模块资源 = 默认模块` (memory module source = default module, i.e. XMP
off) — the DRAM voltage comes back at 1.25 V.
3. Power off, then insert the **2×48G** in the remaining slots.
4. Boot; the board retrains once (1–3 min, possibly a few reboots), then works.
5. Last step: back in BIOS, set `Gear选择` (Gear mode) to `Gear2` and raise `Memory Voltage VDD` and
`内存电压VDDQ` from 1.25 V to `1.28 V`. Leave every other setting alone. 1.29 V and up do not
train.
Resulting layout: `ChannelA/B-DIMM0` = 48G (2R), `ChannelA/B-DIMM1` = 16G (1R).
## Working configuration
- `stressapptest` 8G / 32G / 100G all PASS at both 1.25 V and 1.28 V.
Current BIOS settings (`超频OC → 内存设置`, the Overclocking → Memory settings page). The BIOS was
used in Chinese; the English in the table translates those labels and is not the firmware's own
English wording:
| Field | Value |
| --------------------------------------- | ------------------------------------ |
| `内存模块资源` (memory module source) | `默认模块` (default module, XMP off) |
| `Gear选择` (Gear mode) | `Gear2` |
| `内存频率(MHz)` (DRAM frequency) | `4800` |
| `CPU VDD2电压` (CPU VDD2 voltage) | `1.104 V` (Auto) |
| `VCCSA电压` (VCCSA voltage) | `1.288 V` (Auto) |
| `Vdd2Mv` | `1.280 V` (Auto) |
| `Memory Voltage VDD` | **`1.280 V`** (fixed) |
| `内存电压VDDQ` (DRAM VDDQ voltage) | **`1.280 V`** (fixed) |
| `内存电压VPP` (DRAM VPP voltage) | `1.800 V` (Auto) |
| `Primary Timing` `tCL` / `tRCD` / `tRP` | `40` / `40` |
| `Primary Timing` `tRAS` | `77` |
The only hand-set voltages are the two DRAM rails, `Memory Voltage VDD` and `内存电压VDDQ`, both
**1.280 V** (not `Auto`) — this is what `dmidecode` reports as `Configured Voltage: 1.28 V`. These
four DIMMs only train up to 1.28 V: 1.29 / 1.30 / 1.32 V all fail training.
Confirm a BIOS change actually applied:
```bash
sudo dmidecode -t memory | grep -E 'Locator|Size|Rank|Speed|Configured Voltage'
```
## Stress testing
`script` block-buffers its log (use `-f`), and `/home/ryan` is tmpfs, so log to `~/tmp`:
```bash
SP=$(nix build --no-link --print-out-paths nixpkgs#stressapptest)
stdbuf -oL -eL "$SP/bin/stressapptest" -s 300 -M 32000 -v 4 2>&1 | tee ~/tmp/memtest-32G.log
```
Pass = exit 0 + `Found 0 hardware incidents` + `Status: PASS`. Escalate 8G → 32G → 100G → overnight.
## What does not work
- **XMP @ 5600 with 4 DIMMs**: the board never reaches BIOS. It can be a failed training, or
training passing (the debug LED settles on **white** or **green**) with the hang on the
display/iGPU side. Two stuck modes were seen: (1) the logo screen (`Del`/`F11`) with a white LED,
then a hang; or (2) a black screen on the green LED. In every case there is no BIOS entry and the
recovery is the same.
- Intel/JEDEC validate two DIMMs per channel well below 4800 (2DPC dual-rank ≈ 4400 or lower), so
4800 is already above spec. 5600 needs two DIMMs (1DPC).
## Recover a non-POSTing board
All of the above — a failed training, the logo screen with a white LED, or a black screen on the
green LED — can leave no BIOS entry. The recovery is the same in every case: redo the **bring-up
order** above (pull the 48G pair, boot on the 16G pair with XMP off, then re-add the 48G pair). If
BIOS is still unreachable, clear CMOS and repeat.
## Firmware-change checklist
LUKS TPM auto-unlock (PCR 0+7) breaks on every BIOS change. Re-enroll both disks **by partlabel**,
after all BIOS changes are final:
```bash
for d in /dev/disk/by-partlabel/disk-nixos-ai-root /dev/disk/by-partlabel/disk-data-datapart; do
sudo systemd-cryptenroll --wipe-slot=tpm2 "$d"
sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 "$d"
done
```
Keep the passphrase slot (never `--wipe-slot=all`). Secure Boot check: `sudo sbctl status`.
## Notes
- A hang that forces a reboot can corrupt the Nix store; it is a risk whenever memory is unstable or
not thoroughly tested, which is why a full-RAM stress test matters. After any forced reboot run
`nix-store --verify --check-contents --repair` and `btrfs scrub`.
- The board silently reverts to defaults on failed training, so re-check with `dmidecode`.
- A passing stress test is not proof either: the 1.25 V config passed 8G / 32G / 100G and still
hard-froze under a real llama.cpp load — no kernel log, one BERT hardware-error record in
firmware.
- Decision: keep the current 128G 4-DIMM config at 4800. The board supports at most 48 GB per slot,
so larger modules are not an option.
## Open items
- [ ] Confirm stability overnight: an overnight `stressapptest` → `~/tmp/memtest-overnight.log`, or
the real llama.cpp load run overnight
- [ ] `nix-store --verify --check-contents --repair` + `btrfs scrub`
+1
View File
@@ -10,6 +10,7 @@ Related:
`nix-config/nixos-installer`:
`nix run github:nix-community/disko -- --mode destroy,format,mount ../hosts/idols-ai/disko-fs.nix`
- [disko-fs-data.nix](./disko-fs-data.nix) – data disk layout (LUKS + btrfs at /data)
- [MIXED-MEMORY.md](./MIXED-MEMORY.md) – mixed 4-DIMM RAM bring-up, stress testing, and recovery
## Info
+4 -2
View File
@@ -7,7 +7,8 @@
}:
#############################################################
#
# Ai - my main computer, with NixOS + I5-13600KF + RTX 4090 GPU, for gaming & daily use.
# Ai - my main computer, with NixOS + Core Ultra 7 270K Plus + RTX 4090 GPU,
# 128G DDR5-4800 (mixed 4-DIMM, see MIXED-MEMORY.md), for gaming & daily use.
#
#############################################################
let
@@ -50,7 +51,8 @@ in
# - zstd: CPU is not the bottleneck here (llama.cpp peaks ~30% util); its ~2.5x ratio
# keeps ~5G more anon bytes in the capped pool than lz4, and ~5us decompress is noise
# vs the ~100us SSD fault it avoids.
# - 10% pool (~9G): the module default 25% (~23G) would compete with the weight cache.
# - 10% pool (~13G on 128G): the module default 25% (~32G) would compete with the weight
# cache.
boot.zswap = {
enable = true;
compressor = "zstd";
+11
View File
@@ -22,6 +22,17 @@
nvidiaBusId = "PCI:2@0:0:0";
};
# Games launched through GameScope should use the dGPU. prime.offload keeps the
# Intel iGPU as the default renderer so the dGPU stays free for LLM workloads,
# so opt GameScope games into PRIME render offload here. Games launched outside
# GameScope need `nvidia-offload %command%` in their Steam launch options.
programs.gamescope.env = {
__NV_PRIME_RENDER_OFFLOAD = "1";
__NV_PRIME_RENDER_OFFLOAD_PROVIDER = "NVIDIA-G0";
__GLX_VENDOR_LIBRARY_NAME = "nvidia";
__VK_LAYER_NV_optimus = "NVIDIA_only";
};
boot.kernelParams = [
# Since NVIDIA does not load kernel mode setting by default,
# enabling it is required to make Wayland compositors function properly.
+2
View File
@@ -176,6 +176,7 @@ in
".agents" # skills for all agents
".config/agents"
".codex"
".dsh" # DeepSeek Harness
".pi"
".config/opencode"
".local/share/opencode"
@@ -264,6 +265,7 @@ in
"Games"
".steam"
".config/MangoHud"
".config/blender"
".local/share/umu"
+5
View File
@@ -28,6 +28,9 @@
"/home/ryan/src"
"/home/ryan/nix-config"
"/home/ryan/.local/state"
# dsh (DeepSeek Harness) state: session transcripts, workspace storages,
# profiles. Its credentials file is excluded below.
"/home/ryan/.dsh"
];
# anything bigger than this is a re-downloadable artifact (models, datasets,
@@ -79,6 +82,8 @@
"**/.cache"
# git object packs: re-fetchable from the remotes
"**/.git/objects/pack"
# dsh login credentials, same rule as the module's built-in credential excludes
"**/.dsh/.credentials.yaml"
];
};
}
+2 -4
View File
@@ -22,10 +22,8 @@
pkgs.sbctl
];
# Lanzaboote currently replaces the systemd-boot module.
# This setting is usually set to true in configuration.nix
# generated at installation time. So we force it to false
# for now.
# Lanzaboote replaces the systemd-boot module. NixOS's generated
# configuration.nix sets this to true, so force it off.
boot.loader.systemd-boot.enable = lib.mkForce false;
boot.lanzaboote = {
+1 -2
View File
@@ -6,8 +6,7 @@ Steps to install:
```bash
# 1. format & mount the filesystem
nix-shell -p disko
sudo disko --mode destroy,format,mount hosts/idols-akane/disko-fs.nix
sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko -- --mode destroy,format,mount hosts/idols-akane/disko-fs.nix
# 2. install nixos
nixos-install --root /mnt --flake .#akane --no-root-password --show-trace --verbose --option substituters "https://mirrors.ustc.edu.cn/nix-channels/store https://cache.nixos.org/" # install-2
@@ -7,25 +7,8 @@
{
imports = mylib.scanPaths ./.;
# environment.systemPackages = with pkgs; [
# podman-compose
# ];
virtualisation = {
docker.enable = true;
# podman = {
# enable = true;
# # Create a `docker` alias for podman, to use it as a drop-in replacement
# dockerCompat = true;
# # Required for containers under podman-compose to be able to talk to each other.
# defaultNetwork.settings.dns_enabled = true;
# # Periodically prune Podman resources
# autoPrune = {
# enable = true;
# dates = "weekly";
# flags = [ "--all" ];
# };
# };
oci-containers = {
backend = "docker";
+2 -2
View File
@@ -21,8 +21,8 @@ its state in three sparse ext4 images under the host's `/var/lib/microvms/<name>
The guest's root is a tmpfs and `/nix/store` is the host's store shared read-only (virtiofs), so no
image has to be built or uploaded; only the volumes above persist. The guest's tap interface is
bridged onto `br0`, and its name is derived from the guest IP (e.g. `192.168.5.114` -> `vm114`, as
`IFNAMSIZ` caps interface names at 15 characters).
bridged onto `br0`, and its name is derived from the last octet of the guest IP by
`lib/genMicrovmGuestModule.nix` (e.g. `192.168.5.114` -> `vm114`).
### Updating a running guest
+2
View File
@@ -16,6 +16,7 @@ cd nix-config
# encrypt the root partition with luks2 and argon2id, will prompt for a passphrase, which will be used to unlock the partition.
sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko -- --mode destroy,format,mount hosts/k8s/disko-config/host-disko-fs.nix
## 2. setup the automatic unlock via the tpm2 chip
# find the LUKS partition with: lsblk -f
systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 /dev/<encrypted-disk-part-path>
## 3. install nixos
@@ -31,6 +32,7 @@ nixos-enter
# otherwise the / will be cleared and data will lost
## NOTE: preservation just create links from / to /persistent
## We need to copy files into /persistent manually!!!
mkdir -p /persistent/etc
mv /etc/machine-id /persistent/etc/
mv /etc/ssh /persistent/etc/
mkdir -p /persistent/home/ryan
+7 -4
View File
@@ -64,7 +64,10 @@ Each subdirectory contains its own Terraform configuration:
## Security Considerations
- All storage buckets are configured with appropriate access policies
- State files are encrypted at rest
- Access credentials are managed through environment variables
- Network access is restricted to necessary hosts only
- Buckets are declared as bare `aws_s3_bucket` resources, with no bucket policy or server-side
encryption configuration. The only guard in Terraform is `prevent_destroy` on the `tf-s3-backend`
state bucket.
- IAM users and policies are created by hand with the `rc` client, not Terraform (see
[rustfs/README.md](./rustfs/README.md)).
- Access credentials are managed through environment variables (`AWS_ACCESS_KEY_ID` /
`AWS_SECRET_ACCESS_KEY`).
+3
View File
@@ -21,6 +21,9 @@ set -a; . <(sudo cat /run/agenix/rustfs.env); set +a
rc alias set rustfs https://s3.writefor.fun "$RUSTFS_ACCESS_KEY" "$RUSTFS_SECRET_KEY"
```
Sourcing the file is a deliberate exception to the rule against reading decrypted secrets: `cat`
runs inside the process substitution, so the values go into the shell and are never printed.
## Buckets
```bash
+3 -6
View File
@@ -28,12 +28,9 @@ reduce code duplication and make it easier to add new machines.
## Usage
These functions are designed to:
- Generate consistent configurations across different architectures
- Provide type-safe configuration for complex systems
- Enable easy scaling of the infrastructure
- Support both local development and production deployments
The generators import the shared host modules, so a new machine supplies its own values and
system-specific attributes. `colmenaSystem` covers remote deployment, and `genLibvirtDomainXml`
renders the domain XML for one guest.
## Architecture Support
+7 -18
View File
@@ -12,23 +12,16 @@ in
{
environment.systemPackages = [ package ];
# Kernel modules required by cilium
boot.kernelModules = [
"ip6_tables"
"ip6table_mangle"
"ip6table_raw"
"ip6table_filter"
];
networking.enableIPv6 = true;
networking.nat = {
enable = true;
enableIPv6 = true;
boot.kernel.sysctl = {
"net.ipv4.ip_forward" = 1;
"net.ipv6.conf.all.forwarding" = 1;
};
# Cilium pods reach host services (e.g. the API server) from the pod CIDR.
# `mkAfter` keeps this after the shared base rules (incl. the node_exporter
# drop), so pods cannot scrape node_exporter either.
# Deny pods the credential-bearing host ports before the pod accept below.
networking.firewall.extraInputRules = pkgs.lib.mkAfter ''
ip saddr 10.0.0.0/8 tcp dport { 22, 2049, 2283, 5432, 5900, 5901, 5902, 5903, 8000, 8081, 8082, 9090, 9093, 9100, 9633, 9835 } drop
ip6 saddr fd00::/104 tcp dport { 22, 2049, 2283, 5432, 5900, 5901, 5902, 5903, 8000, 8081, 8082, 9090, 9093, 9100, 9633, 9835 } drop
ip saddr 10.0.0.0/8 accept
ip6 saddr fd00::/104 accept
'';
@@ -51,11 +44,7 @@ in
pkgs.lib.concatStringsSep " " flagList;
};
# Link k3s's CNI directories to the conventional locations, so CNI plugins
# that write to /etc/cni/net.d or /opt/cni/bin (cilium, istio-cni) share them
# with k3s. Without this, cilium writes /etc/cni/net.d while istio-cni reads
# k3s's own dir, and the chained plugin never finds a network config.
# Mirrors the server module.
# Share k3s's CNI dirs with plugins using the conventional paths (cilium, istio-cni).
systemd.tmpfiles.rules = [
"L+ /opt/cni/bin - - - - /var/lib/rancher/k3s/data/cni/"
"d /var/lib/rancher/k3s/agent/etc/cni/net.d 0751 root root - -"
+7 -13
View File
@@ -39,23 +39,16 @@ in
dive # explore docker layers
];
# Kernel modules required by cilium
boot.kernelModules = [
"ip6_tables"
"ip6table_mangle"
"ip6table_raw"
"ip6table_filter"
];
networking.enableIPv6 = true;
networking.nat = {
enable = true;
enableIPv6 = true;
boot.kernel.sysctl = {
"net.ipv4.ip_forward" = 1;
"net.ipv6.conf.all.forwarding" = 1;
};
# Cilium pods reach host services (e.g. the API server) from the pod CIDR.
# `mkAfter` keeps this after the shared base rules (incl. the node_exporter
# drop), so pods cannot scrape node_exporter either.
# Deny pods the credential-bearing host ports before the pod accept below.
networking.firewall.extraInputRules = lib.mkAfter ''
ip saddr 10.0.0.0/8 tcp dport { 22, 2049, 2283, 5432, 5900, 5901, 5902, 5903, 8000, 8081, 8082, 9090, 9093, 9100, 9633, 9835 } drop
ip6 saddr fd00::/104 tcp dport { 22, 2049, 2283, 5432, 5900, 5901, 5902, 5903, 8000, 8081, 8082, 9090, 9093, 9100, 9633, 9835 } drop
ip saddr 10.0.0.0/8 accept
ip6 saddr fd00::/104 accept
'';
@@ -84,6 +77,7 @@ in
"--disable=traefik" # deploy our own ingress controller instead
"--disable=servicelb" # we use kube-vip instead
"--disable-network-policy" # Cilium enforces network policies instead
"--disable-kube-proxy" # Cilium's eBPF replacement handles services
"--tls-san=${masterHost}"
]
++ (map (label: "--node-label=${label}") nodeLabels)
+3 -1
View File
@@ -45,7 +45,9 @@
<address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
</interface>
<controller type='usb' model='qemu-xhci'/>
<graphics type='vnc' listen='0.0.0.0' port='${toString vncPort}' autoport='no'/>
<graphics type='vnc' port='${toString vncPort}' autoport='no' listen='127.0.0.1'>
<listen type='address' address='127.0.0.1'/>
</graphics>
<video>
<model type='virtio'/>
</video>
+6
View File
@@ -127,6 +127,12 @@ in
system.stateVersion = "26.05";
# The guest shares the host's read-only /nix/store (virtiofs) and has no store
# of its own, so its nix-gc.service can never succeed; it just failed on every
# k3s guest and tripped HostSystemdServiceCrashed. The host's own nix.gc
# reclaims the shared store, so disable automatic GC inside the guest.
nix.gc.automatic = false;
# MicroVM guests share the host's store and have no physical hardware to
# inspect, nothing to trace, no persisted /var/cache for a `locate` index,
# and nothing to advertise over mDNS.
+5 -3
View File
@@ -7,9 +7,11 @@
let
# Exporters bind to this host's static LAN IPv4 (the same address
# VictoriaMetrics scrapes), so the socket exists only on the LAN interface —
# defence in depth behind the firewall allowlist. Hosts without a static LAN
# address (laptops like shoukei, DHCP VMs like akane) run no exporters.
lanAddr = myvars.networking.hostsAddr.${config.networking.hostName}.ipv4 or null;
# defence in depth behind the firewall allowlist. Hosts without an always-on
# static LAN address (the `homeOnly` laptop, DHCP VMs like akane) run no
# exporters.
hostAddr = myvars.networking.hostsAddr.${config.networking.hostName} or { };
lanAddr = if hostAddr.homeOnly or false then null else hostAddr.ipv4 or null;
in
{
# enable the node exporter on all nixos hosts
@@ -38,6 +38,11 @@ in
# this does not restrict other IPv6 services or loopback access.
meta nfproto ipv6 tcp dport { 9100, 9835, 9633 } drop
# VNC consoles (libvirt on the VM hosts, and x11vnc inside the guests)
# are never exposed to the LAN, tailnet, or containers: reach them
# through an SSH tunnel. Loopback is accepted by the firewall's own rule.
tcp dport { 5900, 5901, 5902, 5903, 5910 } drop
# The local container bridge and the tailnet have the same access as the
# LAN. Kept after the drop above so neither can reach node_exporter.
iifname "podman0" accept
+5 -4
View File
@@ -1,8 +1,9 @@
{ lib, ... }:
{ lib, pkgs, ... }:
{
# auto upgrade nix to the unstable version
# https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/tools/package-management/nix/default.nix#L284
# nix.package = pkgs.nixVersions.latest;
# Nix 2.35 is newer than nixpkgs' nixVersions.stable (still 2.34), so opt into
# the latest released version until stable catches up.
# https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/tools/package-management/nix/default.nix
nix.package = pkgs.nixVersions.latest;
# https://lix.systems/add-to-config/
# nix.package = pkgs.lix;
+12
View File
@@ -133,6 +133,17 @@ in
after uploading).
'';
};
checkOpts = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "--read-data-subset=1/20" ];
description = ''
Arguments for `restic check`, run after each backup. Non-empty enables
the check. The default reads 5% of the pack data as a fraction rather
than `5%`, so systemd does not treat the percent as a specifier; set
to `[ ]` to disable, or `--read-data` for a full read.
'';
};
};
config = lib.mkIf cfg.enable {
@@ -168,6 +179,7 @@ in
};
inherit (cfg) pruneOpts;
inherit (cfg) checkOpts;
}
// lib.optionalAttrs (cfg.excludeLargerThan != null) {
extraBackupArgs = [
+7
View File
@@ -18,6 +18,13 @@
openFirewall = true;
};
# NixOS appends an `Include` of systemd's ssh_config.d drop-in to
# /etc/ssh/ssh_config, and OpenSSH re-applies SSHCONF_CHECKPERM to included
# files. A bubblewrap sandbox (`--unshare-user`) exposes root-owned store
# files as `nobody`, which would abort ssh there. We do not use
# systemd-ssh-proxy (.host, machine/*, unix/*, vsock/*).
programs.ssh.systemd-ssh-proxy.enable = false;
# Terminfo for the terminals we use, so `$TERM` resolves on hosts we SSH into.
environment.systemPackages = [
pkgs.ghostty.terminfo
+21 -6
View File
@@ -1,6 +1,5 @@
{
pkgs,
pkgs-x64,
nix-gaming,
config,
lib,
@@ -39,11 +38,7 @@ in
# ~/.steam/root - A symlink to ~/.local/share/Steam
# ~/.steam - Some Symlinks & user info
enable = true;
package = pkgs-x64.steam;
# https://github.com/ValveSoftware/gamescope
# Run a GameScope driven Steam session from your display-manager
# fix resolution upscaling and stretched aspect ratios
gamescopeSession.enable = true;
package = pkgs.steam;
# https://github.com/Winetricks/winetricks
# Whether to enable protontricks, a simple wrapper for running Winetricks commands for Proton-enabled games.
protontricks.enable = true;
@@ -52,6 +47,26 @@ in
fontPackages = [
pkgs.wqy_zenhei # Need by steam for Chinese
];
# DW-Proton (Dawn Winery's Proton fork) carries the anti-cheat and game
# patches that mainline Proton/GE-Proton lack, so it is what runs the anime
# gacha games (Wuthering Waves, Honkai: Star Rail, Arknights: Endfield, ...);
# GE-Proton is the general fallback. Both appear as compatibility tools in
# each game's Properties -> Compatibility.
# https://dawn.wine/dawn-winery/dwproton
extraCompatPackages = [
pkgs.dwproton-bin
pkgs.proton-ge-bin
];
};
# GameScope: run a game in its own nested compositor and let it renice
# itself for steadier frame pacing. GPU-specific PRIME render offload belongs
# to the host, not here (see programs.gamescope.env in
# hosts/idols-ai/hardware-nvidia.nix).
# https://github.com/ValveSoftware/gamescope
programs.gamescope = {
enable = true;
capSysNice = true;
};
# see https://github.com/fufexan/nix-gaming/#pipewire-low-latency
+11
View File
@@ -64,6 +64,17 @@
# overloads the capslock key to function as both escape (when tapped) and control (when held)
capslock = "overload(control, esc)";
esc = "capslock";
# keyd rewrites right-hand modifiers as their left counterparts, so
# pin them to their own keycodes. Vinput's MenuKey is right Ctrl and
# Rime's right Shift switches CN/EN.
rightcontrol = "rightcontrol";
rightshift = "rightshift";
rightmeta = "rightmeta";
# Right Alt is AltGr, the third-level shift on many European layouts
# (e.g. `AltGr+2` is `@` in Spanish); keyd forwards it as-is.
rightalt = "layer(altgr)";
};
};
};
+5 -4
View File
@@ -1,7 +1,7 @@
# Nix Environment Setup for Host: Idols - Ai
> :red_circle: **IMPORTANT**: **Do not deploy this flake directly on your machine.** Write your own
> configuration from scratch and use this only as reference.\*\*
> configuration from scratch and use this only as reference.
This flake prepares a Nix environment for setting up the desktop host
[hosts/idols-ai](../hosts/idols-ai/) (from the main flake) on a new machine.
@@ -52,6 +52,7 @@ nix run github:nix-community/disko -- --mode destroy,format,mount ../hosts/idols
nix run github:nix-community/disko -- --mode destroy,format,mount ../hosts/idols-ai/disko-fs-data.nix
# setup the automatic unlock via the tpm2 chip
# find the LUKS partition with: lsblk -f
systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 /dev/<encrypted-disk-part-path>
```
@@ -60,8 +61,8 @@ systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 /dev/<encrypted-disk-part
```bash
sudo su
# add ssh key to ssh-agent, it's required to pull my asahi=firmware
$(ssh-agent)
# add ssh key to ssh-agent, required to pull the my-asahi-firmware input
eval "$(ssh-agent)"
ssh-add /path/to/ssh-key
# From nix-config/nixos-installer
@@ -109,7 +110,7 @@ After the first boot:
```
2. Rekey secrets for the new host: follow [../secrets/README.md](../secrets/README.md) so agenix can
decrypt using this host’s SSH key.
decrypt using this host's SSH key.
3. Deploy the main config:
Loaded 100 of 119 files, more files were not shown because too many files have changed in this diff. Show more