diff --git a/CLAUDE.md b/CLAUDE.md index a1f9a1f..8daa532 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -287,3 +287,16 @@ kept its ssh host key. Run it after ANY change to the kexec paths. existing immich cluster — hence the `\gexec` CREATE DATABASE in `postgresql-setup`'s `ExecStartPost`. Synapse's signing key is a sops secret, not generated on first start: it IS the server's federation identity, and the array it would live on is RAID0. +- **A MAS compat token is "not active" until Synapse has its device.** Synapse rejects + any token whose device it doesn't know, and `mas manage register-user` immediately + followed by `issue-compatibility-token` races: the new user's provisioning job syncs + devices before the token's session is committed and deletes the device just created. + `mas manage provision-all-users` re-syncs it. luna's Matrix bot token + (`hosts/mars/secrets.nix`) hit this. +- **Run the Hermes CLI on mars as `hermes`, never as root** (`podman exec -u hermes`, or + the `hermes` zsh alias). Since v0.22, optional deps (ElevenLabs `tts-premium`, plugin + deps like Honcho's `honcho-ai`) live in PM generations under `/opt/data/installs`; a + root `hermes pm status` created a root-owned `.leases` dir there and every later + install failed with "install state is not writable by this user". Those deps are + luna's volume state, not Nix: after a reset, `hermes pm install --extra tts-premium` + and `hermes plugins install honcho --force --yes-deps --enable`. diff --git a/dotfiles/quickshell/CLAUDE.md b/dotfiles/quickshell/CLAUDE.md index e9daba2..cad4250 100644 --- a/dotfiles/quickshell/CLAUDE.md +++ b/dotfiles/quickshell/CLAUDE.md @@ -105,6 +105,8 @@ on it, hence the index loops in `HyprChromeShell`. rail's monitor (`NotificationCard` is the headless-renderable card); `Widgets/Greeter/` is the greetd login screen, run standalone via `greeter.qml` (see `services/desktop/quickshell-greeter.nix`), NOT part of `shell.qml`; + `Widgets/Lock/` is the session lock, which reuses the greeter's + `LoginContent` over PAM and runs as its own instance via `lock.qml`; `Theme/Theme.qml` is this tree's palette singleton. `DebugWindow.qml` stages a single widget on the secondary monitor for eyeballing it in isolation. diff --git a/dotfiles/quickshell/HyprChrome/Widgets/Greeter/LoginContent.qml b/dotfiles/quickshell/HyprChrome/Widgets/Greeter/LoginContent.qml index 8d195e4..7873408 100644 --- a/dotfiles/quickshell/HyprChrome/Widgets/Greeter/LoginContent.qml +++ b/dotfiles/quickshell/HyprChrome/Widgets/Greeter/LoginContent.qml @@ -10,6 +10,13 @@ Item { property string hostName: "" property string sessionName: "" + property string title: "SESSION // " + root.hostName.toUpperCase() + property string panelId: "LGN" + property string meta: "GREETD" + property string submitLabel: "LOG IN" + // Off for the lock screen: the session's user is the only one who unlocks. + property bool userEditable: true + property bool showPower: true property date now: new Date() // Label over the secret field. Empty means the plain password step; set @@ -139,9 +146,9 @@ Item { id: panel width: root.width - panelId: "LGN" - title: "SESSION // " + root.hostName.toUpperCase() - meta: "GREETD" + panelId: root.panelId + title: root.title + meta: root.meta busy: root.busy ColumnLayout { @@ -220,7 +227,7 @@ Item { anchors.fill: parent verticalAlignment: TextInput.AlignVCenter - enabled: !root.busy && root.inputPrompt === "" + enabled: root.userEditable && !root.busy && root.inputPrompt === "" color: Theme.text selectionColor: Theme.accent selectedTextColor: Theme.surface @@ -292,12 +299,12 @@ Item { Layout.fillWidth: true spacing: 14 - MicroText { text: "ENTER LOG IN" } - MicroText { text: "TAB SWITCH FIELD" } + MicroText { text: "ENTER " + root.submitLabel } + MicroText { text: "TAB SWITCH FIELD"; visible: root.userEditable } Item { Layout.fillWidth: true } - PowerChip { label: "REBOOT"; action: "reboot" } - PowerChip { label: "POWER OFF"; action: "poweroff" } + PowerChip { label: "REBOOT"; action: "reboot"; visible: root.showPower } + PowerChip { label: "POWER OFF"; action: "poweroff"; visible: root.showPower } } } } diff --git a/dotfiles/quickshell/HyprChrome/Widgets/Lock/Lock.qml b/dotfiles/quickshell/HyprChrome/Widgets/Lock/Lock.qml new file mode 100644 index 0000000..69d5ca4 --- /dev/null +++ b/dotfiles/quickshell/HyprChrome/Widgets/Lock/Lock.qml @@ -0,0 +1,208 @@ +pragma ComponentBehavior: Bound + +import QtQuick +import Quickshell +import Quickshell.Io +import Quickshell.Wayland +import Quickshell.Services.Pam +import qs.HyprChrome.Widgets.Greeter + +// ext-session-lock screen: the greeter's panel on every output, so whichever +// one Hyprland gives the keyboard has a field. Runs as its own instance +// (lock.qml) so a reload of the main shell cannot drop the lock; exits once +// unlocked. +Scope { + id: root + + readonly property string userName: Quickshell.env("USER") ?? "" + readonly property string hostName: hostFile.text().trim() || "localhost" + + // Typed password, held until PAM's first secret prompt arrives. + property string pendingSecret: "" + // PAM asked a follow-up (OTP etc.) that the user must answer directly. + property bool awaitingResponse: false + property bool busy: false + property bool unlocking: false + + property string message: "" + property bool messageIsError: false + property bool failed: false + property string inputPrompt: "" + property bool responseVisible: false + property date now: new Date() + + // Each surface keeps its own field; this resets all of them. + signal resetSecret + + function setMessage(text, isError) { + root.message = text; + root.messageIsError = isError; + } + + function resetToPassword() { + root.pendingSecret = ""; + root.awaitingResponse = false; + root.busy = false; + root.inputPrompt = ""; + root.responseVisible = false; + root.resetSecret(); + } + + function submit(secret) { + root.failed = false; + + if (root.awaitingResponse) { + root.awaitingResponse = false; + root.busy = true; + root.resetSecret(); + pam.respond(secret); + return; + } + + if (pam.active) + return; + + root.setMessage("", false); + root.pendingSecret = secret; + root.busy = true; + if (!pam.start()) { + root.resetToPassword(); + root.setMessage("pam failed to start", true); + } + } + + FileView { + id: hostFile + + path: "/etc/hostname" + blockLoading: true + } + + PamContext { + id: pam + + // security.pam.services.hyprchrome-lock (services/desktop/desktop-hyprland.nix). + config: "hyprchrome-lock" + user: root.userName + + onPamMessage: { + if (!pam.responseRequired) { + root.setMessage(pam.message, pam.messageIsError); + return; + } + + // First hidden prompt is the password already typed. + if (root.pendingSecret !== "" && !pam.responseVisible) { + const secret = root.pendingSecret; + root.pendingSecret = ""; + pam.respond(secret); + return; + } + + root.busy = false; + root.awaitingResponse = true; + root.inputPrompt = pam.message.replace(/:\s*$/, ""); + root.responseVisible = pam.responseVisible; + root.resetSecret(); + } + + onCompleted: result => { + if (result === PamResult.Success) { + root.setMessage("unlocked", false); + root.unlocking = true; + return; + } + root.resetToPassword(); + root.failed = true; + root.setMessage(result === PamResult.MaxTries ? "too many attempts" : "authentication failed", true); + } + + onError: error => { + root.resetToPassword(); + root.setMessage(PamError.toString(error), true); + } + } + + // Fade out, then release the outputs. The quit is deferred so the unlock + // request is flushed before the connection closes; exiting while still + // locked would leave Hyprland's "lock app died" screen up. + Timer { + running: root.unlocking + interval: 220 + onTriggered: { + lock.locked = false; + quitTimer.start(); + } + } + + Timer { + id: quitTimer + + interval: 100 + onTriggered: Qt.quit() + } + + Timer { + running: true + repeat: true + interval: 1000 + triggeredOnStart: true + onTriggered: root.now = new Date() + } + + WlSessionLock { + id: lock + + locked: true + + WlSessionLockSurface { + color: "transparent" + + LockBackdrop { + anchors.fill: parent + } + + LoginContent { + id: content + + width: 640 + anchors.horizontalCenter: parent.horizontalCenter + y: Math.max(32, Math.round(parent.height * 0.42 - height / 2)) + (1 - opacity) * 12 + + opacity: root.unlocking ? 0 : 1 + Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutCubic } } + + title: "LOCKED // " + root.hostName.toUpperCase() + panelId: "LCK" + meta: "PAM" + submitLabel: "UNLOCK" + userEditable: false + showPower: false + + hostName: root.hostName + sessionName: "hyprland" + user: root.userName + now: root.now + busy: root.busy || root.unlocking + message: root.message + messageIsError: root.messageIsError + failed: root.failed + inputPrompt: root.inputPrompt + responseVisible: root.responseVisible + + onSubmitted: (user, secret) => root.submit(secret) + + Component.onCompleted: content.focusSecret() + + Connections { + target: root + + function onResetSecret() { + content.clearSecret(); + content.focusSecret(); + } + } + } + } + } +} diff --git a/dotfiles/quickshell/HyprChrome/Widgets/Lock/LockBackdrop.qml b/dotfiles/quickshell/HyprChrome/Widgets/Lock/LockBackdrop.qml new file mode 100644 index 0000000..09441fa --- /dev/null +++ b/dotfiles/quickshell/HyprChrome/Widgets/Lock/LockBackdrop.qml @@ -0,0 +1,86 @@ +pragma ComponentBehavior: Bound + +import QtQuick +import qs.HyprChrome.Theme + +// ChromeBackdrop's drafting grid at full dim, as a plain Item: a lock surface +// cannot host a PanelWindow, and nothing behind it is shown anyway. +Item { + id: root + + property int gridSpacing: 60 + property real gridOpacity: 0.10 + property real crossOpacity: 0.15 + property int crossSize: 20 + property int crossWeight: 3 + + readonly property color gridColor: Qt.hsla(Theme.accent.hslHue, + Theme.accent.hslSaturation * 0.45, + Theme.accent.hslLightness, + 1) + + Rectangle { + anchors.fill: parent + color: Theme.surface + } + + Repeater { + model: Math.ceil(root.width / root.gridSpacing) + + Rectangle { + required property int index + + x: index * root.gridSpacing + width: 1 + height: root.height + color: root.gridColor + opacity: root.gridOpacity + } + } + + Repeater { + model: Math.ceil(root.height / root.gridSpacing) + + Rectangle { + required property int index + + y: index * root.gridSpacing + width: root.width + height: 1 + color: root.gridColor + opacity: root.gridOpacity + } + } + + Repeater { + id: crosses + + readonly property int columns: Math.ceil(root.width / (root.gridSpacing * 2)) + 1 + readonly property int rows: Math.ceil(root.height / (root.gridSpacing * 2)) + 1 + model: columns * rows + + Item { + required property int index + + x: (index % crosses.columns) * root.gridSpacing * 2 - Math.floor(root.crossSize / 2) + y: Math.floor(index / crosses.columns) * root.gridSpacing * 2 - Math.floor(root.crossSize / 2) + width: root.crossSize + height: root.crossSize + opacity: root.crossOpacity + + Rectangle { + y: Math.floor(root.crossSize / 2) - Math.floor(root.crossWeight / 2) + width: parent.width + height: root.crossWeight + color: Theme.muted + } + + Rectangle { + x: Math.floor(root.crossSize / 2) - Math.floor(root.crossWeight / 2) + width: root.crossWeight + height: parent.height + color: Theme.muted + } + } + } +} diff --git a/dotfiles/quickshell/lock.qml b/dotfiles/quickshell/lock.qml new file mode 100644 index 0000000..e457be0 --- /dev/null +++ b/dotfiles/quickshell/lock.qml @@ -0,0 +1,9 @@ +import Quickshell +import qs.HyprChrome.Widgets.Lock + +// Session lock entry point: `qs -n -p lock.qml`, from the SUPER+L bind and +// hypridle (home/desktop/hyprland.nix). Separate from shell.qml so a shell +// reload or crash cannot take the lock down with it. +Scope { + Lock {} +} diff --git a/dotfiles/quickshell/tests/LockPanelHeadless.qml b/dotfiles/quickshell/tests/LockPanelHeadless.qml new file mode 100644 index 0000000..f75e460 --- /dev/null +++ b/dotfiles/quickshell/tests/LockPanelHeadless.qml @@ -0,0 +1,27 @@ +import QtQuick +import qs.HyprChrome.Widgets.Greeter + +// Offscreen render of the lock panel (Lock.qml) after a rejected password. +// +// ./tools/quickshell-preview/render.sh \ +// tests/LockPanelHeadless.qml \ +// .artifacts/quickshell-preview/lock-panel.png 700 340 +LoginContent { + width: 640 + + title: "LOCKED // TERRA" + panelId: "LCK" + meta: "PAM" + submitLabel: "UNLOCK" + userEditable: false + showPower: false + + sessionName: "hyprland" + now: new Date(2026, 8, 18, 21, 47, 38) + user: "darman" + response: "hunter2" + + message: "authentication failed" + messageIsError: true + failed: true +} diff --git a/dotfiles/scripts/start-communications.sh b/dotfiles/scripts/start-communications.sh index 4b97e2b..e058f2f 100755 --- a/dotfiles/scripts/start-communications.sh +++ b/dotfiles/scripts/start-communications.sh @@ -1,4 +1,6 @@ #!/usr/bin/env bash -# Start both comms apps; Hyprland window rules move them to special:communications. +# Start the comms apps; Hyprland window rules move them to special:communications. flatpak run org.telegram.desktop & flatpak run com.discordapp.Discord & +# terra only (hosts/terra/configuration.nix). +command -v TeamSpeak >/dev/null && TeamSpeak & diff --git a/flake.lock b/flake.lock index 62259dd..e0fe118 100644 --- a/flake.lock +++ b/flake.lock @@ -96,6 +96,20 @@ "type": "github" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1777699697, + "narHash": "sha256-Eg9b/rq/ECYwNwEXs5i9wHyhxNI0JrYx2srdI2uZMaQ=", + "rev": "382052b74656a369c5408822af3f2501e9b1af81", + "type": "tarball", + "url": "https://git.lix.systems/api/v1/repos/lix-project/flake-compat/archive/382052b74656a369c5408822af3f2501e9b1af81.tar.gz?rev=382052b74656a369c5408822af3f2501e9b1af81" + }, + "original": { + "type": "tarball", + "url": "https://git.lix.systems/lix-project/flake-compat/archive/main.tar.gz" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -114,6 +128,24 @@ "type": "github" } }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_2" + }, + "locked": { + "lastModified": 1787559586, + "narHash": "sha256-onL0VLf9vPllmT0H/OlURIU5r5t5WIEl7t4tVNKT0Nw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9d0d87172c374f89da73c1cfe6d81ae62feac1f1", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": [ @@ -135,6 +167,33 @@ "type": "github" } }, + "git-hooks": { + "inputs": { + "flake-compat": [ + "nix-citizen", + "nix-gaming", + "flake-compat" + ], + "nixpkgs": [ + "nix-citizen", + "nix-gaming", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1787424939, + "narHash": "sha256-O2tBn84NNuHrnqNVxx/XqsXwfYvS1YwBh+7CBnbCYsk=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "809414f0cdadf82cf11b06c2b29ba9b3168b3297", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -203,11 +262,11 @@ ] }, "locked": { - "lastModified": 1792568604, - "narHash": "sha256-40PabARRs++ptuCotyOi/i6P3ji2Qfr+uEtoD874iGU=", + "lastModified": 1792708132, + "narHash": "sha256-KWzan2yw8+TNAom52z9fl7QLb9YtlmdBljrU3rHruG0=", "ref": "refs/heads/main", - "rev": "44047fe73352e452766898f825c999f1dba12eff", - "revCount": 12, + "rev": "db9eb1effdb826d92af10da9a15b6fa1a41adc57", + "revCount": 15, "type": "git", "url": "file:///mnt/hdd_01/data/Dev/repos/hyprchrome-claude" }, @@ -223,11 +282,11 @@ ] }, "locked": { - "lastModified": 1792519848, - "narHash": "sha256-nMIiq5qAJoEYdR4RKVWOBMyi7iHPs+TyNz7DdbhEjmw=", + "lastModified": 1792599601, + "narHash": "sha256-gTialtsxWsqwDJP1g/WXq4zaAdPpxbTPfFNtRT8clvg=", "ref": "refs/heads/m5-polish", - "rev": "b2408c0789ca34949db15c861318ceac360963bc", - "revCount": 7, + "rev": "e8a47ccc70b82193acfa595c1070343d6b91bd9e", + "revCount": 8, "type": "git", "url": "file:///mnt/hdd_01/data/Dev/repos/hyprchrome-files" }, @@ -333,6 +392,46 @@ "type": "github" } }, + "nexusmods-app": { + "flake": false, + "locked": { + "lastModified": 1792841846, + "narHash": "sha256-phMkc6bsvT0IzQ81rIMdnsrwXSHkwX69hL1mM1QW6e0=", + "ref": "feat/bg3-load-order", + "rev": "2a118e6e98811223526e1f5595390d81f9206b62", + "revCount": 8786, + "submodules": true, + "type": "git", + "url": "file:///mnt/hdd_01/data/Dev/repos/nexus-mods-app" + }, + "original": { + "ref": "feat/bg3-load-order", + "submodules": true, + "type": "git", + "url": "file:///mnt/hdd_01/data/Dev/repos/nexus-mods-app" + } + }, + "nix-citizen": { + "inputs": { + "flake-compat": "flake-compat_2", + "nix-gaming": "nix-gaming", + "nixpkgs": "nixpkgs_2", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1788562485, + "narHash": "sha256-tOCjZk7HheGqcyPtEWnMjCO6W9dZI6ATo/RpMsASeLg=", + "owner": "LovingMelody", + "repo": "nix-citizen", + "rev": "4d6a91388f113ecdd8aff478a50b947c584b0b2f", + "type": "github" + }, + "original": { + "owner": "LovingMelody", + "repo": "nix-citizen", + "type": "github" + } + }, "nix-flatpak": { "locked": { "lastModified": 1791644268, @@ -348,6 +447,33 @@ "type": "github" } }, + "nix-gaming": { + "inputs": { + "flake-compat": [ + "nix-citizen", + "flake-compat" + ], + "flake-parts": "flake-parts_2", + "git-hooks": "git-hooks", + "nixpkgs": [ + "nix-citizen", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1788236945, + "narHash": "sha256-MmEtOeX/RQlnan/jIgjFhm1j7KUKv8p5o7zRsXEEq3g=", + "owner": "fufexan", + "repo": "nix-gaming", + "rev": "f4434220501c23e7154bca5262e5b2fd7efa4490", + "type": "github" + }, + "original": { + "owner": "fufexan", + "repo": "nix-gaming", + "type": "github" + } + }, "nix-vm-test": { "inputs": { "nixpkgs": [ @@ -384,7 +510,7 @@ "nixpkgs": [ "nixpkgs" ], - "treefmt-nix": "treefmt-nix" + "treefmt-nix": "treefmt-nix_2" }, "locked": { "lastModified": 1792008544, @@ -485,6 +611,21 @@ "type": "github" } }, + "nixpkgs-lib_2": { + "locked": { + "lastModified": 1785031560, + "narHash": "sha256-OmshNvn2vupOFpYinLUu+1Dnpu4n7Q5N3ggGVNHpkUI=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "0e79af5e3d4dcfcd676ab5ba3f95d2e3352e078c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "nixpkgs-unstable": { "locked": { "lastModified": 1792116957, @@ -502,6 +643,22 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1788316716, + "narHash": "sha256-bc7rSpXIdn9QWGNqfWcPZWOhEVF8NoeAZkWq0XWnf/k=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3ed67ec0a4d3c7ab4ae1f04f8ee8df07bfa506a2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1792295010, "narHash": "sha256-F7meJtbqGttmUoMmYjRRgkVs42sn7bh7vvRvLPlUN98=", @@ -629,10 +786,12 @@ "livesync-bridge": "livesync-bridge", "mediamanager-nix": "mediamanager-nix", "millennium": "millennium", + "nexusmods-app": "nexusmods-app", + "nix-citizen": "nix-citizen", "nix-flatpak": "nix-flatpak", "nixos-anywhere": "nixos-anywhere", "nixos-images": "nixos-images", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", "nixpkgs-unstable": "nixpkgs-unstable", "sops-nix": "sops-nix", "tbctl": "tbctl", @@ -712,6 +871,27 @@ } }, "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nix-citizen", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1786901030, + "narHash": "sha256-WSFCsDSE5ffgD2MqzkM2CYjeFiKhRF/dJUN8uedb6YE=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "27b3b12a8e6375f28ebe122f07d230ca5459bbfa", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, + "treefmt-nix_2": { "inputs": { "nixpkgs": [ "nixos-anywhere", diff --git a/flake.nix b/flake.nix index 8788c0e..021d5c5 100644 --- a/flake.nix +++ b/flake.nix @@ -95,12 +95,21 @@ url = "git+file:///mnt/hdd_01/data/Dev/repos/hyprchrome-files"; inputs.nixpkgs.follows = "nixpkgs"; }; + # NexusMods.App (terra): source of nixpkgs' package overridden with the + # local checkout's BG3 branch, see services/desktop/nexusmods-app.nix. + # Commit there, then `nix flake update nexusmods-app` here. + nexusmods-app = { + url = "git+file:///mnt/hdd_01/data/Dev/repos/nexus-mods-app?ref=feat/bg3-load-order&submodules=1"; + flake = false; + }; # Millennium Steam client modding (terra). Its overlay builds against our # nixpkgs; nixpkgs-bun stays pinned since a fixed-output hash depends on it. millennium = { url = "github:SteamClientHomebrew/Millennium?dir=packages/nix"; inputs.nixpkgs.follows = "nixpkgs"; }; + # Star Citizen (terra). No nixpkgs follows: keeps wine-astral on its Cachix. + nix-citizen.url = "github:LovingMelody/nix-citizen"; }; outputs = { self, nixpkgs, disko, nixos-anywhere, sops-nix, nixos-images, home-manager, mediamanager-nix, authentik-nix, ... }@inputs: diff --git a/home/desktop/default.nix b/home/desktop/default.nix index 51564f6..21cdd46 100644 --- a/home/desktop/default.nix +++ b/home/desktop/default.nix @@ -69,6 +69,16 @@ in nix-direnv.enable = true; }; + # Only active under `mangohud %command%`; logs every frame from launch. + programs.mangohud = { + enable = true; + settings = { + output_folder = "/home/darman/mangologs"; + log_interval = 0; + autostart_log = 1; + }; + }; + # Rootless podman runs containers as darman; compose v2 talks to a socket # rather than the docker CLI shim, so point it at the user podman socket # instead of the root one. diff --git a/home/desktop/hyprland.nix b/home/desktop/hyprland.nix index 95d823c..0e23dd7 100644 --- a/home/desktop/hyprland.nix +++ b/home/desktop/hyprland.nix @@ -38,6 +38,10 @@ let bindo = keys: dispatcher: opts: { _args = [ keys dispatcher opts ]; }; # SUPER + 1..9 → workspaces 1..9, SUPER + 0 → workspace 10. + # HyprChrome lock screen (dotfiles/quickshell/lock.qml); -n so a second + # lock request is a no-op. + lockCmd = "${lib.getExe pkgs.quickshell} -n -p ${config.xdg.configHome}/quickshell/lock.qml"; + wsKeys = [ { k = "1"; n = 1; } { k = "2"; n = 2; } { k = "3"; n = 3; } { k = "4"; n = 4; } { k = "5"; n = 5; } { k = "6"; n = 6; } @@ -56,6 +60,15 @@ in }; }; + # Turns `loginctl lock-session` (SUPER+L, and logind before suspend) into the lock. + services.hypridle = { + enable = true; + settings.general = { + lock_cmd = lockCmd; + before_sleep_cmd = "loginctl lock-session"; + }; + }; + wayland.windowManager.hyprland = { enable = true; # Unloaded for now; re-add together with the plugin.hyprchrome settings below. @@ -118,6 +131,9 @@ in close_special_on_empty = true; disable_hyprland_logo = true; disable_splash_rendering = true; + # Lets a crashed lock be retaken by relaunching it instead of + # leaving the "lock app died" screen up. + allow_session_lock_restore = true; }; binds = { @@ -202,7 +218,7 @@ in (bind "SUPER + S" (dsp.exec "grim -o ${cfg.primaryOutput} ~/screenshot.png")) (bind "SUPER + SHIFT + S" (dsp.exec "grimblast copy area --freeze")) (bind "Print" (dsp.exec "rishot")) - (bind "SUPER + L" (dsp.exec "hyprlock")) + (bind "SUPER + L" (dsp.exec "loginctl lock-session")) (bind "SUPER + W" (dsp.exec "waypaper --random")) # window management @@ -263,10 +279,12 @@ in # ---- window rules (windowrules.conf) ---- window_rule = [ { name = "games"; match.class = "gamescope"; workspace = "name:game"; opacity = "1 1 override"; } + # wine's wayland driver sets the class to the lowercased exe name + { name = "star-citizen"; match.class = "starcitizen[.]exe"; workspace = "name:game"; opacity = "1 1 override"; } { name = "vivaldi"; match.title = "(.*)(- YouTube - Vivaldi)"; opacity = "1 1 override"; } { name = "jetbrains"; match.class = "(jetbrains-)(.*)"; no_initial_focus = true; float = true; center = true; } { name = "jetbrains-toolbox"; match.class = "jetbrains-toolbox"; move = "1933 21"; } - { name = "comms"; match.class = "discord|org.telegram.desktop"; workspace = "special:communications"; } + { name = "comms"; match.class = "discord|org.telegram.desktop|teamspeak-client"; workspace = "special:communications"; } { name = "music"; match.class = "qbz"; workspace = "special:music"; } { name = "vicinae"; match.class = "vicinae"; stay_focused = true; } { name = "gitkraken"; match.class = "gitkraken"; workspace = "special:version_control"; } @@ -299,5 +317,8 @@ in }; }; - xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-cosmic ]; + # home-manager points the portal at ITS profile (NIX_XDG_DESKTOP_PORTAL_DIR), + # so backends must be listed here too, not only in desktop-hyprland.nix. + # gtk provides AppChooser, without which there is no OpenURI (xdg-open). + xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-cosmic pkgs.xdg-desktop-portal-gtk ]; } diff --git a/hosts/mars/hermes-agent.nix b/hosts/mars/hermes-agent.nix index 72066c0..a6d1ab3 100644 --- a/hosts/mars/hermes-agent.nix +++ b/hosts/mars/hermes-agent.nix @@ -38,9 +38,10 @@ let # it's inside Hermes's own write-safe root (HERMES_WRITE_SAFE_ROOT). dropboxDir = "/mnt/jupiter/AppData/hermes-dropbox"; - # v2026.9.14, pinned by index digest rather than floating + # v0.22.3, pinned by index digest rather than floating # :latest, so bumping Hermes is an explicit edit here, not silent drift. - hermesImage = "docker.io/nousresearch/hermes-agent@sha256:99641e57ec762c59e54cb44aa6746b7fc68c18b3c5ddb088af54234c613d9294"; + # Its Python is 3.14 — the in-process STT venv below must match it. + hermesImage = "docker.io/nousresearch/hermes-agent@sha256:2f305c9bdc81731f48664586d23cb6a6f838a15ad7be1bfabe0c3c269d8e09b9"; # Kept identical to jupiter's instance purely so nothing else needs to # change if state ever gets migrated over. @@ -78,9 +79,6 @@ let builtins.readFile ./gitea-pr-review-prompt.md ); - # Mnemosyne memory provider: third-party plugin, not in the image. - mnemosyneEnv = pkgs.callPackage ../../pkgs/mnemosyne-env.nix { }; - # KittenTTS voice provider inputs (CPU-only; model + wheel hash-pinned). # Provisioning unit near the bottom of this file; background on why the # deps deviate from upstream's declaration lives in @@ -97,12 +95,26 @@ let kittenttsReqs = pkgs.writeText "kittentts-requirements.txt" ( builtins.readFile ./kittentts/requirements.txt ); - # STT add-on: faster-whisper (CPU) for Telegram voice-note transcription, - # same side-venv, appended by the provisioning unit. Keeps one venv + one - # stamp for the whole local-audio stack. See kittentts/stt-requirements.txt. + # STT: faster-whisper (CPU) for voice-note transcription, in its own venv: + # Hermes imports it in-process, so it must be built for the IMAGE's Python + # (3.14), while KittenTTS runs its venv's own 3.13 interpreter as a command. + # Same provisioning unit and stamp. See kittentts/stt-requirements.txt. kittenttsSttReqs = pkgs.writeText "kittentts-stt-requirements.txt" ( builtins.readFile ./kittentts/stt-requirements.txt ); + # stt.local.model "base", staged into the same offline HF cache: re-delivery + # replaces that whole tree, so an unpinned download would be wiped with it. + whisperRev = "ebe41f70d5b6dfa9166e2c581c45c9c0cfc57b66"; + whisperFile = name: hash: pkgs.fetchurl { + url = "https://huggingface.co/Systran/faster-whisper-base/resolve/${whisperRev}/${name}"; + inherit hash; + }; + whisperModel = pkgs.linkFarm "faster-whisper-base" { + "config.json" = whisperFile "config.json" "sha256-VqbYEQ0xHxnI8EceVigyx1J/FGtWcnW/yln898GE2po="; + "model.bin" = whisperFile "model.bin" "sha256-0BwwFIgcnG8xM8GC89KIfrbKHHiadTjFwAcZaFegpqk="; + "tokenizer.json" = whisperFile "tokenizer.json" "sha256-+3tjGR6bsEUILHn9dCoxBqEsmVE6sw30oNR/pstv0Ks="; + "vocabulary.txt" = whisperFile "vocabulary.txt" "sha256-NM4/4cUEECez+NQpEicJk/mG28S7NM8n+VHjSh5FORM="; + }; kittenttsStub = pkgs.writeText "kitten-tts-stub.py" ( builtins.readFile ./kittentts/kitten-misaki-stub.py ); @@ -145,10 +157,12 @@ in users.groups.hermes.gid = 983; users.users.darman.extraGroups = [ "hermes" ]; - # `hermes ` == `sudo podman exec -it hermes-agent hermes `. sudo - # is needed because oci-containers runs rootful podman, a separate - # namespace from darman's own rootless one. - programs.zsh.shellAliases.hermes = "sudo podman exec -it hermes-agent hermes"; + # `hermes ` runs the CLI in the container. sudo is needed because + # oci-containers runs rootful podman, a separate namespace from darman's own + # rootless one. `-u hermes`: run as root, `hermes pm`/`plugins` leave + # root-owned state under /opt/data/installs that the gateway then can't + # write ("install state is not writable by this user"; 2026-10-21). + programs.zsh.shellAliases.hermes = "sudo podman exec -it -u hermes -w /opt/data hermes-agent hermes"; systemd.tmpfiles.rules = [ "d ${stateDir} 0750 root hermes -" @@ -330,6 +344,11 @@ in mv -f "$f.new" "$f" ' _ ${hermesHome}/honcho.json write_env_key API_SERVER_KEY < ${config.sops.secrets.hermes_api_server_key.path} + write_env_key MATRIX_ACCESS_TOKEN < ${config.sops.secrets.matrix_access_token.path} + # Not a secret, but with gateway.multiplex_profiles on the authorization check + # reads only the profile's .env; from the container env it answered with a + # pairing code instead. + printf %s "@darman:mgaction.town" | write_env_key MATRIX_ALLOWED_USERS # Pinned: overwritten every start, so dashboard edits and her own approved # edits don't survive (a broken one corrupted it on 2026-09-24). Persona @@ -410,12 +429,22 @@ in HF_HOME = "/opt/data/kittentts-hf"; HF_HUB_OFFLINE = "1"; - # STT (local whisper): expose the side-venv's site-packages to Hermes's + # STT (local whisper): expose the STT venv's site-packages to Hermes's # own interpreter so faster-whisper imports in-process. PYTHONPATH dirs # don't run .pth auto-imports, but faster-whisper has no dead imports — # it imports cleanly from a plain path injection (unlike kittentts, # which is driven through the command wrapper for exactly that reason). - PYTHONPATH = "/opt/data/kittentts-venv/lib/python3.13/site-packages"; + PYTHONPATH = "/opt/data/stt-venv/lib/python3.14/site-packages"; + + # Matrix as @luna:mgaction.town, alongside Telegram (which keeps cron + # delivery). Device ID must match the token's; E2EE state is in + # /opt/data/platforms/matrix/store. + MATRIX_HOMESERVER = "https://matrix.mgaction.town"; + MATRIX_USER_ID = "@luna:mgaction.town"; + MATRIX_DEVICE_ID = "HERMES"; + MATRIX_E2EE_MODE = "optional"; + # First start bootstraps cross-signing and writes its recovery key here once. + MATRIX_RECOVERY_KEY_OUTPUT_FILE = "/opt/data/matrix-recovery-key"; }; environmentFiles = [ config.sops.templates."hermes-agent.env".path ]; cmd = [ "gateway" "run" ]; @@ -431,7 +460,11 @@ in # prepare-dirs is an inactive oneshot, and switch-to-configuration only # restarts ACTIVE units — so editing its script otherwise lands nowhere # until something else happens to restart the container. - restartTriggers = [ config.systemd.services.hermes-agent-prepare-dirs.script ]; + # Same for the KittenTTS/STT provisioner, which the restart pulls in first. + restartTriggers = [ + config.systemd.services.hermes-agent-prepare-dirs.script + config.systemd.services.hermes-agent-kittentts-provision.script + ]; }; # The two Gitea webhook routes, written as config (not via `hermes webhook @@ -480,7 +513,7 @@ in # sticks until the next restart. # # Routes not named here are left alone (the merge below is per-key); - # retire one with `sudo podman exec hermes-agent hermes webhook remove `. + # retire one with `hermes webhook remove ` (the alias above). systemd.services.hermes-agent-webhook-routes = { description = "Write Hermes's Gitea webhook route config"; wantedBy = [ "multi-user.target" ]; @@ -568,35 +601,6 @@ in ''; }; - # Hermes discovers memory providers under $HERMES_HOME/plugins; the target - # is a store path, readable in the container via the /nix/store ro mount. - # wantedBy, not requiredBy: a failure leaves Hermes on built-in memory. - systemd.services.hermes-agent-mnemosyne-plugin = { - description = "Link Mnemosyne provider into the Hermes plugin dir"; - before = [ "podman-hermes-agent.service" ]; - wantedBy = [ "podman-hermes-agent.service" ]; - after = [ "hermes-agent-prepare-dirs.service" ]; - requires = [ "hermes-agent-prepare-dirs.service" ]; - path = [ pkgs.coreutils ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - }; - script = '' - set -euo pipefail - pluginsDir=${hermesHome}/plugins - pluginDir=$pluginsDir/mnemosyne - target=${mnemosyneEnv}/${mnemosyneEnv.sitePackages}/hermes_memory_provider - [ -d "$target" ] || { echo "$target missing" >&2; exit 1; } - - mkdir -p "$pluginsDir" - chown ${hermesUid}:${hermesGid} "$pluginsDir" - ln -sfn "$target" "$pluginDir.new" - mv -Tf "$pluginDir.new" "$pluginDir" - chown -h ${hermesUid}:${hermesGid} "$pluginDir" - ''; - }; - # ---- KittenTTS voice provider ------------------------------------------ # CPU-only onnxruntime TTS (no GPU on mars), mini model per darman. The # upstream `misaki[en]` declaration is deliberately not honored — it pulls @@ -605,7 +609,7 @@ in # .pth-registered stub (kitten-misaki-stub.py) that fails loudly if misaki # is ever actually used. # - # Provisioner invariants (shaped by the Mnemosyne + KittenTTS review rounds): + # Provisioner invariants (shaped by its review rounds): # - Build in a ROOT-OWNED staging dir (/var/lib/hermes-kittentts, 0755 so # the uid-986 delivery step can read it; nothing in it is secret): # stamp, staging venv, uv cache and staging model copies all live there. @@ -624,7 +628,7 @@ in # - Idempotency stamp keyed on the FULL input set (requirements + wheel + # stub + model files), not just requirements (review #5); a deleted # delivered file falls out of the fast path and re-provisions cheaply. - # - Order after prepare-dirs (review #6) — mirrors the mnemosyne unit. + # - Order after prepare-dirs (review #6). # # Trust boundary: the DELIVERED venv lives inside hermesHome # (HERMES_WRITE_SAFE_ROOT), so luna can alter her own TTS engine — and a @@ -639,17 +643,15 @@ in wants = [ "network-online.target" ]; # after prepare-dirs (review #6): on a fresh state dir this unit must not # create hermesHome root-owned before prepare-dirs sets the ownership - # layout — same ordering contract the mnemosyne unit has. PLUS - # network-online ordering (review2 #3): this unit CAN download at boot - # (unlike mnemosyne's store-path build), so uv must not run before the - # network is actually up. + # layout. PLUS network-online ordering (review2 #3): this unit CAN + # download at boot, so uv must not run before the network is actually up. after = [ "network-online.target" "hermes-agent-prepare-dirs.service" ]; requires = [ "hermes-agent-prepare-dirs.service" ]; # diffutils: `cmp` in the fast path; missing, it silently re-delivers every boot. - path = [ pkgs.uv pkgs.coreutils pkgs.diffutils pkgs.util-linux pkgs.auto-patchelf pkgs.patchelf ]; + path = [ pkgs.uv pkgs.coreutils pkgs.findutils pkgs.diffutils pkgs.util-linux pkgs.patchelf ]; serviceConfig = { Type = "oneshot"; TimeoutStartSec = 600; @@ -671,34 +673,59 @@ in # into hermesHome, and only after being validated. Root doesn't follow # any uid-986-writable path while running as root. stageDir=/var/lib/hermes-kittentts + # Copied, not uv's default hardlinks: patchelf edits files in place, so + # hardlinked venvs had rewritten the CACHED wheels — av's RPATH pointed + # into a long-deleted venv in every venv built after. Hence also a fresh + # cache dir (the old one was deleted 2026-10-21). + export UV_CACHE_DIR=$stageDir/uv-cache-v2 UV_LINK_MODE=copy # Root-side staging of the DELIVERED TREE (venv + full HF hub layout # including refs/main) — everything root writes lives here. # review2 #4: root never writes into hermesHome; delivery happens as # the container uid via setpriv, copying from these root-owned sources. stageVenv=$stageDir/venv + stageStt=$stageDir/stt-venv + sttVenv=${hermesHome}/stt-venv stageHub=$stageDir/kittentts-hf stageSnap=$stageDir/hf-model + whisperDir=models--Systran--faster-whisper-base # Input key: requirements + wheel + stub + model files + resolved script. # Review #5 — a miss on the old requirements-only stamp let a changed # wheel/stub/model URL keep running the stale install forever. inputHash=$({ cat ${kittenttsReqs} ${kittenttsSttReqs} ${kittenttsWheel} ${kittenttsStub} \ ${kittenttsModelOnnx} ${kittenttsModelVoices} ${kittenttsModelConfig} - echo ${kittenttsRuntimeLibs}; } | sha256sum | cut -d' ' -f1) + echo ${kittenttsRuntimeLibs} ${pkgs.python314} ${whisperModel}; } | sha256sum | cut -d' ' -f1) stampFile=$stageDir/provision.stamp + # Appends Nix's libstdc++/zlib to every ELF's RPATH. Not auto-patchelf: it + # resolved the wheels' own vendored libs (av.libs) to absolute STAGING + # paths, gone once the venv is copied into hermesHome — STT then failed + # with "libavformat-….so: cannot open shared object file" (2026-10). + # --force-rpath keeps DT_RPATH, which unlike DT_RUNPATH also covers the + # vendored libs' own deps (libctranslate2 -> its bundled libgomp). + add_nix_rpath() { + find "$1" -type f -name '*.so*' -print0 | while IFS= read -r -d "" so; do + patchelf --print-rpath "$so" >/dev/null 2>&1 || continue + patchelf --force-rpath --add-rpath ${pkgs.lib.replaceStrings [ " " ] [ ":" ] kittenttsRuntimeLibs} "$so" + done + } + # Idempotent early exit: stamp matches the full input hash, staging venv # validated, delivered copy intact check runs below. if [ -f "$stampFile" ] && [ "$(cat "$stampFile")" = "$inputHash" ] \ && [ -x "$stageVenv/bin/python" ] \ + && [ -x "$stageStt/bin/python" ] \ && [ -f "$stageSnap/config.json" ]; then # Delivered artifacts in hermesHome must ALSO match the staging copy: # luna can rewrite her copy, that's fine — but then the missing file # forces a re-provision (cheap copy, not a rebuild) so deletions # cannot wedge the gateway without a voice. if [ -x "$venv/bin/python" ] \ + && [ -x "$sttVenv/bin/python" ] \ && cmp -s "$stageSnap/config.json" "$snap/config.json" 2>/dev/null \ && cmp -s "$stageSnap/kitten_tts_mini_v0_8.onnx" "$snap/kitten_tts_mini_v0_8.onnx" 2>/dev/null \ - && cmp -s "$stageSnap/voices.npz" "$snap/voices.npz" 2>/dev/null; then + && cmp -s "$stageSnap/voices.npz" "$snap/voices.npz" 2>/dev/null \ + && cmp -s ${whisperModel}/model.bin \ + "${hermesHome}/kittentts-hf/hub/$whisperDir/snapshots/${whisperRev}/model.bin" 2>/dev/null; then exit 0 fi fi @@ -724,16 +751,13 @@ in || ! [ -x "$stageVenv/bin/python" ] \ || ! [ -f "$stageVenv/lib/python3.13/site-packages/kitten_tts_stub.py" ]; then rm -rf "$stageVenv" - UV_CACHE_DIR=$stageDir/uv-cache \ - uv venv "$stageVenv" --python ${pkgs.python313}/bin/python3 --quiet - UV_CACHE_DIR=$stageDir/uv-cache \ - uv pip install --python "$stageVenv/bin/python" --quiet \ - --requirement ${kittenttsReqs} + uv venv "$stageVenv" --python ${pkgs.python313}/bin/python3 --quiet + uv pip install --python "$stageVenv/bin/python" --quiet \ + --requirement ${kittenttsReqs} # kittentts --no-deps: its overlay of spacy/misaki[en] is what drags in # the CUDA tree; the requirements freeze already covers its real needs. - UV_CACHE_DIR=$stageDir/uv-cache \ - uv pip install --python "$stageVenv/bin/python" --quiet --no-deps \ - ${kittenttsWheelFile} + uv pip install --python "$stageVenv/bin/python" --quiet --no-deps \ + ${kittenttsWheelFile} # Dead-import shim: .pth auto-loads kitten_tts_stub at interpreter # start so `from misaki import en, espeak` resolves without the real @@ -744,17 +768,18 @@ in # PyPI manylinux .so's (numpy, onnxruntime) need libstdc++, which the # Nix loader never finds, on the host or in the container. - auto-patchelf --paths "$stageVenv" --libs ${kittenttsRuntimeLibs} + add_nix_rpath "$stageVenv" + fi - # STT add-on: faster-whisper into the SAME venv (shares the - # numpy/onnxruntime pins; see kittentts/stt-requirements.txt). - UV_CACHE_DIR=$stageDir/uv-cache \ - uv pip install --python "$stageVenv/bin/python" --quiet \ - --requirement ${kittenttsSttReqs} - # av's bundled ffmpeg libs also need the stdc++/zlib link (already - # covered by the auto-patchelf pass above — rerun it so the newly - # installed ctranslate2/av binaries get RPATHs too). - auto-patchelf --paths "$stageVenv" --libs ${kittenttsRuntimeLibs} + # STT venv on the image's Python; the KittenTTS freeze as constraints keeps + # the shared numpy/onnxruntime/tokenizers pins. + if [ "$(cat "$stampFile" 2>/dev/null)" != "$inputHash" ] \ + || ! [ -x "$stageStt/bin/python" ]; then + rm -rf "$stageStt" + uv venv "$stageStt" --python ${pkgs.python314}/bin/python3 --quiet + uv pip install --python "$stageStt/bin/python" --quiet \ + --requirement ${kittenttsSttReqs} --constraint ${kittenttsReqs} + add_nix_rpath "$stageStt" fi # Stage the full delivered hub tree (exact hf_hub_download layout: @@ -768,6 +793,12 @@ in # No blobs/ indirection: kittentts reads paths RETURNED by # hf_hub_download, which serves the resolved snapshot file directly # (prefer-dir layout works offline for fully-materialized files). + stageWhisper=$stageHub/hub/$whisperDir + mkdir -p "$stageWhisper/refs" "$stageWhisper/snapshots/${whisperRev}" + printf '%s' "${whisperRev}" > "$stageWhisper/refs/main" + for f in config.json model.bin tokenizer.json vocabulary.txt; do + install -m 0444 ${whisperModel}/$f "$stageWhisper/snapshots/${whisperRev}/$f" + done # Root-side sanity: the staged interpreter must construct the model # END-TO-END offline (review2 minor — import alone doesn't exercise @@ -778,6 +809,8 @@ in PHONEMIZER_ESPEAK_LIBRARY="$("$stageVenv/bin/python" -c 'import espeakng_loader,pathlib;print(pathlib.Path(espeakng_loader.get_library_path()))')" \ PHONEMIZER_ESPEAK_DATA_PATH="$("$stageVenv/bin/python" -c 'import espeakng_loader,pathlib;print(pathlib.Path(espeakng_loader.get_data_path()))')" \ "$stageVenv/bin/python" -c 'from kittentts import KittenTTS; KittenTTS("KittenML/kitten-tts-mini-0.8"); print("kittentts offline build ok")' >/dev/null + HF_HOME=$stageHub HF_HUB_OFFLINE=1 \ + "$stageStt/bin/python" -c 'from faster_whisper import WhisperModel; WhisperModel("base", device="cpu", compute_type="int8")' # ---- deliver AS THE CONTAINER USER (review2 #4): root never writes # into hermesHome, so no symlink race and no `chown` step. setpriv @@ -787,14 +820,21 @@ in setpriv --reuid=${hermesUid} --regid=${hermesGid} --clear-groups \ ${pkgs.runtimeShell} -c ' set -eu - rm -rf "$1" "$2" + rm -rf "$1" "$2" "$5" cp -a "$3" "$1" cp -a "$4" "$2" + cp -a "$6" "$5" + # From the DELIVERED paths: the staging checks above passed while + # STT was broken, because only the copy had lost its libraries. + "$1/bin/python" -c "import numpy, onnxruntime" + "$5/bin/python" -c "import faster_whisper, av, ctranslate2" ' _ \ "${hermesHome}/kittentts-venv" \ "${hermesHome}/kittentts-hf" \ "$stageVenv" \ - "$stageHub" + "$stageHub" \ + "$sttVenv" \ + "$stageStt" # Stamp LAST, root-owned outside hermesHome — luna can delete it (which # forces a cheap re-delivery on next boot), not tamper via symlink. diff --git a/hosts/mars/kittentts/stt-requirements.txt b/hosts/mars/kittentts/stt-requirements.txt index 7bca9d4..eae594b 100644 --- a/hosts/mars/kittentts/stt-requirements.txt +++ b/hosts/mars/kittentts/stt-requirements.txt @@ -1,17 +1,11 @@ -# STT add-on pins for the KittenTTS side-venv on mars (faster-whisper CPU). +# STT pins for mars's in-process faster-whisper venv (stt-venv). # -# APPENDED to hosts/mars/kittentts/requirements.txt by the provisioning unit -# (see hermes-agent.nix, KittenTTS section) so ONE venv covers the entire -# local-audio stack: TTS (KittenTTS) + STT (faster-whisper). Shares the -# numpy/onnxruntime pins already frozen there — no version conflicts. +# Installed into its OWN venv on the Hermes image's Python (3.14 since v0.22), +# with kittentts/requirements.txt as constraints so the shared +# numpy/onnxruntime/tokenizers pins stay identical (see hermes-agent.nix, +# KittenTTS section). The "base" model is pinned and staged offline there too. # -# faster-whisper runs CTranslate2 on CPU; the tiny/base model (~150 MB) -# downloads once from the HF hub then works fully offline. Validated -# 2026-09-19 with a live Telegram voice note transcribed on i5-4460 CPU. -# -# NOTE on av: PyP AV 18.x needs libz/libstdc++ from the host. On NixOS those -# come via the nix store — the provisioning unit exports LD_LIBRARY_PATH with -# them at runtime (see hermes-agent.nix's kittenttsLDLibraryPath). +# Validated 2026-09-19 with a live Telegram voice note on mars's i5-4460 CPU. faster-whisper==1.2.1 ctranslate2==4.8.2 av==18.1.0 diff --git a/hosts/mars/secrets.nix b/hosts/mars/secrets.nix index 6b72843..7c3d6ea 100644 --- a/hosts/mars/secrets.nix +++ b/hosts/mars/secrets.nix @@ -56,6 +56,15 @@ "hermes-agent-prepare-dirs.service" "podman-hermes-agent.service" ]; + # @luna:mgaction.town's token (services/comms/matrix.nix): a MAS compatibility + # token for device HERMES, which never expires. Reissue on jupiter with + # `mas manage issue-compatibility-token luna HERMES`, then + # `mas manage provision-all-users` if whoami says "Token is not active" (see + # CLAUDE.md). Same .env route as above. + sops.secrets.matrix_access_token.restartUnits = [ + "hermes-agent-prepare-dirs.service" + "podman-hermes-agent.service" + ]; sops.templates."hermes-agent.env".content = '' OPENCODE_GO_API_KEY=${config.sops.placeholder.opencode_go_api_key} TELEGRAM_BOT_TOKEN=${config.sops.placeholder.telegram_bot_token} diff --git a/hosts/terra/configuration.nix b/hosts/terra/configuration.nix index 8c087fe..59589e2 100644 --- a/hosts/terra/configuration.nix +++ b/hosts/terra/configuration.nix @@ -11,6 +11,8 @@ ../../services/desktop/luna-voice.nix ../../services/dev/turtle-beach-re.nix ../../services/desktop/qbittorrent-vpn.nix + ../../services/desktop/star-citizen.nix + ../../services/desktop/nexusmods-app.nix inputs.turtle-beach-swarm-re.nixosModules.release inputs.tbctl.nixosModules.tbctl ]; @@ -32,6 +34,7 @@ # PATH, which home/desktop already provides. environment.systemPackages = [ inputs.hyprchrome-claude.packages.${pkgs.stdenv.hostPlatform.system}.default + pkgs.teamspeak6-client # successor of the TeamSpeak 5 beta ]; # hyprchrome-files (dev): the default file manager and file picker, built @@ -121,6 +124,39 @@ wallpaper = "/mnt/hdd_01/data/Pictures/Wallhaven/wallhaven-mlwz78.png"; }; + # Cast target for Jellyfin: plays files as-is in mpv, so 4K remuxes with + # DTS/DV skip the HLS remux a browser forces on jupiter's Celeron. + # Server login is a one-time dialog on first start (stored in cred.json). + home-manager.users.darman.services.jellyfin-mpv-shim = { + enable = true; + settings = { + player_name = "terra"; + fullscreen = false; + # uosc replaces both; enable_osc would re-show mpv's own OSC on top. + enable_osc = false; + thumbnail_osc_builtin = false; + }; + mpvConfig = { + vo = "gpu-next"; + hwdec = "auto-safe"; + # SDR panel: tone-map HDR10/DV down instead of passing PQ through. + target-colorspace-hint = false; + osc = false; + osd-bar = false; + osd-font = "DepartureMono Nerd Font"; + }; + }; + # The shim runs libmpv with its own config dir, so scripts go there. + home-manager.users.darman.xdg.configFile = let uosc = pkgs.mpvScripts.uosc; in { + "jellyfin-mpv-shim/scripts/uosc".source = "${uosc}/share/mpv/scripts/uosc"; + "jellyfin-mpv-shim/fonts/uosc_icons.otf".source = "${uosc}/share/fonts/uosc_icons.otf"; + "jellyfin-mpv-shim/fonts/uosc_textures.ttf".source = "${uosc}/share/fonts/uosc_textures.ttf"; + # Desktop palette (home/desktop/hyprland.nix colours). + "jellyfin-mpv-shim/script-opts/uosc.conf".text = '' + color=foreground=e8722a,foreground_text=0f1012,background=0f1012,background_text=eeeeee,curtain=0f1012,match=ff9d42 + ''; + }; + hardware.cpu.amd.updateMicrocode = true; # ---- GPU (Radeon RX 6800 XT / Navi 21) ---- diff --git a/pkgs/mnemosyne-env.nix b/pkgs/mnemosyne-env.nix deleted file mode 100644 index bc57508..0000000 --- a/pkgs/mnemosyne-env.nix +++ /dev/null @@ -1,56 +0,0 @@ -# Mnemosyne memory provider for Hermes. Built here rather than pip-installed: -# the image's Python has no pip and is PEP 668 managed. -# -# Core deps only: the embeddings extra (fastembed/onnxruntime) is optional at -# runtime, and recall falls back to FTS5. -{ - python3, - fetchPypi, -}: - -let - mnemosyneMemory = python3.pkgs.buildPythonPackage rec { - pname = "mnemosyne-memory"; - version = "3.15.1"; - pyproject = true; - - src = fetchPypi { - pname = "mnemosyne_memory"; - inherit version; - hash = "sha256-lspUMxc0pUSkhSUrNdiiO5OJ1NMC/S853EYSanXtXKM="; - }; - - build-system = with python3.pkgs; [ setuptools ]; - dependencies = with python3.pkgs; [ pyyaml ]; - - doCheck = false; # tests want a live Hermes + LLM key - # Ships the Hermes plugin package too, not just the core. - pythonImportsCheck = [ - "mnemosyne" - "hermes_memory_provider" - ]; - }; - - mnemosyneHermes = python3.pkgs.buildPythonPackage rec { - pname = "mnemosyne-hermes"; - version = "0.5.0"; - pyproject = true; - - src = fetchPypi { - pname = "mnemosyne_hermes"; - inherit version; - hash = "sha256-CzEvnUw5oPFtT5bHQQ/GBdy2C/E7qShQn32irIRYKqw="; - }; - - build-system = with python3.pkgs; [ setuptools ]; - # Upstream asks for mnemosyne-memory[embeddings]; see the header. - dependencies = [ mnemosyneMemory ] ++ (with python3.pkgs; [ pyyaml ]); - - doCheck = false; - pythonImportsCheck = [ "mnemosyne_hermes" ]; - }; -in -python3.withPackages (_: [ - mnemosyneMemory - mnemosyneHermes -]) diff --git a/secrets/mars.yaml b/secrets/mars.yaml index 32620a5..2a3da47 100644 --- a/secrets/mars.yaml +++ b/secrets/mars.yaml @@ -14,6 +14,7 @@ openrouter_api_key: ENC[AES256_GCM,data:klv/11iORtM8nbUv7RB79AyVM996V8vCU6hrTqgR pass_broker_pat: ENC[AES256_GCM,data:9fg2TG4RvmcAbd4xI1lPIRURVTNUrakTYsjfssa/v7se6RJvmX0Op6FPzufPHo8J412Fr62emGQcbPc1DFk2tEEUIJIuAGEGXp/2MADIo5XA8eM71DczzI5BTfyk67B32MfGr1hvW7AWCQWA719mg1c=,iv:1i3nA+t/Jh1vE4gHu47fAd1hsC70HB1yWywHITRLlE8=,tag:S/nIlHP4UbrQnbL+4SVqTQ==,type:str] pass_broker_telegram_token: ENC[AES256_GCM,data:l50+HIyGDQ5V9S9sD/r0z5lP2krPRV1BhrWHSAK5kQoFceQLV9GRkx5JMICTww==,iv:zuL7nXGFjYmZFVqo1rjkSNFQqE1JOlybNmCBr1rirc0=,tag:ogpFMy8txSyuGfys86k9QA==,type:str] darman_telegram_user_id: ENC[AES256_GCM,data:jdi/eFS8ZoQ=,iv:1aFs4vJjdXA2eXKxLJymcRUQtBRFyMVBNXGaTrcToo8=,tag:zpAqSpYdgs02J3WOzJwwNg==,type:str] +matrix_access_token: ENC[AES256_GCM,data:P/vKj7WNzZVusTlyeoUknZ5WcbCbhJJV92iSEnmUwAvxntb+AUVXFis=,iv:Pk6cZSqSG7LZ5Hs/Iir9do7SuP+cahnnZsNM9iwxi+g=,tag:6tN7Y/OrHsFUNQ5LlsLqew==,type:str] sops: age: - enc: | @@ -34,7 +35,7 @@ sops: oyJ7PS3lW+PxH5AZkeeU7gXO/pz2oDku0aDOds7kaD3n0+qSWicQ+Q== -----END AGE ENCRYPTED FILE----- recipient: age1eapjg6tdrr0fuvmgs3q3nlvnjkaxez298qynqqqxt0lpcv0lrsyq7ayxjk - lastmodified: "2026-10-15T23:30:38Z" - mac: ENC[AES256_GCM,data:cUtgKQ++tv3gupyFbNGaLHBHKCf6926N9a++xFFziTx9msXg5nztyWIalj8Spo4mW7hZiy1dQuyqkwxO2/ChdBnmnu2qF3JRH8k2BEJ6Cg6RmVHfvgoVefaDGv4lV+E2izloJJY0V1oKVnV6szZK+Pjkwsx8i6WqoXx8pMEMy5g=,iv:DqNRr1TOnT2ShNFRoYRwZaUoj5ZPzg0MF/cKxaqHiB4=,tag:AaphOTCdZlQZcQKsE+9fjQ==,type:str] + lastmodified: "2026-10-21T12:19:12Z" + mac: ENC[AES256_GCM,data:+JJLcpHWlQqZAfXGfSzBTxVCV2/+ADqR5v7HtwWkNPbIL5wSH5Hn40rvhuhFfhZq7rBaQQI0orri/9xbWpS3o5qC3Cfw5BYNedbs+HoG/gRO6TdY8iEwNhmioIFr13SMfJh4mji9/cA9jdliPSpeXXasmMghAT3djIjvhAZNeFg=,iv:oDszif8PrMz0bbR4Cg0Em/9pQN6zl/YGxWINVoIutg4=,tag:O7vmpT06EtQszVy9kWfeIw==,type:str] unencrypted_suffix: _unencrypted version: 3.13.3 diff --git a/services/desktop/desktop-apps.nix b/services/desktop/desktop-apps.nix index 90a507e..325458a 100644 --- a/services/desktop/desktop-apps.nix +++ b/services/desktop/desktop-apps.nix @@ -15,6 +15,11 @@ in "steam" "steam-unwrapped" "steam-run" + "rsi-launcher" # services/desktop/star-citizen.nix (terra) + "rsi-installer" + "teamspeak6-client" # terra + "7zz" # nexusmods-app-unfree (terra): RAR support + "uasm" # builds 7zz "claude-code" "claude-desktop" # services/desktop/claude-desktop.nix "proton-pass-cli" @@ -35,6 +40,9 @@ in }; hardware.graphics.enable32Bit = true; + # Rocket League LAN (UE3): 14001 discovery, 7777 game + networking.firewall.allowedUDPPorts = [ 7777 14001 ]; + environment.systemPackages = with pkgs; [ alacritty zed-editor @@ -49,8 +57,7 @@ in jq dotnetCorePackages.sdk_10_0 nodejs - yaak # desktop API client (REST/GraphQL/gRPC) - # pkgsRocm, not plain blender: Cycles needs HIP to render on the RX 6800 XT. + yaak # desktop API client (REST/GraphQL/gRPC) # pkgsRocm, not plain blender: Cycles needs HIP to render on the RX 6800 XT. pkgsRocm.blender ]; diff --git a/services/desktop/desktop-hyprland.nix b/services/desktop/desktop-hyprland.nix index 9100f16..fe17dcf 100644 --- a/services/desktop/desktop-hyprland.nix +++ b/services/desktop/desktop-hyprland.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ config, pkgs, ... }: # Hyprland (wayland) desktop: compositor, login manager, audio, portals. { @@ -9,6 +9,20 @@ services.gnome.gnome-keyring.enable = true; security.pam.services.login.enableGnomeKeyring = true; security.pam.services.greetd.enableGnomeKeyring = true; + # Quickshell lock screen (dotfiles/quickshell/HyprChrome/Widgets/Lock). + security.pam.services.hyprchrome-lock = { }; + + # The daemon PAM spawns inside greetd's session dies unseen, and Vivaldi then + # D-Bus-activates a locked one. Run it from the (lingering) user manager so + # PAM unlocks that one instead; nixpkgs builds it without socket activation. + systemd.user.services.gnome-keyring-daemon = { + description = "GNOME Keyring daemon"; + wantedBy = [ "default.target" ]; + serviceConfig = { + ExecStart = "${config.security.wrapperDir}/gnome-keyring-daemon --foreground --components=pkcs11,secrets --control-directory=%t/keyring"; + Restart = "on-failure"; + }; + }; # Audio (pipewire replaces pulseaudio/jack). security.rtkit.enable = true; @@ -20,12 +34,24 @@ xdg.portal = { enable = true; - extraPortals = [ pkgs.xdg-desktop-portal-hyprland pkgs.xdg-desktop-portal-cosmic ]; + extraPortals = [ pkgs.xdg-desktop-portal-hyprland pkgs.xdg-desktop-portal-cosmic pkgs.xdg-desktop-portal-gtk ]; config.common.default = [ "hyprland" "cosmic" ]; + # OpenURI (xdg-open via xdgOpenUsePortal, apps opening links) is only + # exported when some backend implements AppChooser; only gtk does. + config.common."org.freedesktop.impl.portal.AppChooser" = [ "gtk" ]; + # Steam's private /tmp hides vivaldi's singleton socket; links opened there + # started a second browser on the same profile. + xdgOpenUsePortal = true; }; hardware.graphics.enable = true; # OpenGL/Vulkan for the compositor + apps services.libinput.enable = true; networking.networkmanager.enable = true; + networking.networkmanager.dns = "systemd-resolved"; + # Fallback only applies when DHCP gave no DNS; networks that block public :53 still work. + services.resolved = { + enable = true; + settings.Resolve.FallbackDNS = [ "1.1.1.1" "9.9.9.9" ]; + }; } diff --git a/services/desktop/nexusmods-app.nix b/services/desktop/nexusmods-app.nix new file mode 100644 index 0000000..8a9a490 --- /dev/null +++ b/services/desktop/nexusmods-app.nix @@ -0,0 +1,28 @@ +{ pkgs, inputs, ... }: + +# NexusMods.App (dev): nixpkgs' package built from the local checkout instead +# of the v0.21.1 release, for the Baldur's Gate 3 load order (modsettings.lsx) +# work on the feat/bg3-load-order branch. Builds the branch's last commit, so +# commit there, then `nix flake update nexusmods-app` here. +# +# The branch is based on a main commit after v0.21.1 with the same +# Directory.Packages.props, so nixpkgs' NuGet lock (deps.json) still applies. +# If a build fails restoring packages, regenerate it with the package's +# passthru.fetch-deps. +let + version = "0.21.1-bg3"; + nexusmods-app = pkgs.nexusmods-app-unfree.overrideAttrs (old: { + inherit version; + src = inputs.nexusmods-app; + # nixpkgs links the release tag, which a local checkout doesn't have + meta = old.meta // { + changelog = "https://github.com/Nexus-Mods/NexusMods.App/blob/main/CHANGELOG.md"; + }; + }); +in +{ + environment.systemPackages = [ nexusmods-app ]; + + # Upstream discontinued the app, which nixpkgs flags as a known vulnerability. + nixpkgs.config.permittedInsecurePackages = [ "nexusmods-app-unfree-${version}" ]; +} diff --git a/services/desktop/star-citizen.nix b/services/desktop/star-citizen.nix new file mode 100644 index 0000000..bdbb9e4 --- /dev/null +++ b/services/desktop/star-citizen.nix @@ -0,0 +1,37 @@ +{ inputs, pkgs, ... }: + +let + sc = inputs.nix-citizen.packages.${pkgs.stdenv.hostPlatform.system}; +in + +# Star Citizen via nix-citizen's RSI Launcher (wine-astral). The module also +# sets the LUG prerequisites: vm.max_map_count, file limits, joystick udev, ntsync. +{ + imports = [ inputs.nix-citizen.nixosModules.StarCitizen ]; + + nix.settings = { + substituters = [ "https://nix-citizen.cachix.org" ]; + trusted-public-keys = [ "nix-citizen.cachix.org-1:lPMkWc2X8XD4/7YPEEwXKKBg+SVbYTVrAaLA2wQTKCo=" ]; + }; + + programs.rsi-launcher = { + enable = true; + # The overlay rebuilds wine-astral + mingw gcc against our nixpkgs (no cache + # hit; froze terra), and its fallback indexes packages by the platform attrset. + includeOverlay = false; + package = sc.rsi-launcher; + wine = sc.wine-astral; + location = "/mnt/ssd_01/games/rsi-launcher"; # ~130G, wants an SSD + # No gamescope: nested it has no clipboard sync and a us keymap, and it can't + # wrap just the game (the launcher spawns it). Workspace: home/desktop/hyprland.nix. + # Back onto wine's X11 driver: the Wayland one's clipboard dies on Hyprland + # ("opcode 3 of zwlr_data_control_device_v1 is NULL"). Runs after the script disables it. + preCommands = ''WINEDLLOVERRIDES="''${WINEDLLOVERRIDES%;winex11.drv=d}"''; + }; + + # The game peaks above terra's 32G and has no swap to fall back on. + zramSwap = { + enable = true; + memoryPercent = 50; + }; +}