Compare commits

..
Author SHA1 Message Date
luna 76ebc8c822 mars: add KittenTTS voice provider (CPU-only, offline mini model)
tts.provider: kittentts, voice Luna, mini-0.8 model (80M params) per
darman. CPU-only onnxruntime inference — no GPU on mars, validated ~1x
realtime on a weaker dev box. Upstream's misaki[en]+spacy declaration is
deliberately not honored (pulls torch→CUDA, 5.6 GB); a .pth-registered
stub satisfies the dead misaki import, failing loudly if it is ever
actually used. HF model cache pre-seeded from hash-pinned store paths so
HF_HUB_OFFLINE=1 runs with zero boot-time network. Provisioner shaped by
the Mnemosyne review: uv venv --clear, root never executes python from
the venv, ownership to the container uid before anything imports, stamp
checked against venv+model files.
2026-09-19 12:09:03 +00:00
16 changed files with 422 additions and 980 deletions
+2 -5
View File
@@ -70,9 +70,8 @@ configured via `.qmlls.ini` for editor diagnostics.
## Architecture
`shell.qml` is a `Scope` instantiating the top-level pieces as siblings:
`HyprChromeShell` (the status rail, plus the surfaces it owns — launcher, polkit,
askpass, notifications), the ten remaining launcher variants,
`VolumeOsd` and `Vitals`. Each manages its own
`HyprChromeShell` (the status rail), the eleven launcher variants,
`Notifications`, `VolumeOsd` and `Vitals`. Each manages its own
`PanelWindow`(s); there is no central layout manager.
The one exception, and the pattern to follow for anything new that needs it, is
@@ -101,8 +100,6 @@ on it, hence the index loops in `HyprChromeShell`.
and its panels, with `Bar/Panels/BarPanel.qml` the chamfered chrome they all
extend; `Widgets/Polkit/` is the authentication agent and its dialog;
`Widgets/Launcher/` is the primary application launcher (`SUPER_L`);
`Widgets/Notifications/` is the notification daemon and its popup stack on the
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`;
`Theme/Theme.qml` is this tree's palette singleton. `DebugWindow.qml` stages a
@@ -8,7 +8,6 @@ import qs.HyprChrome.Widgets
import qs.HyprChrome.Widgets.Polkit
import qs.HyprChrome.Widgets.Launcher
import qs.HyprChrome.Widgets.Askpass
import qs.HyprChrome.Widgets.Notifications
// The hyprchrome shell: owns everything the rail's surfaces have to agree on,
// and instantiates them.
@@ -211,11 +210,6 @@ Scope {
onDismissed: shell.expanded = false
}
// Popups on the rail's monitor, below its exclusive zone.
Notifications {
screen: shell.targetScreen
}
// Polkit authentication agent. It registers for this logind session on
// creation, so it replaces hyprpolkitagent rather than coexisting with it —
// only one agent may hold a session (see hosts/terra/home/hyprland.nix).
@@ -1,272 +0,0 @@
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Widgets
import qs.HyprChrome.Theme
// Headlessly renderable visual core of one notification. Every field arrives as
// a plain property and every action leaves as a signal; Notifications.qml maps
// the server's Notification onto it.
//
// Owns its own expiry: the drain meter IS the timer, so hovering pauses both.
Item {
id: root
property string appName: ""
property string summary: ""
property string body: ""
// Icon name, path or URL; `image` (avatar, album art) wins over it.
property string appIcon: ""
property string image: ""
// 0 low, 1 normal, 2 critical — NotificationUrgency's values.
property int urgency: 1
property string time: ""
// Read structurally ({ identifier, text }). The "default" action is the
// card's own click, not a chip.
property var actions: []
// Milliseconds; 0 never expires.
property int timeout: 0
// Off for headless renders, which set `remaining` directly.
property bool countdown: true
property real remaining: 1
signal dismissed
signal expired
signal actionInvoked(string identifier)
readonly property bool critical: root.urgency === 2
readonly property color tint: root.critical ? Theme.hot : root.urgency === 0 ? Theme.muted : Theme.accent
readonly property var chipActions: {
const out = [];
for (let i = 0; i < root.actions.length; i++) {
if (root.actions[i].identifier !== "default")
out.push(root.actions[i]);
}
return out;
}
readonly property bool hasDefault: root.chipActions.length !== root.actions.length
readonly property string iconSource: {
const s = root.image !== "" ? root.image : root.appIcon;
if (s === "")
return "";
if (s.startsWith("/"))
return "file://" + s;
if (s.includes(":/"))
return s;
return Quickshell.iconPath(s, true);
}
implicitWidth: 360
implicitHeight: panel.implicitHeight
NumberAnimation on remaining {
id: drain
from: 1
to: 0
duration: Math.max(1, root.timeout)
running: root.countdown && root.timeout > 0
paused: running && hover.hovered
}
// Not drain's finished(): a value-source animation need not emit it.
onRemainingChanged: {
if (root.remaining <= 0 && root.countdown && root.timeout > 0)
root.expired();
}
HoverHandler {
id: hover
}
// Under the panel, so the close box and chips take their own clicks.
MouseArea {
anchors.fill: parent
cursorShape: root.hasDefault ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: {
if (root.hasDefault)
root.actionInvoked("default");
else
root.dismissed();
}
}
component MicroText: Text {
color: Theme.muted
font.family: Theme.microFont
font.pixelSize: 8
font.letterSpacing: 0.9
elide: Text.ElideRight
}
NotificationPanel {
id: panel
width: root.width
panelId: root.critical ? "CRT" : root.urgency === 0 ? "LOW" : "NTF"
title: (root.appName !== "" ? root.appName : "NOTIFICATION").toUpperCase()
meta: root.time
accentColor: root.tint
onCloseRequested: root.dismissed()
ColumnLayout {
width: parent.width
spacing: 8
RowLayout {
Layout.fillWidth: true
spacing: 10
// Framed, so a transparent icon still reads as a tile.
Rectangle {
Layout.alignment: Qt.AlignTop
visible: root.iconSource !== ""
implicitWidth: 40
implicitHeight: 40
color: Theme.selection
border.width: 1
border.color: Theme.hair
IconImage {
anchors.centerIn: parent
implicitSize: root.image !== "" ? 38 : 28
source: root.iconSource
}
}
ColumnLayout {
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
spacing: 3
Text {
Layout.fillWidth: true
visible: root.summary !== ""
text: root.summary
textFormat: Text.PlainText
wrapMode: Text.Wrap
maximumLineCount: 2
elide: Text.ElideRight
color: Theme.text
font.family: Theme.displayFont
font.pixelSize: 13
font.bold: true
font.letterSpacing: 0.4
}
// Body markup is advertised, so StyledText, never RichText.
Text {
Layout.fillWidth: true
visible: root.body !== ""
text: root.body
textFormat: Text.StyledText
wrapMode: Text.Wrap
maximumLineCount: 5
elide: Text.ElideRight
color: Theme.textAlpha(0.72)
linkColor: root.tint
font.family: Theme.displayFont
font.pixelSize: 11
font.letterSpacing: 0.3
onLinkActivated: link => Qt.openUrlExternally(link)
}
}
}
Flow {
Layout.fillWidth: true
visible: root.chipActions.length > 0
spacing: 6
Repeater {
model: root.chipActions
Rectangle {
id: chip
required property var modelData
width: chipLabel.implicitWidth + 16
height: chipLabel.implicitHeight + 10
color: chipArea.containsMouse ? root.tint : "transparent"
border.width: 1
border.color: chipArea.containsMouse ? root.tint : Theme.disabled
Text {
id: chipLabel
anchors.centerIn: parent
text: chip.modelData.text.toUpperCase()
color: chipArea.containsMouse ? Theme.surface : Theme.text
font.family: Theme.microFont
font.pixelSize: 9
font.letterSpacing: 0.8
}
MouseArea {
id: chipArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.actionInvoked(chip.modelData.identifier)
}
}
}
}
// Expiry drain; a sticky card states it instead.
RowLayout {
Layout.fillWidth: true
spacing: 8
Row {
id: meter
readonly property int segments: 24
Layout.fillWidth: true
Layout.preferredHeight: 4
visible: root.timeout > 0
spacing: 2
Repeater {
model: meter.segments
Rectangle {
required property int index
readonly property bool lit: index < Math.ceil(root.remaining * meter.segments)
width: Math.max(2, (meter.width - (meter.segments - 1) * meter.spacing) / meter.segments)
height: meter.height
color: lit ? root.tint : Theme.textAlpha(0.06)
border.width: 1
border.color: lit ? root.tint : Theme.textAlpha(0.18)
}
}
}
MicroText {
visible: root.timeout > 0
text: hover.hovered ? "HOLD" : Math.ceil(root.remaining * root.timeout / 1000) + "S"
color: hover.hovered ? root.tint : Theme.muted
}
MicroText {
Layout.fillWidth: true
visible: root.timeout <= 0
text: root.critical ? "CRITICAL · STICKY" : "STICKY"
color: root.critical ? Theme.hot : Theme.muted
}
}
}
}
}
@@ -1,210 +0,0 @@
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Shapes
import qs.HyprChrome.Theme
// Chamfered chrome for one notification card: PolkitPanel's silhouette, tighter
// metrics, a tintable accent (urgency) and a close box in the header.
//
// Not PolkitPanel itself: that file is the prompt's alone to restyle.
Item {
id: panel
property string panelId: ""
property string title: ""
property string meta: ""
property color accentColor: Theme.accent
property int chamfer: 12
property int padding: 12
property int outlineWidth: 1
property int accentLineThickness: 3
readonly property int headerHeight: 26
property int headerGap: 10
readonly property int headerPadding: 8
property real capGap: 4
readonly property real capOffset: panel.capGap / Math.SQRT2
readonly property real activeChamfer: Math.max(2, Math.min(panel.chamfer, panel.height / 2 - 1))
readonly property real accentLineWidth: Math.min(panel.width, slugChip.width + panel.headerPadding * 2)
default property alias content: body.data
signal closeRequested
implicitHeight: Math.round(body.y + body.height + panel.padding)
Shape {
id: panelShape
anchors.fill: parent
preferredRendererType: Shape.CurveRenderer
ShapePath {
fillColor: Theme.surface
strokeColor: Theme.hair
strokeWidth: panel.outlineWidth
startX: 0; startY: 0
PathLine { x: panelShape.width - panel.activeChamfer; y: 0 }
PathLine { x: panelShape.width; y: panel.activeChamfer }
PathLine { x: panelShape.width; y: panelShape.height }
PathLine { x: panel.activeChamfer; y: panelShape.height }
PathLine { x: 0; y: panelShape.height - panel.activeChamfer }
PathLine { x: 0; y: 0 }
}
ShapePath {
fillColor: panel.accentColor
strokeWidth: 0
startX: panelShape.width - panel.activeChamfer + panel.capOffset
startY: -panel.capOffset
PathLine { x: panelShape.width + panel.capOffset; y: panel.activeChamfer - panel.capOffset }
PathLine { x: panelShape.width + panel.capOffset; y: -panel.capOffset }
PathLine { x: panelShape.width - panel.activeChamfer + panel.capOffset; y: -panel.capOffset }
}
ShapePath {
fillColor: panel.accentColor
strokeWidth: 0
startX: panel.activeChamfer - panel.capOffset
startY: panelShape.height + panel.capOffset
PathLine { x: -panel.capOffset; y: panelShape.height - panel.activeChamfer + panel.capOffset }
PathLine { x: -panel.capOffset; y: panelShape.height + panel.capOffset }
PathLine { x: panel.activeChamfer - panel.capOffset; y: panelShape.height + panel.capOffset }
}
ShapePath {
fillColor: panel.accentColor
strokeWidth: 0
startX: 0; startY: 0
PathLine { x: panel.accentLineWidth; y: 0 }
PathLine { x: panel.accentLineWidth; y: panel.accentLineThickness }
PathLine { x: 0; y: panel.accentLineThickness }
PathLine { x: 0; y: 0 }
}
ShapePath {
fillColor: panel.accentColor
strokeWidth: 0
startX: panelShape.width; startY: panelShape.height
PathLine { x: panelShape.width - panel.accentLineWidth; y: panelShape.height }
PathLine { x: panelShape.width - panel.accentLineWidth; y: panelShape.height - panel.accentLineThickness }
PathLine { x: panelShape.width; y: panelShape.height - panel.accentLineThickness }
PathLine { x: panelShape.width; y: panelShape.height }
}
}
Row {
id: headerRow
x: panel.headerPadding
y: Math.round((panel.headerHeight - height) / 2)
width: headerEnd.x - x - 8
spacing: panel.headerPadding + 6
Rectangle {
id: slugChip
width: slugText.implicitWidth + 8
height: slugText.implicitHeight + 4
color: panel.accentColor
Text {
id: slugText
anchors.centerIn: parent
text: panel.panelId
color: Theme.surface
font.family: Theme.microFont
font.pixelSize: 10
font.bold: true
}
}
Text {
anchors.verticalCenter: slugChip.verticalCenter
width: Math.max(0, headerRow.width - slugChip.width - headerRow.spacing)
text: panel.title
color: Theme.text
font.family: Theme.displayFont
font.pixelSize: 11
font.bold: true
font.letterSpacing: 1.1
elide: Text.ElideRight
}
}
Row {
id: headerEnd
// Clear of the top-right chamfer.
anchors.right: parent.right
anchors.rightMargin: panel.activeChamfer + 2
y: Math.round((panel.headerHeight - height) / 2)
spacing: 8
Text {
anchors.verticalCenter: parent.verticalCenter
visible: panel.meta.length > 0
text: panel.meta
color: Theme.muted
font.family: Theme.microFont
font.pixelSize: 8
font.letterSpacing: 0.7
}
Rectangle {
id: closeBox
width: 16
height: 16
color: closeArea.containsMouse ? panel.accentColor : "transparent"
border.width: 1
border.color: closeArea.containsMouse ? panel.accentColor : Theme.disabled
Text {
anchors.centerIn: parent
text: "✕"
color: closeArea.containsMouse ? Theme.surface : Theme.muted
font.family: Theme.microFont
font.pixelSize: 9
font.bold: true
}
MouseArea {
id: closeArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: panel.closeRequested()
}
}
}
Rectangle {
x: 1
y: panel.headerHeight
width: parent.width - 2
height: 1
color: Theme.text
opacity: 0.12
}
// Measured by childrenRect: children carry their own size, no anchoring.
Item {
id: body
x: panel.padding
y: panel.headerHeight + panel.headerGap
width: Math.max(0, panel.width - panel.padding * 2)
height: childrenRect.height
}
}
@@ -1,131 +0,0 @@
pragma ComponentBehavior: Bound
import Quickshell
import Quickshell.Services.Notifications
import Quickshell.Wayland
import QtQuick
// Notification daemon and its popup stack, migrated from widgets/notifications.
// Owns the server and the surface; NotificationCard is the visual core.
Scope {
id: root
// Driven by the shell: the rail's monitor.
property var screen: null
// Arrival time per notification id; the server keeps none.
property var arrived: ({})
// expireTimeout is in ms (verified); -1 means "server default".
function timeoutFor(n) {
if (n.expireTimeout > 0)
return n.expireTimeout;
if (n.expireTimeout === 0 || n.urgency === NotificationUrgency.Critical)
return 0;
return 5000;
}
NotificationServer {
id: server
keepOnReload: true
bodySupported: true
bodyMarkupSupported: true
bodyHyperlinksSupported: true
imageSupported: true
actionsSupported: true
onNotification: notification => {
const id = notification.id;
root.arrived[id] = Qt.formatTime(new Date(), "hh:mm");
notification.closed.connect(() => delete root.arrived[id]);
notification.tracked = true;
}
}
PanelWindow {
id: win
screen: root.screen
visible: server.trackedNotifications.values.length > 0
WlrLayershell.namespace: "hyprchrome-notifications"
WlrLayershell.layer: WlrLayer.Overlay
// Normal with no zone of its own: sits below the rail's exclusive zone.
exclusionMode: ExclusionMode.Normal
color: "transparent"
anchors {
top: true
right: true
}
margins.top: 12
margins.right: 16
// Slack on every side for the corner caps, which sit outside each card.
implicitWidth: 360 + 8
implicitHeight: Math.max(1, stack.implicitHeight + 8)
mask: Region {
item: stack
}
Column {
id: stack
x: 4
y: 4
width: 360
spacing: 14
Repeater {
model: server.trackedNotifications
NotificationCard {
id: card
required property Notification modelData
width: stack.width
appName: card.modelData.appName
summary: card.modelData.summary
body: card.modelData.body
appIcon: card.modelData.appIcon
image: card.modelData.image
urgency: card.modelData.urgency
time: root.arrived[card.modelData.id] ?? ""
actions: card.modelData.actions
timeout: root.timeoutFor(card.modelData)
onDismissed: card.modelData.dismiss()
onExpired: card.modelData.expire()
// invoke() closes a non-resident notification itself.
onActionInvoked: identifier => {
const actions = card.modelData.actions;
for (let i = 0; i < actions.length; i++) {
if (actions[i].identifier === identifier) {
actions[i].invoke();
return;
}
}
}
// Slides in from the right edge.
opacity: 0
transform: Translate { id: slide; x: 40 }
Component.onCompleted: enter.start()
ParallelAnimation {
id: enter
NumberAnimation { target: card; property: "opacity"; to: 1; duration: 160; easing.type: Easing.OutCubic }
NumberAnimation { target: slide; property: "x"; to: 0; duration: 200; easing.type: Easing.OutCubic }
}
}
}
}
}
}
+3
View File
@@ -5,6 +5,7 @@ import Quickshell
import Quickshell.Widgets
import qs.widgets.bar
import qs.widgets.launcher
import qs.widgets.notifications
import qs.widgets.osd
import qs.widgets.systray
import qs.widgets.theme
@@ -35,6 +36,8 @@ Scope {
OrbitLauncher {} // 10 — radial targeting arena
CyberDock {} // 11 — cyberpunk bottom cartridge dock
Notifications {}
VolumeOsd {}
// Host vitals HUD — toggle with SUPER CTRL V.
@@ -1,58 +0,0 @@
import QtQuick
import qs.HyprChrome.Widgets.Notifications
// Offscreen render of the three urgencies, with actions, a link and a
// part-drained meter.
//
// ./tools/quickshell-preview/render.sh \
// tests/NotificationCardHeadless.qml \
// .artifacts/quickshell-preview/notifications.png 400 520
Rectangle {
width: 400
height: 520
color: "#1b1d20"
Column {
x: 20
y: 20
width: 360
spacing: 14
NotificationCard {
width: parent.width
appName: "Firefox"
summary: "Download complete"
body: "<b>nixos-26.05-x86_64.iso</b> finished — <a href=\"file:///tmp\">open folder</a>"
appIcon: "firefox"
time: "14:32"
actions: [
{ identifier: "default", text: "Open" },
{ identifier: "show", text: "Show in folder" },
{ identifier: "dismiss", text: "Dismiss" }
]
timeout: 5000
countdown: false
remaining: 0.6
}
NotificationCard {
width: parent.width
appName: "smartd"
summary: "Disk /dev/sdb reports 8 reallocated sectors"
body: "SMART attribute 5 crossed its threshold. Back up the RAID0 set on /mnt/data now."
urgency: 2
time: "14:30"
}
NotificationCard {
width: parent.width
appName: "nix"
summary: "Build finished"
urgency: 0
time: "14:28"
timeout: 5000
countdown: false
remaining: 0.2
}
}
}
@@ -0,0 +1,120 @@
import Quickshell.Services.Notifications
import Quickshell.Widgets
import QtQuick
import QtQuick.Layouts
import qs.widgets.theme
ColumnLayout {
id: root
required property Notification modelData
spacing: 0
Layout.fillWidth: true
Rectangle {
color: Theme.accent
implicitHeight: 5
Layout.fillWidth: true
}
WrapperRectangle {
Layout.fillWidth: true
margin: 12
border.width: 1
border.color: Theme.accent
color: Theme.surface
opacity: .9
ColumnLayout {
spacing: 4
Layout.fillWidth: true
RowLayout {
spacing: 8
Layout.fillWidth: true
IconImage {
visible: root.modelData.appIcon !== ""
source: root.modelData.appIcon
implicitSize: 20
}
Text {
text: root.modelData.summary
color: Theme.text
font.pointSize: 14
font.bold: true
elide: Text.ElideRight
Layout.fillWidth: true
}
Text {
id: dismissButton
text: "×"
color: Theme.accent
font.pointSize: 18
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: root.modelData.dismiss()
}
}
}
Text {
visible: root.modelData.body !== ""
text: root.modelData.body
color: Theme.text
font.pointSize: 12
wrapMode: Text.Wrap
Layout.fillWidth: true
}
RowLayout {
visible: root.modelData.actions.length > 0
spacing: 6
Layout.fillWidth: true
Repeater {
model: root.modelData.actions
Rectangle {
id: actionButton
required property NotificationAction modelData
color: Theme.raised
border.width: 1
border.color: Theme.accent
implicitHeight: 28
implicitWidth: actionText.implicitWidth + 16
Text {
id: actionText
anchors.centerIn: parent
text: actionButton.modelData.text
color: Theme.text
font.pointSize: 12
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: actionButton.modelData.invoke()
}
}
}
}
}
}
}
@@ -0,0 +1,79 @@
import Quickshell
import Quickshell.Services.Notifications
import QtQuick
import QtQuick.Layouts
Scope {
id: root
NotificationServer {
id: server
keepOnReload: true
bodySupported: true
bodyMarkupSupported: true
imageSupported: true
actionsSupported: true
actionIconsSupported: true
onNotification: notification => {
notification.tracked = true;
const timeout = notification.expireTimeout === 0 ? 0 : notification.expireTimeout > 0 ? notification.expireTimeout : (notification.urgency === NotificationUrgency.Critical ? 0 : 5000);
if (timeout <= 0)
return;
let closed = false;
notification.closed.connect(() => {
closed = true;
});
const timer = expiryTimerComponent.createObject(root, {
interval: timeout
});
timer.triggered.connect(() => {
if (!closed)
notification.expire();
timer.destroy();
});
}
}
Component {
id: expiryTimerComponent
Timer {
running: true
}
}
PanelWindow {
screen: Quickshell.screens.find(s => s.name === "DP-2")
color: "transparent"
anchors {
top: true
right: true
}
margins.top: 12
margins.right: 12
implicitWidth: 340
implicitHeight: column.implicitHeight
ColumnLayout {
id: column
anchors.fill: parent
spacing: 8
Repeater {
model: server.trackedNotifications
NotificationPopup {}
}
}
}
}
-22
View File
@@ -47,30 +47,8 @@
# the container with it — confirmed the hard way (~60-70s per start).
"x-systemd.mount-timeout=10s"
"_netdev"
# Hermes' RequiresMountsFor mounts this at boot, not lazily, and nothing
# retries a failed mount.
"x-systemd.requires=jupiter-reachable.service"
];
};
# jupiter resolves to its tailnet IP, and network-online.target fires on the
# LAN link before tailscaled has routed tailscale0. 5min covers jupiter
# cold-booting alongside mars.
systemd.services.jupiter-reachable = {
description = "Wait for jupiter's samba over the tailnet";
after = [ "network-online.target" "tailscaled.service" ];
wants = [ "network-online.target" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
TimeoutStartSec = 300;
};
script = ''
until timeout 2 ${pkgs.bash}/bin/bash -c 'exec 3<>/dev/tcp/jupiter/445' 2>/dev/null; do
sleep 2
done
'';
};
system.stateVersion = "26.05"; # set at install time; do NOT bump on upgrades
}
+112 -224
View File
@@ -52,10 +52,6 @@ let
# is hers to make, anywhere inside HERMES_WRITE_SAFE_ROOT=/opt/data.
giteaHost = "git.mgaction.town";
# neptun's tailnet IP: its Caddy is the only proxy whose X-Forwarded-Proto
# the dashboard should trust.
neptunTailnetIp = "100.64.0.5";
# luna's webhook filters, mounted READ-ONLY from the nix store rather than
# written into hermesHome: that IS her write-safe root, so a writable copy
# would let her edit her own loop guard back out. A missing script fails
@@ -78,7 +74,11 @@ let
builtins.readFile ./gitea-pr-review-prompt.md
);
# Mnemosyne memory provider: third-party plugin, not in the image.
# Mnemosyne memory provider (local SQLite, third-party plugin — not bundled
# with the official image). Fully built as a Nix derivation — see
# pkgs/mnemosyne-env.nix — and mounted READ-ONLY into the container at a
# fixed path. The oneshot near the bottom of this file only writes the
# plugin symlink Docker needs at $HERMES_HOME/plugins/mnemosyne.
mnemosyneEnv = pkgs.callPackage ../../pkgs/mnemosyne-env.nix { };
# KittenTTS voice provider inputs (CPU-only; model + wheel hash-pinned).
@@ -89,33 +89,22 @@ let
url = "https://github.com/KittenML/KittenTTS/releases/download/0.8.1/kittentts-0.8.1-py3-none-any.whl";
sha256 = "sha256-SCpDbE8fMZIVNxA3bkWf82iVF+vNp8KwUeL9QYe0GFE=";
};
# uv parses the version out of the filename; the store hash prefix breaks it.
kittenttsWheelFile = "${pkgs.linkFarm "kittentts-wheel" {
"kittentts-0.8.1-py3-none-any.whl" = kittenttsWheel;
}}/kittentts-0.8.1-py3-none-any.whl";
kittenttsRuntimeLibs = "${pkgs.stdenv.cc.cc.lib}/lib ${pkgs.zlib}/lib";
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.
kittenttsSttReqs = pkgs.writeText "kittentts-stt-requirements.txt" (
builtins.readFile ./kittentts/stt-requirements.txt
);
kittenttsStub = pkgs.writeText "kitten-tts-stub.py" (
builtins.readFile ./kittentts/kitten-misaki-stub.py
);
kittenttsModelOnnx = pkgs.fetchurl {
url = "https://huggingface.co/KittenML/kitten-tts-mini-0.8/resolve/c02725660cea441db4c383af69f1f26f5cd00947/kitten_tts_mini_v0_8.onnx";
url = "https://huggingface.co/KittenML/kitten-tts-mini-0.8/resolve/main/kitten_tts_mini_v0_8.onnx";
sha256 = "sha256-D1u65PxIAMmNvFRKh+z6eVEN4vuCItsw0S5b/pF335E=";
};
kittenttsModelVoices = pkgs.fetchurl {
url = "https://huggingface.co/KittenML/kitten-tts-mini-0.8/resolve/c02725660cea441db4c383af69f1f26f5cd00947/voices.npz";
url = "https://huggingface.co/KittenML/kitten-tts-mini-0.8/resolve/main/voices.npz";
sha256 = "sha256-QK0mOJUrd7ey8wEn4mCOFp/GndJWtTvYqqNAmjMZPEI=";
};
kittenttsModelConfig = pkgs.fetchurl {
url = "https://huggingface.co/KittenML/kitten-tts-mini-0.8/resolve/c02725660cea441db4c383af69f1f26f5cd00947/config.json";
url = "https://huggingface.co/KittenML/kitten-tts-mini-0.8/resolve/main/config.json";
sha256 = "sha256-axYLybGeJOyyHoS8FPin2iH99H7HLUJFC8XPUUthgEo=";
};
@@ -181,7 +170,7 @@ in
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
unitConfig.RequiresMountsFor = [ "/mnt/jupiter" ];
path = [ pkgs.git pkgs.tea pkgs.curl pkgs.coreutils pkgs.yq-go ];
path = [ pkgs.git pkgs.tea pkgs.curl pkgs.coreutils ];
serviceConfig.Type = "oneshot";
# Everything here is either local or bounded to ~30s by the probe loop, so
# anything past two minutes is a hang, not slowness.
@@ -252,19 +241,6 @@ in
# scripts as uid ${hermesUid}.
chown ${hermesUid}:${hermesGid} ${hermesHome}/scripts
# trusted_proxies has no env override and Hermes owns config.yaml, so
# only this key is merged in; without it the Secure cookie flag breaks.
conf=${hermesHome}/config.yaml
[ -e "$conf" ] || : > "$conf"
# tts.provider is seeded, not pinned: `=` would stomp luna's own choice on
# every restart, and the engine is hers to change (KittenTTS stays as the
# offline fallback). `//` only fills it in when unset.
yq '.dashboard.trusted_proxies = ["${neptunTailnetIp}"]
| .tts.provider = (.tts.provider // "elevenlabs")' "$conf" > "$conf.new"
chown ${hermesUid}:${hermesGid} "$conf.new"
chmod --reference="$conf" "$conf.new"
mv -f "$conf.new" "$conf"
if [ -d ${hermesHome}/.config ]; then
chown ${hermesUid}:${hermesGid} ${hermesHome}/.config
fi
@@ -286,6 +262,15 @@ in
"${hermesHome}:/opt/data"
"${dropboxDir}:/opt/data/dropbox"
# Mnemosyne memory provider — a Nix-built python env, mounted :ro.
# Nothing fetched at boot, nothing writable from inside the container.
# The plugin symlink the oneshot at the bottom of this file writes
# points at the canonical store path (site-packages passthru), which
# is visible inside thanks to the existing /nix/store ro mount, so
# this /opt/data restatement is a readability alias, not a load
# bearing path.
"${mnemosyneEnv}:/opt/data/mnemosyne-env:ro"
# luna's Obsidian vault, synced with CouchDB on jupiter by
# livesync-bridge.nix. Under /opt/data so she can write notes, not just
# read them; the bridge runs as this same uid/gid so no chown is needed.
@@ -323,21 +308,12 @@ in
HERMES_DASHBOARD_HOST = "0.0.0.0"; # must be tailscale0-reachable, not just loopback
HERMES_DASHBOARD_OIDC_ISSUER = "https://auth.mgaction.town/application/o/hermes/";
HERMES_DASHBOARD_OIDC_CLIENT_ID = "4BqdJu3htnMtSZnyEu5zHnsSOvlEbw3Ie3mYVlh6";
# Pins the OIDC redirect_uri to https; otherwise it is rebuilt from
# forwarded headers (see trusted_proxies in prepare-dirs).
HERMES_DASHBOARD_PUBLIC_URL = "https://hermes.mgaction.town";
# KittenTTS: point huggingface_hub at the pre-seeded offline cache and
# forbid network — no model drift, no boot-time fetch (review #4).
HF_HOME = "/opt/data/kittentts-hf";
HF_HUB_OFFLINE = "1";
# STT (local whisper): expose the side-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";
# uvicorn only trusts X-Forwarded-Proto from forwarded_allow_ips
# (default 127.0.0.1); neptun's Caddy reaches this over a real routed
# tailnet IP, so without this it builds an http:// redirect_uri that
# Authentik rejects. Safe to trust any peer: 9119 is already scoped to
# loopback + tailscale0 only.
FORWARDED_ALLOW_IPS = "*";
};
environmentFiles = [ config.sops.templates."hermes-agent.env".path ];
cmd = [ "gateway" "run" ];
@@ -486,9 +462,26 @@ 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.
# ---- Mnemosyne memory provider ----------------------------------------
# The provider's Python closure (mnemosyneEnv, callPackage'd
# pkgs/mnemosyne-env.nix above) is a READ-ONLY nix store path mounted into
# the container — nothing fetched at boot, nothing inside the container can
# write to it, and the mono-repo reproducibility story applies. Hermes only
# needs one mutable pickup point: $HERMES_HOME/plugins/mnemosyne, the
# symlink its discovery scan looks for. Both the plugin wrapper and its
# sibling `mnemosyne` core package live in that env's single site-packages,
# so one link covers them.
#
# Path handling: the symlink target is spelled in the CONTAINER's path
# space (/opt/data/...), because Hermes resolves the plugin from inside the
# container — the same host/container mismatch the webhook prompts already
# navigate via containerHome. Host-side the identical literal resolves
# onto the same store path through hermesHome's bind mount.
#
# Failure posture: after=, not requires= — a failed link write leaves the
# container running with whatever memory.provider falls back to Hermes's
# built-in memory, not a dead bot. The ro mount itself is evaluated at
# build time, so there is nothing provisionable to drift at runtime.
systemd.services.hermes-agent-mnemosyne-plugin = {
description = "Link Mnemosyne provider into the Hermes plugin dir";
before = [ "podman-hermes-agent.service" ];
@@ -502,13 +495,27 @@ in
};
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; }
# Target is the STORE path itself, not a /opt/data restatement: the
# container already ro-mounts /nix/store for git/tea (see the volumes
# list), so the identical literal resolves on both sides of the bind
# mount. Using the canonical store path directly — not the
# /opt/data/mnemosyne-env mount — keeps one truth and still works
# whether Hermes resolves the link inside the container or host-side
# during debugging.
target="${mnemosyneEnv.sitePackages}/hermes_memory_provider"
if [ ! -d "$target" ]; then
echo "hermes_memory_provider not found in the mnemosyne env — unit bug, not transient" >&2
exit 1
fi
mkdir -p "$pluginsDir"
chown ${hermesUid}:${hermesGid} "$pluginsDir"
# Atomic swap: write to a temp name, rename over the old link. `-T`
# errors loudly if the target turned into a directory for any reason.
ln -sfn "$target" "$pluginDir.new"
mv -Tf "$pluginDir.new" "$pluginDir"
chown -h ${hermesUid}:${hermesGid} "$pluginDir"
@@ -523,51 +530,27 @@ 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):
# - 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.
# Root never reads or executes anything the container can write — the
# container cannot symlink-takeover the stamp (review #1) or plant a
# wheel in the uv cache (review #2); only FINISHED artifacts are copied
# into hermesHome, and the stamp compares the delivered copy against
# staging byte-for-byte.
# - Root runs python ONLY from the staging venv (never from the delivered
# uid-986-owned tree in hermesHome) — after a root-side offline import
# check; a failing build aborts before anything is delivered.
# - HF model cache delivered to hermesHome from staging (refs/main ->
# snapshots/<real commit sha>), and the container env pins
# HF_HOME=/opt/data/kittentts-hf + HF_HUB_OFFLINE=1: zero boot-time
# network, no drift.
# - 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.
# Provisioner invariants (shaped by the Mnemosyne-round review):
# - `uv venv --clear`: re-provision cannot wedge on an existing dir.
# - Root runs NO python from this venv: the unit itself does only fs
# writes; the venv is chowned to the container uid before Hermes ever
# imports from it. (Hermes executes provider code as uid 986.)
# - HF model cache is PRE-SEEDED from hash-pinned store paths, so
# HF_HUB_OFFLINE=1 gives zero boot-time network and no drift.
# - Idempotent via a stamp keyed on the requirements hash; checked
# against BOTH the venv python and model files being intact.
#
# Trust boundary: the DELIVERED venv lives inside hermesHome
# (HERMES_WRITE_SAFE_ROOT), so luna can alter her own TTS engine — and a
# deleted/modified copy just triggers a fresh delivery from the root-owned
# staging area on next boot (self-heals instead of wedging). Deliberate: it's
# her voice, not her jail — the webhook filter scripts remain the only
# Trust boundary: the venv lives inside hermesHome (HERMES_WRITE_SAFE_ROOT),
# so luna can technically alter her own TTS engine. Deliberate: it's her
# voice, not her jail — the webhook filter scripts remain the only
# write-protected-but-load-bearing items.
systemd.services.hermes-agent-kittentts-provision = {
description = "Provision KittenTTS voice provider (side venv + offline HF cache)";
before = [ "podman-hermes-agent.service" ];
wantedBy = [ "podman-hermes-agent.service" ];
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.
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 ];
after = [ "network-online.target" ];
path = [ pkgs.uv pkgs.coreutils ];
serviceConfig = {
Type = "oneshot";
TimeoutStartSec = 600;
@@ -577,146 +560,51 @@ in
venv=${hermesHome}/kittentts-venv
hubDir=${hermesHome}/kittentts-hf/hub/models--KittenML--kitten-tts-mini-0.8
# Real upstream commit SHA as snapshot dir: hf_hub_download resolves
# refs/main -> snapshots/<sha>; "kitten" (review #3) is never found
# offline and silently triggers a re-download.
modelSha=c02725660cea441db4c383af69f1f26f5cd00947
snap=$hubDir/snapshots/$modelSha
# REVIEW #1/#2: nothing root touches lives in hermesHome. Stamp, staging
# venv and uv cache live root-owned under /var/lib/hermes-kittentts (a
# path the container can not pathwrite or symlinks into its own tree);
# the FINISHED staging venv and model files are the only things copied
# 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
# 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
stageHub=$stageDir/kittentts-hf
stageSnap=$stageDir/hf-model
# 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)
stampFile=$stageDir/provision.stamp
snap=$hubDir/snapshots/kitten
stampFile=${hermesHome}/kittentts-provision.stamp
reqHash=$(sha256sum ${kittenttsReqs} | cut -d' ' -f1)
# 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" ] \
&& [ -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" ] \
&& 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
exit 0
fi
# Idempotent early exit: stamp + venv + all three model files intact.
if [ -f "$stampFile" ] && [ "$(cat "$stampFile")" = "$reqHash" ] \
&& [ -x "$venv/bin/python" ] \
&& [ -f "$snap/kitten_tts_mini_v0_8.onnx" ] \
&& [ -f "$snap/voices.npz" ] \
&& [ -f "$venv/lib/python3.13/site-packages/kitten_tts_stub.py" ]; then
exit 0
fi
# ---- staging venv + staged hub tree: root-owned path, uv cache
# included. Root runs python from HERE (container can write nothing in
# this tree); the FINISHED result is copied into hermesHome AS THE
# CONTAINER USER via setpriv (review2 #4) — root never writes into
# hermesHome, so no uid-986-controlled path is ever followed while
# running as root; symlink-takeover of stamps/refs/install targets is
# structurally impossible. ----
mkdir -p "$stageDir" "$stageSnap" "$stageVenv" "$stageHub"
# 0755: the setpriv'd uid-986 delivery below must be able to read it.
chmod 0755 "$stageDir"
install -m 0444 ${kittenttsModelConfig} "$stageSnap/config.json"
install -m 0444 ${kittenttsModelOnnx} "$stageSnap/kitten_tts_mini_v0_8.onnx"
install -m 0444 ${kittenttsModelVoices} "$stageSnap/voices.npz"
# Venv (rebuilt rather than broken on --no-clear: uv exits 2 otherwise).
uv venv "$venv" --python ${pkgs.python313}/bin/python3 --clear --quiet
UV_CACHE_DIR=${hermesHome}/kittentts-uv-cache \
uv pip install --python "$venv/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=${hermesHome}/kittentts-uv-cache \
uv pip install --python "$venv/bin/python" --quiet --no-deps \
${kittenttsWheel}
# Skip the venv REBUILD when staging is still valid (review2 minor:
# damaged delivery should be a copy, not a rebuild) — but only for the
# CURRENT inputs, else a bump delivers the old venv under a new stamp.
if [ "$(cat "$stampFile" 2>/dev/null)" != "$inputHash" ] \
|| ! [ -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}
# 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}
# Dead-import shim: .pth auto-loads kitten_tts_stub at interpreter start
# so `from misaki import en, espeak` resolves without the real misaki.en.
siteDir=$("$venv/bin/python" -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])')
cp ${kittenttsStub} "$siteDir/kitten_tts_stub.py"
printf 'import kitten_tts_stub\n' > "$siteDir/zz-kitten-stub.pth"
# Dead-import shim: .pth auto-loads kitten_tts_stub at interpreter
# start so `from misaki import en, espeak` resolves without the real
# misaki.en.
siteDir=$("$stageVenv/bin/python" -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])')
cp ${kittenttsStub} "$siteDir/kitten_tts_stub.py"
printf 'import kitten_tts_stub\n' > "$siteDir/zz-kitten-stub.pth"
# Seed the HF cache with the hashed model files (exact hub layout;
# hf_hub_download scans refs/snapshots on disk offline).
mkdir -p "$hubDir/refs" "$snap"
install -m 0444 ${kittenttsModelOnnx} "$snap/kitten_tts_mini_v0_8.onnx"
install -m 0444 ${kittenttsModelVoices} "$snap/voices.npz"
install -m 0444 ${kittenttsModelConfig} "$snap/config.json"
# 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}
# Hand ownership to the container uid BEFORE any python runs in this
# tree (root never imports from it — that was Mnemosyne review #3).
chown -R ${hermesUid}:${hermesGid} "$venv" "$hubDir"
# 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}
fi
# Stage the full delivered hub tree (exact hf_hub_download layout:
# refs/main -> snapshots/<sha>; review1 #3) under root-owned staging.
stageModelDir=$stageHub/hub/models--KittenML--kitten-tts-mini-0.8
mkdir -p "$stageModelDir/refs" "$stageModelDir/snapshots/$modelSha"
printf '%s' "$modelSha" > "$stageModelDir/refs/main"
install -m 0444 ${kittenttsModelOnnx} "$stageModelDir/snapshots/$modelSha/kitten_tts_mini_v0_8.onnx"
install -m 0444 ${kittenttsModelVoices} "$stageModelDir/snapshots/$modelSha/voices.npz"
install -m 0444 ${kittenttsModelConfig} "$stageModelDir/snapshots/$modelSha/config.json"
# 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).
# Root-side sanity: the staged interpreter must construct the model
# END-TO-END offline (review2 minor — import alone doesn't exercise
# hf_hub_download; a broken cache layout must fail HERE, not in the
# gateway). Points HF_HOME at the staged hub tree itself.
HF_HOME=$stageHub \
HF_HUB_OFFLINE=1 \
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
# ---- deliver AS THE CONTAINER USER (review2 #4): root never writes
# into hermesHome, so no symlink race and no `chown` step. setpriv
# drops to uid 986, rm -rf's the old delivered copies and copies the
# fresh staging tree in. cp-as-986 also fixes review2 #2: rm+cp in one
# step, no mv -Tf rename-replace on a non-empty directory.
setpriv --reuid=${hermesUid} --regid=${hermesGid} --clear-groups \
${pkgs.runtimeShell} -c '
set -eu
rm -rf "$1" "$2"
cp -a "$3" "$1"
cp -a "$4" "$2"
' _ \
"${hermesHome}/kittentts-venv" \
"${hermesHome}/kittentts-hf" \
"$stageVenv" \
"$stageHub"
# Stamp LAST, root-owned outside hermesHome — luna can delete it (which
# forces a cheap re-delivery on next boot), not tamper via symlink.
printf '%s' "$inputHash" > "$stampFile"
# Stamp LAST — a half-provisioned venv fails the integrity check and
# re-provisions on next boot rather than being trusted.
printf '%s' "$reqHash" > "$stampFile"
chown ${hermesUid}:${hermesGid} "$stampFile"
'';
};
}
-17
View File
@@ -1,17 +0,0 @@
# STT add-on pins for the KittenTTS side-venv on mars (faster-whisper CPU).
#
# 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.
#
# 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).
faster-whisper==1.2.1
ctranslate2==4.8.2
av==18.1.0
+46
View File
@@ -0,0 +1,46 @@
# Pinned requirements for a Mnemosyne side-venv on mars.
#
# Hermes vendors its own Python (the official image's venv) and deliberately
# stays minimal: no pip module inside it, PEP 668 external-management on top.
# Installing provider packages straight into that interpreter would fight the
# image on every rebuild, so Mnemosyne (and its plugin wrapper) live in their
# own venv instead — see the provisioning unit in hosts/mars/hermes-agent.nix.
#
# Freeze captured 2026-09-19 from a verified container-side install of
# `mnemosyne-memory[embeddings]` + `mnemosyne-hermes` — side venv at
# $HERMES_HOME/mnemosyne-venv, activated via $HERMES_HOME/plugins/mnemosyne.
# Versions pinned exactly; transitive deps frozen for reproducibility
# (onnxruntime/numpy drift under a long-lived SQLite state dir is what a
# freeze is here to prevent).
#
anyio==4.15.0
certifi==2026.7.22
charset-normalizer==3.5.1
click==8.5.0
fastembed==0.8.0
filelock==3.32.5
flatbuffers==25.12.19
fsspec==2026.7.0
h11==0.16.0
hf-xet==1.6.0
httpcore==1.0.9
httpx==0.28.1
huggingface-hub==1.32.0
idna==3.19
loguru==0.7.3
mmh3==5.3.0
mnemosyne-hermes==0.5.0
mnemosyne-memory==3.15.1
numpy==2.5.3
onnxruntime==1.30.0
packaging==26.3
pillow==12.3.0
protobuf==7.36.1
py-rust-stemmers==0.1.8
pyyaml==6.0.3
requests==2.34.2
sqlite-vec==0.1.9
tokenizers==0.23.2
tqdm==4.70.0
typing-extensions==4.16.0
urllib3==2.7.0
-4
View File
@@ -28,9 +28,6 @@
sops.secrets.opencode_go_api_key = { };
sops.secrets.telegram_bot_token = { };
sops.secrets.hermes_dashboard_oidc_client_secret = { };
# ElevenLabs TTS/STT. Unlike the webhook secret this must live in the
# container env — luna calls the API herself.
sops.secrets.elevenlabs_api_key = { };
# Same value as secrets/jupiter.yaml (the sending side), stored WITHOUT a
# trailing newline — a stray newline would change the HMAC key and fail
# every delivery. Written host-side by hermes-agent-webhook-routes, so it
@@ -46,7 +43,6 @@
WEBHOOK_ENABLED=true
WEBHOOK_PORT=8644
HERMES_DASHBOARD_OIDC_CLIENT_SECRET=${config.sops.placeholder.hermes_dashboard_oidc_client_secret}
ELEVENLABS_API_KEY=${config.sops.placeholder.elevenlabs_api_key}
'';
# luna's gitea push token (services/dev/gitea.nix provisions the account +
+58 -28
View File
@@ -1,56 +1,86 @@
# Mnemosyne memory provider for Hermes. Built here rather than pip-installed:
# the image's Python has no pip and is PEP 668 managed.
# Mnemosyne memory provider for Hermes on mars — packaged for real (Nix).
#
# Core deps only: the embeddings extra (fastembed/onnxruntime) is optional at
# runtime, and recall falls back to FTS5.
# Why derivations instead of a runtime side-venv: the official Hermes image
# vendors its own Python and stays off-limits to pip (no pip module, PEP 668),
# and a runtime venv built host-side breaks twice over inside the container:
# the venv's pyvenv.cfg records a /nix/store python home the container never
# mounts, and a plugins symlink with an absolute host path points nowhere
# from /opt/data. Building here means nothing is fetched at boot, nothing
# under the provider's control is writable from inside the container, and
# the closure is as reproducible as the rest of the host.
#
# Package set (one shared site-packages — the plugin wrapper imports its
# sibling `mnemosyne` core package, so withPackages, not separate envs):
#
# mnemosyne-memory core engine: SQLite/FTS5 storage, recall, tools.
# Base deps only (PyYAML); the optional extras (llm,
# embeddings via fastembed/onnxruntime, mcp, sync) are
# deliberately NOT pulled — recall uses the bundled FTS5
# lexical path, and the heavyweight ML stack (~hundreds of
# MB, live network on first vector use) buys nothing for
# a first deployment. Adding the embeddings extra later
# is pinning fastembed + sqlite-vec here.
# mnemosyne-hermes the wrapper Hermes discovers under $HERMES_HOME/plugins
# (installs itself as package `hermes_memory_provider`).
# Hard dependency: mnemosyne-memory, PyYAML.
#
# Platform note: both sdists are pure Python (build no C extensions), so
# nothing here constrains the host arch beyond the interpreter itself.
{
python3,
fetchPypi,
}:
let
mnemosyneMemory = python3.pkgs.buildPythonPackage rec {
python = python3;
mnemosyneMemory = python.pkgs.buildPythonPackage rec {
pname = "mnemosyne-memory";
version = "3.15.1";
pyproject = true;
src = fetchPypi {
pname = "mnemosyne_memory";
inherit version;
hash = "sha256-lspUMxc0pUSkhSUrNdiiO5OJ1NMC/S853EYSanXtXKM=";
inherit pname version;
sha256 = "sha256-lspUMxc0pUSkhSUrNdiiO5OJ1NMC/S853EYSanXtXKM=";
};
build-system = with python3.pkgs; [ setuptools ];
dependencies = with python3.pkgs; [ pyyaml ];
build-system = with python.pkgs; [ setuptools ];
doCheck = false; # tests want a live Hermes + LLM key
# Ships the Hermes plugin package too, not just the core.
pythonImportsCheck = [
"mnemosyne"
"hermes_memory_provider"
];
# Base dependency set — everything else in the upstream metadata is an
# optional extra (llm / embeddings / mcp / sync / test / dev) and is not
# installed; see the file-level comment.
dependencies = with python.pkgs; [ pyyaml ];
doCheck = false; # upstream tests want a live Hermes + LLM key present
pythonImportsCheck = [ "mnemosyne" ];
};
mnemosyneHermes = python3.pkgs.buildPythonPackage rec {
mnemosyneHermes = python.pkgs.buildPythonPackage rec {
pname = "mnemosyne-hermes";
version = "0.5.0";
pyproject = true;
src = fetchPypi {
pname = "mnemosyne_hermes";
inherit version;
hash = "sha256-CzEvnUw5oPFtT5bHQQ/GBdy2C/E7qShQn32irIRYKqw=";
inherit pname version;
sha256 = "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 ]);
build-system = with python.pkgs; [ setuptools ];
# The wrapper declares `mnemosyne-memory[embeddings]>=3.11.1` on PyPI, but
# the embeddings extra is only consulted when vector recall is enabled
# (see above) — pass the core dependency explicitly rather than dragging
# in onnxruntime for nothing.
dependencies = [ mnemosyneMemory ] ++ (with python.pkgs; [ pyyaml ]);
doCheck = false;
pythonImportsCheck = [ "mnemosyne_hermes" ];
pythonImportsCheck = [ "hermes_memory_provider" ];
};
# The exposed value is the python env itself (a store path mounted :ro).
# Hermes only needs the site-packages dir inside it; `sitePackages` is a
# passthru the python interpreter derivation (and hence withPackages envs)
# exposes, so the caller uses `${env.sitePackages}` instead of guessing
# the python version in a path literal.
in
python3.withPackages (_: [
mnemosyneMemory
mnemosyneHermes
])
python.withPackages (_: [ mnemosyneMemory mnemosyneHermes ])
+2 -3
View File
@@ -8,7 +8,6 @@ gitea_luna_token: ENC[AES256_GCM,data:0ypW9oVFs1mXYPhPareMFRdkSYcvHSCm+fQOd7/76l
gitea_hermes_webhook_secret: ENC[AES256_GCM,data:lV78H0xAehPxusSO/QruOYkt7fkMJrW+ScZL4UWYvgnBGn/D+1XHYPyHCqe2sEEWSlIaAgWMMoZzoVJ1Z1NFVQ==,iv:GmTZxoH2iiL/vTVgPfziXIFYD+Rl3cbh9hqXvWps+iw=,tag:jtXEUOVFfKrpTRK7S9PZMA==,type:str]
couchdb_luna_password: ENC[AES256_GCM,data:V91is2h7UskI1rtwMzQyduNXoDPTYNwa4sw9K9WU+wE=,iv:k976ImKR19+CvGOVsHsrqMaFFtSQxVi6zABCJuQ5AWE=,tag:W2SN4SET/+o4+Wt6BOJ1LA==,type:str]
obsidian_luna_passphrase: ENC[AES256_GCM,data:fqHtP3g4J40ddYL9lzCixrisdC/DEJJermE=,iv:FU6BGNcBnyP8Rz3dNBk0+K0aAQTDW6/0aVaFm1rBFkk=,tag:Mg1aKqh++2rmU8ROaVIgDw==,type:str]
elevenlabs_api_key: ENC[AES256_GCM,data:2oJeClO4/SFsbLwRgMe3bFXrmuDX7YOc57VfSjElV5A3vaIQqfN9eHzo/cm0vISxYgUv,iv:eIeKQJ6odDnmGLjHSLV3HbErVnLr7tatOtV83TvB2QA=,tag:XPkXRfDJ2ZK98TYXKeK/CA==,type:str]
sops:
age:
- enc: |
@@ -29,7 +28,7 @@ sops:
oyJ7PS3lW+PxH5AZkeeU7gXO/pz2oDku0aDOds7kaD3n0+qSWicQ+Q==
-----END AGE ENCRYPTED FILE-----
recipient: age1eapjg6tdrr0fuvmgs3q3nlvnjkaxez298qynqqqxt0lpcv0lrsyq7ayxjk
lastmodified: "2026-09-20T15:42:01Z"
mac: ENC[AES256_GCM,data:9xSoG1hJuPxYgY3LVWKlufvYV043PGCXS9Doznsfoof66INq8MnNc//wQa6Y5/IGD36WIskXGGo0TrLOolj0P91B4zQsus7xnJ8TjQTScD9GezW/iQfdVnkFGr72B6H0K+NOnRCm3lz6ahEn+II99ux/Gji8eq8iTaiOMMfjFXE=,iv:6tA41DUyfSrZk8SM2ml6M75INErRVrPZ7Oduy61SgTk=,tag:QFaUPWlld2q9B5KqSgmg4w==,type:str]
lastmodified: "2026-08-25T21:51:24Z"
mac: ENC[AES256_GCM,data:dz249hf3w8Tn0JStFOhhpdCZFMx2yxmNABx1CbeIQ/JlICAU82e4fg8AzJQY9EMOEs3Zx6L61yieljD4A/HLip5rDVlAXqqLeklW60eb7BHuSO79YfFgot+rS05g8WqFkRJYWzmkXhMbErCI133n72XEdeqMUU/m0djOUZlVRLs=,iv:d7G6TJRLfmXvQ2BUG9Hi83lOB9anhmb9qneLeVSCBhc=,tag:F6X/0z00PjiYum5kf8YApA==,type:str]
unencrypted_suffix: _unencrypted
version: 3.13.3