Commit Graph
497 Commits
Author SHA1 Message Date
ryan4yin | 二花 21d64e7add security: hardening pass 1 (AppArmor, firewall default, loopback metrics, k3s perms, SSH X11) (#266)
* security: make firewall secure-by-default, disable explicitly on servers

Flip the base firewall default to ON so new hosts are protected by default. Servers keep the firewall off (trusted internal LAN, WAN protected at the router) via explicit overrides in modules/nixos/server/{server,server-aarch64}.nix. Behavior-preserving for all 18 current hosts; adds a security-firewall eval test guarding the per-host state.

* test: fix security-firewall eval test to scalar per-host values

* security: enable AppArmor (complain) on all Linux hosts

* security: bind aquamarine metrics exporters to loopback

* security: restrict k3s kubeconfig file mode to 600

* security: disable SSH X11 forwarding on servers, keep on desktops

* security: add conservative systemd hardening to aquamarine services

* docs(apparmor): correct FHS-alias comment (nixpkgs has no broad FHS layer)

nixpkgs only creates /run/current-system, /usr/bin/env and /bin/sh; it does not
provide a broad FHS->store alias tree, so FHS-oriented abstractions are incomplete
on NixOS. They are safe only because the profiles run in complain mode.

* fix(aquamarine): scrape same-host exporters over loopback

The v2ray/postgres/sftpgo exporters were bound to 127.0.0.1 but VictoriaMetrics
scraped them via the host's routable IP, so those scrapes refused connections.
Point the three same-host scrape targets at 127.0.0.1 (VM runs on the same host).
node-exporter keeps the host IP since it binds 0.0.0.0.

* Revert "security: add conservative systemd hardening to aquamarine services"

This reverts commit f9cf99dadb.
2026-08-27 00:13:01 +08:00
ryan4yin | 二花 6e0d44c50d feat(nixos): manage scattered trash dirs with trash-cli retention timer (#265)
* feat(nushell): add trash command using the home trash can

On a tmpfs root with persistent dirs bind-mounted in, `rm --trash`
scatters items into per-mount .Trash-$uid dirs that file managers never
show, and gio refuses to trash on those internal mounts.

Add a `trash` command implementing the freedesktop trash spec
'failsafe' mode: items are moved to ~/.local/share/Trash with
spec-compliant .trashinfo entries, so Thunar can list and restore them.

Also preserve ~/.local/share/Trash on idols-ai so the trash survives
reboots.

* feat(nixos): manage scattered trash dirs with trash-cli retention timer

Replace the hand-written nushell trash command with the established
trash-cli tooling. On a tmpfs root with persistent dirs bind-mounted
in, the trash crate (nushell rm --trash) scatters items into per-mount
.Trash-$uid dirs that file managers never show and nothing cleans up.

- add trash-cli to system packages: trash-list scans/trash-restore
  handles every mount point's trash dir
- daily systemd timer runs 'trash-empty 30 -f', purging items older
  than 30 days across the home trash and all mount points
- drop the hand-written trash.nu module
- note in preservation.nix: do NOT persist ~/.local/share/Trash; a
  bind-mounted trash dir breaks the trash crate's home-topdir match
  for files straight under $HOME (it would try /.Trash-$uid, EACCES)

* fix(nixos): order trash-empty after preservation.target

The scattered .Trash-$uid dirs live inside the preservation bind
mounts, which use DefaultDependencies=no and are therefore NOT ordered
after local-fs.target. Add preservation.target to After= so trash-empty
only runs once all those mounts are up.
2026-08-23 23:40:53 +08:00
Ryan Yin 6f100d94a9 feat(gh): persist user-managed configuration 2026-08-04 17:45:24 +08:00
Ryan Yin cce15300d6 feat(niri): reorganize workspaces 2026-08-03 22:42:37 +08:00
Ryan Yin 6264190c49 fix(idols-ai): reset camera after resume 2026-08-01 10:04:22 +08:00
Ryan Yin 41512097e5 feat(grafana): add kubernetes service and storage dashboards 2026-07-31 17:34:52 +08:00
Ryan Yin 071212e40f feat(niri): reorganize workspace layout 2026-07-31 12:06:27 +08:00
Ryan Yin 64ecc1cf66 fix(grafana): scope hwmon joins to selected node 2026-07-27 20:57:10 +08:00
Ryan Yin 095dc5dee8 feat(desktop): enable the firewall on desktop machines
Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>
2026-07-26 22:26:01 +08:00
Ryan Yin 74598b6f6b chore(monitoring): stop scraping offline hosts, mute noisy alert levels
- Add an offlineHosts list to VictoriaMetrics scrape generation: SBCs
  and the whole k3s-prod-1 cluster are powered off, shoukei's exporter
  is disabled on the machine; also comment out the dnsmasq-exporter
  job (runs on suzi).
- Disable node-exporter on shoukei: a laptop on untrusted networks
  should not expose :9100 (the firewall is off repo-wide).
- Route severity none|info alerts to the null receiver; meta alerts
  and info noise should never page.

Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>
2026-07-26 22:19:56 +08:00
Ryan Yin ec208ab4d1 fix(monitoring): exclude shm from HostFilesystemDeviceError
node-exporter always reports device_error=1 for containerd sandbox shm
bind mounts (tmpfs), producing ~50 bogus critical alerts on the
kubevirt hosts. Verified against live metrics that no non-shm device
errors exist, so nothing real is filtered out.

Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>
2026-07-26 15:28:41 +08:00
Ryan Yin 21c6d9b7bc fix(monitoring): drop $vars from telegram template to survive envsubst
The NixOS alertmanager module pipes the generated config through
envsubst to inject secrets, which silently replaced the template's
$i/$a variables with empty strings, so every telegram notification
failed with a template parse error since Friday's deploy.

Rewrite the template without variables: range + dot, define/template
for the per-alert block, and an if/else split to cap a group at 5
alerts (slice errors when fewer than 5). Verified with amtool template
render against post-envsubst content for both branches.

Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>
2026-07-26 15:16:46 +08:00
Ryan Yin b6a7a8f49b feat(monitoring): restructure telegram alert template for readability
- Show group-level labels (alertgroup/cluster/env/namespace) once in
  the header instead of repeating them per alert.
- Use each rule's summary annotation as the per-alert headline (it
  already carries the distinguishing resource name), falling back to
  the instance label; show nodename on its own line when present.
- Drop the noisy per-alert label dump and the always-N/A value line.

Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>
2026-07-24 22:57:13 +08:00
Ryan Yin 35d41a4391 fix(monitoring): bound telegram message length and mute meta alerts
- Trim the telegram template: drop the full label dump, render at
  most 5 alerts per group, and note how many were omitted, so
  messages stay within Telegram's 4096-char limit.
- Route severity=none meta alerts (Watchdog, InfoInhibitor) to a new
  null receiver so they no longer notify.

Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>
2026-07-24 20:57:54 +08:00
Ryan Yin 149d8bc137 feat(monitoring): add UPS reference lines and alerts
fix(grafana): clarify UPS voltage references

Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>
2026-07-24 20:13:11 +08:00
Ryan Yin 8a0e1a648f feat(grafana): add UPS monitoring dashboard 2026-07-24 16:25:25 +08:00
Ryan Yin bae7e05a9a fix(aquamarine): remove insecure MinIO service 2026-07-24 15:07:49 +08:00
Ryan Yin 3550c6af2a feat(monitoring): collect homelab UPS metrics 2026-07-24 12:44:17 +08:00
Ryan Yin dda800f65d chore: preserve kimi-code data 2026-07-17 10:45:55 +08:00
Ryan Yin ac7755e5ee chore: add kimi-code 2026-07-17 10:39:53 +08:00
Ryan Yin c44aa91e96 chore: preserve bambu studio's data 2026-07-10 13:07:05 +08:00
Ryan Yin 0e5f1801cf feat(nixos): add orca-slicer
Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>
2026-06-25 22:19:14 +08:00
Ryan Yin cfc192afc4 feat: replace vscode with zed-editor (#263)
* feat: replace vscode with zed-editor
* docs: helix
2026-06-04 23:20:59 +08:00
Ryan Yin bea4f7cf06 chore: add llm agents & helix for ruby/kana/akane
Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>
2026-06-03 15:48:03 +08:00
Ryan Yin 27e2fb0df0 fix: remove unused pipx 2026-06-01 10:34:02 +08:00
Ryan Yin 662316c18a Nixos 26.05 (#261)
* flake.lock: Update

Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/7aaa00e7cc9be6c316cb5f6617bd740dd435c59d?narHash=sha256-WacE23EbHTsBKvr8cu%2B1DFNbP6Rh1brHUH5SDUI0NQI%3D' (2026-04-30)
  → 'github:NixOS/nixpkgs/e9a7635a57597d9754eccebdfc7045e6c8600e6b?narHash=sha256-u6WU/yd/o8iYQrHX3RAwO1hYa3LkoSL%2BWNQD0rJfJZQ%3D' (2026-05-29)

* feat: upgrade to nixos 26.05
2026-06-01 10:02:49 +08:00
Ryan Yin 9eb532a461 chore: remove kimi-cli, add opencode permission template 2026-05-29 08:38:00 +08:00
Ryan Yin 7c286099b6 chore: remove gemini-cli 2026-05-20 16:15:48 +08:00
Ryan Yin 495ed3f938 chore: remove aagl, run them via steam+dw-proton instead
Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>
2026-05-10 12:42:02 +08:00
Ryan Yin 77ca37eab1 chore: idols-ai - update kernel, add nvidia-offload command, etc 2026-04-27 10:38:57 +08:00
Ryan Yin 306741c2a7 feat: idols-ai - use intel intel iGPU by default, choose Nvidia dGPU manullay - via prime (#258)
* feat: idols-ai - use intel intel iGPU by default, choose Nvidia dGPU manullay - via prime

* fix: niri - update output names for new motherboard

* fix: niri - DP-1 with prime offload mode - supports only 120HZ

* flake.lock: Update

Flake lock file updates:

• Updated input 'nixpkgs-master':
    'github:nixos/nixpkgs/3879e47ce293fb2932d656aa56551a8e80718533?narHash=sha256-siN4x7y/S0FOdjPC1W0Z/vrX4Rlu%2BVClkEGngmSd0vM%3D' (2026-03-24)
  → 'github:nixos/nixpkgs/03de9fe87cb2dcec8da9dbaa3ad1c71ea7fef223?narHash=sha256-B7GmxbRADkklyXzV1ahgY4QhCpbQ3crzPCCs2hf6bPM%3D' (2026-04-26)

* flake.lock: Update

Flake lock file updates:

• Updated input 'nixpkgs-stable':
    'github:nixos/nixpkgs/e9f278faa1d0c2fc835bd331d4666b59b505a410?narHash=sha256-Jms57zzlFf64ayKzzBWSE2SGvJmK%2BNGt8Gli71d9kmY%3D' (2026-03-14)
  → 'github:nixos/nixpkgs/a4bf06618f0b5ee50f14ed8f0da77d34ecc19160?narHash=sha256-AIiMJiqvGrN4HyLEbKAoCSRRYn0rnlW5VbKNIMIYqm4%3D' (2026-04-25)
2026-04-27 02:33:51 +08:00
Ryan Yin 3a6a75c703 feat: helix - use stable version 2026-04-27 00:40:49 +08:00
Ryan Yin f398c44307 chore: homelab - use proxyGateway's dns service 2026-03-26 13:33:40 +08:00
Ryan Yin d2590d3653 chore: docker for ruby/kana 2026-03-26 13:06:52 +08:00
Ryan Yin f373f5ee5b feat(nixos): add cursor-cli/claude-code/gemini-cli/opencode 2026-03-24 12:20:47 +08:00
Ryan Yin 914239487c feat(nixos): add cursor-cli 2026-03-24 10:45:20 +08:00
Ryan Yin 8207ccbdff refactor(home): consolidate host home modules under home/hosts 2026-03-23 12:38:55 +08:00
Ryan Yin cf7b5a5be7 refactor(home): move host home-manager configs out of hosts 2026-03-23 10:57:09 +08:00
Ryan Yin 8b4e922e5b feat(networking): move tailscale subnet router to kubevirt-youko 2026-03-23 10:34:51 +08:00
Ryan Yin 7f6759ce06 chore: comment out netbird, migrate back to tailscale 2026-03-23 10:00:49 +08:00
Ryan Yin f5444150ef feat: agents 2026-03-21 20:54:40 +08:00
Ryan Yin 73363d5ca8 chore: disabe sunshine 2026-03-20 23:25:45 +08:00
Ryan Yin 0c23a823c6 feat(shoukei): reduce size limit for root tmpfs 2026-03-20 22:49:21 +08:00
Ryan Yin 6a03dddcbd feat: add size limit for root tmpfs 2026-03-20 18:27:41 +08:00
Ryan Yin 4db8d0d2cb fix: persist ~/Desktop 2026-03-20 18:10:57 +08:00
Ryan Yin 3e3365f51f fix: aqua - fileshare permission 2026-03-20 01:27:49 +08:00
Ryan Yin be9be72aff chore: preserve davfs2 driver's cache to avoid large memory usage 2026-03-20 00:31:44 +08:00
Ryan Yin 2f777ff38f polish: style 2026-03-20 00:02:14 +08:00
Ryan Yin b143a89443 feat(ai): add webdav mount (#253)
feat(aquamarine): add group for filesharing, protect /data on subvolume mount failures
2026-03-19 22:25:48 +08:00
Ryan Yin ce99c3e2d3 Update aqua (#252)
* fix: Grafana's secret key doesn't have a default value anymore

flake.lock: Update

Flake lock file updates:

• Updated input 'mysecrets':
    'git+ssh://git@github.com/ryan4yin/nix-secrets.git?ref=refs/heads/main&rev=cfe34c222cf7ee4290438c97e6cc734aa7792346&shallow=1' (2025-12-18)
  → 'git+ssh://git@github.com/ryan4yin/nix-secrets.git?ref=refs/heads/main&rev=86de5313787257806723f03dccabd52bb7501ff3&shallow=1' (2026-03-18)

* fix: gitea sendmail path

* fix: transmission_4
2026-03-19 01:02:42 +08:00