Commit Graph
81 Commits
Author SHA1 Message Date
ryan4yin | 二花 71fa928254 feat(canokey): sudo, SSH, LUKS and OpenPGP setup for daily use (#516)
Use the CanoKey for daily authentication on idols-ai and shoukei, with
the existing passwords, passphrases and per-host SSH keys as fallback.

- sudo: pam_u2f with a shared origin (pam://ryan4yin) and a Nix-store
  authfile built from myvars.canokeyU2fKeys; the primary key is
  registered and touch-to-sudo works on idols-ai.
- SSH: one resident ed25519-sk key (application=ssh:ryan4yin) exported
  to ~/.ssh/id_ed25519_sk; GitHub tries it before the per-host key.
- shoukei LUKS: fido2-device=auto with token-timeout=10s. Update
  nixos-apple-silicon (linux-asahi 7.2.14), whose initrd adds
  thunderbolt_apple and reset_apple_cio so USB-C comes up before unlock.
- GPG: scdaemon disable-ccid so it uses pcscd.
- docs/security-keys.md: setup, PINs, enrollment, backup key and
  recovery; deduplicate the FIDO notes left by #515.

Assisted-by: Claude Code (claude-opus-5-5)
2026-11-04 01:50:21 -06:00
ryan4yin | 二花 2cf3a58028 feat(nixpak): pass FIDO2 keys to Firefox, Chromium and Chrome (#515)
* feat(nixpak): pass FIDO2 keys to Firefox, Chromium and Chrome

Assisted-by: DeepSeek Harness (deepseek-flash)

* feat(nixpak): support FIDO2 hotplug via udev-maintained node directory

Replace launch-time hidraw discovery with host udev rules that hard-link
FIDO-tagged hidraw nodes into /dev/fido-hidraw and remove them on unplug.
The sandbox dev-binds that directory and gets static /dev/hidrawN symlinks
into it, so keys plugged in after launch work and no stale node survives a
reused hidraw minor.

Narrow the extra mounts from whole /sys and /run/udev to /sys/class/hidraw,
/run/udev/data and /run/udev/control; the policy suite now forbids the
broad mounts and checks the wrapper and bind follow the fido2 option.

Assisted-by: Claude Code (claude-opus-5-5)

* refactor(nixpak): rewrite FIDO2 bwrap wrapper in Python

The bash argument loop was hard to follow. Python inserts the /dev/hidrawN
symlinks before "--" with a single list splice, and the header now explains
the whole host-udev -> bind -> symlink chain step by step.

Assisted-by: Claude Code (claude-opus-5-5)

* docs(canokey): document phone-only management policy

PCs only use the CanoKey; CanoKey Console management stays in the phone
app and the Admin PIN is never typed on a PC. Record what the config
enforces (sandboxed browsers get no raw USB/CCID, no vendor WebUSB udev
rule) and what it does not (uaccess on the raw USB node, PC/SC access to
the Admin applet, CTAP management from browsers).

Assisted-by: Claude Code (claude-opus-5-5)

* docs(canokey): separate management from use, link CanoKey docs

Assisted-by: Claude Code (claude-opus-5-5)

* fix(nixpak): create /dev/fido-hidraw from the udev rule

NixOS applies /dev tmpfiles entries only at boot; switch-to-configuration
runs systemd-tmpfiles-resetup with --exclude-prefix=/dev. After a switch
without reboot the directory was missing and every `ln` failed with exit
code 1, so no browser saw the key. The add rule now runs `mkdir -p` first.

Also fix the documented trigger command: `udevadm trigger` defaults to
`change`, which the add-only rule ignores.

Assisted-by: Claude Code (claude-opus-5-5)

* refactor(nixpak): keep tmpfiles as the only creator of /dev/fido-hidraw

The /dev tmpfiles units run before systemd-udevd on every boot, so the
directory always exists before coldplug. The mkdir in the udev rule only
covered the first switch without reboot and duplicated the tmpfiles rule;
drop it and document the one-time `systemd-tmpfiles --prefix` command.

Assisted-by: Claude Code (claude-opus-5-5)

* docs(nixpak): record FIDO2 hardware validation in Firefox and Chrome

After a reboot on ai with the CanoKey present at boot, udev linked only
the FIDO interface and WebAuthn works in Firefox and Chrome. Chromium and
plugging the key in after launch remain pending.

Assisted-by: Claude Code (claude-opus-5-5)
2026-11-04 13:38:32 +08:00
Ryan Yin 4470b3d014 docs: centralize documentation under docs/
Move standalone repository docs from the root into docs/ and add a documentation index that links the moved docs and the code-local runbooks.

Update Markdown links, source comments, and the root entry points to the new locations. Keep README.md and AGENTS.md at the root as required entry points.

Assisted-by: DeepSeek Harness (deepseek-flash)
2026-11-02 17:48:57 +08:00
Ryan Yin e4c2548a93 refactor: replace redundant mkForce with plain values and mkDefault
Each of these overrode a value nothing else set at a higher priority:

- qemu-guest: btrbk, hardwareTools and cloud-init have no competing
  definition on the guests.
- mdns: nixpkgs' sunshine module sets avahi.publish.* with mkDefault.
- computer-use: i18n now sets the time zone with mkDefault.
- darwin terminal: the shared ghostty/kitty font sizes are now mkDefault.
- shoukei: sunshine is mkDefault false in remote-desktop.nix, zram's
  memoryPercent is mkDefault 50; supportedFilesystems now merges instead
  of discarding the fsType entries other modules add.
- youko: nothing enables docker.
- nixpak: pasta.enable and sockets.pipewire are mkDefault in the shared
  modules, sockets.pulse already was.

Every NixOS host's toplevel drvPath is unchanged; on fern and frieren the
terminal font sizes and time zone evaluate to the same values.

Assisted-by: Claude Code (claude-opus-5-5)
2026-11-01 10:14:27 -06:00
Ryan Yin 88ff500dfc chore(wechat): use nixpkgs-master now that NixOS/nixpkgs#560225 is merged 2026-11-01 23:34:00 +08:00
ryan4yin | 二花 c277c81cd6 feat(nixpak): sandbox six desktop apps (#497)
* feat(nixpak): sandbox six desktop apps

* chore(nixpak): trim OBS plugin set

* fix(nixpak): enable OBS on aarch64

* fix(nixpak): let imv read the full home directory

* fix(home): drop redundant freerdp package

* fix(nixpak): grant OBS access to V4L2 camera devices

* fix(nixpak): expose V4L2 sysfs to OBS

* fix(nixpak): expose NVIDIA encode library to OBS

* docs(nixpak): record OBS interactive validation

* docs(nixpak): record OBS RTMP validation

* fix(nixpak): run MuseScore via XWayland and PulseAudio

* docs(nixpak): explain app sandboxing rationale

* fix(nixpak): route MuseScore ALSA through PipeWire
2026-11-01 01:24:47 -05:00
Ryan Yin 5e5ceae108 docs(nixpak): record slicer runtime validation 2026-11-01 11:52:08 +08:00
Ryan Yin 98d1c2d6e7 fix(nixpak): allow WebKit network portals for slicers 2026-11-01 11:46:58 +08:00
ryan4yin | 二花 c3990cc4be feat(nixpak): sandbox Bambu Studio and OrcaSlicer (#495)
Assisted-by: DeepSeek Harness (deepseek-flash)
2026-11-01 11:43:35 +08:00
ryan4yin | 二花 1a939e2c9a fix(nixpak): use host fontconfig in sandboxes (#496)
Reuse the host fontconfig for Nixpak GUI apps so host and sandboxed apps resolve fonts consistently.

Assisted-by: DeepSeek Harness (deepseek-flash)
2026-11-01 11:26:25 +08:00
Ryan Yin d54b49b799 docs(nixpak): document intentional Firefox media limits 2026-11-01 10:49:52 +08:00
ryan4yin | 二花 3e6d89b3c4 feat(nixpak): sandbox Foliate and Krita (#494)
Assisted-by: DeepSeek Harness (deepseek-flash)
2026-11-01 10:34:47 +08:00
ryan4yin | 二花 090a7b622b refactor(nixpak): split policy checks into per-app suites (#493)
* refactor(nixpak): split policy checks into per-app suites

Make hardening/tests/policy.nix a small loader that auto-discovers one suite per app under hardening/tests/policy. Shared checks live in policy-lib.nix and common expectations are generated by mkAppPolicy; app files only declare differences and special cases. The loader also discovers wrappers from hardening/nixpaks and fails when wrapper/suite inventory or check names diverge.

Assisted-by: DeepSeek Harness (deepseek-flash)

* fix(nixpak): reject duplicate per-app policy checks

mkAppPolicy merges generated and custom checks, so an extraChecks key could silently override a standard assertion. Fail explicitly when a per-app check name is defined twice.

Assisted-by: DeepSeek Harness (deepseek-flash)
2026-11-01 10:05:15 +08:00
Ryan Yin 87b7a23cf3 docs(nixpak): consolidate runtime validation notes
Merge the three runtime-validation files into one concise record, update the interactive browser and Zoom results, and document the intentional Chromium host-loopback and Brave/Edge no-media exceptions. Tighten the remaining cookie-crypto workaround and the smoke-test prerequisites.

Assisted-by: DeepSeek Harness (deepseek-flash)
2026-11-01 09:24:23 +08:00
ryan4yin | 二花 ccffddc864 feat(wechat): native nixpkgs package with app-scoped data (#492)
Switch to the native deb package from nixpkgs-patched (#560225), remove the AppImage/FHS bwrap layer, and enable native Wayland while keeping the X11 fallback.

Keep only WeChat state under one app-scoped HOME and bind the host Documents and Downloads directories like the other desktop apps. User-selected files also go through the XDG FileChooser portal. Remove the launcher, activation script, and compatibility symlinks.

Assisted-by: DeepSeek Harness (deepseek-flash)
2026-11-01 00:09:27 +08:00
ryan4yin | 二花 818965a11f feat(nixpak): unify desktop app sandboxes (#491)
* refactor(nixpak): unify desktop app sandboxes

Move common GUI, portal, and network policy into reusable modules and migrate browsers plus Zoom/WeChat/QQ/Telegram to the same boundary.

Assisted-by: DeepSeek Harness (deepseek-flash)
2026-10-31 22:27:58 +08:00
ryan4yin | 二花 707da35996 feat(nixpak): clear env, drop system bus, isolate network (#490)
* fix(nixpak): stop exposing the system D-Bus to apps
* fix(nixpak): bind only the PulseAudio socket
* feat(nixpak): run apps in a new session tied to the launcher
* feat(nixpak): start apps from an allowlisted environment
* feat(nixpak): isolate app networking with pasta
* fix(nixpak): keep Firefox on the host network

Assisted-by: Claude Code (claude-opus-5-5)
2026-10-31 16:39:25 +08:00
ryan4yin | 二花 9c38819517 docs: review and correct comments and documentation (#436) 2026-10-12 10:02:38 +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 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
ryan4yin | 二花 5f6a1dadf4 docs: fix stale claims and AI-flavored prose (#397) 2026-10-07 14:48:36 +08:00
ryan4yin | 二花 3a5b9ec4c6 docs: README audit fixes and de-duplication (#371) 2026-10-03 18:28:58 +08:00
ryan4yin | 二花 37d79fbb08 chore(hardening): consolidate system hardening and fix stale docs (#368) 2026-10-03 17:11:51 +08:00
ryan4yin | 二花 8b37fc0a7d chore: remove dead configuration (#352)
Drop declarations that nothing references, including the incorrect
`attrs.listToAttrs = lib.genAttrs` alias.
2026-10-03 10:09:38 +08:00
Ryan Yin a1ec97d3a2 refactor(bwraps): source wechat from nixpkgs-master and reuse its AppImage
Reuse the already-extracted, libtiff-patched AppImage from the nixpkgs wechat package (`wechat.src`) instead of keeping our own CDN URLs and hashes, which had to be refreshed whenever Tencent replaced the versionless files. Take the package from nixpkgs-master, which carries the newest builds.
2026-10-03 00:14:00 +08:00
Ryan Yin d27818e948 docs: update stale workaround comments
- wechat.nix: repacking is needed because nixpkgs' wechat package does not expose its AppImage wrapper args for `.override`, not because wrapAppImage lacks overriding (it forwards args to buildFHSEnv).
- peripherals.nix: drop a link to an already-closed issue and fix a typo.
2026-10-03 00:14:00 +08:00
ryan4yin | 二花 97c2d1325d docs: refresh stale docs after the VM and backup refactors 2026-09-21 22:03:21 +08:00
ryan4yin | 二花 efb5c08696 Merge pull request #274 from ryan4yin/fix/nixpak-pulse-audio
fix(nixpak): repair sandboxed audio and deduplicate mounts
2026-09-20 09:43:21 +08:00
Ryan Yin 7bd873e414 fix(firefox): share MPRIS artwork, trash and host config paths
The sandbox remaps XDG_DATA_HOME/XDG_CONFIG_HOME, so paths Firefox exposes to
or shares with the host ended up isolated. Bind the MPRIS artwork dir and the
real trash rw, and mimeapps.list, user-dirs.dirs and the shared NSS cert store
ro.

recently-used.xbel stays isolated: GTK writes it atomically, which a
single-file rw bind would break.
2026-09-20 02:11:58 +08:00
Ryan Yin 7242892355 fix(hardening): refresh wechat source hashes
Tencent replaced the file behind the versionless CDN URLs, so the pinned hashes stopped matching. Refresh the x86_64 and aarch64 hashes with nix store prefetch-file.
2026-09-19 13:26:20 +08:00
Ryan Yin d06543819d fix(nixpak): expose Asahi GPU metadata and quiet D-Bus logs 2026-09-11 14:29:59 +08:00
Ryan Yin a7f7cb68f0 fix(apparmor): use inherit exec modifier in sudo complain profile
The broad 'file /** rwlkUx' rule conflicts with rix exec rules pulled in
via nested abstractions (xdg-open): AppArmor 5.0 rejects merged rules
with differing exec modifiers, failing apparmor.service on first load.
2026-08-30 12:57:09 +08:00
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
Ryan Yin d91b861cd6 feat(bwraps): update wechat to 4.1.1.8 2026-08-25 13:41:34 +08:00
Ryan Yin 95088c4ff8 fix(nixpaks): route qq via pkgs-master for 3.2.32-2026-08-12 2026-08-18 09:59:45 +08:00
Ryan Yin bb13a43ff9 fix(nixpaks): route qq via pkgs-patched for 3.2.32-2026-07-30 2026-08-16 15:40:11 +08:00
Ryan Yin 21c76cf9cc fix(nixpaks): route qq via nixpkgs-master for 3.2.32-2026-07-30 2026-08-15 20:53:50 +08:00
Ryan Yin 7826934b23 fix(nixpak): allow document portal saves 2026-08-01 09:37:43 +08:00
Ryan Yin 3aadd65a36 fix(telegram): preserve Wayland app ID in nixpak 2026-07-31 17:35:31 +08:00
Ryan Yin af0ef6d154 flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs-patched':
    'github:ryan4yin/nixpkgs/d373b16187b32770d99f6ff54a133d9543e68702?narHash=sha256-75W3YfzkkKvpE3/wtHMihlT9kOnQZxWpLoshw1xu0T8%3D' (2026-03-20)
  → 'github:ryan4yin/nixpkgs/4425024452e93ce3d10e11bcd9b47f1dfa78593b?narHash=sha256-pu3loLm4gvcbh8iibeYDGgPHOVFXb8sAKEzJ9AxX5L4%3D' (2026-06-03)

fix: qq
2026-06-03 11:56:48 +08:00
Ryan Yin 5f87926bd6 chore: update wechat 2026-04-28 12:43:32 +08:00
Ryan Yin b9c76b8f22 fix: update wechat appimage hash 2026-03-16 17:48:07 +08:00
Ryan Yin 023d3fd4e9 fix: update wechat appimage hash 2026-03-16 17:36:42 +08:00
Ryan Yin 1222bb25d0 feat(preservation): add .openclaw, harden home dir permissions
Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>
2026-02-27 10:18:49 +08:00
Ryan Yin 6a8e4c24d9 fix: qq 2026-02-20 13:35:57 +08:00
Ryan Yin 6fdc5e7fb9 fix: update wechat, fix warnings & issues after update 2026-02-15 18:09:25 +08:00
Ryan Yin 94e431abfc fix: error - only one wireless daemon is allowed at the time, speed up wechat download 2026-01-02 22:37:38 +08:00
Ryan Yin 60d1909055 fix: package rename 2025-11-11 11:06:20 +08:00
Ryan Yin de05214ec5 chore: nixpaks - update dbus policies
Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>
2025-11-01 21:26:01 +08:00
Ryan Yin 34fdd92351 feat: comment out nixpkgs-unstable, we use unstable by default (#232)
* feat: comment out nixpkgs-unstable, we use unstable by default

Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>

* fix: typo...

---------

Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>
2025-11-01 07:21:57 -06:00