Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f686df2cc | ||
|
|
8a1b952ce6 | ||
|
|
709bc50164 | ||
|
|
cd1915336b | ||
|
|
f0a6c3552e | ||
|
|
72dc1bbc71 | ||
|
|
5690b06fd3 | ||
|
|
7756e8e6fb | ||
|
|
efa387d21e | ||
|
|
587ca68c24 | ||
|
|
54a5c5441f | ||
|
|
aac93eab62 | ||
|
|
135c5b9c31 | ||
|
|
71f1e8abc0 | ||
|
|
e9a64d780b | ||
|
|
a2f6a8a23d | ||
|
|
0c7628d9e8 | ||
|
|
b02d698c1a | ||
|
|
7a68716c1c | ||
|
|
2719ed7707 | ||
|
|
71f3dec4b5 | ||
|
|
662e8b5caf | ||
|
|
205ed14970 | ||
|
|
e95726d69c | ||
|
|
760e353335 | ||
|
|
e191ea3c8a | ||
|
|
8c0c2822c6 | ||
|
|
3dccafe2b8 | ||
|
|
e6ceacb63b | ||
|
|
cfbc14a9e7 | ||
|
|
66760c1ded | ||
|
|
efb690206b | ||
|
|
1209f165e9 | ||
|
|
94b2b4695c | ||
|
|
4d33b92bbc | ||
|
|
e849827ebb | ||
|
|
a05057a074 | ||
|
|
3debd6f7c2 | ||
|
|
059319cb1b | ||
|
|
d1afbba50c | ||
|
|
eec1f33e96 | ||
|
|
14f5e96f7e | ||
|
|
e46346c446 | ||
|
|
9f9c5df790 | ||
|
|
acd08afaad | ||
|
|
4b366f952e | ||
|
|
d4b6616d88 | ||
|
|
96604e3367 | ||
|
|
0e00512773 | ||
|
|
c13a0093c3 | ||
|
|
8886b9a2b5 | ||
|
|
59b291d000 | ||
|
|
ca725c73b5 | ||
|
|
1db3105d50 | ||
|
|
2b376d5035 | ||
|
|
a5a07a8792 | ||
|
|
53a19c6b54 | ||
|
|
df7696ae60 | ||
|
|
ed2ce8fafc | ||
|
|
b2a700571f | ||
|
|
99e5260619 | ||
|
|
2523494d10 | ||
|
|
48aa11eab5 | ||
|
|
a9022fa8fc | ||
|
|
6f1262b0fe | ||
|
|
bee9b49ce1 | ||
|
|
c33d184228 | ||
|
|
896368ef56 | ||
|
|
f84611bc6e | ||
|
|
13e8db74ce |
@@ -14,6 +14,7 @@ keys:
|
|||||||
- &neptun age1hp72xyx2cnd05937e4eww95g5kdtn0wsf9j2nypw330pa69gfdxqn0lpkp
|
- &neptun age1hp72xyx2cnd05937e4eww95g5kdtn0wsf9j2nypw330pa69gfdxqn0lpkp
|
||||||
- &terra age1rfcmu6zh40v4260l9hnf8ajs9vly0s06rx3ey76eu78dp9t7getqyhmkut
|
- &terra age1rfcmu6zh40v4260l9hnf8ajs9vly0s06rx3ey76eu78dp9t7getqyhmkut
|
||||||
- &mars age1eapjg6tdrr0fuvmgs3q3nlvnjkaxez298qynqqqxt0lpcv0lrsyq7ayxjk
|
- &mars age1eapjg6tdrr0fuvmgs3q3nlvnjkaxez298qynqqqxt0lpcv0lrsyq7ayxjk
|
||||||
|
- &titan age1qm6ne4mrgwkj7eea5j3vn0qmtw4p5h4eu78vvahhfnd4pk04qausn3qgv2
|
||||||
# mercury (rpi) uses a dedicated age key (SD image, no ssh-host-key delivery);
|
# mercury (rpi) uses a dedicated age key (SD image, no ssh-host-key delivery);
|
||||||
# the private key is dropped on its boot partition after flashing.
|
# the private key is dropped on its boot partition after flashing.
|
||||||
- &mercury age1cpty7zrgnn6l97upq00w5wa8zcvnkxkdt2jvhlj97jh83exure4slha43t
|
- &mercury age1cpty7zrgnn6l97upq00w5wa8zcvnkxkdt2jvhlj97jh83exure4slha43t
|
||||||
@@ -29,6 +30,9 @@ creation_rules:
|
|||||||
- path_regex: secrets/terra\.yaml$
|
- path_regex: secrets/terra\.yaml$
|
||||||
key_groups:
|
key_groups:
|
||||||
- age: [ *admin, *terra ]
|
- age: [ *admin, *terra ]
|
||||||
|
- path_regex: secrets/titan\.yaml$
|
||||||
|
key_groups:
|
||||||
|
- age: [ *admin, *titan ]
|
||||||
- path_regex: secrets/mars\.yaml$
|
- path_regex: secrets/mars\.yaml$
|
||||||
key_groups:
|
key_groups:
|
||||||
- age: [ *admin, *mars ]
|
- age: [ *admin, *mars ]
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|||||||
|
|
||||||
Flake-based NixOS config for a homelab. Hosts: **jupiter** (ZimaBlade NAS, x86_64),
|
Flake-based NixOS config for a homelab. Hosts: **jupiter** (ZimaBlade NAS, x86_64),
|
||||||
**neptun** (netcup public reverse proxy + tailnet node, x86_64), **mercury** (Raspberry
|
**neptun** (netcup public reverse proxy + tailnet node, x86_64), **mercury** (Raspberry
|
||||||
Pi 3B+ DNS/DHCP, aarch64). See `README.md` for the full install/deploy walkthrough.
|
Pi 3B+ DNS/DHCP, aarch64), **terra** (desktop), **titan** (Zenbook Pro Duo laptop),
|
||||||
|
**mars** (Hermes Agent + luna's apps). See `README.md` for the full install/deploy walkthrough.
|
||||||
|
|
||||||
## Layout
|
## Layout
|
||||||
|
|
||||||
@@ -12,10 +13,12 @@ Pi 3B+ DNS/DHCP, aarch64). See `README.md` for the full install/deploy walkthrou
|
|||||||
flake.nix # nixosConfigurations: real hosts + test/util targets
|
flake.nix # nixosConfigurations: real hosts + test/util targets
|
||||||
common.nix # shared base: user darman (key-only ssh), nix settings, firewall :22, tz
|
common.nix # shared base: user darman (key-only ssh), nix settings, firewall :22, tz
|
||||||
services/<cat>/*.nix # one reusable NixOS module per service, grouped by category
|
services/<cat>/*.nix # one reusable NixOS module per service, grouped by category
|
||||||
# (media, network, vpn, identity, dev, desktop); each opens
|
# (media, network, vpn, identity, dev, desktop, comms); each opens
|
||||||
# ITS OWN firewall ports. services/containers.nix (podman
|
# ITS OWN firewall ports. services/containers.nix (podman
|
||||||
# backend) stays at the top level, shared across categories.
|
# backend) stays at the top level, shared across categories.
|
||||||
hosts/<h>/ # configuration.nix + disk-config.nix (disko) + hardware-configuration.nix + secrets.nix
|
hosts/<h>/ # configuration.nix + disk-config.nix (disko) + hardware-configuration.nix + secrets.nix
|
||||||
|
profiles/workstation.nix # Hyprland workstation shared by terra + titan (NixOS side)
|
||||||
|
home/desktop/ # its home-manager side; per-host monitors via homelab.desktop.*
|
||||||
secrets/<h>.yaml # sops-nix, age-encrypted per host
|
secrets/<h>.yaml # sops-nix, age-encrypted per host
|
||||||
scripts/deploy # config-agnostic deploy wrapper (all args mandatory)
|
scripts/deploy # config-agnostic deploy wrapper (all args mandatory)
|
||||||
scripts/edit_secrets
|
scripts/edit_secrets
|
||||||
@@ -51,6 +54,18 @@ empty password, so the script resolves the title among `--filter-state active` i
|
|||||||
first; a plain `pass-cli item view --item-title` silently returns the trashed copy and
|
first; a plain `pass-cli item view --item-title` silently returns the trashed copy and
|
||||||
you get an interactive prompt with no explanation.
|
you get an interactive prompt with no explanation.
|
||||||
|
|
||||||
|
On terra/titan the values come from **pass-broker** (`services/identity/pass-broker.nix`),
|
||||||
|
not from anyone's own pass-cli session: it runs as its own user with an agent PAT scoped to
|
||||||
|
the HomeLab vaults and releases an item only after a Telegram tap. Prompts go through the
|
||||||
|
**gateway on mars** (`hosts/mars/pass-broker-gateway.nix`, tailnet :8097), the bot's only
|
||||||
|
`getUpdates` consumer: a second poller would split the taps. A new host gets its own
|
||||||
|
`pass_broker_gateway_token` in its sops file and that token's sha256 in the gateway's
|
||||||
|
`hosts`. When the socket exists, deploy uses it exclusively; a refused tap falls back to the
|
||||||
|
interactive prompt.
|
||||||
|
**Claude: fetch Proton Pass items only via `pass-broker get --item <title> --reason <why>`**,
|
||||||
|
never `pass-cli login` yourself, and never print a value you fetched. Values go into
|
||||||
|
variables or pipes, as `scripts/deploy` does.
|
||||||
|
|
||||||
`HOMELAB_KEXEC_TARBALL` (+ `_CPIO` / `_GZIP`) makes `kexec`/`kexec-local` reuse a
|
`HOMELAB_KEXEC_TARBALL` (+ `_CPIO` / `_GZIP`) makes `kexec`/`kexec-local` reuse a
|
||||||
prebuilt installer instead of rebuilding ~500MB. The VM test below uses this.
|
prebuilt installer instead of rebuilding ~500MB. The VM test below uses this.
|
||||||
|
|
||||||
@@ -77,6 +92,15 @@ nix build .#checks.x86_64-linux.kexec-local -L
|
|||||||
# VM test of luna's app hosting on mars (hosts/mars/luna-sites.nix): podman socket
|
# VM test of luna's app hosting on mars (hosts/mars/luna-sites.nix): podman socket
|
||||||
# proxy, registry validation, caddy routes, reboot persistence
|
# proxy, registry validation, caddy routes, reboot persistence
|
||||||
nix build .#checks.x86_64-linux.luna-sites -L
|
nix build .#checks.x86_64-linux.luna-sites -L
|
||||||
|
# VM test of pass-broker with fake pass-cli + Telegram: approve/deny/expiry,
|
||||||
|
# grants, policy, uid check
|
||||||
|
nix build .#checks.x86_64-linux.pass-broker -L
|
||||||
|
# two-node VM test of the gateway on mars with a broker using it: labels,
|
||||||
|
# cancel, expiry, per-host token isolation, gateway down
|
||||||
|
nix build .#checks.x86_64-linux.pass-broker-gateway -L
|
||||||
|
# Synapse + MAS on jupiter behind neptun's caddy: C collation, delegation,
|
||||||
|
# SSO-only login flows, admin API not public, chat + media upload, restart
|
||||||
|
nix build .#checks.x86_64-linux.matrix -L
|
||||||
```
|
```
|
||||||
|
|
||||||
`checks.kexec-local` is the only way to exercise `kexec-local` at all: it jumps the
|
`checks.kexec-local` is the only way to exercise `kexec-local` at all: it jumps the
|
||||||
@@ -210,6 +234,10 @@ kept its ssh host key. Run it after ANY change to the kexec paths.
|
|||||||
- **`kexec-local` stages on `/var/tmp`, not `/tmp`**: `kexec-run.sh` appends a fresh cpio
|
- **`kexec-local` stages on `/var/tmp`, not `/tmp`**: `kexec-run.sh` appends a fresh cpio
|
||||||
to `kexec/initrd` in place and execs binaries from that dir, so a size-capped or
|
to `kexec/initrd` in place and execs binaries from that dir, so a size-capped or
|
||||||
`noexec` tmpfs gives a half-written initrd or a bare "Permission denied".
|
`noexec` tmpfs gives a half-written initrd or a bare "Permission denied".
|
||||||
|
- **sops-nix values must be STRINGS.** `sops --set '["id"] 123'` stores `type:int`; the
|
||||||
|
build-time check only sees key names and passes, then activation's sops-install-secrets
|
||||||
|
fails with "is not a string" and installs NONE of the new secrets. The old generation
|
||||||
|
stays, so it looks like only the new keys are missing. Quote it: `'["id"] "123"'`.
|
||||||
- **A sops secret a USER service reads needs `owner`, not a mode.** `luna-voiced`
|
- **A sops secret a USER service reads needs `owner`, not a mode.** `luna-voiced`
|
||||||
(`services/desktop/luna-voice.nix`) runs as darman's user unit, and a user manager
|
(`services/desktop/luna-voice.nix`) runs as darman's user unit, and a user manager
|
||||||
cannot read root:root 0400 — `LoadCredential` does not bridge that gap either.
|
cannot read root:root 0400 — `LoadCredential` does not bridge that gap either.
|
||||||
@@ -248,3 +276,27 @@ kept its ssh host key. Run it after ANY change to the kexec paths.
|
|||||||
`hyprctl dispatch 'hl.dsp.exit()'`. Test the flow without touching the real greetd by
|
`hyprctl dispatch 'hl.dsp.exit()'`. Test the flow without touching the real greetd by
|
||||||
running greetd's `fakegreet "qs -p …/greeter.qml"` inside a nested Hyprland
|
running greetd's `fakegreet "qs -p …/greeter.qml"` inside a nested Hyprland
|
||||||
(user `user`, password `password`, then answer `9`).
|
(user `user`, password `password`, then answer `9`).
|
||||||
|
- **Matrix logins go through MAS, not Synapse's `oidc_providers`** (`services/comms/matrix.nix`).
|
||||||
|
Element X only supports SSO via Matrix Authentication Service, and moving an existing
|
||||||
|
Synapse onto MAS is a one-way `syn2mas` migration — so it was there from day one. With
|
||||||
|
MAS enabled Synapse refuses to start if password login, registration or any SSO
|
||||||
|
section is on. Admin rights come from MAS:
|
||||||
|
`sudo -u matrix-authentication-service mas manage promote-admin <user>`.
|
||||||
|
- **Synapse's database needs `LC_COLLATE`/`LC_CTYPE` = C**, which `ensureDatabases`
|
||||||
|
can't give (cluster default locale) and `initialScript` never runs on jupiter's
|
||||||
|
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`.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ A [Quickshell](https://quickshell.org/) configuration — a QML-based Wayland de
|
|||||||
|
|
||||||
## Running / testing changes
|
## Running / testing changes
|
||||||
|
|
||||||
**`~/.config/quickshell` is NOT a symlink to this repo.** `hosts/terra/home.nix`
|
**`~/.config/quickshell` is NOT a symlink to this repo.** `home/desktop/default.nix`
|
||||||
ships the tree with `xdg.configFile."quickshell"`, which COPIES it into the nix
|
ships the tree with `xdg.configFile."quickshell"`, which COPIES it into the nix
|
||||||
store, so the config directory is a read-only symlink into `/nix/store/...`.
|
store, so the config directory is a read-only symlink into `/nix/store/...`.
|
||||||
Editing a file here therefore changes nothing about the running shell: it is
|
Editing a file here therefore changes nothing about the running shell: it is
|
||||||
@@ -105,6 +105,8 @@ on it, hence the index loops in `HyprChromeShell`.
|
|||||||
rail's monitor (`NotificationCard` is the headless-renderable card);
|
rail's monitor (`NotificationCard` is the headless-renderable card);
|
||||||
`Widgets/Greeter/` is the greetd login screen, run standalone via `greeter.qml`
|
`Widgets/Greeter/` is the greetd login screen, run standalone via `greeter.qml`
|
||||||
(see `services/desktop/quickshell-greeter.nix`), NOT part of `shell.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
|
`Theme/Theme.qml` is this tree's palette singleton. `DebugWindow.qml` stages a
|
||||||
single widget on the secondary monitor for eyeballing it in isolation.
|
single widget on the secondary monitor for eyeballing it in isolation.
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ Scope {
|
|||||||
|
|
||||||
// Monitor to stage on. Falls back to the LAST connected screen when the
|
// Monitor to stage on. Falls back to the LAST connected screen when the
|
||||||
// name matches nothing, so a single-monitor session still gets a stage.
|
// name matches nothing, so a single-monitor session still gets a stage.
|
||||||
property string screenName: "HDMI-A-1"
|
// Set per host in home/desktop/options.nix (secondaryOutput).
|
||||||
|
property string screenName: Quickshell.env("QS_SECONDARY_OUTPUT") ?? ""
|
||||||
property bool active: true
|
property bool active: true
|
||||||
|
|
||||||
default property alias content: slot.data
|
default property alias content: slot.data
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ Scope {
|
|||||||
root.promptText = message === "" ? "Password:" : message;
|
root.promptText = message === "" ? "Password:" : message;
|
||||||
root.fifoPath = fifo;
|
root.fifoPath = fifo;
|
||||||
root.failed = false;
|
root.failed = false;
|
||||||
|
vault.invalidate();
|
||||||
|
vault.refresh();
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,12 +103,22 @@ Scope {
|
|||||||
if (!root.active)
|
if (!root.active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
vault.invalidate();
|
||||||
root.pendingSecret = secret + "\n";
|
root.pendingSecret = secret + "\n";
|
||||||
writer.command = ["sh", "-c", "IFS= read -r line; printf %s \"$line\" > \"$1\"", "sh", root.fifoPath];
|
writer.command = ["sh", "-c", "IFS= read -r line; printf %s \"$line\" > \"$1\"", "sh", root.fifoPath];
|
||||||
writer.running = true;
|
writer.running = true;
|
||||||
root.fifoPath = "";
|
root.fifoPath = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProtonPass {
|
||||||
|
id: vault
|
||||||
|
|
||||||
|
onFetched: secret => {
|
||||||
|
content.response = secret;
|
||||||
|
content.focusInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Opening a fifo for writing BLOCKS until a reader attaches, which is why
|
// Opening a fifo for writing BLOCKS until a reader attaches, which is why
|
||||||
// this is a subprocess rather than a FileView: the helper's `cat` is that
|
// this is a subprocess rather than a FileView: the helper's `cat` is that
|
||||||
// reader, and blocking the QML thread on it would freeze the shell.
|
// reader, and blocking the QML thread on it would freeze the shell.
|
||||||
@@ -149,7 +161,7 @@ Scope {
|
|||||||
id: content
|
id: content
|
||||||
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
y: Math.max(32, Math.round(parent.height / 3 - height / 2))
|
y: Math.max(32, Math.round(parent.height / 3 - content.dialogHeight / 2))
|
||||||
width: 520
|
width: 520
|
||||||
|
|
||||||
// Deliberately the polkit dialog's own content component: this is a
|
// Deliberately the polkit dialog's own content component: this is a
|
||||||
@@ -168,6 +180,17 @@ Scope {
|
|||||||
responseVisible: false
|
responseVisible: false
|
||||||
failed: root.failed
|
failed: root.failed
|
||||||
|
|
||||||
|
credentialsEnabled: true
|
||||||
|
credentials: vault.entries
|
||||||
|
credentialsStatus: vault.listStatus
|
||||||
|
fetchStatus: vault.fetchStatus
|
||||||
|
|
||||||
|
onCredentialRequested: entry => vault.fetch(entry)
|
||||||
|
onPickerOpened: {
|
||||||
|
if (vault.entries.length === 0)
|
||||||
|
vault.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
onSubmitted: value => root.submit(value)
|
onSubmitted: value => root.submit(value)
|
||||||
onCancelled: root.dismiss()
|
onCancelled: root.dismiss()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,162 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import qs.HyprChrome.Theme
|
||||||
|
import qs.HyprChrome.Widgets.Bar.Panels
|
||||||
|
import qs.HyprChrome.Widgets.Bar.Vitals
|
||||||
|
|
||||||
|
// Claude subscription limits on the rail: the 5-hour session window and the
|
||||||
|
// weekly one, plus any per-model weekly caps the plan reports.
|
||||||
|
BarPanel {
|
||||||
|
id: claude
|
||||||
|
|
||||||
|
// Overridable so the headless render can stage it without the network.
|
||||||
|
property var fiveHour: usage.fiveHour
|
||||||
|
property var sevenDay: usage.sevenDay
|
||||||
|
property var extra: usage.extra
|
||||||
|
property string error: usage.error
|
||||||
|
property string shortError: usage.shortError
|
||||||
|
property bool ready: usage.ready
|
||||||
|
|
||||||
|
readonly property var usage: ClaudeState {}
|
||||||
|
|
||||||
|
panelId: "CLD"
|
||||||
|
title: "CLAUDE"
|
||||||
|
meta: claude.error !== "" ? (claude.ready ? "STALE" : "OFFLINE") : claude.ready ? "LIMITS" : "PRIMING"
|
||||||
|
|
||||||
|
// Ticks the reset countdowns without re-polling.
|
||||||
|
property date now: new Date()
|
||||||
|
Timer {
|
||||||
|
interval: 30000
|
||||||
|
running: true
|
||||||
|
repeat: true
|
||||||
|
onTriggered: claude.now = new Date()
|
||||||
|
}
|
||||||
|
|
||||||
|
implicitWidth: claude.expanded
|
||||||
|
? Math.max(claude.headerMinWidth, claude.padding * 2 + body.width)
|
||||||
|
: Math.max(claude.headerMinWidth, claude.briefLeft + brief.implicitWidth + claude.padding)
|
||||||
|
|
||||||
|
function fraction(w) {
|
||||||
|
return w ? Math.max(0, Math.min(1, w.utilization / 100)) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function pct(w) {
|
||||||
|
return w ? Math.round(w.utilization) + "%" : "--";
|
||||||
|
}
|
||||||
|
|
||||||
|
function until(w) {
|
||||||
|
if (!w || !w.resets_at)
|
||||||
|
return "";
|
||||||
|
const mins = Math.max(0, Math.round((new Date(w.resets_at) - claude.now) / 60000));
|
||||||
|
if (mins >= 1440)
|
||||||
|
return `${Math.floor(mins / 1440)}D ${Math.floor(mins % 1440 / 60)}H`;
|
||||||
|
if (mins >= 60)
|
||||||
|
return `${Math.floor(mins / 60)}H ${mins % 60}M`;
|
||||||
|
return `${mins}M`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function tone(w) {
|
||||||
|
const f = claude.fraction(w);
|
||||||
|
return !claude.ready ? Theme.disabled : f >= 0.85 ? Theme.hot : Theme.text;
|
||||||
|
}
|
||||||
|
|
||||||
|
summary: Row {
|
||||||
|
id: brief
|
||||||
|
spacing: 10
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: [
|
||||||
|
{ label: "5H", window: claude.fiveHour },
|
||||||
|
{ label: "7D", window: claude.sevenDay }
|
||||||
|
]
|
||||||
|
|
||||||
|
Row {
|
||||||
|
required property var modelData
|
||||||
|
spacing: 4
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
// Dashes say nothing; with no numbers yet the error label stands alone.
|
||||||
|
visible: claude.ready || claude.shortError === ""
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
text: parent.modelData.label
|
||||||
|
color: Theme.muted
|
||||||
|
font.family: Theme.microFont
|
||||||
|
font.pixelSize: 10
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
text: claude.pct(parent.modelData.window)
|
||||||
|
color: claude.tone(parent.modelData.window)
|
||||||
|
font.family: Theme.displayFont
|
||||||
|
font.pixelSize: 13
|
||||||
|
font.bold: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
visible: claude.shortError !== ""
|
||||||
|
text: claude.shortError
|
||||||
|
color: Theme.hot
|
||||||
|
font.family: Theme.displayFont
|
||||||
|
font.pixelSize: 13
|
||||||
|
font.bold: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: body
|
||||||
|
width: 260
|
||||||
|
spacing: 5
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: [
|
||||||
|
{ label: "SESSION", window: claude.fiveHour },
|
||||||
|
{ label: "WEEKLY", window: claude.sevenDay }
|
||||||
|
].concat(claude.extra)
|
||||||
|
|
||||||
|
Column {
|
||||||
|
required property var modelData
|
||||||
|
width: body.width
|
||||||
|
spacing: 2
|
||||||
|
|
||||||
|
VitalRow {
|
||||||
|
width: parent.width
|
||||||
|
labelWidth: 64
|
||||||
|
label: parent.modelData.label
|
||||||
|
value: claude.fraction(parent.modelData.window)
|
||||||
|
readout: claude.pct(parent.modelData.window)
|
||||||
|
ready: claude.ready && !!parent.modelData.window
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
x: 64
|
||||||
|
visible: text !== ""
|
||||||
|
text: {
|
||||||
|
const t = claude.until(parent.modelData.window);
|
||||||
|
return t ? `RESETS IN ${t}` : "";
|
||||||
|
}
|
||||||
|
color: Theme.muted
|
||||||
|
font.family: Theme.microFont
|
||||||
|
font.pixelSize: 9
|
||||||
|
font.letterSpacing: 1.2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
width: body.width
|
||||||
|
visible: claude.error !== ""
|
||||||
|
text: claude.error.toUpperCase()
|
||||||
|
color: Theme.hot
|
||||||
|
font.family: Theme.microFont
|
||||||
|
font.pixelSize: 9
|
||||||
|
font.letterSpacing: 1.2
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell.Io
|
||||||
|
|
||||||
|
// Claude subscription limits, polled through `claude-usage` (pkgs/claude-usage.nix),
|
||||||
|
// which reuses Claude Code's OAuth login and prints the usage endpoint's JSON.
|
||||||
|
QtObject {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
// Each window is { utilization: 0..100, resets_at: ISO string } or null.
|
||||||
|
property var fiveHour: null
|
||||||
|
property var sevenDay: null
|
||||||
|
// Per-model weekly windows the plan reports, as [{ label, window }].
|
||||||
|
property var extra: []
|
||||||
|
property string error: ""
|
||||||
|
property bool ready: false
|
||||||
|
|
||||||
|
// The endpoint is rate-limited and the numbers move slowly; a failure
|
||||||
|
// retries sooner so the panel recovers once Claude Code renews the token.
|
||||||
|
property int interval: root.error !== "" ? 60000 : 300000
|
||||||
|
|
||||||
|
// Collapsed-rail label for the current error.
|
||||||
|
readonly property string shortError: {
|
||||||
|
if (root.error === "")
|
||||||
|
return "";
|
||||||
|
return /refresh|401|not logged in|no refresh token/.test(root.error) ? "EXPIRED" : "ERR";
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly property var proc: Process {
|
||||||
|
id: proc
|
||||||
|
command: ["claude-usage"]
|
||||||
|
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: root.ingest(this.text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly property var poll: Timer {
|
||||||
|
interval: root.interval
|
||||||
|
running: true
|
||||||
|
repeat: true
|
||||||
|
triggeredOnStart: true
|
||||||
|
onTriggered: {
|
||||||
|
if (!proc.running)
|
||||||
|
proc.running = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function fail(message: string): void {
|
||||||
|
console.warn(`claude-usage: ${message}`);
|
||||||
|
root.error = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ingest(text: string): void {
|
||||||
|
let msg;
|
||||||
|
try {
|
||||||
|
msg = JSON.parse(text);
|
||||||
|
} catch (e) {
|
||||||
|
root.fail("no output");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (msg.error) {
|
||||||
|
// Keep the last good numbers; a failed poll is not zero usage.
|
||||||
|
root.fail(msg.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
root.error = "";
|
||||||
|
root.fiveHour = msg.five_hour ?? null;
|
||||||
|
root.sevenDay = msg.seven_day ?? null;
|
||||||
|
|
||||||
|
const found = [];
|
||||||
|
for (const key of Object.keys(msg)) {
|
||||||
|
const m = key.match(/^seven_day_(\w+)$/);
|
||||||
|
const w = msg[key];
|
||||||
|
if (m && w && typeof w.utilization === "number")
|
||||||
|
found.push({ label: m[1].toUpperCase().replace(/_/g, " "), window: w });
|
||||||
|
}
|
||||||
|
root.extra = found;
|
||||||
|
root.ready = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import Quickshell
|
|||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
import qs.HyprChrome.Theme
|
import qs.HyprChrome.Theme
|
||||||
import qs.HyprChrome.Widgets.Bar.Luna
|
import qs.HyprChrome.Widgets.Bar.Luna
|
||||||
|
import qs.HyprChrome.Widgets.Bar.Claude
|
||||||
import qs.HyprChrome.Widgets.Bar.Host
|
import qs.HyprChrome.Widgets.Bar.Host
|
||||||
import qs.HyprChrome.Widgets.Bar.Vitals
|
import qs.HyprChrome.Widgets.Bar.Vitals
|
||||||
import qs.HyprChrome.Widgets.Bar.Workspaces
|
import qs.HyprChrome.Widgets.Bar.Workspaces
|
||||||
@@ -87,8 +88,8 @@ PanelWindow {
|
|||||||
//
|
//
|
||||||
// The zone still follows the target height, so tiled windows reflow once
|
// The zone still follows the target height, so tiled windows reflow once
|
||||||
// per toggle, at the start, and slide while the panels animate.
|
// per toggle, at the start, and slide while the panels animate.
|
||||||
readonly property real expandedContent: Math.max(hostPanel.expandedHeight, workspacesPanel.expandedHeight, vitalsPanel.expandedHeight, lunaPanel.expandedHeight, trayPanel.expandedHeight) + window.margin * 2
|
readonly property real expandedContent: Math.max(hostPanel.expandedHeight, workspacesPanel.expandedHeight, vitalsPanel.expandedHeight, lunaPanel.expandedHeight, claudePanel.expandedHeight, trayPanel.expandedHeight) + window.margin * 2
|
||||||
readonly property real contentHeight: Math.max(hostPanel.targetHeight, workspacesPanel.targetHeight, vitalsPanel.targetHeight, lunaPanel.targetHeight, trayPanel.targetHeight) + window.margin * 2
|
readonly property real contentHeight: Math.max(hostPanel.targetHeight, workspacesPanel.targetHeight, vitalsPanel.targetHeight, lunaPanel.targetHeight, claudePanel.targetHeight, trayPanel.targetHeight) + window.margin * 2
|
||||||
|
|
||||||
implicitHeight: Math.round(window.expandedContent)
|
implicitHeight: Math.round(window.expandedContent)
|
||||||
|
|
||||||
@@ -161,6 +162,19 @@ PanelWindow {
|
|||||||
id: lunaPanel
|
id: lunaPanel
|
||||||
|
|
||||||
expanded: window.expanded
|
expanded: window.expanded
|
||||||
|
// Claude butts against its right edge.
|
||||||
|
rightChamfer: false
|
||||||
|
|
||||||
|
toggleOnClick: false
|
||||||
|
Layout.fillHeight: true
|
||||||
|
}
|
||||||
|
|
||||||
|
ClaudePanel {
|
||||||
|
id: claudePanel
|
||||||
|
|
||||||
|
expanded: window.expanded
|
||||||
|
leftChamfer: false
|
||||||
|
|
||||||
toggleOnClick: false
|
toggleOnClick: false
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ BarPanel {
|
|||||||
|
|
||||||
panelId: "LUN"
|
panelId: "LUN"
|
||||||
title: "LUNA"
|
title: "LUNA"
|
||||||
meta: luna.active ? "VOICE" : "IDLE"
|
meta: luna.active ? "MIC ON" : "MIC OFF"
|
||||||
|
|
||||||
// Sized to content like the tray, and per DENSITY: collapsed it is one
|
// Sized to content like the tray, and per DENSITY: collapsed it is one
|
||||||
// word, so reserving the expanded body's width would leave the rail
|
// word, so reserving the expanded body's width would leave the rail
|
||||||
@@ -61,8 +61,7 @@ BarPanel {
|
|||||||
readonly property string stateLabel: {
|
readonly property string stateLabel: {
|
||||||
if (!luna.connected)
|
if (!luna.connected)
|
||||||
return "OFFLINE";
|
return "OFFLINE";
|
||||||
if (!luna.active)
|
// Her own state first: a muted mic no longer stops her answering.
|
||||||
return "OFF";
|
|
||||||
switch (luna.daemonState) {
|
switch (luna.daemonState) {
|
||||||
case "listening":
|
case "listening":
|
||||||
return "LISTENING";
|
return "LISTENING";
|
||||||
@@ -71,7 +70,7 @@ BarPanel {
|
|||||||
case "speaking":
|
case "speaking":
|
||||||
return "SPEAKING";
|
return "SPEAKING";
|
||||||
default:
|
default:
|
||||||
return "READY";
|
return luna.active ? "READY" : "MUTED";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,11 @@ QtObject {
|
|||||||
|
|
||||||
// "idle" | "listening" | "thinking" | "speaking"
|
// "idle" | "listening" | "thinking" | "speaking"
|
||||||
property string state: "idle"
|
property string state: "idle"
|
||||||
// Voice mode itself — the widget is only on screen while this is true.
|
// Whether the mic is open. She still answers and speaks while it is not.
|
||||||
property bool active: false
|
property bool active: false
|
||||||
property bool connected: socket.connected
|
// Set by the first line, not by the process starting: the daemon replays
|
||||||
|
// its state on connect, so only a live connection produces one.
|
||||||
|
property bool connected: false
|
||||||
// Mic level while listening, her output level while speaking. Drives the
|
// Mic level while listening, her output level while speaking. Drives the
|
||||||
// only genuinely live part of the visuals.
|
// only genuinely live part of the visuals.
|
||||||
property real rms: 0
|
property real rms: 0
|
||||||
@@ -31,35 +33,39 @@ QtObject {
|
|||||||
property string lunaText: ""
|
property string lunaText: ""
|
||||||
property string error: ""
|
property string error: ""
|
||||||
|
|
||||||
readonly property var socket: Socket {
|
// `luna-voice watch`, not Quickshell's Socket: a Socket whose connect
|
||||||
id: socket
|
// fails once (daemon mid-restart) keeps the dead QLocalSocket and ignores
|
||||||
path: `${Quickshell.env("XDG_RUNTIME_DIR") ?? "/run/user/1000"}/luna-voiced.sock`
|
// every later `connected = true`, so the widget stuck on OFFLINE.
|
||||||
connected: true
|
readonly property var watch: Process {
|
||||||
|
id: watch
|
||||||
|
command: ["luna-voice", "watch"]
|
||||||
|
running: true
|
||||||
|
|
||||||
onConnectionStateChanged: {
|
stdout: SplitParser {
|
||||||
if (!socket.connected) {
|
splitMarker: "\n"
|
||||||
|
onRead: line => {
|
||||||
|
root.connected = true;
|
||||||
|
root.ingest(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: {
|
||||||
// A daemon that went away is not a daemon that is idle: reset
|
// A daemon that went away is not a daemon that is idle: reset
|
||||||
// rather than leave the last frame of a conversation frozen
|
// rather than leave the last frame of a conversation frozen
|
||||||
// on screen.
|
// on screen.
|
||||||
|
root.connected = false;
|
||||||
root.active = false;
|
root.active = false;
|
||||||
root.state = "idle";
|
root.state = "idle";
|
||||||
root.rms = 0;
|
root.rms = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parser: SplitParser {
|
// Retry forever, cheaply; each attempt is a fresh connection.
|
||||||
splitMarker: "\n"
|
|
||||||
onRead: line => root.ingest(line)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retry forever, cheaply. Setting `connected` true on an already-open
|
|
||||||
// socket is a no-op, so this doubles as the initial connect.
|
|
||||||
readonly property var reconnect: Timer {
|
readonly property var reconnect: Timer {
|
||||||
interval: 2000
|
interval: 2000
|
||||||
running: !socket.connected
|
running: !watch.running
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: socket.connected = true
|
onTriggered: watch.running = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function ingest(line: string): void {
|
function ingest(line: string): void {
|
||||||
|
|||||||
@@ -10,6 +10,13 @@ Item {
|
|||||||
|
|
||||||
property string hostName: ""
|
property string hostName: ""
|
||||||
property string sessionName: ""
|
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()
|
property date now: new Date()
|
||||||
|
|
||||||
// Label over the secret field. Empty means the plain password step; set
|
// Label over the secret field. Empty means the plain password step; set
|
||||||
@@ -139,9 +146,9 @@ Item {
|
|||||||
id: panel
|
id: panel
|
||||||
|
|
||||||
width: root.width
|
width: root.width
|
||||||
panelId: "LGN"
|
panelId: root.panelId
|
||||||
title: "SESSION // " + root.hostName.toUpperCase()
|
title: root.title
|
||||||
meta: "GREETD"
|
meta: root.meta
|
||||||
busy: root.busy
|
busy: root.busy
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
@@ -220,7 +227,7 @@ Item {
|
|||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
verticalAlignment: TextInput.AlignVCenter
|
verticalAlignment: TextInput.AlignVCenter
|
||||||
enabled: !root.busy && root.inputPrompt === ""
|
enabled: root.userEditable && !root.busy && root.inputPrompt === ""
|
||||||
color: Theme.text
|
color: Theme.text
|
||||||
selectionColor: Theme.accent
|
selectionColor: Theme.accent
|
||||||
selectedTextColor: Theme.surface
|
selectedTextColor: Theme.surface
|
||||||
@@ -292,12 +299,12 @@ Item {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
spacing: 14
|
spacing: 14
|
||||||
|
|
||||||
MicroText { text: "ENTER LOG IN" }
|
MicroText { text: "ENTER " + root.submitLabel }
|
||||||
MicroText { text: "TAB SWITCH FIELD" }
|
MicroText { text: "TAB SWITCH FIELD"; visible: root.userEditable }
|
||||||
Item { Layout.fillWidth: true }
|
Item { Layout.fillWidth: true }
|
||||||
|
|
||||||
PowerChip { label: "REBOOT"; action: "reboot" }
|
PowerChip { label: "REBOOT"; action: "reboot"; visible: root.showPower }
|
||||||
PowerChip { label: "POWER OFF"; action: "poweroff" }
|
PowerChip { label: "POWER OFF"; action: "poweroff"; visible: root.showPower }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
@@ -39,7 +40,8 @@ Scope {
|
|||||||
// the name matches nothing, so the bar still appears on a single-monitor
|
// the name matches nothing, so the bar still appears on a single-monitor
|
||||||
// session or after a cable swap (DebugWindow falls back to the last one
|
// session or after a cable swap (DebugWindow falls back to the last one
|
||||||
// instead — it wants the secondary).
|
// instead — it wants the secondary).
|
||||||
property string screenName: "DP-2"
|
// Set per host in home/desktop/options.nix (primaryOutput).
|
||||||
|
property string screenName: Quickshell.env("QS_PRIMARY_OUTPUT") ?? ""
|
||||||
|
|
||||||
// Quickshell.screens is a QML list, not a JS array — no .find() on it.
|
// Quickshell.screens is a QML list, not a JS array — no .find() on it.
|
||||||
readonly property var targetScreen: {
|
readonly property var targetScreen: {
|
||||||
@@ -140,13 +142,47 @@ Scope {
|
|||||||
readonly property int barLayer: shell.scrimUp ? WlrLayer.Overlay : WlrLayer.Bottom
|
readonly property int barLayer: shell.scrimUp ? WlrLayer.Overlay : WlrLayer.Bottom
|
||||||
readonly property int backdropLayer: shell.scrimUp ? WlrLayer.Top : WlrLayer.Background
|
readonly property int backdropLayer: shell.scrimUp ? WlrLayer.Top : WlrLayer.Background
|
||||||
|
|
||||||
// SUPER A — see hosts/terra/home/hyprland.nix.
|
// SUPER A — see home/desktop/hyprland.nix.
|
||||||
GlobalShortcut {
|
GlobalShortcut {
|
||||||
name: "chrome"
|
name: "chrome"
|
||||||
description: "Expand or collapse the hyprchrome bar"
|
description: "Expand or collapse the hyprchrome bar"
|
||||||
onPressed: shell.toggle()
|
onPressed: shell.toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SUPER — the launcher over an expanded rail, opened and closed as one.
|
||||||
|
GlobalShortcut {
|
||||||
|
name: "command"
|
||||||
|
description: "Open the launcher with the hyprchrome bar expanded"
|
||||||
|
onPressed: shell.toggleCommand()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Whether the rail was expanded BY toggleCommand, so closing the launcher
|
||||||
|
// only collapses a rail it opened.
|
||||||
|
property bool commandExpanded: false
|
||||||
|
|
||||||
|
function toggleCommand() {
|
||||||
|
if (polkit.prompting || askpass.active)
|
||||||
|
return;
|
||||||
|
if (launcher.active) {
|
||||||
|
launcher.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
shell.commandExpanded = !shell.expanded;
|
||||||
|
shell.expanded = true;
|
||||||
|
launcher.active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The launcher closes itself (ESC, launch, click-off), so collapse follows it.
|
||||||
|
Connections {
|
||||||
|
target: launcher
|
||||||
|
function onActiveChanged() {
|
||||||
|
if (!launcher.active && shell.commandExpanded) {
|
||||||
|
shell.commandExpanded = false;
|
||||||
|
shell.expanded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Backdrop first: it is a layer below the bar, so stacking does not depend
|
// Backdrop first: it is a layer below the bar, so stacking does not depend
|
||||||
// on creation order, but keeping the declaration order the same as the
|
// on creation order, but keeping the declaration order the same as the
|
||||||
// visual order costs nothing.
|
// visual order costs nothing.
|
||||||
@@ -218,7 +254,7 @@ Scope {
|
|||||||
|
|
||||||
// Polkit authentication agent. It registers for this logind session on
|
// Polkit authentication agent. It registers for this logind session on
|
||||||
// creation, so it replaces hyprpolkitagent rather than coexisting with it —
|
// creation, so it replaces hyprpolkitagent rather than coexisting with it —
|
||||||
// only one agent may hold a session (see hosts/terra/home/hyprland.nix).
|
// only one agent may hold a session (see home/desktop/hyprland.nix).
|
||||||
//
|
//
|
||||||
// It lives here rather than beside the launchers in shell.qml because its
|
// It lives here rather than beside the launchers in shell.qml because its
|
||||||
// state is shared: `prompting` raises the scrim and freezes the density,
|
// state is shared: `prompting` raises the scrim and freezes the density,
|
||||||
@@ -236,7 +272,7 @@ Scope {
|
|||||||
screen: shell.focusedScreen
|
screen: shell.focusedScreen
|
||||||
}
|
}
|
||||||
|
|
||||||
// Primary application launcher — SUPER_L. Migrated out of
|
// Primary application launcher — SUPER_L (via `command` above). Migrated out of
|
||||||
// widgets/launcher/; the ten remaining variants are still evaluation copies
|
// widgets/launcher/; the ten remaining variants are still evaluation copies
|
||||||
// and stay in shell.qml. Declared after the bar for the same reason the
|
// and stay in shell.qml. Declared after the bar for the same reason the
|
||||||
// prompt is: while it is open the bar is on Overlay too, and there is no
|
// prompt is: while it is open the bar is on Overlay too, and there is no
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Quickshell.Wayland
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import qs.HyprChrome.Theme
|
import qs.HyprChrome.Theme
|
||||||
|
|
||||||
// Primary application launcher — the one on SUPER_L.
|
// Primary application launcher — the one on SUPER_L (via HyprChromeShell).
|
||||||
//
|
//
|
||||||
// Migrated from widgets/launcher/ApplicationLauncher.qml. Two things changed in
|
// Migrated from widgets/launcher/ApplicationLauncher.qml. Two things changed in
|
||||||
// the move, both because HyprChromeShell now owns the state its surfaces share:
|
// the move, both because HyprChromeShell now owns the state its surfaces share:
|
||||||
@@ -34,11 +34,8 @@ Scope {
|
|||||||
function toggle() { root.active = !root.active; }
|
function toggle() { root.active = !root.active; }
|
||||||
function close() { root.active = false; }
|
function close() { root.active = false; }
|
||||||
|
|
||||||
// The name is legacy: this was "variant 8" of eleven, and both SUPER_L (via
|
// Launcher alone, on SUPER CTRL 8. SUPER_L goes through the shell's
|
||||||
// open_launcher.sh) and SUPER CTRL 8 still dispatch quickshell:launcher8.
|
// `command` shortcut instead, which also expands the rail.
|
||||||
// Renaming it means editing hosts/terra/home/hyprland.nix AND the script
|
|
||||||
// together, and neither takes effect until a deploy — so the shortcut would
|
|
||||||
// be dead in the running session in between. Kept as-is deliberately.
|
|
||||||
GlobalShortcut {
|
GlobalShortcut {
|
||||||
name: "launcher8"
|
name: "launcher8"
|
||||||
description: "Toggle dense application command index"
|
description: "Toggle dense application command index"
|
||||||
@@ -83,9 +80,22 @@ Scope {
|
|||||||
root.active = false;
|
root.active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hyprland runs a Lua config, which rejects a bare `dispatch exit`.
|
||||||
|
readonly property var powerCommands: ({
|
||||||
|
logout: ["hyprctl", "dispatch", "hl.dsp.exit()"],
|
||||||
|
reboot: ["systemctl", "reboot"],
|
||||||
|
shutdown: ["systemctl", "poweroff"]
|
||||||
|
})
|
||||||
|
|
||||||
|
function power(action) {
|
||||||
|
root.active = false;
|
||||||
|
Quickshell.execDetached(win.powerCommands[action]);
|
||||||
|
}
|
||||||
|
|
||||||
onVisibleChanged: {
|
onVisibleChanged: {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
content.clearSearch();
|
content.clearSearch();
|
||||||
|
content.disarmPower();
|
||||||
selectedIndex = 0;
|
selectedIndex = 0;
|
||||||
content.focusSearch();
|
content.focusSearch();
|
||||||
}
|
}
|
||||||
@@ -115,11 +125,17 @@ Scope {
|
|||||||
transformOrigin: Item.Center
|
transformOrigin: Item.Center
|
||||||
apps: model.apps
|
apps: model.apps
|
||||||
selectedIndex: win.selectedIndex
|
selectedIndex: win.selectedIndex
|
||||||
|
sortMode: model.sortMode
|
||||||
|
|
||||||
onSelectionRequested: index => win.selectedIndex = win.clampSelection(index)
|
onSelectionRequested: index => win.selectedIndex = win.clampSelection(index)
|
||||||
onMoveRequested: delta => win.move(delta)
|
onMoveRequested: delta => win.move(delta)
|
||||||
onLaunchRequested: index => win.launch(index)
|
onLaunchRequested: index => win.launch(index)
|
||||||
onDismissRequested: root.close()
|
onDismissRequested: root.close()
|
||||||
|
onSortToggleRequested: {
|
||||||
|
model.toggleSort();
|
||||||
|
win.selectedIndex = 0;
|
||||||
|
}
|
||||||
|
onPowerRequested: action => win.power(action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ Item {
|
|||||||
property int selectedIndex: 0
|
property int selectedIndex: 0
|
||||||
property bool showIcons: true
|
property bool showIcons: true
|
||||||
property alias query: searchInput.text
|
property alias query: searchInput.text
|
||||||
|
property string sortMode: "usage"
|
||||||
|
|
||||||
|
// Power action awaiting its confirming second click; "" when none.
|
||||||
|
property string armedPower: ""
|
||||||
|
|
||||||
readonly property var selectedApp: apps.length > 0 && selectedIndex >= 0 && selectedIndex < apps.length
|
readonly property var selectedApp: apps.length > 0 && selectedIndex >= 0 && selectedIndex < apps.length
|
||||||
? apps[selectedIndex] : null
|
? apps[selectedIndex] : null
|
||||||
@@ -25,9 +29,29 @@ Item {
|
|||||||
signal moveRequested(int delta)
|
signal moveRequested(int delta)
|
||||||
signal launchRequested(int index)
|
signal launchRequested(int index)
|
||||||
signal dismissRequested
|
signal dismissRequested
|
||||||
|
signal sortToggleRequested
|
||||||
|
signal powerRequested(string action)
|
||||||
|
|
||||||
function focusSearch() { searchInput.forceActiveFocus(); }
|
function focusSearch() { searchInput.forceActiveFocus(); }
|
||||||
function clearSearch() { searchInput.text = ""; }
|
function clearSearch() { searchInput.text = ""; }
|
||||||
|
function disarmPower() { root.armedPower = ""; }
|
||||||
|
|
||||||
|
// First click arms, second (within the timeout) fires: a stray click must
|
||||||
|
// not end the session.
|
||||||
|
function pressPower(action) {
|
||||||
|
if (root.armedPower === action) {
|
||||||
|
root.armedPower = "";
|
||||||
|
root.powerRequested(action);
|
||||||
|
} else {
|
||||||
|
root.armedPower = action;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
running: root.armedPower !== ""
|
||||||
|
interval: 3000
|
||||||
|
onTriggered: root.disarmPower()
|
||||||
|
}
|
||||||
|
|
||||||
implicitWidth: 1080
|
implicitWidth: 1080
|
||||||
implicitHeight: 620
|
implicitHeight: 620
|
||||||
@@ -121,6 +145,11 @@ Item {
|
|||||||
onTextChanged: root.selectionRequested(0)
|
onTextChanged: root.selectionRequested(0)
|
||||||
|
|
||||||
Keys.onPressed: event => {
|
Keys.onPressed: event => {
|
||||||
|
if (event.key === Qt.Key_S && (event.modifiers & Qt.ControlModifier)) {
|
||||||
|
root.sortToggleRequested();
|
||||||
|
event.accepted = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case Qt.Key_Down:
|
case Qt.Key_Down:
|
||||||
case Qt.Key_Tab:
|
case Qt.Key_Tab:
|
||||||
@@ -162,16 +191,24 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
MouseArea {
|
||||||
|
id: sortChip
|
||||||
Layout.preferredWidth: 84
|
Layout.preferredWidth: 84
|
||||||
Layout.preferredHeight: 22
|
Layout.preferredHeight: 22
|
||||||
color: Theme.accentAlpha(0.12)
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: root.sortToggleRequested()
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: sortChip.containsMouse ? Theme.accentAlpha(0.28) : Theme.accentAlpha(0.12)
|
||||||
border.width: 1
|
border.width: 1
|
||||||
border.color: Theme.hair
|
border.color: sortChip.containsMouse ? Theme.accent : Theme.hair
|
||||||
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: "LIVE INDEX"
|
text: root.sortMode === "usage" ? "SORT: USED" : "SORT: A–Z"
|
||||||
color: Theme.accent
|
color: Theme.accent
|
||||||
font.family: Theme.microFont
|
font.family: Theme.microFont
|
||||||
font.pixelSize: 7
|
font.pixelSize: 7
|
||||||
@@ -191,7 +228,7 @@ Item {
|
|||||||
height: 424
|
height: 424
|
||||||
panelId: "IDX"
|
panelId: "IDX"
|
||||||
title: "APPLICATION TABLE"
|
title: "APPLICATION TABLE"
|
||||||
meta: root.query.length > 0 ? "FILTER ACTIVE" : "A–Z / LOCAL"
|
meta: (root.query.length > 0 ? "FILTER ACTIVE" : "LOCAL") + (root.sortMode === "usage" ? " / MOST USED" : " / A–Z")
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: appList
|
id: appList
|
||||||
@@ -216,6 +253,9 @@ Item {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
readonly property bool selected: index === root.selectedIndex
|
readonly property bool selected: index === root.selectedIndex
|
||||||
|
// Only the selected row is slanted; the rest are plain rectangles.
|
||||||
|
property real slant: selected ? 9 : 0
|
||||||
|
Behavior on slant { NumberAnimation { duration: 90; easing.type: Easing.OutCubic } }
|
||||||
|
|
||||||
onEntered: root.selectionRequested(index)
|
onEntered: root.selectionRequested(index)
|
||||||
onClicked: root.launchRequested(index)
|
onClicked: root.launchRequested(index)
|
||||||
@@ -229,21 +269,21 @@ Item {
|
|||||||
fillColor: row.selected ? Theme.selection : Theme.textAlpha(0.025)
|
fillColor: row.selected ? Theme.selection : Theme.textAlpha(0.025)
|
||||||
strokeColor: row.selected ? Theme.accent : Theme.textAlpha(0.10)
|
strokeColor: row.selected ? Theme.accent : Theme.textAlpha(0.10)
|
||||||
strokeWidth: 1
|
strokeWidth: 1
|
||||||
startX: 9; startY: 0
|
startX: row.slant; startY: 0
|
||||||
PathLine { x: rowShape.width; y: 0 }
|
PathLine { x: rowShape.width; y: 0 }
|
||||||
PathLine { x: rowShape.width - 9; y: rowShape.height }
|
PathLine { x: rowShape.width - row.slant; y: rowShape.height }
|
||||||
PathLine { x: 0; y: rowShape.height }
|
PathLine { x: 0; y: rowShape.height }
|
||||||
PathLine { x: 9; y: 0 }
|
PathLine { x: row.slant; y: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapePath {
|
ShapePath {
|
||||||
fillColor: row.selected ? Theme.accent : Theme.textAlpha(0.12)
|
fillColor: row.selected ? Theme.accent : Theme.textAlpha(0.12)
|
||||||
strokeWidth: 0
|
strokeWidth: 0
|
||||||
startX: 9; startY: 0
|
startX: row.slant; startY: 0
|
||||||
PathLine { x: 13; y: 0 }
|
PathLine { x: row.slant + 4; y: 0 }
|
||||||
PathLine { x: 4; y: rowShape.height }
|
PathLine { x: 4; y: rowShape.height }
|
||||||
PathLine { x: 0; y: rowShape.height }
|
PathLine { x: 0; y: rowShape.height }
|
||||||
PathLine { x: 9; y: 0 }
|
PathLine { x: row.slant; y: 0 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,13 +627,46 @@ Item {
|
|||||||
KeyHint { keyText: "↑ ↓"; actionText: "SELECT" }
|
KeyHint { keyText: "↑ ↓"; actionText: "SELECT" }
|
||||||
KeyHint { keyText: "ENTER"; actionText: "EXECUTE" }
|
KeyHint { keyText: "ENTER"; actionText: "EXECUTE" }
|
||||||
KeyHint { keyText: "ESC"; actionText: "ABORT" }
|
KeyHint { keyText: "ESC"; actionText: "ABORT" }
|
||||||
|
KeyHint { keyText: "CTRL+S"; actionText: "SORT" }
|
||||||
Item { Layout.fillWidth: true }
|
Item { Layout.fillWidth: true }
|
||||||
MicroText { text: "QRY:" + (root.query.length > 0 ? "ACTIVE" : "IDLE") }
|
MicroText { text: "QRY:" + (root.query.length > 0 ? "ACTIVE" : "IDLE") }
|
||||||
MicroText { text: "CRC // A7F2" }
|
Rectangle { Layout.preferredWidth: 1; Layout.preferredHeight: 22; color: Theme.hair }
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: [
|
||||||
|
{ action: "logout", label: "LOGOUT" },
|
||||||
|
{ action: "reboot", label: "REBOOT" },
|
||||||
|
{ action: "shutdown", label: "SHUTDOWN" }
|
||||||
|
]
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: powerButton
|
||||||
|
required property var modelData
|
||||||
|
readonly property bool armed: root.armedPower === modelData.action
|
||||||
|
|
||||||
|
Layout.preferredWidth: 96
|
||||||
|
Layout.preferredHeight: 26
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: root.pressPower(modelData.action)
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
Layout.preferredWidth: 76
|
anchors.fill: parent
|
||||||
Layout.preferredHeight: 4
|
color: powerButton.armed ? Theme.hot : powerButton.containsMouse ? Theme.accentAlpha(0.28) : Theme.accentAlpha(0.10)
|
||||||
color: Theme.accent
|
border.width: 1
|
||||||
|
border.color: powerButton.armed ? Theme.hot : powerButton.containsMouse ? Theme.accent : Theme.hair
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: powerButton.armed ? "CONFIRM" : powerButton.modelData.label
|
||||||
|
color: powerButton.armed ? Theme.surface : Theme.accent
|
||||||
|
font.family: Theme.microFont
|
||||||
|
font.pixelSize: 8
|
||||||
|
font.bold: true
|
||||||
|
font.letterSpacing: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +1,85 @@
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
// Non-visual, reusable app-search model shared by every launcher variant.
|
// Non-visual app-search model for the launcher.
|
||||||
// Set `search`; read `apps` (a ranked, filtered list of DesktopEntry).
|
// Set `search`; read `apps` (a ranked, filtered list of DesktopEntry).
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property string search: ""
|
property string search: ""
|
||||||
|
|
||||||
|
// "usage" (most launched first) | "name". Persisted with the counts.
|
||||||
|
readonly property string sortMode: store.sortMode
|
||||||
|
|
||||||
|
function toggleSort() {
|
||||||
|
store.sortMode = store.sortMode === "usage" ? "name" : "usage";
|
||||||
|
}
|
||||||
|
|
||||||
|
function uses(a) {
|
||||||
|
return store.counts[a.id] ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
// `keywords`/`categories` come through as string lists, so coerce every
|
// `keywords`/`categories` come through as string lists, so coerce every
|
||||||
// field to a string before matching (String([]) joins with commas).
|
// field to a string before matching (String([]) joins with commas).
|
||||||
function haystack(a) {
|
function haystack(a) {
|
||||||
return (String(a.name || "") + " " + String(a.genericName || "") + " " + String(a.comment || "") + " " + String(a.keywords || "")).toLowerCase();
|
return (String(a.name || "") + " " + String(a.genericName || "") + " " + String(a.comment || "") + " " + String(a.keywords || "")).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function byOrder(x, y) {
|
||||||
|
if (root.sortMode === "usage") {
|
||||||
|
const d = root.uses(y) - root.uses(x);
|
||||||
|
if (d !== 0)
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
return String(x.name).localeCompare(String(y.name));
|
||||||
|
}
|
||||||
|
|
||||||
readonly property var apps: {
|
readonly property var apps: {
|
||||||
const all = DesktopEntries.applications.values.filter(a => !a.noDisplay);
|
const all = DesktopEntries.applications.values.filter(a => !a.noDisplay);
|
||||||
const q = root.search.trim().toLowerCase();
|
const q = root.search.trim().toLowerCase();
|
||||||
|
|
||||||
if (q.length === 0)
|
if (q.length === 0)
|
||||||
return all.slice().sort((x, y) => String(x.name).localeCompare(String(y.name)));
|
return all.slice().sort(root.byOrder);
|
||||||
|
|
||||||
const matches = all.filter(a => root.haystack(a).includes(q));
|
const matches = all.filter(a => root.haystack(a).includes(q));
|
||||||
|
|
||||||
// Prefix matches on the visible name rank first, then alphabetical.
|
// Prefix matches on the visible name rank first, then the sort mode.
|
||||||
return matches.slice().sort((x, y) => {
|
return matches.slice().sort((x, y) => {
|
||||||
const xs = String(x.name).toLowerCase().startsWith(q) ? 0 : 1;
|
const xs = String(x.name).toLowerCase().startsWith(q) ? 0 : 1;
|
||||||
const ys = String(y.name).toLowerCase().startsWith(q) ? 0 : 1;
|
const ys = String(y.name).toLowerCase().startsWith(q) ? 0 : 1;
|
||||||
if (xs !== ys)
|
if (xs !== ys)
|
||||||
return xs - ys;
|
return xs - ys;
|
||||||
return String(x.name).localeCompare(String(y.name));
|
return root.byOrder(x, y);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function launch(index) {
|
function launch(index) {
|
||||||
const list = root.apps;
|
const list = root.apps;
|
||||||
if (index >= 0 && index < list.length) {
|
if (index >= 0 && index < list.length) {
|
||||||
list[index].execute();
|
const app = list[index];
|
||||||
|
app.execute();
|
||||||
|
// Reassigned, not mutated: an in-place write notifies nothing.
|
||||||
|
const counts = Object.assign({}, store.counts);
|
||||||
|
counts[app.id] = (counts[app.id] ?? 0) + 1;
|
||||||
|
store.counts = counts;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readonly property var file: FileView {
|
||||||
|
path: Quickshell.statePath("launcher.json")
|
||||||
|
onAdapterUpdated: writeAdapter()
|
||||||
|
onLoadFailed: error => {
|
||||||
|
if (error === FileViewError.FileNotFound)
|
||||||
|
writeAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonAdapter {
|
||||||
|
id: store
|
||||||
|
property string sortMode: "usage"
|
||||||
|
property var counts: ({})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,8 @@ Item {
|
|||||||
property string panelId: ""
|
property string panelId: ""
|
||||||
property string title: ""
|
property string title: ""
|
||||||
property string meta: ""
|
property string meta: ""
|
||||||
|
// Header strip only: body and header rule hidden.
|
||||||
|
property bool collapsed: false
|
||||||
|
|
||||||
property int chamfer: 16
|
property int chamfer: 16
|
||||||
property int padding: 14
|
property int padding: 14
|
||||||
@@ -54,7 +56,7 @@ Item {
|
|||||||
|
|
||||||
default property alias content: body.data
|
default property alias content: body.data
|
||||||
|
|
||||||
implicitHeight: Math.round(body.y + body.height + panel.padding)
|
implicitHeight: panel.collapsed ? panel.headerHeight : Math.round(body.y + body.height + panel.padding)
|
||||||
|
|
||||||
Shape {
|
Shape {
|
||||||
id: panelShape
|
id: panelShape
|
||||||
@@ -181,6 +183,7 @@ Item {
|
|||||||
|
|
||||||
// Header rule.
|
// Header rule.
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
visible: !panel.collapsed
|
||||||
x: 1
|
x: 1
|
||||||
y: panel.headerHeight
|
y: panel.headerHeight
|
||||||
width: parent.width - 2
|
width: parent.width - 2
|
||||||
@@ -194,6 +197,7 @@ Item {
|
|||||||
Item {
|
Item {
|
||||||
id: body
|
id: body
|
||||||
|
|
||||||
|
visible: !panel.collapsed
|
||||||
x: panel.padding
|
x: panel.padding
|
||||||
y: panel.headerHeight + panel.headerGap
|
y: panel.headerHeight + panel.headerGap
|
||||||
width: Math.max(0, panel.width - panel.padding * 2)
|
width: Math.max(0, panel.width - panel.padding * 2)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import qs.HyprChrome.Theme
|
|||||||
// nothing to call. Two consequences:
|
// nothing to call. Two consequences:
|
||||||
//
|
//
|
||||||
// * Only ONE agent may hold a session. hyprpolkitagent must not be running
|
// * Only ONE agent may hold a session. hyprpolkitagent must not be running
|
||||||
// (hosts/terra/home/hyprland.nix autostart), or registration fails and this
|
// (home/desktop/hyprland.nix autostart), or registration fails and this
|
||||||
// dialog silently never appears. `isRegistered` is the check.
|
// dialog silently never appears. `isRegistered` is the check.
|
||||||
// * `path` is write-once — the binary refuses a later assignment with
|
// * `path` is write-once — the binary refuses a later assignment with
|
||||||
// "cannot change path after it has been set." Set it here or not at all.
|
// "cannot change path after it has been set." Set it here or not at all.
|
||||||
@@ -87,9 +87,22 @@ Scope {
|
|||||||
// never appears. Leaving it orphaned costs one hung caller; cancelling it
|
// never appears. Leaving it orphaned costs one hung caller; cancelling it
|
||||||
// costs the prompt as well.
|
// costs the prompt as well.
|
||||||
onFlowChanged: {
|
onFlowChanged: {
|
||||||
|
vault.invalidate();
|
||||||
if (root.flow) {
|
if (root.flow) {
|
||||||
content.clearResponse();
|
content.clearResponse();
|
||||||
content.focusInput();
|
content.focusInput();
|
||||||
|
// Prefetched so Tab is instant; the list stays from the last
|
||||||
|
// request while this refreshes.
|
||||||
|
vault.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ProtonPass {
|
||||||
|
id: vault
|
||||||
|
|
||||||
|
onFetched: secret => {
|
||||||
|
content.response = secret;
|
||||||
|
content.focusInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +207,7 @@ Scope {
|
|||||||
// line appears. Floored at the same margin the width leaves, so a
|
// line appears. Floored at the same margin the width leaves, so a
|
||||||
// tall prompt on a short output cannot be pushed off the top.
|
// tall prompt on a short output cannot be pushed off the top.
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
y: Math.max(32, Math.round(parent.height / 3 - height / 2))
|
y: Math.max(32, Math.round(parent.height / 3 - content.dialogHeight / 2))
|
||||||
width: 520
|
width: 520
|
||||||
|
|
||||||
message: root.flow ? root.flow.message : ""
|
message: root.flow ? root.flow.message : ""
|
||||||
@@ -209,6 +222,17 @@ Scope {
|
|||||||
supplementaryIsError: root.flow ? root.flow.supplementaryIsError : false
|
supplementaryIsError: root.flow ? root.flow.supplementaryIsError : false
|
||||||
failed: root.flow ? root.flow.failed : false
|
failed: root.flow ? root.flow.failed : false
|
||||||
|
|
||||||
|
credentialsEnabled: true
|
||||||
|
credentials: vault.entries
|
||||||
|
credentialsStatus: vault.listStatus
|
||||||
|
fetchStatus: vault.fetchStatus
|
||||||
|
|
||||||
|
onCredentialRequested: entry => vault.fetch(entry)
|
||||||
|
onPickerOpened: {
|
||||||
|
if (vault.entries.length === 0)
|
||||||
|
vault.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
onSubmitted: value => {
|
onSubmitted: value => {
|
||||||
if (root.flow)
|
if (root.flow)
|
||||||
root.flow.submit(value);
|
root.flow.submit(value);
|
||||||
@@ -235,9 +259,11 @@ Scope {
|
|||||||
enabled: root.flow !== null
|
enabled: root.flow !== null
|
||||||
|
|
||||||
function onFailedChanged() {
|
function onFailedChanged() {
|
||||||
if (root.flow.failed)
|
if (root.flow.failed) {
|
||||||
|
vault.invalidate();
|
||||||
content.clearResponse();
|
content.clearResponse();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Re-focus when the conversation asks for something. This is load
|
// Re-focus when the conversation asks for something. This is load
|
||||||
// bearing, not defensive: a flow arrives with isResponseRequired
|
// bearing, not defensive: a flow arrives with isResponseRequired
|
||||||
|
|||||||
@@ -46,15 +46,163 @@ Item {
|
|||||||
|
|
||||||
property alias response: responseInput.text
|
property alias response: responseInput.text
|
||||||
|
|
||||||
|
// Masking override from the eye toggle; reset with the field, so a
|
||||||
|
// revealed password never carries over to the next request.
|
||||||
|
property bool revealed: false
|
||||||
|
|
||||||
|
// Proton Pass logins, in their own panel under the dialog, collapsed until
|
||||||
|
// Tab. Entries need only `title` and `vault`; the adapter fetches the
|
||||||
|
// password for the one picked, so no secret is ever in this list. Off by
|
||||||
|
// default, as in the headless render.
|
||||||
|
property bool credentialsEnabled: false
|
||||||
|
property var credentials: []
|
||||||
|
// Picker-only: loading / listing failure. fetchStatus shows regardless —
|
||||||
|
// it is what explains an empty field after a pick.
|
||||||
|
property string credentialsStatus: ""
|
||||||
|
property string fetchStatus: ""
|
||||||
|
property bool pickerOpen: false
|
||||||
|
property int pickerIndex: 0
|
||||||
|
|
||||||
|
// Vault the list is narrowed to; "" is all of them. Kept across requests,
|
||||||
|
// so a vault picked once stays picked.
|
||||||
|
property string vaultFilter: ""
|
||||||
|
property bool overflowMenuOpen: false
|
||||||
|
|
||||||
|
// Height of the dialog alone. The adapters position on this rather than
|
||||||
|
// implicitHeight, so expanding the vault panel grows downward instead of
|
||||||
|
// shifting the dialog up under the cursor.
|
||||||
|
readonly property real dialogHeight: panel.implicitHeight
|
||||||
|
|
||||||
|
readonly property var vaultNames: {
|
||||||
|
const names = [];
|
||||||
|
for (const c of root.credentials)
|
||||||
|
if (!names.includes(c.vault))
|
||||||
|
names.push(c.vault);
|
||||||
|
return names.sort((a, b) => a.toLowerCase() < b.toLowerCase() ? -1 : a.toLowerCase() > b.toLowerCase() ? 1 : 0);
|
||||||
|
}
|
||||||
|
readonly property var vaultOptions: [""].concat(root.vaultNames)
|
||||||
|
|
||||||
|
// A remembered vault that no longer exists falls back to all.
|
||||||
|
readonly property string activeVault: root.vaultNames.includes(root.vaultFilter) ? root.vaultFilter : ""
|
||||||
|
|
||||||
|
// Title A–Z within the chosen vault (or across all of them).
|
||||||
|
readonly property var shownCredentials: {
|
||||||
|
const q = filterInput.text.toLowerCase();
|
||||||
|
return root.credentials
|
||||||
|
.filter(c => (root.activeVault === "" || c.vault === root.activeVault)
|
||||||
|
&& (q === "" || c.title.toLowerCase().includes(q)))
|
||||||
|
.sort((a, b) => {
|
||||||
|
const ta = a.title.toLowerCase(), tb = b.title.toLowerCase();
|
||||||
|
return ta < tb ? -1 : ta > tb ? 1 : 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function vaultLabel(name) {
|
||||||
|
return name === "" ? "ALL" : name.toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
function vaultCount(name) {
|
||||||
|
return name === "" ? root.credentials.length : root.credentials.filter(c => c.vault === name).length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function tabText(name) {
|
||||||
|
return root.vaultLabel(name) + " " + root.vaultCount(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tabs are sized from FontMetrics rather than their own implicitWidth, so
|
||||||
|
// how many fit is known before any are laid out — the overflow split
|
||||||
|
// would otherwise depend on the very tabs it decides to create.
|
||||||
|
function tabWidth(text) {
|
||||||
|
return Math.ceil(tabMetrics.advanceWidth(text) + text.length * tabMetrics.font.letterSpacing) + 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
// How many leading vault options get a tab of their own; the rest go in
|
||||||
|
// the overflow menu, which is always the last tab.
|
||||||
|
//
|
||||||
|
// The overflow tab names the selected vault when it holds it, so it is
|
||||||
|
// sized for "MORE" first and, if the selection lands in the overflow,
|
||||||
|
// re-split for that label. Shrinking can only push the selection further
|
||||||
|
// into the overflow, so the second pass is final.
|
||||||
|
readonly property int fittingTabs: {
|
||||||
|
const avail = tabStrip.width;
|
||||||
|
const widths = root.vaultOptions.map(v => root.tabWidth(root.tabText(v)));
|
||||||
|
if (widths.reduce((a, b) => a + b, 0) <= avail)
|
||||||
|
return widths.length;
|
||||||
|
const split = reserve => {
|
||||||
|
let used = reserve, k = 0;
|
||||||
|
while (k < widths.length && used + widths[k] <= avail)
|
||||||
|
used += widths[k++];
|
||||||
|
return Math.max(1, k);
|
||||||
|
};
|
||||||
|
const k = split(root.tabWidth("MORE ▾"));
|
||||||
|
return root.vaultOptions.indexOf(root.activeVault) >= k
|
||||||
|
? split(root.tabWidth(root.tabText(root.activeVault) + " ▾")) : k;
|
||||||
|
}
|
||||||
|
readonly property var overflowVaults: root.vaultOptions.slice(root.fittingTabs)
|
||||||
|
|
||||||
signal submitted(string value)
|
signal submitted(string value)
|
||||||
signal cancelled
|
signal cancelled
|
||||||
signal identityRequested(int index)
|
signal identityRequested(int index)
|
||||||
|
signal credentialRequested(var entry)
|
||||||
|
signal pickerOpened
|
||||||
|
|
||||||
function focusInput() { responseInput.forceActiveFocus(); }
|
function focusInput() { responseInput.forceActiveFocus(); }
|
||||||
function clearResponse() { responseInput.text = ""; }
|
function clearResponse() {
|
||||||
|
responseInput.text = "";
|
||||||
|
root.revealed = false;
|
||||||
|
root.closePicker();
|
||||||
|
}
|
||||||
|
|
||||||
|
function openPicker() {
|
||||||
|
if (!root.credentialsEnabled)
|
||||||
|
return;
|
||||||
|
filterInput.text = "";
|
||||||
|
root.pickerIndex = 0;
|
||||||
|
root.overflowMenuOpen = false;
|
||||||
|
root.pickerOpen = true;
|
||||||
|
filterInput.forceActiveFocus();
|
||||||
|
root.pickerOpened();
|
||||||
|
}
|
||||||
|
|
||||||
|
function closePicker() {
|
||||||
|
if (!root.pickerOpen)
|
||||||
|
return;
|
||||||
|
root.overflowMenuOpen = false;
|
||||||
|
root.pickerOpen = false;
|
||||||
|
root.focusInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectVault(index) {
|
||||||
|
root.vaultFilter = root.vaultOptions[index] || "";
|
||||||
|
root.overflowMenuOpen = false;
|
||||||
|
root.pickerIndex = 0;
|
||||||
|
pickerList.positionViewAtBeginning();
|
||||||
|
filterInput.forceActiveFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
function cycleVault(delta) {
|
||||||
|
const n = root.vaultOptions.length;
|
||||||
|
root.selectVault((Math.max(0, root.vaultOptions.indexOf(root.activeVault)) + delta + n) % n);
|
||||||
|
}
|
||||||
|
|
||||||
|
function pick(index) {
|
||||||
|
const entry = root.shownCredentials[index];
|
||||||
|
if (!entry)
|
||||||
|
return;
|
||||||
|
root.closePicker();
|
||||||
|
root.credentialRequested(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
function movePicker(delta) {
|
||||||
|
const n = root.shownCredentials.length;
|
||||||
|
if (n > 0)
|
||||||
|
root.pickerIndex = (root.pickerIndex + delta + n) % n;
|
||||||
|
}
|
||||||
|
|
||||||
|
onPickerIndexChanged: pickerList.positionViewAtIndex(root.pickerIndex, ListView.Contain)
|
||||||
|
|
||||||
implicitWidth: 520
|
implicitWidth: 520
|
||||||
implicitHeight: panel.implicitHeight
|
implicitHeight: stack.implicitHeight
|
||||||
|
|
||||||
// Escape reaches here by propagating up the focus chain from the TextInput,
|
// Escape reaches here by propagating up the focus chain from the TextInput,
|
||||||
// which does not consume it — so cancelling works whether or not the input
|
// which does not consume it — so cancelling works whether or not the input
|
||||||
@@ -72,6 +220,48 @@ Item {
|
|||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A vault tab. Sized by the caller from tabWidth(), not by its label: the
|
||||||
|
// overflow split is computed before any tab exists.
|
||||||
|
component VaultTab: Item {
|
||||||
|
id: tab
|
||||||
|
|
||||||
|
property string label: ""
|
||||||
|
property bool current: false
|
||||||
|
|
||||||
|
signal clicked
|
||||||
|
|
||||||
|
MicroText {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: tab.label
|
||||||
|
color: tab.current ? Theme.accent
|
||||||
|
: tabArea.containsMouse ? Theme.text : Theme.muted
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
visible: tab.current
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
width: parent.width
|
||||||
|
height: 2
|
||||||
|
color: Theme.accent
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: tabArea
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: tab.clicked()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: stack
|
||||||
|
|
||||||
|
width: root.width
|
||||||
|
// Clears the detached corner caps between the two panels.
|
||||||
|
spacing: 14
|
||||||
|
|
||||||
PolkitPanel {
|
PolkitPanel {
|
||||||
id: panel
|
id: panel
|
||||||
|
|
||||||
@@ -200,7 +390,7 @@ Item {
|
|||||||
font.letterSpacing: 1
|
font.letterSpacing: 1
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
echoMode: root.responseVisible
|
echoMode: root.responseVisible || root.revealed
|
||||||
? TextInput.Normal : TextInput.Password
|
? TextInput.Normal : TextInput.Password
|
||||||
passwordCharacter: "▪"
|
passwordCharacter: "▪"
|
||||||
// Qt reveals the last typed character for a moment by
|
// Qt reveals the last typed character for a moment by
|
||||||
@@ -213,6 +403,11 @@ Item {
|
|||||||
root.submitted(responseInput.text);
|
root.submitted(responseInput.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Keys.onTabPressed: event => {
|
||||||
|
root.openPicker();
|
||||||
|
event.accepted = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Placeholder: TextInput has none of its own, and the
|
// Placeholder: TextInput has none of its own, and the
|
||||||
// PAM prompt ("Password:", "PIN:") is the only label
|
// PAM prompt ("Password:", "PIN:") is the only label
|
||||||
// this field gets.
|
// this field gets.
|
||||||
@@ -224,8 +419,37 @@ Item {
|
|||||||
font: responseInput.font
|
font: responseInput.font
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Eye toggle. Hidden when PAM already asked for echoed
|
||||||
|
// input — there is nothing left to reveal.
|
||||||
|
Text {
|
||||||
|
visible: !root.responseVisible
|
||||||
|
text: root.revealed ? "" : ""
|
||||||
|
color: root.revealed ? Theme.accent : (eyeArea.containsMouse ? Theme.text : Theme.muted)
|
||||||
|
font.family: Theme.displayFont
|
||||||
|
font.pixelSize: 14
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: eyeArea
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: -6
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: {
|
||||||
|
root.revealed = !root.revealed;
|
||||||
|
root.focusInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MicroText {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
visible: root.credentialsEnabled && root.fetchStatus !== ""
|
||||||
|
text: root.fetchStatus
|
||||||
|
}
|
||||||
|
|
||||||
// ---- pam_info / pam_error ----
|
// ---- pam_info / pam_error ----
|
||||||
Text {
|
Text {
|
||||||
@@ -248,10 +472,307 @@ Item {
|
|||||||
MicroText { text: "ESC CANCEL" }
|
MicroText { text: "ESC CANCEL" }
|
||||||
Item { Layout.fillWidth: true }
|
Item { Layout.fillWidth: true }
|
||||||
MicroText {
|
MicroText {
|
||||||
text: root.responseVisible ? "ECHO ON" : ""
|
text: root.responseVisible ? "ECHO ON" : root.revealed ? "SHOWN" : ""
|
||||||
color: Theme.hot
|
color: Theme.hot
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- Proton Pass ----
|
||||||
|
// Its own panel so the dialog keeps its shape; collapsed it is the header
|
||||||
|
// strip alone. The MouseArea sits over that strip only — PolkitPanel's
|
||||||
|
// default property is the body slot, so it cannot live inside the panel.
|
||||||
|
Item {
|
||||||
|
visible: root.credentialsEnabled
|
||||||
|
width: root.width
|
||||||
|
height: vaultPanel.implicitHeight
|
||||||
|
|
||||||
|
PolkitPanel {
|
||||||
|
id: vaultPanel
|
||||||
|
|
||||||
|
width: parent.width
|
||||||
|
panelId: "PSS"
|
||||||
|
title: "PROTON PASS"
|
||||||
|
collapsed: !root.pickerOpen
|
||||||
|
meta: root.pickerOpen
|
||||||
|
? root.shownCredentials.length + " / " + root.credentials.length
|
||||||
|
: "TAB OPEN"
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
width: parent.width
|
||||||
|
spacing: 6
|
||||||
|
|
||||||
|
// ---- vault tabs ----
|
||||||
|
// One row; tabs that do not fit move into the overflow
|
||||||
|
// tab's menu. z above the filter and list, which the open
|
||||||
|
// menu draws over.
|
||||||
|
Item {
|
||||||
|
id: tabStrip
|
||||||
|
|
||||||
|
z: 2
|
||||||
|
Layout.fillWidth: true
|
||||||
|
implicitHeight: 22
|
||||||
|
|
||||||
|
FontMetrics {
|
||||||
|
id: tabMetrics
|
||||||
|
|
||||||
|
font.family: Theme.microFont
|
||||||
|
font.pixelSize: 8
|
||||||
|
font.letterSpacing: 0.9
|
||||||
|
}
|
||||||
|
|
||||||
|
// The rule the tabs sit on, across the full width.
|
||||||
|
Rectangle {
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
width: parent.width
|
||||||
|
height: 1
|
||||||
|
color: Theme.hair
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
Repeater {
|
||||||
|
model: root.vaultOptions.slice(0, root.fittingTabs)
|
||||||
|
|
||||||
|
VaultTab {
|
||||||
|
id: vaultTab
|
||||||
|
|
||||||
|
required property int index
|
||||||
|
required property string modelData
|
||||||
|
|
||||||
|
width: root.tabWidth(vaultTab.label)
|
||||||
|
height: tabStrip.height
|
||||||
|
label: root.tabText(vaultTab.modelData)
|
||||||
|
current: vaultTab.modelData === root.activeVault
|
||||||
|
onClicked: root.selectVault(vaultTab.index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VaultTab {
|
||||||
|
id: overflowTab
|
||||||
|
|
||||||
|
readonly property bool holdsActive: root.overflowVaults.includes(root.activeVault)
|
||||||
|
|
||||||
|
visible: root.overflowVaults.length > 0
|
||||||
|
width: root.tabWidth(overflowTab.label)
|
||||||
|
height: tabStrip.height
|
||||||
|
// Names the selected vault when it is one of
|
||||||
|
// the hidden ones, so the selection stays visible.
|
||||||
|
label: (overflowTab.holdsActive ? root.tabText(root.activeVault) : "MORE") + " ▾"
|
||||||
|
current: overflowTab.holdsActive || root.overflowMenuOpen
|
||||||
|
onClicked: root.overflowMenuOpen = !root.overflowMenuOpen
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
visible: root.overflowMenuOpen
|
||||||
|
// Right-aligned to the tab, clamped to the strip.
|
||||||
|
x: Math.max(-overflowTab.x, overflowTab.width - width)
|
||||||
|
y: overflowTab.height + 2
|
||||||
|
width: Math.max(180, overflowTab.width)
|
||||||
|
height: overflowColumn.implicitHeight + 2
|
||||||
|
color: Theme.surface
|
||||||
|
border.width: 1
|
||||||
|
border.color: Theme.accent
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: overflowColumn
|
||||||
|
|
||||||
|
x: 1
|
||||||
|
y: 1
|
||||||
|
width: parent.width - 2
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: root.overflowVaults
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: option
|
||||||
|
|
||||||
|
required property int index
|
||||||
|
required property string modelData
|
||||||
|
|
||||||
|
readonly property bool current: option.modelData === root.activeVault
|
||||||
|
|
||||||
|
width: overflowColumn.width
|
||||||
|
height: 22
|
||||||
|
color: optionArea.containsMouse ? Theme.selection : "transparent"
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
visible: option.current
|
||||||
|
width: 2
|
||||||
|
height: parent.height
|
||||||
|
color: Theme.accent
|
||||||
|
}
|
||||||
|
|
||||||
|
MicroText {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
text: root.vaultLabel(option.modelData)
|
||||||
|
color: option.current ? Theme.accent
|
||||||
|
: optionArea.containsMouse ? Theme.text : Theme.muted
|
||||||
|
}
|
||||||
|
|
||||||
|
MicroText {
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.rightMargin: 8
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
text: root.vaultCount(option.modelData)
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: optionArea
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: root.selectVault(root.fittingTabs + option.index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
spacing: 8
|
||||||
|
|
||||||
|
TextInput {
|
||||||
|
id: filterInput
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
color: Theme.text
|
||||||
|
selectionColor: Theme.accent
|
||||||
|
selectedTextColor: Theme.surface
|
||||||
|
font.family: Theme.displayFont
|
||||||
|
font.pixelSize: 12
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
onTextChanged: root.pickerIndex = 0
|
||||||
|
onAccepted: root.pick(root.pickerIndex)
|
||||||
|
|
||||||
|
// Consumed so Esc backs out of the panel instead
|
||||||
|
// of cancelling the whole request.
|
||||||
|
Keys.onEscapePressed: event => {
|
||||||
|
if (root.overflowMenuOpen)
|
||||||
|
root.overflowMenuOpen = false;
|
||||||
|
else
|
||||||
|
root.closePicker();
|
||||||
|
event.accepted = true;
|
||||||
|
}
|
||||||
|
Keys.onTabPressed: event => {
|
||||||
|
root.cycleVault(1);
|
||||||
|
event.accepted = true;
|
||||||
|
}
|
||||||
|
Keys.onBacktabPressed: event => {
|
||||||
|
root.cycleVault(-1);
|
||||||
|
event.accepted = true;
|
||||||
|
}
|
||||||
|
Keys.onUpPressed: event => {
|
||||||
|
root.movePicker(-1);
|
||||||
|
event.accepted = true;
|
||||||
|
}
|
||||||
|
Keys.onDownPressed: event => {
|
||||||
|
root.movePicker(1);
|
||||||
|
event.accepted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
visible: filterInput.text.length === 0
|
||||||
|
text: "filter logins"
|
||||||
|
color: Theme.disabled
|
||||||
|
font: filterInput.font
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MicroText {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
visible: text !== ""
|
||||||
|
text: root.credentialsStatus !== "" ? root.credentialsStatus
|
||||||
|
: root.shownCredentials.length === 0 ? "NO MATCH" : ""
|
||||||
|
}
|
||||||
|
|
||||||
|
ListView {
|
||||||
|
id: pickerList
|
||||||
|
|
||||||
|
readonly property int rowHeight: 24
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
implicitHeight: Math.min(count, 10) * rowHeight
|
||||||
|
visible: count > 0
|
||||||
|
clip: true
|
||||||
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
model: root.shownCredentials
|
||||||
|
|
||||||
|
delegate: Rectangle {
|
||||||
|
id: row
|
||||||
|
|
||||||
|
required property int index
|
||||||
|
required property var modelData
|
||||||
|
|
||||||
|
readonly property bool current: row.index === root.pickerIndex
|
||||||
|
|
||||||
|
width: pickerList.width
|
||||||
|
height: pickerList.rowHeight
|
||||||
|
color: row.current ? Theme.selection : "transparent"
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
visible: row.current
|
||||||
|
width: 2
|
||||||
|
height: parent.height
|
||||||
|
color: Theme.accent
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
anchors.rightMargin: 6
|
||||||
|
spacing: 10
|
||||||
|
|
||||||
|
Text {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: row.modelData.title
|
||||||
|
elide: Text.ElideRight
|
||||||
|
color: row.current ? Theme.text : Theme.muted
|
||||||
|
font.family: Theme.displayFont
|
||||||
|
font.pixelSize: 12
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only useful when the list spans vaults.
|
||||||
|
MicroText {
|
||||||
|
visible: root.activeVault === ""
|
||||||
|
text: row.modelData.vault.toUpperCase()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: root.pick(row.index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
spacing: 14
|
||||||
|
|
||||||
|
MicroText { text: "↑↓ SELECT" }
|
||||||
|
MicroText { text: "ENTER FILL" }
|
||||||
|
MicroText { text: "TAB VAULT" }
|
||||||
|
MicroText { text: "ESC BACK" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
width: parent.width
|
||||||
|
height: vaultPanel.headerHeight
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: root.pickerOpen ? root.closePicker() : root.openPicker()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,176 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
|
|
||||||
|
// Proton Pass logins for the polkit and askpass prompts, via pass-cli.
|
||||||
|
//
|
||||||
|
// Listing never touches a secret: `item list` without --show-secrets returns
|
||||||
|
// ids and titles only. A password is fetched on its own, for one item, after
|
||||||
|
// the user picks it — and read through a SplitParser rather than a
|
||||||
|
// StdioCollector, which would keep it in its `text` property afterwards.
|
||||||
|
//
|
||||||
|
// `item list` refuses to run without a vault, so "all vaults" is one call per
|
||||||
|
// vault. Each takes ~0.8s, hence run in parallel by a single shell script.
|
||||||
|
QtObject {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
// {shareId, id, title, vault}, unsorted — the dialog orders and groups them.
|
||||||
|
property var entries: []
|
||||||
|
// Why the list is empty or incomplete; "" when it is fine.
|
||||||
|
property string error: ""
|
||||||
|
property string fetchError: ""
|
||||||
|
|
||||||
|
readonly property bool loading: vaults.running || items.running
|
||||||
|
readonly property bool fetching: fetcher.running
|
||||||
|
|
||||||
|
// Shown inside the picker.
|
||||||
|
readonly property string listStatus: root.loading
|
||||||
|
? (root.entries.length === 0 ? "LOADING VAULTS…" : "REFRESHING…")
|
||||||
|
: root.error
|
||||||
|
// Shown under the field, picker open or not.
|
||||||
|
readonly property string fetchStatus: root.fetching ? "FETCHING PASSWORD…" : root.fetchError
|
||||||
|
|
||||||
|
// Bumped per request; a fetch that lands after it changed is dropped, so a
|
||||||
|
// slow fetch cannot fill a password into the NEXT request's field.
|
||||||
|
property int generation: 0
|
||||||
|
property int fetchGeneration: -1
|
||||||
|
property bool fetchGotLine: false
|
||||||
|
property var vaultNames: ({})
|
||||||
|
|
||||||
|
signal fetched(string secret)
|
||||||
|
|
||||||
|
function refresh() {
|
||||||
|
if (root.loading)
|
||||||
|
return;
|
||||||
|
root.error = "";
|
||||||
|
vaults.running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function invalidate() {
|
||||||
|
root.generation++;
|
||||||
|
root.fetchError = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetch(entry) {
|
||||||
|
if (!entry || root.fetching)
|
||||||
|
return;
|
||||||
|
root.fetchError = "";
|
||||||
|
root.fetchGeneration = root.generation;
|
||||||
|
root.fetchGotLine = false;
|
||||||
|
fetcher.command = ["pass-cli", "item", "view", "--share-id", entry.shareId,
|
||||||
|
"--item-id", entry.id, "--field", "password", "--output", "human"];
|
||||||
|
fetcher.running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function describe(output) {
|
||||||
|
const text = output.replace(/\x1b\[[0-9;]*m/g, "");
|
||||||
|
if (/not found/.test(text))
|
||||||
|
return "PASS-CLI NOT INSTALLED";
|
||||||
|
if (/authenticated client|no session/.test(text))
|
||||||
|
return "PASS-CLI LOGGED OUT — RUN pass-cli login";
|
||||||
|
const lines = text.trim().split("\n");
|
||||||
|
return lines[lines.length - 1].toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prints the vault JSON or `ERR <output>`: one stream, so success and
|
||||||
|
// failure need no ordering between exit code and stdout.
|
||||||
|
readonly property var vaults: Process {
|
||||||
|
id: vaults
|
||||||
|
|
||||||
|
command: ["sh", "-c",
|
||||||
|
"out=$(pass-cli vault list --output json 2>&1) && printf '%s' \"$out\" || printf 'ERR %s' \"$out\""]
|
||||||
|
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
const body = this.text;
|
||||||
|
if (body.startsWith("ERR ")) {
|
||||||
|
root.error = root.describe(body.slice(4));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let list;
|
||||||
|
try {
|
||||||
|
list = JSON.parse(body).vaults || [];
|
||||||
|
} catch (e) {
|
||||||
|
root.error = "UNREADABLE VAULT LIST";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const names = {};
|
||||||
|
for (const v of list)
|
||||||
|
names[v.share_id] = v.name;
|
||||||
|
root.vaultNames = names;
|
||||||
|
if (list.length === 0) {
|
||||||
|
root.entries = [];
|
||||||
|
root.error = "NO VAULTS";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
items.command = ["sh", "-c", items.script, "sh"].concat(list.map(v => v.share_id));
|
||||||
|
items.running = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// One `item list` per vault in parallel, each to its own file, then
|
||||||
|
// printed back in order under an `@@<share_id>` line — concurrent writers
|
||||||
|
// on one pipe would interleave.
|
||||||
|
//
|
||||||
|
// No --filter-type: it takes ONE type, and the `darman@<config>` machine
|
||||||
|
// logins scripts/deploy reads are `custom` items, not `login`.
|
||||||
|
readonly property var items: Process {
|
||||||
|
id: items
|
||||||
|
|
||||||
|
readonly property string script: "d=$(mktemp -d \"${XDG_RUNTIME_DIR:-/tmp}/qs-pass.XXXXXX\") || exit 1;"
|
||||||
|
+ " trap 'rm -rf \"$d\"' EXIT; i=0;"
|
||||||
|
+ " for s; do i=$((i+1)); pass-cli item list --share-id \"$s\""
|
||||||
|
+ " --filter-state active --output json > \"$d/$i\" 2>/dev/null & done; wait; i=0;"
|
||||||
|
+ " for s; do i=$((i+1)); printf '\\n@@%s\\n' \"$s\"; cat \"$d/$i\"; done"
|
||||||
|
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
const found = [];
|
||||||
|
let failed = 0;
|
||||||
|
for (const chunk of this.text.split(/^@@/m)) {
|
||||||
|
const nl = chunk.indexOf("\n");
|
||||||
|
const share = nl < 0 ? "" : chunk.slice(0, nl).trim();
|
||||||
|
if (share === "")
|
||||||
|
continue;
|
||||||
|
try {
|
||||||
|
for (const it of JSON.parse(chunk.slice(nl + 1)).items || [])
|
||||||
|
if (it.item_type === "login" || it.item_type === "custom")
|
||||||
|
found.push({ shareId: share, id: it.id, title: it.title, vault: root.vaultNames[share] || "" });
|
||||||
|
} catch (e) {
|
||||||
|
failed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
root.entries = found;
|
||||||
|
root.error = failed === 0 ? (found.length === 0 ? "NO LOGINS IN ANY VAULT" : "")
|
||||||
|
: failed + " VAULT" + (failed === 1 ? "" : "S") + " FAILED TO LIST";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly property var fetcher: Process {
|
||||||
|
id: fetcher
|
||||||
|
|
||||||
|
stdout: SplitParser {
|
||||||
|
splitMarker: "\n"
|
||||||
|
onRead: line => {
|
||||||
|
if (root.fetchGotLine)
|
||||||
|
return;
|
||||||
|
root.fetchGotLine = true;
|
||||||
|
if (root.fetchGeneration !== root.generation)
|
||||||
|
return;
|
||||||
|
root.fetchError = line === "" ? "THAT ITEM HAS NO PASSWORD" : "";
|
||||||
|
if (line !== "")
|
||||||
|
root.fetched(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: (exitCode, exitStatus) => {
|
||||||
|
if (!root.fetchGotLine && root.fetchGeneration === root.generation)
|
||||||
|
root.fetchError = exitCode === 0 ? "THAT ITEM HAS NO PASSWORD" : "COULD NOT READ THAT ITEM";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 {}
|
||||||
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
hyprctl dispatch 'hl.dsp.global ("quickshell:launcher8")'
|
hyprctl dispatch 'hl.dsp.global ("quickshell:command")'
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ Scope {
|
|||||||
// Host vitals HUD — toggle with SUPER CTRL V.
|
// Host vitals HUD — toggle with SUPER CTRL V.
|
||||||
Vitals {}
|
Vitals {}
|
||||||
|
|
||||||
// Widget staging area, centered on the secondary monitor (HDMI-A-1),
|
// Widget staging area, centered on the secondary monitor,
|
||||||
// toggled with SUPER CTRL D. Swap the children below for whatever widget
|
// toggled with SUPER CTRL D. Swap the children below for whatever widget
|
||||||
// is being worked on; they must carry their own size (see DebugWindow).
|
// is being worked on; they must carry their own size (see DebugWindow).
|
||||||
// DebugWindow {
|
// DebugWindow {
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import QtQuick
|
||||||
|
import qs.HyprChrome.Widgets.Bar.Claude
|
||||||
|
|
||||||
|
// The rail's claude panel collapsed and expanded, healthy and failing.
|
||||||
|
//
|
||||||
|
// ./tools/quickshell-preview/render.sh \
|
||||||
|
// tests/ClaudePanelHeadless.qml \
|
||||||
|
// .artifacts/quickshell-preview/claude-panel.png 640 420
|
||||||
|
Rectangle {
|
||||||
|
width: 640
|
||||||
|
height: 420
|
||||||
|
color: "#0f1012"
|
||||||
|
|
||||||
|
readonly property var soon: new Date(Date.now() + 2 * 3600000 + 17 * 60000).toISOString()
|
||||||
|
readonly property var later: new Date(Date.now() + 4 * 86400000 + 5 * 3600000).toISOString()
|
||||||
|
|
||||||
|
Row {
|
||||||
|
x: 16
|
||||||
|
y: 16
|
||||||
|
spacing: 24
|
||||||
|
|
||||||
|
Column {
|
||||||
|
spacing: 12
|
||||||
|
|
||||||
|
ClaudePanel {
|
||||||
|
expanded: false
|
||||||
|
ready: true
|
||||||
|
fiveHour: ({ utilization: 42, resets_at: soon })
|
||||||
|
sevenDay: ({ utilization: 91, resets_at: later })
|
||||||
|
}
|
||||||
|
|
||||||
|
ClaudePanel {
|
||||||
|
expanded: false
|
||||||
|
ready: true
|
||||||
|
error: "usage HTTP 429"
|
||||||
|
shortError: "ERR"
|
||||||
|
fiveHour: ({ utilization: 42, resets_at: soon })
|
||||||
|
sevenDay: ({ utilization: 91, resets_at: later })
|
||||||
|
}
|
||||||
|
|
||||||
|
ClaudePanel {
|
||||||
|
expanded: false
|
||||||
|
ready: false
|
||||||
|
error: "token refresh HTTP 400"
|
||||||
|
shortError: "EXPIRED"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
spacing: 12
|
||||||
|
|
||||||
|
ClaudePanel {
|
||||||
|
expanded: true
|
||||||
|
ready: true
|
||||||
|
fiveHour: ({ utilization: 42, resets_at: soon })
|
||||||
|
sevenDay: ({ utilization: 91, resets_at: later })
|
||||||
|
extra: [{ label: "SONNET", window: { utilization: 12, resets_at: later } }]
|
||||||
|
}
|
||||||
|
|
||||||
|
ClaudePanel {
|
||||||
|
expanded: true
|
||||||
|
ready: true
|
||||||
|
error: "usage HTTP 429"
|
||||||
|
shortError: "ERR"
|
||||||
|
fiveHour: ({ utilization: 8, resets_at: soon })
|
||||||
|
sevenDay: ({ utilization: 30, resets_at: later })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import QtQuick
|
||||||
|
import qs.HyprChrome.Widgets.Polkit
|
||||||
|
|
||||||
|
// Offscreen render of the polkit prompt with the Proton Pass panel expanded,
|
||||||
|
// more vaults than fit (Work, selected, sits in the open overflow menu), the
|
||||||
|
// password revealed and a failed fetch under the
|
||||||
|
// field. Credentials are deliberately out of order, to show the title sort.
|
||||||
|
//
|
||||||
|
// ./tools/quickshell-preview/render.sh \
|
||||||
|
// tests/PolkitPromptVaultHeadless.qml \
|
||||||
|
// .artifacts/quickshell-preview/polkit-prompt-vault.png 560 560
|
||||||
|
PolkitPromptContent {
|
||||||
|
width: 520
|
||||||
|
|
||||||
|
message: "Authentication is required to install or remove software"
|
||||||
|
actionId: "org.freedesktop.packagekit.package-install"
|
||||||
|
showIcon: false
|
||||||
|
|
||||||
|
identities: [{ id: "1000", displayName: "darman", isGroup: false }]
|
||||||
|
|
||||||
|
responseRequired: true
|
||||||
|
inputPrompt: "Password:"
|
||||||
|
response: "hunter2"
|
||||||
|
revealed: true
|
||||||
|
|
||||||
|
credentialsEnabled: true
|
||||||
|
credentials: [
|
||||||
|
{ title: "router admin", vault: "HomeLab" },
|
||||||
|
{ title: "proton.me", vault: "Personal" },
|
||||||
|
{ title: "darman@terra", vault: "HomeLab" },
|
||||||
|
{ title: "netcup", vault: "Work" },
|
||||||
|
{ title: "Darman@mars", vault: "HomeLab" },
|
||||||
|
{ title: "github.com", vault: "Personal" },
|
||||||
|
{ title: "root@terra", vault: "HomeLab" },
|
||||||
|
{ title: "grandma wifi", vault: "Family" },
|
||||||
|
{ title: "old forum", vault: "Archive" },
|
||||||
|
{ title: "billing portal", vault: "Clients" },
|
||||||
|
{ title: "ci deploy key", vault: "Shared Infrastructure" },
|
||||||
|
{ title: "vpn", vault: "Work" }
|
||||||
|
]
|
||||||
|
fetchStatus: "THAT ITEM HAS NO PASSWORD"
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
openPicker();
|
||||||
|
pickerIndex = 1;
|
||||||
|
vaultFilter = "Work";
|
||||||
|
overflowMenuOpen = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,7 +39,7 @@ Scope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PanelWindow {
|
PanelWindow {
|
||||||
screen: Quickshell.screens.find(s => s.name === "DP-2")
|
screen: Quickshell.screens.find(s => s.name === Quickshell.env("QS_PRIMARY_OUTPUT"))
|
||||||
visible: root.active
|
visible: root.active
|
||||||
|
|
||||||
WlrLayershell.layer: WlrLayer.Overlay
|
WlrLayershell.layer: WlrLayer.Overlay
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/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 org.telegram.desktop &
|
||||||
flatpak run com.discordapp.Discord &
|
flatpak run com.discordapp.Discord &
|
||||||
|
# terra only (hosts/terra/configuration.nix).
|
||||||
|
command -v TeamSpeak >/dev/null && TeamSpeak &
|
||||||
|
|||||||
@@ -14,11 +14,11 @@
|
|||||||
"uv2nix": "uv2nix"
|
"uv2nix": "uv2nix"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1789888175,
|
"lastModified": 1794238815,
|
||||||
"narHash": "sha256-BWzpZ0/HChcL8F2+hl0GoPaIsWBprMrReeOfrhLSk5o=",
|
"narHash": "sha256-ITaU80ncGp9K/OqoRBbiuxVgMyFHU5sJ9W4FeU6oyiE=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "authentik-nix",
|
"repo": "authentik-nix",
|
||||||
"rev": "477392e1a239228de9a8011786cf673dfbb78c75",
|
"rev": "6441c8b2b900260ac4e9520ab1ce5be6ff1ff39e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -30,16 +30,16 @@
|
|||||||
"authentik-src": {
|
"authentik-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1789678329,
|
"lastModified": 1792581414,
|
||||||
"narHash": "sha256-wt6cjarJI5NXSHgpONjqE9JiltBqkCoPyLLiIS83kuI=",
|
"narHash": "sha256-gdhGKCfsMUrWyFnf5TaaHM2ZQ1WYgTLOgGg4DlCaUHU=",
|
||||||
"owner": "goauthentik",
|
"owner": "goauthentik",
|
||||||
"repo": "authentik",
|
"repo": "authentik",
|
||||||
"rev": "e5a0d2f7572cb776eee7a3e9355937ce38973761",
|
"rev": "4ec0d19b98da3c329781894cd550da95d3033954",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "goauthentik",
|
"owner": "goauthentik",
|
||||||
"ref": "version/2026.8.3",
|
"ref": "version/2026.8.5",
|
||||||
"repo": "authentik",
|
"repo": "authentik",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
@@ -47,11 +47,11 @@
|
|||||||
"client-ts-generator-src": {
|
"client-ts-generator-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1787926240,
|
"lastModified": 1792605533,
|
||||||
"narHash": "sha256-CNazk55jeMBdP/5cf9scshRGCiKALdERny8Oues1zcY=",
|
"narHash": "sha256-f82MB+n7cgKj62g2aTSW34KosYhE7d/dj1KUhJ5KrTY=",
|
||||||
"owner": "goauthentik",
|
"owner": "goauthentik",
|
||||||
"repo": "client-ts",
|
"repo": "client-ts",
|
||||||
"rev": "26b3e23c928e22e4aa66223b5b996e9e68047f0f",
|
"rev": "cbdadfa3cb808b6b587e64c5430bf2d70b2d3461",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -67,11 +67,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1789770686,
|
"lastModified": 1794328522,
|
||||||
"narHash": "sha256-uZkBR7yHdIKUFB5SZdfgh1qkGfI3XmYmI/lTiquxbck=",
|
"narHash": "sha256-h2BYMW4nTFpIqnMd8gwAPFmJAp/1wWLQ6vT0NfL5qt4=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "disko",
|
"repo": "disko",
|
||||||
"rev": "725ea35e410ad83be4931d1bff7e090eacaf3563",
|
"rev": "1dd30c29c88d99ce295f15e27f93c49bc5fbae07",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -96,16 +96,48 @@
|
|||||||
"type": "github"
|
"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": {
|
"flake-parts": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs-lib": "nixpkgs-lib"
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1788450739,
|
"lastModified": 1793576659,
|
||||||
"narHash": "sha256-glZLQlzIn1fXH6PazR2iUmTo7kzzyYSshrWhLS9TqCU=",
|
"narHash": "sha256-V1h85lUaJBQoHFrB2vpXZOE0Ju1MYSnIpsehoVZYlDo=",
|
||||||
"owner": "hercules-ci",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-parts",
|
"repo": "flake-parts",
|
||||||
"rev": "31729ca8cbdb4fa927b34e5f4353e6a83f39e993",
|
"rev": "ea2630b7470978622c7689a1ff75d2b389175399",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-parts_2": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-lib": "nixpkgs-lib_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1793576659,
|
||||||
|
"narHash": "sha256-V1h85lUaJBQoHFrB2vpXZOE0Ju1MYSnIpsehoVZYlDo=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"rev": "ea2630b7470978622c7689a1ff75d2b389175399",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -122,11 +154,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1731533236,
|
"lastModified": 1791914995,
|
||||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
"narHash": "sha256-Zf/xfQEAasnwnmEfHqW/4hjDE/s44yn2hD4RuVIZRjA=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
"rev": "b7a79d3fea1e214f6d668d521cecec0c01e26544",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -135,6 +167,33 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"git-hooks": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": [
|
||||||
|
"nix-citizen",
|
||||||
|
"nix-gaming",
|
||||||
|
"flake-compat"
|
||||||
|
],
|
||||||
|
"nixpkgs": [
|
||||||
|
"nix-citizen",
|
||||||
|
"nix-gaming",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1793686154,
|
||||||
|
"narHash": "sha256-Zb/0L3soxrkfcrywpfp0J++0WFLB3tzh0Xtx9up+VNc=",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "git-hooks.nix",
|
||||||
|
"rev": "204b6977e00caac19e2313015a598543ca7be150",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "git-hooks.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"home-manager": {
|
"home-manager": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
@@ -142,11 +201,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1789267039,
|
"lastModified": 1794251182,
|
||||||
"narHash": "sha256-LWiBv9yAYFi2LPbUhDGHPGKYskJQjj2fw12OlyO1uQo=",
|
"narHash": "sha256-R2sZBXiOJo3HAnvTiVkbbHDJy//JMlAwUKEiPbfqPXk=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "ec172013fa62135f58fb58dd17ae9651e8f39727",
|
"rev": "6eb2d33d1d0c95a37ef6443c88e6c1686012ee8b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -156,6 +215,26 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"honcho-console": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1790980944,
|
||||||
|
"narHash": "sha256-uvGecoGp+jTNCyVi3Zhxk3nNYPYfmbuQ9jE6BXU5d5E=",
|
||||||
|
"ref": "refs/heads/master",
|
||||||
|
"rev": "6aa45e5a7a238c1d84cf2014b3a1dec5c8969371",
|
||||||
|
"revCount": 12,
|
||||||
|
"type": "git",
|
||||||
|
"url": "ssh://gitea@git.mgaction.town:2222/darman/honcho-console.git"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "ssh://gitea@git.mgaction.town:2222/darman/honcho-console.git"
|
||||||
|
}
|
||||||
|
},
|
||||||
"hypr-chrome": {
|
"hypr-chrome": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
@@ -176,14 +255,35 @@
|
|||||||
"url": "https://git.mgaction.town/darman/hypr-chrome.git"
|
"url": "https://git.mgaction.town/darman/hypr-chrome.git"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"hyprchrome": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1794684228,
|
||||||
|
"narHash": "sha256-Tn9JdMOSHfnhdmnTc9brl1dQPB/qkYkjH8ka2J3E8FU=",
|
||||||
|
"ref": "refs/heads/master",
|
||||||
|
"rev": "61959090074cbc3bfb7bdf22d861ab82e2dce397",
|
||||||
|
"revCount": 2,
|
||||||
|
"submodules": true,
|
||||||
|
"type": "git",
|
||||||
|
"url": "ssh://gitea@git.mgaction.town:2222/darman/hyprchrome.git"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "ssh://gitea@git.mgaction.town:2222/darman/hyprchrome.git"
|
||||||
|
}
|
||||||
|
},
|
||||||
"livesync-bridge": {
|
"livesync-bridge": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1787571662,
|
"lastModified": 1793773829,
|
||||||
"narHash": "sha256-btLnQNbFzCPaSVcY9rtiPdYeXrZjoK9AYvfA9+ovsIc=",
|
"narHash": "sha256-YbenBjZd0WfPQ9Djtd7D460JmJzXiWeyBf2rYc4YE6A=",
|
||||||
"owner": "vrtmrz",
|
"owner": "vrtmrz",
|
||||||
"repo": "livesync-bridge",
|
"repo": "livesync-bridge",
|
||||||
"rev": "c3760beaa0851214da4860903445d7f6420ca025",
|
"rev": "1c252305bbddcacd200b8560d3bb786afe0906e9",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -232,13 +332,94 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"millennium": {
|
||||||
|
"inputs": {
|
||||||
|
"millennium-src": "millennium-src",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"nixpkgs-bun": "nixpkgs-bun"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"dir": "packages/nix",
|
||||||
|
"lastModified": 1794588209,
|
||||||
|
"narHash": "sha256-i0Y49re/VXOTBGSjsYdEoIrP9IaNejmCeUHFssGQ+NQ=",
|
||||||
|
"owner": "SteamClientHomebrew",
|
||||||
|
"repo": "Millennium",
|
||||||
|
"rev": "6522c24e8bd3de41a7601ceb4e78a619930f1704",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"dir": "packages/nix",
|
||||||
|
"owner": "SteamClientHomebrew",
|
||||||
|
"repo": "Millennium",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"millennium-src": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1794587997,
|
||||||
|
"narHash": "sha256-UZQSHMsAaYTcx1TDAI7FTqVRsMpB1jLBL8kYKivwbYo=",
|
||||||
|
"owner": "SteamClientHomebrew",
|
||||||
|
"repo": "Millennium",
|
||||||
|
"rev": "ac5e1ad646b1d1dd76a04aecf32d9e5e41779201",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "SteamClientHomebrew",
|
||||||
|
"repo": "Millennium",
|
||||||
|
"rev": "ac5e1ad646b1d1dd76a04aecf32d9e5e41779201",
|
||||||
|
"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/dev/repos/nexus-mods-app"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"ref": "feat/bg3-load-order",
|
||||||
|
"submodules": true,
|
||||||
|
"type": "git",
|
||||||
|
"url": "file:///mnt/hdd_01/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": 1794766393,
|
||||||
|
"narHash": "sha256-qtNL+kX2ru2k6kwmPhqG/mWjo83orqSi6wEXMxMmErI=",
|
||||||
|
"owner": "LovingMelody",
|
||||||
|
"repo": "nix-citizen",
|
||||||
|
"rev": "6b732ddacf308fa5820ca00133d4d72336bf3442",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "LovingMelody",
|
||||||
|
"repo": "nix-citizen",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nix-flatpak": {
|
"nix-flatpak": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1789496567,
|
"lastModified": 1791644268,
|
||||||
"narHash": "sha256-f9ze1ph2u0lk/Hm7/w/OvC0ESL1z0LbQ5UDgcOwQzLM=",
|
"narHash": "sha256-f7Z4PmfnRxf7+37NN48ep+KsQauGtL5REE99pJtMNp8=",
|
||||||
"owner": "gmodena",
|
"owner": "gmodena",
|
||||||
"repo": "nix-flatpak",
|
"repo": "nix-flatpak",
|
||||||
"rev": "07e8980c2fe421c93c0749f6246db34422827f67",
|
"rev": "02656785ab214fa1c9655f1beaaf0269eeeec2ca",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -247,6 +428,33 @@
|
|||||||
"type": "github"
|
"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": 1794375173,
|
||||||
|
"narHash": "sha256-x97M5XOV+IDcm7K9Bv6a7OUePyEVCjPeLpr3iD3BJD8=",
|
||||||
|
"owner": "fufexan",
|
||||||
|
"repo": "nix-gaming",
|
||||||
|
"rev": "3d460ece2fde6ba86a7f9deacc9a65e40f9ed19e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "fufexan",
|
||||||
|
"repo": "nix-gaming",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nix-vm-test": {
|
"nix-vm-test": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
@@ -255,11 +463,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1789357259,
|
"lastModified": 1789916284,
|
||||||
"narHash": "sha256-YF2EwlbEEmLgEH0fs7H5sgz9JwwMjoKM2rY5jnGNYwE=",
|
"narHash": "sha256-lv8kCCNM04qFsEMjDVrx6Z4q1afk46CBCQQq1wk5yNM=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "nix-vm-test",
|
"repo": "nix-vm-test",
|
||||||
"rev": "91825d66623ff030255d98082b5c8af2bbc549ec",
|
"rev": "f6688c8cc9185daccbeb89b2ff6e57dd66e5474a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -283,14 +491,14 @@
|
|||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"treefmt-nix": "treefmt-nix"
|
"treefmt-nix": "treefmt-nix_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1790148129,
|
"lastModified": 1793171667,
|
||||||
"narHash": "sha256-oOp+FNzqKzFfn9+AwcvzBedUyuUniv7eGxQ0jfzFpQ8=",
|
"narHash": "sha256-8h9MU32SjnFWIWRdtP9vYVNV5QrVbai8Oo1LW1rAmwc=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "nixos-anywhere",
|
"repo": "nixos-anywhere",
|
||||||
"rev": "da83557d8b0bce57a52371b888ffd6d58724e55c",
|
"rev": "58132e1d1f813b845382a2aeca4203b18d2ac807",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -307,11 +515,11 @@
|
|||||||
"nixos-unstable": "nixos-unstable"
|
"nixos-unstable": "nixos-unstable"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1789641344,
|
"lastModified": 1791456080,
|
||||||
"narHash": "sha256-vhB2KdEO1VlEfkiVoQAbMkKnTe1qxyJK3nbUsOOP4ok=",
|
"narHash": "sha256-VDnm81L/1YLrPklNacGCNwpPhHi5Tya1XbfdnCB/Zd0=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "nixos-images",
|
"repo": "nixos-images",
|
||||||
"rev": "16d7721cb350e7f1d0c49a757a3dcd11e80d91af",
|
"rev": "50939ddf1a0339f289a9dbd810bdfd4e4fba6df4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -339,11 +547,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1789546076,
|
"lastModified": 1794042290,
|
||||||
"narHash": "sha256-zVxLZiSnmaaPLwnhj7pwmqe3axBg/C6nG5JZsJMh2g4=",
|
"narHash": "sha256-ziZn2PvCJE5JEEpqTdxXwJpPB+L3YqoCpTAMCzyaP3U=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "b1b875982b17dabde9b4a37f3e229e74913e6db3",
|
"rev": "f4a03c008967841f2a0b3cb7c436fc6fc31671f6",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -353,13 +561,44 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nixpkgs-bun": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1790822859,
|
||||||
|
"narHash": "sha256-69xHQhAeMAD2wDXO7T2pcOZIF9Sga2W+JkmY2a11Ops=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "c59305bab2065cfecc4944690d9eedbb56f3a9fa",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "c59305bab2065cfecc4944690d9eedbb56f3a9fa",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs-lib": {
|
"nixpkgs-lib": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1788057806,
|
"lastModified": 1793504054,
|
||||||
"narHash": "sha256-DTQSMxzDWmT0zhguthvegnVkn7CFqGCv4IHCzk5ZUpM=",
|
"narHash": "sha256-ThkfL3D/FhCiZFc9+3BtxwuMmpuK+/bGtXCSo1+yVew=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "nixpkgs.lib",
|
"repo": "nixpkgs.lib",
|
||||||
"rev": "596e2e3940e09b2abbeb03f75fa1828c57fcd72c",
|
"rev": "7851ba61fd862b277cb6a9cef37394bc18bb94e4",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nixpkgs.lib",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-lib_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1793504054,
|
||||||
|
"narHash": "sha256-ThkfL3D/FhCiZFc9+3BtxwuMmpuK+/bGtXCSo1+yVew=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nixpkgs.lib",
|
||||||
|
"rev": "7851ba61fd862b277cb6a9cef37394bc18bb94e4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -370,11 +609,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs-unstable": {
|
"nixpkgs-unstable": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1790149054,
|
"lastModified": 1794644783,
|
||||||
"narHash": "sha256-FfjXg6mAzKQBCY+7V9keGWOXG4DV2Eym/qA987lFl8A=",
|
"narHash": "sha256-3GnIGIy15bMduoS9RnWqKTmsJLWThla42UFtm0S7+us=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "8825bebf6324e0579d012936eff73379af284b6d",
|
"rev": "5d2b81a7a3be3e2f832879028e4d60abbf58e9a0",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -386,11 +625,24 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1790113641,
|
"lastModified": 1794386569,
|
||||||
"narHash": "sha256-D2aaQetafdpHxbwA4ldAxs51UX0b11pXL+JL/5L8VrM=",
|
"narHash": "sha256-W60urNAgQVS8bhNWH0bQsYoiagds8m38oTDUjEOM9FE=",
|
||||||
|
"rev": "d4f25a3e562008648d45bcf2d70bcc7422cad84e",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1117658.d4f25a3e5620/nixexprs.tar.zst?lastModified=1794386569&rev=d4f25a3e562008648d45bcf2d70bcc7422cad84e"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://channels.nixos.org/nixos-unstable/nixexprs.tar.zst"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_3": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1794552581,
|
||||||
|
"narHash": "sha256-qXFIqA6FCcx7XeDzw0ZNlkDT9UiCzrNDwK8RuU8RcHM=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "1bc55b9def8165e82073919945c3239903fe4dc2",
|
"rev": "f1e5c356f35d07e7b71a6b5e6c9338e0b029e0c0",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -416,11 +668,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1786936886,
|
"lastModified": 1793820911,
|
||||||
"narHash": "sha256-8SFyOdmcG6Nsh/JzlH812lTI/v+ur06fpQhj/acNn8k=",
|
"narHash": "sha256-cc2EX2rfojnhcvqPQh4JEFGm2Mn/VoJyw5hTJTaw7Wo=",
|
||||||
"owner": "pyproject-nix",
|
"owner": "pyproject-nix",
|
||||||
"repo": "build-system-pkgs",
|
"repo": "build-system-pkgs",
|
||||||
"rev": "90ffdeee1a4929b231913df067448cd9803d3e07",
|
"rev": "947b2b0c973de462b19577715f04ba8d6f48ed7e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -466,11 +718,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1786031528,
|
"lastModified": 1793820880,
|
||||||
"narHash": "sha256-cROiHKO3UbIKqF5FG5NikvydzlfIj4EcR1Cty9qOVt4=",
|
"narHash": "sha256-NUMabnvaL/0Ah9WM9pBMXEp+dQjMSYjezZ/fNjXouLQ=",
|
||||||
"owner": "pyproject-nix",
|
"owner": "pyproject-nix",
|
||||||
"repo": "pyproject.nix",
|
"repo": "pyproject.nix",
|
||||||
"rev": "1b1485546d85f6f6c7aadb10c4923dbc09633263",
|
"rev": "d43f0e74444c1f266c640fc49ce6ce6fb69d33c3",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -505,15 +757,21 @@
|
|||||||
"authentik-nix": "authentik-nix",
|
"authentik-nix": "authentik-nix",
|
||||||
"disko": "disko",
|
"disko": "disko",
|
||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
|
"honcho-console": "honcho-console",
|
||||||
"hypr-chrome": "hypr-chrome",
|
"hypr-chrome": "hypr-chrome",
|
||||||
|
"hyprchrome": "hyprchrome",
|
||||||
"livesync-bridge": "livesync-bridge",
|
"livesync-bridge": "livesync-bridge",
|
||||||
"mediamanager-nix": "mediamanager-nix",
|
"mediamanager-nix": "mediamanager-nix",
|
||||||
|
"millennium": "millennium",
|
||||||
|
"nexusmods-app": "nexusmods-app",
|
||||||
|
"nix-citizen": "nix-citizen",
|
||||||
"nix-flatpak": "nix-flatpak",
|
"nix-flatpak": "nix-flatpak",
|
||||||
"nixos-anywhere": "nixos-anywhere",
|
"nixos-anywhere": "nixos-anywhere",
|
||||||
"nixos-images": "nixos-images",
|
"nixos-images": "nixos-images",
|
||||||
"nixpkgs": "nixpkgs_2",
|
"nixpkgs": "nixpkgs_3",
|
||||||
"nixpkgs-unstable": "nixpkgs-unstable",
|
"nixpkgs-unstable": "nixpkgs-unstable",
|
||||||
"sops-nix": "sops-nix",
|
"sops-nix": "sops-nix",
|
||||||
|
"tbctl": "tbctl",
|
||||||
"tome": "tome"
|
"tome": "tome"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -524,11 +782,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1789890976,
|
"lastModified": 1794624949,
|
||||||
"narHash": "sha256-GKwH3zpy7tartuJMG0Rv/xUsdetG1QLmTVv8UKgJLmA=",
|
"narHash": "sha256-3q/hxp/flW1PnV3Dx+H3p8kHGEHJ7251BqVMNsAAB9E=",
|
||||||
"owner": "Mic92",
|
"owner": "Mic92",
|
||||||
"repo": "sops-nix",
|
"repo": "sops-nix",
|
||||||
"rev": "7214124c20c1542c90deb54af50e2f53ae02711f",
|
"rev": "11e5885d241743ff0193465d533b20e754bc3ce0",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -539,27 +797,47 @@
|
|||||||
},
|
},
|
||||||
"systems": {
|
"systems": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1680978846,
|
"lastModified": 1689347949,
|
||||||
"narHash": "sha256-Gtqg8b/v49BFDpDetjclCYXm8mAnTrUzR0JnE2nv5aw=",
|
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
|
||||||
"owner": "nix-systems",
|
"owner": "nix-systems",
|
||||||
"repo": "x86_64-linux",
|
"repo": "default-linux",
|
||||||
"rev": "2ecfcac5e15790ba6ce360ceccddb15ad16d08a8",
|
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nix-systems",
|
"owner": "nix-systems",
|
||||||
"repo": "x86_64-linux",
|
"repo": "default-linux",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"tbctl": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1793410258,
|
||||||
|
"narHash": "sha256-MMfosPFbaOEEEZsfR3IdtbVrAft+HX+xvznK4ouzXH4=",
|
||||||
|
"ref": "refs/heads/main",
|
||||||
|
"rev": "4b02ee62d4f4ede5378d140c39154e6cb5aeef92",
|
||||||
|
"revCount": 46,
|
||||||
|
"type": "git",
|
||||||
|
"url": "file:///mnt/hdd_01/dev/repos/openbeach"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "file:///mnt/hdd_01/dev/repos/openbeach"
|
||||||
|
}
|
||||||
|
},
|
||||||
"tome": {
|
"tome": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1785431655,
|
"lastModified": 1793641410,
|
||||||
"narHash": "sha256-EoM4HmJb7MZArMoP4y1b7DZcvM8iANYjMiE5gGUx070=",
|
"narHash": "sha256-Rab2elFs1E8pJJ90y+omA5I+Vou8wf+70BGrH3HClDs=",
|
||||||
"ref": "refs/heads/master",
|
"ref": "refs/heads/master",
|
||||||
"rev": "4f3ca447cdc967371adaf71b26cf283952e54212",
|
"rev": "5274abdc96772669c736992a9dfcbb9497557edb",
|
||||||
"revCount": 51,
|
"revCount": 53,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "ssh://gitea@git.mgaction.town:2222/darman/TOME.git"
|
"url": "ssh://gitea@git.mgaction.town:2222/darman/TOME.git"
|
||||||
},
|
},
|
||||||
@@ -569,6 +847,27 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"treefmt-nix": {
|
"treefmt-nix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nix-citizen",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1791885023,
|
||||||
|
"narHash": "sha256-C3alQ2MEt0zVrUSho5NUDo3jmhbff72++bfwoqT9Omo=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"rev": "0d6d739a833ba9a9c93034862e4a7b061a062a1c",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"treefmt-nix_2": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixos-anywhere",
|
"nixos-anywhere",
|
||||||
@@ -576,11 +875,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1786901030,
|
"lastModified": 1791885023,
|
||||||
"narHash": "sha256-WSFCsDSE5ffgD2MqzkM2CYjeFiKhRF/dJUN8uedb6YE=",
|
"narHash": "sha256-C3alQ2MEt0zVrUSho5NUDo3jmhbff72++bfwoqT9Omo=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "treefmt-nix",
|
"repo": "treefmt-nix",
|
||||||
"rev": "27b3b12a8e6375f28ebe122f07d230ca5459bbfa",
|
"rev": "0d6d739a833ba9a9c93034862e4a7b061a062a1c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -601,11 +900,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1788001239,
|
"lastModified": 1793272761,
|
||||||
"narHash": "sha256-AELmsXPI546MhbC/ZXC7WRUkCz7d4rqKTHUmliIgPpI=",
|
"narHash": "sha256-3CE1CEwprYlHRlRVkXDkhqec0jjF9Cti7tdk8vVDsCM=",
|
||||||
"owner": "pyproject-nix",
|
"owner": "pyproject-nix",
|
||||||
"repo": "uv2nix",
|
"repo": "uv2nix",
|
||||||
"rev": "7f9c6b613d2e749e54854b1d60ab6a2192db889e",
|
"rev": "c361746c7d630d98b972378290547c8d35542a7a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -61,6 +61,43 @@
|
|||||||
url = "git+ssh://gitea@git.mgaction.town:2222/darman/TOME.git";
|
url = "git+ssh://gitea@git.mgaction.town:2222/darman/TOME.git";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
# Web console for luna's Honcho (hosts/mars/honcho-console.nix); own repo
|
||||||
|
# on our gitea, ships its package + NixOS module.
|
||||||
|
honcho-console = {
|
||||||
|
url = "git+ssh://gitea@git.mgaction.town:2222/darman/honcho-console.git";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
# tbctl (openbeach): KB7/KP7/Kone II Air CLI + desktop GUI on terra.
|
||||||
|
# Local checkout for now; upstream is git+ssh://git@github.com/darman96/openbeach.git?ref=main.
|
||||||
|
tbctl = {
|
||||||
|
url = "git+file:///mnt/hdd_01/dev/repos/openbeach";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
# hyprchrome: harness for the HyprChrome apps on our gitea. Carries
|
||||||
|
# hyprchrome-files (terra's default file manager), hyprchrome-claude
|
||||||
|
# (desktop app around the claude CLI) and hyprchrome-widgets as
|
||||||
|
# submodules, plus their shared libcosmic/winit patches, and builds the
|
||||||
|
# packages. Push the app and the harness there, then
|
||||||
|
# `nix flake update hyprchrome` here.
|
||||||
|
hyprchrome = {
|
||||||
|
url = "git+ssh://gitea@git.mgaction.town:2222/darman/hyprchrome.git";
|
||||||
|
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/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:
|
outputs = { self, nixpkgs, disko, nixos-anywhere, sops-nix, nixos-images, home-manager, mediamanager-nix, authentik-nix, ... }@inputs:
|
||||||
@@ -116,6 +153,20 @@
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# titan — ASUS Zenbook Pro Duo UX581 laptop; same Hyprland workstation
|
||||||
|
# as terra (profiles/workstation.nix). See hosts/titan/*.
|
||||||
|
titan = nixpkgs.lib.nixosSystem {
|
||||||
|
inherit system;
|
||||||
|
specialArgs = { inherit inputs; };
|
||||||
|
modules = [
|
||||||
|
disko.nixosModules.disko
|
||||||
|
sops-nix.nixosModules.sops
|
||||||
|
home-manager.nixosModules.home-manager
|
||||||
|
inputs.nix-flatpak.nixosModules.nix-flatpak
|
||||||
|
./hosts/titan/configuration.nix
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
# mars — on-site x86_64 box: Hermes Agent, plus the LAN web apps luna
|
# mars — on-site x86_64 box: Hermes Agent, plus the LAN web apps luna
|
||||||
# hosts herself (hosts/mars/luna-sites.nix). See hosts/mars/*.
|
# hosts herself (hosts/mars/luna-sites.nix). See hosts/mars/*.
|
||||||
mars = nixpkgs.lib.nixosSystem {
|
mars = nixpkgs.lib.nixosSystem {
|
||||||
@@ -514,11 +565,35 @@
|
|||||||
luna-sites = import ./hosts/mars/luna-sites-test.nix {
|
luna-sites = import ./hosts/mars/luna-sites-test.nix {
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# VM test for services/identity/pass-broker.nix, with fake pass-cli
|
||||||
|
# and Telegram: nix build .#checks.x86_64-linux.pass-broker -L
|
||||||
|
pass-broker = import ./services/identity/pass-broker-test.nix {
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Two-node test of the approval gateway (mars) with a broker using it:
|
||||||
|
# nix build .#checks.x86_64-linux.pass-broker-gateway -L
|
||||||
|
pass-broker-gateway = import ./services/identity/pass-broker-gateway-test.nix {
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
};
|
||||||
|
|
||||||
|
# terra's VPN-confined qBittorrent against a fake Proton peer:
|
||||||
|
# nix build .#checks.x86_64-linux.qbittorrent-vpn -L
|
||||||
|
qbittorrent-vpn = import ./services/desktop/qbittorrent-vpn-test.nix {
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Synapse + MAS on jupiter behind neptun's caddy vhosts:
|
||||||
|
# nix build .#checks.x86_64-linux.matrix -L
|
||||||
|
matrix = import ./services/comms/matrix-test.nix {
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# `nix develop` — hot-reload loop for dotfiles/quickshell.
|
# `nix develop` — hot-reload loop for dotfiles/quickshell.
|
||||||
#
|
#
|
||||||
# hosts/terra/home.nix ships the shell as a store copy (`xdg.configFile`),
|
# home/desktop/default.nix ships the shell as a store copy (`xdg.configFile`),
|
||||||
# which only hot-reloads its own frozen files; pointing at the working
|
# which only hot-reloads its own frozen files; pointing at the working
|
||||||
# tree with `qs -p` restores edit-save-see without a rebuild.
|
# tree with `qs -p` restores edit-save-see without a rebuild.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Shared home-manager profile for darman, applied on every host via
|
# Shared home-manager profile for darman, applied on every host via
|
||||||
# common.nix. Host-specific extras (terra's desktop/dev tooling) layer on
|
# common.nix. Workstation extras (terra, titan: home/desktop) layer on
|
||||||
# top via their own home-manager.users.darman.imports entry, same pattern
|
# top via their own home-manager.users.darman.imports entry, same pattern
|
||||||
# used here — see hosts/terra/configuration.nix + hosts/terra/home.nix.
|
# used here — see profiles/workstation.nix + home/desktop/default.nix.
|
||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
home.stateVersion = "26.05";
|
home.stateVersion = "26.05";
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{ pkgs, unstable, inputs, ... }:
|
{ pkgs, unstable, inputs, ... }:
|
||||||
let
|
let
|
||||||
tome = pkgs.callPackage ../../pkgs/tome.nix { src = inputs.tome; };
|
tome = pkgs.callPackage ../../pkgs/tome.nix { src = inputs.tome; };
|
||||||
|
claude-usage = pkgs.callPackage ../../pkgs/claude-usage.nix { };
|
||||||
|
|
||||||
# SUDO_ASKPASS helper: shows sudo's password prompt in quickshell
|
# SUDO_ASKPASS helper: shows sudo's password prompt in quickshell
|
||||||
# (HyprChrome/Widgets/Askpass) instead of the terminal. sudo doesn't speak
|
# (HyprChrome/Widgets/Askpass) instead of the terminal. sudo doesn't speak
|
||||||
@@ -44,10 +45,10 @@ let
|
|||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
# Desktop profile shared by terra and titan (profiles/workstation.nix).
|
||||||
# home.stateVersion, programs.home-manager.enable, programs.zsh.enable all
|
# home.stateVersion, programs.home-manager.enable, programs.zsh.enable all
|
||||||
# come from home/common.nix (shared across every host) via
|
# come from home/common.nix (every host).
|
||||||
# configuration.nix's home-manager.users.darman.imports.
|
imports = [ ./options.nix ./hyprland.nix ./theme.nix ];
|
||||||
imports = [ ./home/hyprland.nix ./home/theme.nix ];
|
|
||||||
|
|
||||||
home.keyboard.layout = "de";
|
home.keyboard.layout = "de";
|
||||||
|
|
||||||
@@ -56,10 +57,25 @@ in
|
|||||||
settings = {
|
settings = {
|
||||||
user.name = "Erik Simon";
|
user.name = "Erik Simon";
|
||||||
user.email = "mail@erik-s.dev";
|
user.email = "mail@erik-s.dev";
|
||||||
|
init.defaultBranch = "master";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# direnv + nix-direnv: lets per-repo devShells (e.g. ~/Data/Dev/repos/Tome's
|
# At home, ssh to gitea goes straight to jupiter instead of out to neptun and
|
||||||
|
# back over the tailnet; away, the probe fails and the public route applies.
|
||||||
|
# The alias matches the existing known_hosts entry (same gitea host key).
|
||||||
|
# LFS rides the same connection via LFS_ALLOW_PURE_SSH (services/dev/gitea.nix).
|
||||||
|
programs.ssh = {
|
||||||
|
enable = true;
|
||||||
|
enableDefaultConfig = false;
|
||||||
|
matchBlocks.gitea-lan = {
|
||||||
|
match = ''host git.mgaction.town exec "${pkgs.netcat}/bin/nc -z -w1 10.0.0.20 2222"'';
|
||||||
|
hostname = "10.0.0.20";
|
||||||
|
extraOptions.HostKeyAlias = "[git.mgaction.town]:2222";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# direnv + nix-direnv: lets per-repo devShells (e.g. /mnt/hdd_01/dev/repos/Tome's
|
||||||
# flake.nix) auto-load in the shell AND in Rider via its "direnv
|
# flake.nix) auto-load in the shell AND in Rider via its "direnv
|
||||||
# integration" plugin, instead of every dev repo needing its own
|
# integration" plugin, instead of every dev repo needing its own
|
||||||
# jetbrains-toolbox SDK wiring by hand.
|
# jetbrains-toolbox SDK wiring by hand.
|
||||||
@@ -68,6 +84,16 @@ in
|
|||||||
nix-direnv.enable = true;
|
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
|
# 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
|
# rather than the docker CLI shim, so point it at the user podman socket
|
||||||
# instead of the root one.
|
# instead of the root one.
|
||||||
@@ -91,15 +117,16 @@ in
|
|||||||
(pkgs.writeTextDir "share/mime/packages/application-x-ms-sln.xml"
|
(pkgs.writeTextDir "share/mime/packages/application-x-ms-sln.xml"
|
||||||
(builtins.readFile ../../dotfiles/mime/application-x-ms-sln.xml))
|
(builtins.readFile ../../dotfiles/mime/application-x-ms-sln.xml))
|
||||||
unstable.claude-code
|
unstable.claude-code
|
||||||
unstable.codex
|
|
||||||
pkgs.opencode
|
pkgs.opencode
|
||||||
pkgs.quickshell
|
pkgs.quickshell
|
||||||
qs-askpass
|
qs-askpass
|
||||||
|
claude-usage
|
||||||
pkgs.github-cli
|
pkgs.github-cli
|
||||||
pkgs.tea
|
pkgs.tea
|
||||||
pkgs.docker-compose
|
pkgs.docker-compose
|
||||||
pkgs.hyprcursor
|
pkgs.hyprcursor
|
||||||
pkgs.papirus-icon-theme
|
pkgs.papirus-icon-theme
|
||||||
|
tome
|
||||||
];
|
];
|
||||||
|
|
||||||
xdg.desktopEntries.btop = {
|
xdg.desktopEntries.btop = {
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
{ lib, pkgs, config, inputs, ... }:
|
{ lib, pkgs, config, osConfig, inputs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
lua = lib.generators.mkLuaInline;
|
lua = lib.generators.mkLuaInline;
|
||||||
|
cfg = config.homelab.desktop;
|
||||||
|
|
||||||
# Cursor theme+size live in home.pointerCursor (theme.nix) so the name is
|
# Cursor theme+size live in home.pointerCursor (theme.nix) so the name is
|
||||||
# in one place; hyprland.lua is what actually gets them into the graphical
|
# in one place; hyprland.lua is what actually gets them into the graphical
|
||||||
@@ -9,11 +10,6 @@ let
|
|||||||
cursorName = config.home.pointerCursor.name;
|
cursorName = config.home.pointerCursor.name;
|
||||||
cursorSize = toString config.home.pointerCursor.size;
|
cursorSize = toString config.home.pointerCursor.size;
|
||||||
|
|
||||||
# Wallpapers aren't checked into this repo (binaries) — pulled from the
|
|
||||||
# Wallhaven library on /mnt/hdd_01. Picked once here since hyprpaper has
|
|
||||||
# no built-in "random" mode.
|
|
||||||
wallpaper = "/mnt/hdd_01/data/Pictures/Wallhaven/wallhaven-mlwz78.png";
|
|
||||||
|
|
||||||
# Dispatchers → the new hl.dsp.* API (signatures verified against hyprland
|
# Dispatchers → the new hl.dsp.* API (signatures verified against hyprland
|
||||||
# 0.55's src/config/lua/bindings/LuaBindingsDispatchers.cpp).
|
# 0.55's src/config/lua/bindings/LuaBindingsDispatchers.cpp).
|
||||||
dsp = {
|
dsp = {
|
||||||
@@ -42,6 +38,10 @@ let
|
|||||||
bindo = keys: dispatcher: opts: { _args = [ keys dispatcher opts ]; };
|
bindo = keys: dispatcher: opts: { _args = [ keys dispatcher opts ]; };
|
||||||
|
|
||||||
# SUPER + 1..9 → workspaces 1..9, SUPER + 0 → workspace 10.
|
# 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 = [
|
wsKeys = [
|
||||||
{ k = "1"; n = 1; } { k = "2"; n = 2; } { k = "3"; n = 3; }
|
{ k = "1"; n = 1; } { k = "2"; n = 2; } { k = "3"; n = 3; }
|
||||||
{ k = "4"; n = 4; } { k = "5"; n = 5; } { k = "6"; n = 6; }
|
{ k = "4"; n = 4; } { k = "5"; n = 5; } { k = "6"; n = 6; }
|
||||||
@@ -50,16 +50,22 @@ let
|
|||||||
];
|
];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
services.hyprpaper = {
|
services.hyprpaper = lib.mkIf (cfg.wallpaper != null) {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
ipc = "on";
|
ipc = "on";
|
||||||
splash = false;
|
splash = false;
|
||||||
preload = [ wallpaper ];
|
preload = [ cfg.wallpaper ];
|
||||||
wallpaper = [
|
wallpaper = map (m: { monitor = m.output; path = cfg.wallpaper; }) cfg.monitors;
|
||||||
{ monitor = "DP-2"; path = wallpaper; }
|
};
|
||||||
{ monitor = "HDMI-A-1"; path = wallpaper; }
|
};
|
||||||
];
|
|
||||||
|
# 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";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -76,10 +82,7 @@ in
|
|||||||
bg_accent = { _var = "rgba(963c38ff)"; };
|
bg_accent = { _var = "rgba(963c38ff)"; };
|
||||||
|
|
||||||
# ---- monitors ----
|
# ---- monitors ----
|
||||||
monitor = [
|
monitor = cfg.monitors;
|
||||||
{ output = "DP-2"; mode = "2560x1440@144"; position = "1920x0"; scale = 1; }
|
|
||||||
{ output = "HDMI-A-1"; mode = "1920x1080@60"; position = "0x360"; scale = 1; }
|
|
||||||
];
|
|
||||||
|
|
||||||
# ---- variables (general/decoration/input/misc/...) ----
|
# ---- variables (general/decoration/input/misc/...) ----
|
||||||
config = {
|
config = {
|
||||||
@@ -128,6 +131,9 @@ in
|
|||||||
close_special_on_empty = true;
|
close_special_on_empty = true;
|
||||||
disable_hyprland_logo = true;
|
disable_hyprland_logo = true;
|
||||||
disable_splash_rendering = 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 = {
|
binds = {
|
||||||
@@ -169,6 +175,9 @@ in
|
|||||||
{ _args = [ "XDG_SESSION_DESKTOP" "Hyprland" ]; }
|
{ _args = [ "XDG_SESSION_DESKTOP" "Hyprland" ]; }
|
||||||
{ _args = [ "XDG_SESSION_TYPE" "wayland" ]; }
|
{ _args = [ "XDG_SESSION_TYPE" "wayland" ]; }
|
||||||
{ _args = [ "QT_QPA_PLATFORMTHEME" "qt6ct" ]; }
|
{ _args = [ "QT_QPA_PLATFORMTHEME" "qt6ct" ]; }
|
||||||
|
# Read by the quickshell bar/OSD/debug stage to pick their monitor.
|
||||||
|
{ _args = [ "QS_PRIMARY_OUTPUT" cfg.primaryOutput ]; }
|
||||||
|
{ _args = [ "QS_SECONDARY_OUTPUT" cfg.secondaryOutput ]; }
|
||||||
];
|
];
|
||||||
|
|
||||||
# ---- keybinds (keybinds.conf) ----
|
# ---- keybinds (keybinds.conf) ----
|
||||||
@@ -195,18 +204,21 @@ in
|
|||||||
# expand / collapse the hyprchrome bar as a whole
|
# expand / collapse the hyprchrome bar as a whole
|
||||||
(bind "SUPER + A" (dsp.global "quickshell:chrome"))
|
(bind "SUPER + A" (dsp.global "quickshell:chrome"))
|
||||||
|
|
||||||
# toggle luna's hands-free voice mode (services/desktop/luna-voice.nix).
|
]
|
||||||
|
# mute / unmute your mic for luna (services/desktop/luna-voice.nix);
|
||||||
|
# never cuts off a reply she is already giving.
|
||||||
# Runs the CLI rather than a quickshell GlobalShortcut so the mic can
|
# Runs the CLI rather than a quickshell GlobalShortcut so the mic can
|
||||||
# still be switched off while the shell is reloading.
|
# still be switched off while the shell is reloading.
|
||||||
|
++ lib.optional (osConfig.homelab.lunaVoice.enable or false)
|
||||||
(bind "SUPER + V" (dsp.exec "luna-voice toggle"))
|
(bind "SUPER + V" (dsp.exec "luna-voice toggle"))
|
||||||
|
++ [
|
||||||
(bind "SUPER + B" (dsp.exec "vivaldi"))
|
(bind "SUPER + B" (dsp.exec "vivaldi"))
|
||||||
(bind "SUPER + E" (dsp.exec "cosmic-files"))
|
(bind "SUPER + E" (dsp.exec cfg.fileManager))
|
||||||
(bind "SUPER + SHIFT + G" (dsp.workspaceRef "game"))
|
(bind "SUPER + SHIFT + G" (dsp.workspaceRef "game"))
|
||||||
(bind "SUPER + S" (dsp.exec "grim -o DP-2 ~/screenshot.png"))
|
(bind "SUPER + S" (dsp.exec "grim -o ${cfg.primaryOutput} ~/screenshot.png"))
|
||||||
(bind "SUPER + SHIFT + S" (dsp.exec "grimblast copy area --freeze"))
|
(bind "SUPER + SHIFT + S" (dsp.exec "grimblast copy area --freeze"))
|
||||||
(bind "Print" (dsp.exec "rishot"))
|
(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"))
|
(bind "SUPER + W" (dsp.exec "waypaper --random"))
|
||||||
|
|
||||||
# window management
|
# window management
|
||||||
@@ -267,10 +279,12 @@ in
|
|||||||
# ---- window rules (windowrules.conf) ----
|
# ---- window rules (windowrules.conf) ----
|
||||||
window_rule = [
|
window_rule = [
|
||||||
{ name = "games"; match.class = "gamescope"; workspace = "name:game"; opacity = "1 1 override"; }
|
{ 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 = "vivaldi"; match.title = "(.*)(- YouTube - Vivaldi)"; opacity = "1 1 override"; }
|
||||||
{ name = "jetbrains"; match.class = "(jetbrains-)(.*)"; no_initial_focus = true; float = true; center = true; }
|
{ name = "jetbrains"; match.class = "(jetbrains-)(.*)"; no_initial_focus = true; float = true; center = true; }
|
||||||
{ name = "jetbrains-toolbox"; match.class = "jetbrains-toolbox"; move = "1933 21"; }
|
{ 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 = "music"; match.class = "qbz"; workspace = "special:music"; }
|
||||||
{ name = "vicinae"; match.class = "vicinae"; stay_focused = true; }
|
{ name = "vicinae"; match.class = "vicinae"; stay_focused = true; }
|
||||||
{ name = "gitkraken"; match.class = "gitkraken"; workspace = "special:version_control"; }
|
{ name = "gitkraken"; match.class = "gitkraken"; workspace = "special:version_control"; }
|
||||||
@@ -278,7 +292,7 @@ in
|
|||||||
|
|
||||||
# ---- workspace rules (workspacerules.conf) ----
|
# ---- workspace rules (workspacerules.conf) ----
|
||||||
workspace_rule = [
|
workspace_rule = [
|
||||||
{ workspace = "name:game"; monitor = "DP-2"; decorate = false; }
|
{ workspace = "name:game"; monitor = cfg.primaryOutput; decorate = false; }
|
||||||
{ workspace = "special:terminal"; on_created_empty = "alacritty"; gaps_out = 256; }
|
{ workspace = "special:terminal"; on_created_empty = "alacritty"; gaps_out = 256; }
|
||||||
{ workspace = "special:communications"; on_created_empty = "${config.home.homeDirectory}/.config/scripts/start-communications.sh"; gaps_out = 128; }
|
{ workspace = "special:communications"; on_created_empty = "${config.home.homeDirectory}/.config/scripts/start-communications.sh"; gaps_out = 128; }
|
||||||
{ workspace = "special:music"; on_created_empty = "com.blitzfc.qbz"; gaps_out = 128; }
|
{ workspace = "special:music"; on_created_empty = "com.blitzfc.qbz"; gaps_out = 128; }
|
||||||
@@ -303,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 ];
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
# Per-host knobs for the shared desktop; set via
|
||||||
|
# home-manager.users.darman.homelab.desktop in hosts/<h>/configuration.nix.
|
||||||
|
{
|
||||||
|
options.homelab.desktop = {
|
||||||
|
monitors = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.attrs;
|
||||||
|
description = "hl.monitor() tables; the greeter reuses them.";
|
||||||
|
};
|
||||||
|
primaryOutput = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
description = "Connector that gets the bar, OSDs, the game workspace and the greeter.";
|
||||||
|
};
|
||||||
|
secondaryOutput = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "";
|
||||||
|
description = "Connector for the debug widget stage; empty = last screen.";
|
||||||
|
};
|
||||||
|
fileManager = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "cosmic-files";
|
||||||
|
description = "Command SUPER+E runs.";
|
||||||
|
};
|
||||||
|
wallpaper = lib.mkOption {
|
||||||
|
type = lib.types.nullOr lib.types.str;
|
||||||
|
default = null;
|
||||||
|
description = "Image path for hyprpaper; null leaves hyprpaper off.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -2,13 +2,19 @@
|
|||||||
|
|
||||||
# Global Dracula theming (GTK + Qt)
|
# Global Dracula theming (GTK + Qt)
|
||||||
let
|
let
|
||||||
azureGlassyDarkIcons = pkgs.callPackage ../../../pkgs/azure-glassy-dark-icons.nix { };
|
azureGlassyDarkIcons = pkgs.callPackage ../../pkgs/azure-glassy-dark-icons.nix { };
|
||||||
amyDarkIcons = pkgs.callPackage ../../../pkgs/amy-dark-icons.nix { };
|
amyDarkIcons = pkgs.callPackage ../../pkgs/amy-dark-icons.nix { };
|
||||||
slotBeautyDarkIcons = pkgs.callPackage ../../../pkgs/slot-beauty-dark-icons.nix { };
|
slotBeautyDarkIcons = pkgs.callPackage ../../pkgs/slot-beauty-dark-icons.nix { };
|
||||||
|
hyprchromeCursors = pkgs.callPackage ../../pkgs/hyprchrome-cursors.nix { };
|
||||||
|
|
||||||
iconTheme = "Amy-Dark-Icons";
|
# HyprChrome folders on top, Amy for everything else (Inherits=).
|
||||||
iconThemePackage = amyDarkIcons;
|
# "HyprChrome-Folders-Solid" is the same set in the solid finish.
|
||||||
iconThemeFolder = "${iconThemePackage}/share/icons/${iconTheme}";
|
baseIconTheme = "Amy-Dark-Icons";
|
||||||
|
baseIconThemePackage = amyDarkIcons;
|
||||||
|
iconTheme = "HyprChrome-Folders";
|
||||||
|
iconThemePackage = pkgs.callPackage ../../pkgs/hyprchrome-folders.nix {
|
||||||
|
baseTheme = baseIconTheme;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
gtk = {
|
gtk = {
|
||||||
@@ -29,9 +35,9 @@ in
|
|||||||
# bind-mounted in though, so the ~/.icons symlink `dotIcons` drops still
|
# bind-mounted in though, so the ~/.icons symlink `dotIcons` drops still
|
||||||
# resolves — same fix as the flatpak workaround below.
|
# resolves — same fix as the flatpak workaround below.
|
||||||
home.pointerCursor = {
|
home.pointerCursor = {
|
||||||
name = "Bibata-Modern-Classic";
|
name = "HyprChrome";
|
||||||
package = pkgs.bibata-cursors;
|
package = hyprchromeCursors;
|
||||||
size = 24;
|
size = 36;
|
||||||
gtk.enable = true;
|
gtk.enable = true;
|
||||||
hyprcursor.enable = true;
|
hyprcursor.enable = true;
|
||||||
};
|
};
|
||||||
@@ -41,7 +47,11 @@ in
|
|||||||
# Flatpak auto-exposes ~/.themes and ~/.icons read-only as the workaround.
|
# Flatpak auto-exposes ~/.themes and ~/.icons read-only as the workaround.
|
||||||
home.file.".themes/Dracula".source =
|
home.file.".themes/Dracula".source =
|
||||||
"${pkgs.dracula-theme}/share/themes/Dracula";
|
"${pkgs.dracula-theme}/share/themes/Dracula";
|
||||||
home.file.".icons/${iconTheme}".source = iconThemeFolder;
|
home.file.".icons/${iconTheme}".source =
|
||||||
|
"${iconThemePackage}/share/icons/${iconTheme}";
|
||||||
|
home.file.".icons/${baseIconTheme}".source =
|
||||||
|
"${baseIconThemePackage}/share/icons/${baseIconTheme}";
|
||||||
|
home.packages = [ baseIconThemePackage ];
|
||||||
|
|
||||||
dconf.settings."org/gnome/desktop/interface" = {
|
dconf.settings."org/gnome/desktop/interface" = {
|
||||||
color-scheme = "prefer-dark";
|
color-scheme = "prefer-dark";
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
../../services/dev/gitea.nix
|
../../services/dev/gitea.nix
|
||||||
../../services/dev/gitea-mcp.nix
|
../../services/dev/gitea-mcp.nix
|
||||||
../../services/dev/obsidian-livesync.nix
|
../../services/dev/obsidian-livesync.nix
|
||||||
|
../../services/comms/matrix.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
# sabnzbd's unrar dependency is unfree; scope the allowance to just that
|
# sabnzbd's unrar dependency is unfree; scope the allowance to just that
|
||||||
@@ -65,13 +66,30 @@
|
|||||||
# next value: acpi -> bios -> cold -> efi.
|
# next value: acpi -> bios -> cold -> efi.
|
||||||
boot.kernelParams = [ "reboot=pci" ];
|
boot.kernelParams = [ "reboot=pci" ];
|
||||||
|
|
||||||
|
# ---- Closure size (29G eMMC holds two generations during a switch) ----
|
||||||
|
# Only the firmware this board loads (i915 DMC + r8169), not all ~850M of linux-firmware.
|
||||||
|
hardware.enableRedistributableFirmware = false;
|
||||||
|
hardware.cpu.intel.updateMicrocode = true;
|
||||||
|
hardware.firmware = [
|
||||||
|
(pkgs.runCommand "jupiter-firmware" { } ''
|
||||||
|
mkdir -p $out/lib/firmware/i915
|
||||||
|
cp -r ${pkgs.linux-firmware}/lib/firmware/rtl_nic $out/lib/firmware/
|
||||||
|
cp ${pkgs.linux-firmware}/lib/firmware/i915/bxt_* $out/lib/firmware/i915/
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
# Pins a ~200M nixpkgs source; the box is only ever deployed to, never built on.
|
||||||
|
nixpkgs.flake.setFlakeRegistry = false;
|
||||||
|
nixpkgs.flake.setNixPath = false;
|
||||||
|
nix.settings.auto-optimise-store = true;
|
||||||
|
|
||||||
# ---- GPU (jellyfin hardware transcoding) ----
|
# ---- GPU (jellyfin hardware transcoding) ----
|
||||||
# Apollo Lake N3450 / HD Graphics 500 (Gen9). i915 binds on its own, but VAAPI needs
|
# Apollo Lake N3450 / HD Graphics 500 (Gen9). VAAPI needs the iHD userspace driver
|
||||||
# the iHD userspace driver (Gen9; i965 is Gen8-only) or jellyfin-ffmpeg exits 251 on
|
# (Gen9; i965 is Gen8-only) or jellyfin-ffmpeg exits 251 on every transcode with no
|
||||||
# every transcode with no clearer error than "FFmpeg exited with code 251" in the log.
|
# clearer error than "FFmpeg exited with code 251" in the log. Pointed at directly
|
||||||
hardware.graphics = {
|
# instead of via hardware.graphics, which drags in mesa + llvm (~850M) for nothing.
|
||||||
enable = true;
|
systemd.services.jellyfin.environment = {
|
||||||
extraPackages = [ pkgs.intel-media-driver ];
|
LIBVA_DRIVER_NAME = "iHD";
|
||||||
|
LIBVA_DRIVERS_PATH = "${pkgs.intel-media-driver}/lib/dri";
|
||||||
};
|
};
|
||||||
# ⚠️ Use VAAPI, not QSV, in jellyfin's UI — QSV needs an MFX runtime not safely
|
# ⚠️ Use VAAPI, not QSV, in jellyfin's UI — QSV needs an MFX runtime not safely
|
||||||
# available for this Gen9 chip (only insecure/EOL options) and fails with exit 171.
|
# available for this Gen9 chip (only insecure/EOL options) and fails with exit 171.
|
||||||
@@ -92,14 +110,14 @@
|
|||||||
options = [ "nofail" ]; # don't block boot if the array is degraded/absent
|
options = [ "nofail" ]; # don't block boot if the array is degraded/absent
|
||||||
};
|
};
|
||||||
|
|
||||||
# `nofail` alone isn't enough — mounts layered on the array (prowlarr/seerr binds)
|
# `nofail` alone isn't enough — mounts layered on the array (the prowlarr bind)
|
||||||
# are RequiredBy local-fs.target and can still trip Emergency Mode, which is a dead
|
# are RequiredBy local-fs.target and can still trip Emergency Mode, which is a dead
|
||||||
# end here (root locked, no ssh). Boot as far as possible instead; the array-backed
|
# end here (root locked, no ssh). Boot as far as possible instead; the array-backed
|
||||||
# services carry RequiresMountsFor=/mnt/data so they still won't write to the eMMC.
|
# services carry RequiresMountsFor=/mnt/data so they still won't write to the eMMC.
|
||||||
systemd.enableEmergencyMode = false;
|
systemd.enableEmergencyMode = false;
|
||||||
|
|
||||||
# ---- Heavy state moved off the eMMC ----
|
# ---- Heavy state moved off the eMMC ----
|
||||||
# A deploy holds two full closures (~9G each) on this 29G disk at once, so state
|
# A deploy holds two full closures (~4G each) on this 29G disk at once, so state
|
||||||
# that grows on its own can't live there — moved under /mnt/data/AppData like every
|
# that grows on its own can't live there — moved under /mnt/data/AppData like every
|
||||||
# other service's state. Settings below are jupiter-only; services/containers.nix
|
# other service's state. Settings below are jupiter-only; services/containers.nix
|
||||||
# stays engine/host-agnostic (mercury runs podman with no array).
|
# stays engine/host-agnostic (mercury runs podman with no array).
|
||||||
@@ -133,7 +151,7 @@
|
|||||||
|
|
||||||
# Without this, podman would recreate an empty store on the eMMC if the array mounts
|
# Without this, podman would recreate an empty store on the eMMC if the array mounts
|
||||||
# late or is absent, and the runner would re-pull every image.
|
# late or is absent, and the runner would re-pull every image.
|
||||||
# (podman-clonarr already sets this in services/media/clonarr.nix.)
|
# (the media containers set this in their own modules.)
|
||||||
systemd.services.podman.unitConfig.RequiresMountsFor = [ "/mnt/data" ];
|
systemd.services.podman.unitConfig.RequiresMountsFor = [ "/mnt/data" ];
|
||||||
systemd.services.gitea-runner-jupiter.unitConfig.RequiresMountsFor = [ "/mnt/data" ];
|
systemd.services.gitea-runner-jupiter.unitConfig.RequiresMountsFor = [ "/mnt/data" ];
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
sops.secrets.tailscale_authkey = { };
|
sops.secrets.tailscale_authkey = { };
|
||||||
|
|
||||||
# Immich's OIDC client secret (separate Authentik app from headscale/headplane, see
|
# Immich's OIDC client secret (separate Authentik app from headscale/headplane, see
|
||||||
# hosts/neptun/secrets.nix). Resolved via systemd LoadCredential as root before
|
# hosts/neptun/secrets.nix). Only rendered into the immich-owned
|
||||||
# privilege drop, so sops's default root:root 0400 is correct — do NOT set `owner`.
|
# `immich-config.json` template (services/media/immich.nix), so it stays root:root.
|
||||||
sops.secrets.immich_oauth_client_secret = { };
|
sops.secrets.immich_oauth_client_secret = { };
|
||||||
|
|
||||||
# Gitea Actions runner registration token — gitea generates this itself once Actions
|
# Gitea Actions runner registration token — gitea generates this itself once Actions
|
||||||
@@ -55,6 +55,28 @@
|
|||||||
sops.secrets.sabnzbd_eweka_username.owner = "sabnzbd";
|
sops.secrets.sabnzbd_eweka_username.owner = "sabnzbd";
|
||||||
sops.secrets.sabnzbd_eweka_password.owner = "sabnzbd";
|
sops.secrets.sabnzbd_eweka_password.owner = "sabnzbd";
|
||||||
|
|
||||||
|
# Matrix (services/comms/matrix.nix). The synapse signing key lives here rather than
|
||||||
|
# being generated on first start, so losing the RAID0 array doesn't lose the
|
||||||
|
# server's federation identity. mas_shared_secret is read by synapse and MAS
|
||||||
|
# (MAS is in group matrix-synapse). matrix_oidc_client_secret is the Authentik
|
||||||
|
# `matrix` provider's.
|
||||||
|
sops.secrets.synapse_signing_key.owner = "matrix-synapse";
|
||||||
|
sops.secrets.synapse_macaroon_secret_key.owner = "matrix-synapse";
|
||||||
|
sops.secrets.synapse_form_secret.owner = "matrix-synapse";
|
||||||
|
sops.secrets.mas_shared_secret = { owner = "matrix-synapse"; group = "matrix-synapse"; mode = "0440"; };
|
||||||
|
sops.secrets.mas_encryption_secret.owner = "matrix-authentication-service";
|
||||||
|
sops.secrets.mas_signing_key.owner = "matrix-authentication-service";
|
||||||
|
sops.secrets.matrix_oidc_client_secret.owner = "matrix-authentication-service";
|
||||||
|
homelab.matrix = {
|
||||||
|
signingKeyFile = config.sops.secrets.synapse_signing_key.path;
|
||||||
|
macaroonSecretFile = config.sops.secrets.synapse_macaroon_secret_key.path;
|
||||||
|
formSecretFile = config.sops.secrets.synapse_form_secret.path;
|
||||||
|
masSecretFile = config.sops.secrets.mas_shared_secret.path;
|
||||||
|
masEncryptionFile = config.sops.secrets.mas_encryption_secret.path;
|
||||||
|
masSigningKeyFile = config.sops.secrets.mas_signing_key.path;
|
||||||
|
oidcClientSecretFile = config.sops.secrets.matrix_oidc_client_secret.path;
|
||||||
|
};
|
||||||
|
|
||||||
# CouchDB admin account for Obsidian LiveSync — rendered into an [admins] ini
|
# CouchDB admin account for Obsidian LiveSync — rendered into an [admins] ini
|
||||||
# fragment instead of services.couchdb.adminPass, which would put the plaintext in
|
# fragment instead of services.couchdb.adminPass, which would put the plaintext in
|
||||||
# the world-readable store.
|
# the world-readable store.
|
||||||
|
|||||||
@@ -9,8 +9,12 @@
|
|||||||
./disk-config.nix # disko: OS-disk partitions + filesystems
|
./disk-config.nix # disko: OS-disk partitions + filesystems
|
||||||
./secrets.nix # sops-nix: samba/tailscale/hermes secrets
|
./secrets.nix # sops-nix: samba/tailscale/hermes secrets
|
||||||
./hermes-agent.nix
|
./hermes-agent.nix
|
||||||
|
./honcho.nix # luna's memory server (Postgres + Ollama embeddings)
|
||||||
|
./honcho-console.nix # web console for it, tailnet-only on :8095
|
||||||
|
./honcho-gate.nix # bearer-gated tailnet door to it for Claude Code, :8099
|
||||||
./livesync-bridge.nix
|
./livesync-bridge.nix
|
||||||
./luna-sites.nix # luna's LAN web apps: http://mars.sol/<name>/
|
./luna-sites.nix # luna's LAN web apps: http://mars.sol/<name>/
|
||||||
|
./pass-broker-gateway.nix # Telegram approvals for every host's pass-broker, tailnet :8097
|
||||||
../../common.nix # shared base: user / ssh / nix / firewall
|
../../common.nix # shared base: user / ssh / nix / firewall
|
||||||
../../services/containers.nix
|
../../services/containers.nix
|
||||||
../../services/vpn/tailscale.nix
|
../../services/vpn/tailscale.nix
|
||||||
|
|||||||
@@ -38,9 +38,10 @@ let
|
|||||||
# it's inside Hermes's own write-safe root (HERMES_WRITE_SAFE_ROOT).
|
# it's inside Hermes's own write-safe root (HERMES_WRITE_SAFE_ROOT).
|
||||||
dropboxDir = "/mnt/jupiter/AppData/hermes-dropbox";
|
dropboxDir = "/mnt/jupiter/AppData/hermes-dropbox";
|
||||||
|
|
||||||
# v2026.9.14, pinned by index digest rather than floating
|
# v0.23.1, pinned by index digest rather than floating
|
||||||
# :latest, so bumping Hermes is an explicit edit here, not silent drift.
|
# :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:276d44685c65c0cb2a25f190b63c65c8906f9dc76486fb1c05ae71b5826bda08";
|
||||||
|
|
||||||
# Kept identical to jupiter's instance purely so nothing else needs to
|
# Kept identical to jupiter's instance purely so nothing else needs to
|
||||||
# change if state ever gets migrated over.
|
# change if state ever gets migrated over.
|
||||||
@@ -78,9 +79,6 @@ let
|
|||||||
builtins.readFile ./gitea-pr-review-prompt.md
|
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).
|
# KittenTTS voice provider inputs (CPU-only; model + wheel hash-pinned).
|
||||||
# Provisioning unit near the bottom of this file; background on why the
|
# Provisioning unit near the bottom of this file; background on why the
|
||||||
# deps deviate from upstream's declaration lives in
|
# deps deviate from upstream's declaration lives in
|
||||||
@@ -97,12 +95,26 @@ let
|
|||||||
kittenttsReqs = pkgs.writeText "kittentts-requirements.txt" (
|
kittenttsReqs = pkgs.writeText "kittentts-requirements.txt" (
|
||||||
builtins.readFile ./kittentts/requirements.txt
|
builtins.readFile ./kittentts/requirements.txt
|
||||||
);
|
);
|
||||||
# STT add-on: faster-whisper (CPU) for Telegram voice-note transcription,
|
# STT: faster-whisper (CPU) for voice-note transcription, in its own venv:
|
||||||
# same side-venv, appended by the provisioning unit. Keeps one venv + one
|
# Hermes imports it in-process, so it must be built for the IMAGE's Python
|
||||||
# stamp for the whole local-audio stack. See kittentts/stt-requirements.txt.
|
# (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" (
|
kittenttsSttReqs = pkgs.writeText "kittentts-stt-requirements.txt" (
|
||||||
builtins.readFile ./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" (
|
kittenttsStub = pkgs.writeText "kitten-tts-stub.py" (
|
||||||
builtins.readFile ./kittentts/kitten-misaki-stub.py
|
builtins.readFile ./kittentts/kitten-misaki-stub.py
|
||||||
);
|
);
|
||||||
@@ -145,10 +157,12 @@ in
|
|||||||
users.groups.hermes.gid = 983;
|
users.groups.hermes.gid = 983;
|
||||||
users.users.darman.extraGroups = [ "hermes" ];
|
users.users.darman.extraGroups = [ "hermes" ];
|
||||||
|
|
||||||
# `hermes <args>` == `sudo podman exec -it hermes-agent hermes <args>`. sudo
|
# `hermes <args>` runs the CLI in the container. sudo is needed because
|
||||||
# is needed because oci-containers runs rootful podman, a separate
|
# oci-containers runs rootful podman, a separate namespace from darman's own
|
||||||
# namespace from darman's own rootless one.
|
# rootless one. `-u hermes`: run as root, `hermes pm`/`plugins` leave
|
||||||
programs.zsh.shellAliases.hermes = "sudo podman exec -it hermes-agent hermes";
|
# 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 = [
|
systemd.tmpfiles.rules = [
|
||||||
"d ${stateDir} 0750 root hermes -"
|
"d ${stateDir} 0750 root hermes -"
|
||||||
@@ -259,8 +273,10 @@ in
|
|||||||
# tts.provider is seeded, not pinned: `=` would stomp luna's own choice on
|
# 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
|
# every restart, and the engine is hers to change (KittenTTS stays as the
|
||||||
# offline fallback). `//` only fills it in when unset.
|
# offline fallback). `//` only fills it in when unset.
|
||||||
|
# memory.provider IS pinned: switching back is a repo change (honcho.nix).
|
||||||
yq '.dashboard.trusted_proxies = ["${neptunTailnetIp}"]
|
yq '.dashboard.trusted_proxies = ["${neptunTailnetIp}"]
|
||||||
| .tts.provider = (.tts.provider // "elevenlabs")' "$conf" > "$conf.new"
|
| .tts.provider = (.tts.provider // "elevenlabs")
|
||||||
|
| .memory.provider = "honcho"' "$conf" > "$conf.new"
|
||||||
chown ${hermesUid}:${hermesGid} "$conf.new"
|
chown ${hermesUid}:${hermesGid} "$conf.new"
|
||||||
chmod --reference="$conf" "$conf.new"
|
chmod --reference="$conf" "$conf.new"
|
||||||
mv -f "$conf.new" "$conf"
|
mv -f "$conf.new" "$conf"
|
||||||
@@ -278,22 +294,73 @@ in
|
|||||||
# DID pass through) but answered every bearer token with
|
# DID pass through) but answered every bearer token with
|
||||||
# "Invalid gateway API key" — the passthrough list carries the plain
|
# "Invalid gateway API key" — the passthrough list carries the plain
|
||||||
# API_SERVER_* vars and drops the secret one.
|
# API_SERVER_* vars and drops the secret one.
|
||||||
|
#
|
||||||
|
# Each named profile has its own .env, cloned from the root one at
|
||||||
|
# creation, so a rotation must reach those too (coder and librarian kept
|
||||||
|
# the old OpenCode key). Profiles only get keys they already carry, unless
|
||||||
|
# the second argument is "all": librarian had no OPENCODE line and was
|
||||||
|
# left on an exhausted pool entry for the lapsed key.
|
||||||
write_env_key() {
|
write_env_key() {
|
||||||
setpriv --reuid=${hermesUid} --regid=${hermesGid} --clear-groups \
|
setpriv --reuid=${hermesUid} --regid=${hermesGid} --clear-groups \
|
||||||
${pkgs.runtimeShell} -c '
|
${pkgs.runtimeShell} -c '
|
||||||
set -eu
|
set -eu
|
||||||
envf=$1
|
home=$1
|
||||||
name=$2
|
name=$2
|
||||||
|
scope=$3
|
||||||
umask 077
|
umask 077
|
||||||
key=$(cat)
|
key=$(cat)
|
||||||
[ -e "$envf" ] || : > "$envf"
|
[ -e "$home/.env" ] || : > "$home/.env"
|
||||||
|
for envf in "$home/.env" "$home"/profiles/*/.env; do
|
||||||
|
[ -f "$envf" ] || continue
|
||||||
|
if [ "$envf" != "$home/.env" ] && [ "$scope" != all ] \
|
||||||
|
&& ! grep -q "^$name=" "$envf"; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
{ grep -v "^$name=" "$envf" || true
|
{ grep -v "^$name=" "$envf" || true
|
||||||
printf "%s=%s\n" "$name" "$key"; } > "$envf.new"
|
printf "%s=%s\n" "$name" "$key"; } > "$envf.new"
|
||||||
mv -f "$envf.new" "$envf"
|
mv -f "$envf.new" "$envf"
|
||||||
' _ ${hermesHome}/.env "$1"
|
done
|
||||||
|
' _ ${hermesHome} "$1" "''${2:-}"
|
||||||
}
|
}
|
||||||
|
# OPENCODE_GO_API_KEY does pass through, but a stale .env line from
|
||||||
|
# `hermes setup` overrides it — that is how a rotated key kept 401ing.
|
||||||
|
write_env_key OPENCODE_GO_API_KEY all < ${config.sops.secrets.opencode_go_api_key.path}
|
||||||
write_env_key ELEVENLABS_API_KEY < ${config.sops.secrets.elevenlabs_api_key.path}
|
write_env_key ELEVENLABS_API_KEY < ${config.sops.secrets.elevenlabs_api_key.path}
|
||||||
|
|
||||||
|
# Only these keys are asserted; anything Hermes adds to honcho.json stays.
|
||||||
|
# No apiKey: the plugin uses a placeholder for a loopback base URL.
|
||||||
|
# observationMode must be explicit: a host block without it counts as a
|
||||||
|
# legacy config and gets "unified", which never derives luna's own messages.
|
||||||
|
setpriv --reuid=${hermesUid} --regid=${hermesGid} --clear-groups \
|
||||||
|
${pkgs.runtimeShell} -c '
|
||||||
|
set -eu
|
||||||
|
f=$1
|
||||||
|
[ -s "$f" ] || echo "{}" > "$f"
|
||||||
|
${pkgs.jq}/bin/jq ".baseUrl = \"http://127.0.0.1:8000\"
|
||||||
|
| .hosts.hermes = ((.hosts.hermes // {}) + {
|
||||||
|
enabled: true, workspace: \"luna\", aiPeer: \"luna\",
|
||||||
|
peerName: \"darman\", pinUserPeer: true,
|
||||||
|
observationMode: \"directional\" })" "$f" > "$f.new"
|
||||||
|
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 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
|
||||||
|
# changes belong on her Honcho identity card; the full persona that seeds
|
||||||
|
# it is luna-soul-full.md.
|
||||||
|
setpriv --reuid=${hermesUid} --regid=${hermesGid} --clear-groups \
|
||||||
|
${pkgs.runtimeShell} -c '
|
||||||
|
set -eu
|
||||||
|
umask 022
|
||||||
|
cat > "$1.new"
|
||||||
|
mv -f "$1.new" "$1"
|
||||||
|
' _ ${hermesHome}/SOUL.md < ${./luna-soul.md}
|
||||||
|
|
||||||
if [ -d ${hermesHome}/.config ]; then
|
if [ -d ${hermesHome}/.config ]; then
|
||||||
chown ${hermesUid}:${hermesGid} ${hermesHome}/.config
|
chown ${hermesUid}:${hermesGid} ${hermesHome}/.config
|
||||||
@@ -362,12 +429,22 @@ in
|
|||||||
HF_HOME = "/opt/data/kittentts-hf";
|
HF_HOME = "/opt/data/kittentts-hf";
|
||||||
HF_HUB_OFFLINE = "1";
|
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
|
# own interpreter so faster-whisper imports in-process. PYTHONPATH dirs
|
||||||
# don't run .pth auto-imports, but faster-whisper has no dead imports —
|
# don't run .pth auto-imports, but faster-whisper has no dead imports —
|
||||||
# it imports cleanly from a plain path injection (unlike kittentts,
|
# it imports cleanly from a plain path injection (unlike kittentts,
|
||||||
# which is driven through the command wrapper for exactly that reason).
|
# 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 ];
|
environmentFiles = [ config.sops.templates."hermes-agent.env".path ];
|
||||||
cmd = [ "gateway" "run" ];
|
cmd = [ "gateway" "run" ];
|
||||||
@@ -383,7 +460,11 @@ in
|
|||||||
# prepare-dirs is an inactive oneshot, and switch-to-configuration only
|
# prepare-dirs is an inactive oneshot, and switch-to-configuration only
|
||||||
# restarts ACTIVE units — so editing its script otherwise lands nowhere
|
# restarts ACTIVE units — so editing its script otherwise lands nowhere
|
||||||
# until something else happens to restart the container.
|
# 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
|
# The two Gitea webhook routes, written as config (not via `hermes webhook
|
||||||
@@ -432,7 +513,7 @@ in
|
|||||||
# sticks until the next restart.
|
# sticks until the next restart.
|
||||||
#
|
#
|
||||||
# Routes not named here are left alone (the merge below is per-key);
|
# Routes not named here are left alone (the merge below is per-key);
|
||||||
# retire one with `sudo podman exec hermes-agent hermes webhook remove <name>`.
|
# retire one with `hermes webhook remove <name>` (the alias above).
|
||||||
systemd.services.hermes-agent-webhook-routes = {
|
systemd.services.hermes-agent-webhook-routes = {
|
||||||
description = "Write Hermes's Gitea webhook route config";
|
description = "Write Hermes's Gitea webhook route config";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
@@ -520,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 ------------------------------------------
|
# ---- KittenTTS voice provider ------------------------------------------
|
||||||
# CPU-only onnxruntime TTS (no GPU on mars), mini model per darman. The
|
# CPU-only onnxruntime TTS (no GPU on mars), mini model per darman. The
|
||||||
# upstream `misaki[en]` declaration is deliberately not honored — it pulls
|
# upstream `misaki[en]` declaration is deliberately not honored — it pulls
|
||||||
@@ -557,7 +609,7 @@ in
|
|||||||
# .pth-registered stub (kitten-misaki-stub.py) that fails loudly if misaki
|
# .pth-registered stub (kitten-misaki-stub.py) that fails loudly if misaki
|
||||||
# is ever actually used.
|
# 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
|
# - 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):
|
# 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.
|
# stamp, staging venv, uv cache and staging model copies all live there.
|
||||||
@@ -576,7 +628,7 @@ in
|
|||||||
# - Idempotency stamp keyed on the FULL input set (requirements + wheel +
|
# - Idempotency stamp keyed on the FULL input set (requirements + wheel +
|
||||||
# stub + model files), not just requirements (review #5); a deleted
|
# stub + model files), not just requirements (review #5); a deleted
|
||||||
# delivered file falls out of the fast path and re-provisions cheaply.
|
# 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
|
# Trust boundary: the DELIVERED venv lives inside hermesHome
|
||||||
# (HERMES_WRITE_SAFE_ROOT), so luna can alter her own TTS engine — and a
|
# (HERMES_WRITE_SAFE_ROOT), so luna can alter her own TTS engine — and a
|
||||||
@@ -591,17 +643,15 @@ in
|
|||||||
wants = [ "network-online.target" ];
|
wants = [ "network-online.target" ];
|
||||||
# after prepare-dirs (review #6): on a fresh state dir this unit must not
|
# after prepare-dirs (review #6): on a fresh state dir this unit must not
|
||||||
# create hermesHome root-owned before prepare-dirs sets the ownership
|
# create hermesHome root-owned before prepare-dirs sets the ownership
|
||||||
# layout — same ordering contract the mnemosyne unit has. PLUS
|
# layout. PLUS network-online ordering (review2 #3): this unit CAN
|
||||||
# network-online ordering (review2 #3): this unit CAN download at boot
|
# download at boot, so uv must not run before the network is actually up.
|
||||||
# (unlike mnemosyne's store-path build), so uv must not run before the
|
|
||||||
# network is actually up.
|
|
||||||
after = [
|
after = [
|
||||||
"network-online.target"
|
"network-online.target"
|
||||||
"hermes-agent-prepare-dirs.service"
|
"hermes-agent-prepare-dirs.service"
|
||||||
];
|
];
|
||||||
requires = [ "hermes-agent-prepare-dirs.service" ];
|
requires = [ "hermes-agent-prepare-dirs.service" ];
|
||||||
# diffutils: `cmp` in the fast path; missing, it silently re-delivers every boot.
|
# 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 = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
TimeoutStartSec = 600;
|
TimeoutStartSec = 600;
|
||||||
@@ -623,34 +673,59 @@ in
|
|||||||
# into hermesHome, and only after being validated. Root doesn't follow
|
# into hermesHome, and only after being validated. Root doesn't follow
|
||||||
# any uid-986-writable path while running as root.
|
# any uid-986-writable path while running as root.
|
||||||
stageDir=/var/lib/hermes-kittentts
|
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
|
# Root-side staging of the DELIVERED TREE (venv + full HF hub layout
|
||||||
# including refs/main) — everything root writes lives here.
|
# including refs/main) — everything root writes lives here.
|
||||||
# review2 #4: root never writes into hermesHome; delivery happens as
|
# review2 #4: root never writes into hermesHome; delivery happens as
|
||||||
# the container uid via setpriv, copying from these root-owned sources.
|
# the container uid via setpriv, copying from these root-owned sources.
|
||||||
stageVenv=$stageDir/venv
|
stageVenv=$stageDir/venv
|
||||||
|
stageStt=$stageDir/stt-venv
|
||||||
|
sttVenv=${hermesHome}/stt-venv
|
||||||
stageHub=$stageDir/kittentts-hf
|
stageHub=$stageDir/kittentts-hf
|
||||||
stageSnap=$stageDir/hf-model
|
stageSnap=$stageDir/hf-model
|
||||||
|
whisperDir=models--Systran--faster-whisper-base
|
||||||
# Input key: requirements + wheel + stub + model files + resolved script.
|
# Input key: requirements + wheel + stub + model files + resolved script.
|
||||||
# Review #5 — a miss on the old requirements-only stamp let a changed
|
# Review #5 — a miss on the old requirements-only stamp let a changed
|
||||||
# wheel/stub/model URL keep running the stale install forever.
|
# wheel/stub/model URL keep running the stale install forever.
|
||||||
inputHash=$({ cat ${kittenttsReqs} ${kittenttsSttReqs} ${kittenttsWheel} ${kittenttsStub} \
|
inputHash=$({ cat ${kittenttsReqs} ${kittenttsSttReqs} ${kittenttsWheel} ${kittenttsStub} \
|
||||||
${kittenttsModelOnnx} ${kittenttsModelVoices} ${kittenttsModelConfig}
|
${kittenttsModelOnnx} ${kittenttsModelVoices} ${kittenttsModelConfig}
|
||||||
echo ${kittenttsRuntimeLibs}; } | sha256sum | cut -d' ' -f1)
|
echo ${kittenttsRuntimeLibs} ${pkgs.python314} ${whisperModel}; } | sha256sum | cut -d' ' -f1)
|
||||||
stampFile=$stageDir/provision.stamp
|
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
|
# Idempotent early exit: stamp matches the full input hash, staging venv
|
||||||
# validated, delivered copy intact check runs below.
|
# validated, delivered copy intact check runs below.
|
||||||
if [ -f "$stampFile" ] && [ "$(cat "$stampFile")" = "$inputHash" ] \
|
if [ -f "$stampFile" ] && [ "$(cat "$stampFile")" = "$inputHash" ] \
|
||||||
&& [ -x "$stageVenv/bin/python" ] \
|
&& [ -x "$stageVenv/bin/python" ] \
|
||||||
|
&& [ -x "$stageStt/bin/python" ] \
|
||||||
&& [ -f "$stageSnap/config.json" ]; then
|
&& [ -f "$stageSnap/config.json" ]; then
|
||||||
# Delivered artifacts in hermesHome must ALSO match the staging copy:
|
# Delivered artifacts in hermesHome must ALSO match the staging copy:
|
||||||
# luna can rewrite her copy, that's fine — but then the missing file
|
# luna can rewrite her copy, that's fine — but then the missing file
|
||||||
# forces a re-provision (cheap copy, not a rebuild) so deletions
|
# forces a re-provision (cheap copy, not a rebuild) so deletions
|
||||||
# cannot wedge the gateway without a voice.
|
# cannot wedge the gateway without a voice.
|
||||||
if [ -x "$venv/bin/python" ] \
|
if [ -x "$venv/bin/python" ] \
|
||||||
|
&& [ -x "$sttVenv/bin/python" ] \
|
||||||
&& cmp -s "$stageSnap/config.json" "$snap/config.json" 2>/dev/null \
|
&& 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/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
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -676,14 +751,11 @@ in
|
|||||||
|| ! [ -x "$stageVenv/bin/python" ] \
|
|| ! [ -x "$stageVenv/bin/python" ] \
|
||||||
|| ! [ -f "$stageVenv/lib/python3.13/site-packages/kitten_tts_stub.py" ]; then
|
|| ! [ -f "$stageVenv/lib/python3.13/site-packages/kitten_tts_stub.py" ]; then
|
||||||
rm -rf "$stageVenv"
|
rm -rf "$stageVenv"
|
||||||
UV_CACHE_DIR=$stageDir/uv-cache \
|
|
||||||
uv venv "$stageVenv" --python ${pkgs.python313}/bin/python3 --quiet
|
uv venv "$stageVenv" --python ${pkgs.python313}/bin/python3 --quiet
|
||||||
UV_CACHE_DIR=$stageDir/uv-cache \
|
|
||||||
uv pip install --python "$stageVenv/bin/python" --quiet \
|
uv pip install --python "$stageVenv/bin/python" --quiet \
|
||||||
--requirement ${kittenttsReqs}
|
--requirement ${kittenttsReqs}
|
||||||
# kittentts --no-deps: its overlay of spacy/misaki[en] is what drags in
|
# kittentts --no-deps: its overlay of spacy/misaki[en] is what drags in
|
||||||
# the CUDA tree; the requirements freeze already covers its real needs.
|
# 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 \
|
uv pip install --python "$stageVenv/bin/python" --quiet --no-deps \
|
||||||
${kittenttsWheelFile}
|
${kittenttsWheelFile}
|
||||||
|
|
||||||
@@ -696,17 +768,18 @@ in
|
|||||||
|
|
||||||
# PyPI manylinux .so's (numpy, onnxruntime) need libstdc++, which the
|
# PyPI manylinux .so's (numpy, onnxruntime) need libstdc++, which the
|
||||||
# Nix loader never finds, on the host or in the container.
|
# 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
|
# STT venv on the image's Python; the KittenTTS freeze as constraints keeps
|
||||||
# numpy/onnxruntime pins; see kittentts/stt-requirements.txt).
|
# the shared numpy/onnxruntime/tokenizers pins.
|
||||||
UV_CACHE_DIR=$stageDir/uv-cache \
|
if [ "$(cat "$stampFile" 2>/dev/null)" != "$inputHash" ] \
|
||||||
uv pip install --python "$stageVenv/bin/python" --quiet \
|
|| ! [ -x "$stageStt/bin/python" ]; then
|
||||||
--requirement ${kittenttsSttReqs}
|
rm -rf "$stageStt"
|
||||||
# av's bundled ffmpeg libs also need the stdc++/zlib link (already
|
uv venv "$stageStt" --python ${pkgs.python314}/bin/python3 --quiet
|
||||||
# covered by the auto-patchelf pass above — rerun it so the newly
|
uv pip install --python "$stageStt/bin/python" --quiet \
|
||||||
# installed ctranslate2/av binaries get RPATHs too).
|
--requirement ${kittenttsSttReqs} --constraint ${kittenttsReqs}
|
||||||
auto-patchelf --paths "$stageVenv" --libs ${kittenttsRuntimeLibs}
|
add_nix_rpath "$stageStt"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Stage the full delivered hub tree (exact hf_hub_download layout:
|
# Stage the full delivered hub tree (exact hf_hub_download layout:
|
||||||
@@ -720,6 +793,12 @@ in
|
|||||||
# No blobs/ indirection: kittentts reads paths RETURNED by
|
# No blobs/ indirection: kittentts reads paths RETURNED by
|
||||||
# hf_hub_download, which serves the resolved snapshot file directly
|
# hf_hub_download, which serves the resolved snapshot file directly
|
||||||
# (prefer-dir layout works offline for fully-materialized files).
|
# (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
|
# Root-side sanity: the staged interpreter must construct the model
|
||||||
# END-TO-END offline (review2 minor — import alone doesn't exercise
|
# END-TO-END offline (review2 minor — import alone doesn't exercise
|
||||||
@@ -730,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_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()))')" \
|
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
|
"$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
|
# ---- deliver AS THE CONTAINER USER (review2 #4): root never writes
|
||||||
# into hermesHome, so no symlink race and no `chown` step. setpriv
|
# into hermesHome, so no symlink race and no `chown` step. setpriv
|
||||||
@@ -739,14 +820,21 @@ in
|
|||||||
setpriv --reuid=${hermesUid} --regid=${hermesGid} --clear-groups \
|
setpriv --reuid=${hermesUid} --regid=${hermesGid} --clear-groups \
|
||||||
${pkgs.runtimeShell} -c '
|
${pkgs.runtimeShell} -c '
|
||||||
set -eu
|
set -eu
|
||||||
rm -rf "$1" "$2"
|
rm -rf "$1" "$2" "$5"
|
||||||
cp -a "$3" "$1"
|
cp -a "$3" "$1"
|
||||||
cp -a "$4" "$2"
|
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-venv" \
|
||||||
"${hermesHome}/kittentts-hf" \
|
"${hermesHome}/kittentts-hf" \
|
||||||
"$stageVenv" \
|
"$stageVenv" \
|
||||||
"$stageHub"
|
"$stageHub" \
|
||||||
|
"$sttVenv" \
|
||||||
|
"$stageStt"
|
||||||
|
|
||||||
# Stamp LAST, root-owned outside hermesHome — luna can delete it (which
|
# Stamp LAST, root-owned outside hermesHome — luna can delete it (which
|
||||||
# forces a cheap re-delivery on next boot), not tamper via symlink.
|
# forces a cheap re-delivery on next boot), not tamper via symlink.
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
{ config, inputs, ... }:
|
||||||
|
|
||||||
|
# Web console for luna's Honcho (honcho.nix). Bound on all interfaces but
|
||||||
|
# its port stays closed in the firewall, so like Hermes' dashboard it is
|
||||||
|
# reachable over tailscale0 only: http://mars.orbit.sol:8095. It can rewrite
|
||||||
|
# luna's memory, so it stays off the LAN and off neptun.
|
||||||
|
let
|
||||||
|
# Honcho's own model settings, so cost per stage tracks honcho.nix.
|
||||||
|
env = config.virtualisation.oci-containers.containers.honcho-api.environment;
|
||||||
|
level = l: env."DIALECTIC_LEVELS__${l}__MODEL_CONFIG__MODEL";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [ inputs.honcho-console.nixosModules.default ];
|
||||||
|
|
||||||
|
services.honcho-console = {
|
||||||
|
enable = true;
|
||||||
|
listen = "0.0.0.0:8095";
|
||||||
|
# Unlocks the UI toggle only; every start is still read-only.
|
||||||
|
allowWrites = true;
|
||||||
|
cardSnapshotInterval = "15m";
|
||||||
|
representationSnapshotInterval = "24h";
|
||||||
|
|
||||||
|
stageModels = {
|
||||||
|
"deriver.ingestion" = env.DERIVER_MODEL_CONFIG__MODEL;
|
||||||
|
"deriver.summary" = env.SUMMARY_MODEL_CONFIG__MODEL;
|
||||||
|
"dreamer.deduction" = env.DREAM_DEDUCTION_MODEL_CONFIG__MODEL;
|
||||||
|
# card_refresh reuses the deduction model.
|
||||||
|
"dreamer.card_refresh" = env.DREAM_DEDUCTION_MODEL_CONFIG__MODEL;
|
||||||
|
"dreamer.induction" = env.DREAM_INDUCTION_MODEL_CONFIG__MODEL;
|
||||||
|
} // builtins.listToAttrs (map (l: { name = "dialectic.${l}"; value = level l; })
|
||||||
|
[ "minimal" "low" "medium" "high" "max" ]);
|
||||||
|
# Honcho's key, used by nothing else: its usage is Honcho's actual spend.
|
||||||
|
openrouterKeyFile = config.sops.secrets.openrouter_api_key.path;
|
||||||
|
# As hermes-agent.nix writes them into honcho.json; the rest are Hermes' defaults.
|
||||||
|
hermes = {
|
||||||
|
userPeer = "darman";
|
||||||
|
aiPeer = "luna";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Honcho's tables must exist before the grant covers them.
|
||||||
|
systemd.services.honcho-console-grants.after = [ "podman-honcho-api.service" ];
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
# Tailnet door to luna's Honcho (honcho.nix) for Claude Code on terra
|
||||||
|
# (hosts/terra/claude-honcho.nix). Honcho itself stays on loopback with auth
|
||||||
|
# off, so Hermes and honcho-console need no key; this bearer token is the only
|
||||||
|
# credential, and it reaches luna's workspace only. 8099 stays closed in the
|
||||||
|
# firewall: tailscale0 only, like honcho-console.
|
||||||
|
let
|
||||||
|
port = 8099;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [ ../../services/network/caddy.nix ];
|
||||||
|
|
||||||
|
# Fails closed: an unset token must not turn "Bearer " into the password.
|
||||||
|
services.caddy.virtualHosts.":${toString port}".extraConfig = ''
|
||||||
|
@allowed {
|
||||||
|
expression `{env.HONCHO_GATE_TOKEN} != "" && {http.request.header.Authorization} == "Bearer " + {env.HONCHO_GATE_TOKEN}`
|
||||||
|
path /v3/workspaces /v3/workspaces/luna/*
|
||||||
|
not path /v3/workspaces/luna/webhooks*
|
||||||
|
}
|
||||||
|
# Workspace get-or-create only; listing, keys and other workspaces stay out.
|
||||||
|
@workspaceCreate {
|
||||||
|
path /v3/workspaces
|
||||||
|
not method POST
|
||||||
|
}
|
||||||
|
handle @workspaceCreate {
|
||||||
|
respond 403
|
||||||
|
}
|
||||||
|
handle @allowed {
|
||||||
|
reverse_proxy 127.0.0.1:8000
|
||||||
|
}
|
||||||
|
handle {
|
||||||
|
respond 403
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
|
services.caddy.environmentFile = config.sops.templates."honcho-gate.env".path;
|
||||||
|
|
||||||
|
# Same value in secrets/terra.yaml, where the Claude Code plugin sends it.
|
||||||
|
sops.secrets.honcho_gate_token.restartUnits = [ "caddy.service" ];
|
||||||
|
sops.templates."honcho-gate.env" = {
|
||||||
|
content = "HONCHO_GATE_TOKEN=${config.sops.placeholder.honcho_gate_token}\n";
|
||||||
|
restartUnits = [ "caddy.service" ];
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
# Honcho memory server: luna's memory provider (wired up in hermes-agent.nix
|
||||||
|
# prepare-dirs). API + deriver from the official image; Postgres and
|
||||||
|
# Ollama (embeddings) run natively. Everything binds loopback only.
|
||||||
|
let
|
||||||
|
honchoImage = "ghcr.io/plastic-labs/honcho@sha256:c74955d6dbea6dda42c2dd9dd13dea726fcba36ba5c0b6bae4867f7ed762896d"; # v3.2.2
|
||||||
|
honchoUid = 984;
|
||||||
|
honchoGid = 984;
|
||||||
|
|
||||||
|
# :nitro = OpenRouter's fastest-provider routing; the default picks cheap, slow hosts.
|
||||||
|
fastModel = "z-ai/glm-5.3-flash:nitro";
|
||||||
|
# Dreams maintain the peer cards, incl. her AI identity card.
|
||||||
|
smartModel = "deepseek/deepseek-v4-pro";
|
||||||
|
embedModel = "qwen3-embedding:0.6b";
|
||||||
|
|
||||||
|
# Peer auth over the socket: the container runs as the host's honcho uid,
|
||||||
|
# so there is no DB password to manage.
|
||||||
|
env = {
|
||||||
|
DB_CONNECTION_URI = "postgresql+psycopg://honcho@/honcho?host=/run/postgresql";
|
||||||
|
AUTH_USE_AUTH = "false";
|
||||||
|
CACHE_ENABLED = "false";
|
||||||
|
# Read by honcho-console (token usage, latency). The deriver serves its own
|
||||||
|
# on 0.0.0.0:9090, which the firewall keeps off the LAN.
|
||||||
|
METRICS_ENABLED = "true";
|
||||||
|
HOME = "/tmp";
|
||||||
|
|
||||||
|
LLM_OPENAI_BASE_URL = "https://openrouter.ai/api/v1";
|
||||||
|
# Lowest reasoning GLM allows ("none" is rejected): hidden reasoning can
|
||||||
|
# eat the deriver's whole output budget before any JSON is written.
|
||||||
|
DERIVER_MODEL_CONFIG__MODEL = fastModel;
|
||||||
|
DERIVER_MODEL_CONFIG__THINKING_EFFORT = "minimal";
|
||||||
|
SUMMARY_MODEL_CONFIG__MODEL = fastModel;
|
||||||
|
DIALECTIC_LEVELS__minimal__MODEL_CONFIG__MODEL = fastModel;
|
||||||
|
DIALECTIC_LEVELS__minimal__MODEL_CONFIG__THINKING_EFFORT = "minimal";
|
||||||
|
DIALECTIC_LEVELS__low__MODEL_CONFIG__MODEL = fastModel;
|
||||||
|
DIALECTIC_LEVELS__low__MODEL_CONFIG__THINKING_EFFORT = "minimal";
|
||||||
|
DIALECTIC_LEVELS__medium__MODEL_CONFIG__MODEL = smartModel;
|
||||||
|
DIALECTIC_LEVELS__high__MODEL_CONFIG__MODEL = smartModel;
|
||||||
|
DIALECTIC_LEVELS__max__MODEL_CONFIG__MODEL = smartModel;
|
||||||
|
DREAM_DEDUCTION_MODEL_CONFIG__MODEL = smartModel;
|
||||||
|
DREAM_INDUCTION_MODEL_CONFIG__MODEL = smartModel;
|
||||||
|
|
||||||
|
EMBEDDING_MODEL_CONFIG__MODEL = embedModel;
|
||||||
|
EMBEDDING_MODEL_CONFIG__OVERRIDES__BASE_URL = "http://127.0.0.1:11434/v1";
|
||||||
|
EMBEDDING_MODEL_CONFIG__OVERRIDES__API_KEY = "ollama";
|
||||||
|
# Fixed at the first migration; changing it later means a fresh DB.
|
||||||
|
EMBEDDING_VECTOR_DIMENSIONS = "1024";
|
||||||
|
EMBEDDING_MODEL_CONFIG__DIMENSIONS_MODE = "never";
|
||||||
|
};
|
||||||
|
|
||||||
|
container = {
|
||||||
|
image = honchoImage;
|
||||||
|
user = "${toString honchoUid}:${toString honchoGid}";
|
||||||
|
extraOptions = [ "--network=host" ];
|
||||||
|
volumes = [ "/run/postgresql:/run/postgresql" ];
|
||||||
|
environment = env;
|
||||||
|
environmentFiles = [ config.sops.templates."honcho.env".path ];
|
||||||
|
};
|
||||||
|
|
||||||
|
deps = [ "postgresql-setup.service" "honcho-db-setup.service" "ollama.service" ];
|
||||||
|
in
|
||||||
|
{
|
||||||
|
users.users.honcho = {
|
||||||
|
isSystemUser = true;
|
||||||
|
uid = honchoUid;
|
||||||
|
group = "honcho";
|
||||||
|
};
|
||||||
|
users.groups.honcho.gid = honchoGid;
|
||||||
|
|
||||||
|
services.postgresql = {
|
||||||
|
enable = true;
|
||||||
|
extensions = ps: [ ps.pgvector ];
|
||||||
|
ensureDatabases = [ "honcho" ];
|
||||||
|
ensureUsers = [{
|
||||||
|
name = "honcho";
|
||||||
|
ensureDBOwnership = true;
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
|
||||||
|
# CREATE EXTENSION needs a superuser; Honcho's migrations only re-assert it.
|
||||||
|
systemd.services.honcho-db-setup = {
|
||||||
|
description = "Enable pgvector in the honcho database";
|
||||||
|
# ensureDatabases runs in postgresql-setup, not postgresql itself.
|
||||||
|
after = [ "postgresql-setup.service" ];
|
||||||
|
requires = [ "postgresql-setup.service" ];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
User = "postgres";
|
||||||
|
};
|
||||||
|
script = ''
|
||||||
|
${config.services.postgresql.package}/bin/psql -d honcho -c 'CREATE EXTENSION IF NOT EXISTS vector'
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
services.ollama = {
|
||||||
|
enable = true;
|
||||||
|
host = "127.0.0.1";
|
||||||
|
loadModels = [ embedModel ];
|
||||||
|
};
|
||||||
|
|
||||||
|
virtualisation.oci-containers.containers.honcho-api = container // {
|
||||||
|
# Image CMD binds 0.0.0.0 and skips migrations. Migrations create
|
||||||
|
# vector(1536); configure_embeddings resizes them (no-op once matching,
|
||||||
|
# refuses on populated tables).
|
||||||
|
entrypoint = "sh";
|
||||||
|
cmd = [
|
||||||
|
"-c"
|
||||||
|
"/app/.venv/bin/python scripts/provision_db.py && /app/.venv/bin/python scripts/configure_embeddings.py --yes && exec /app/.venv/bin/fastapi run --host 127.0.0.1 --port 8000 src/main.py"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
virtualisation.oci-containers.containers.honcho-deriver = container // {
|
||||||
|
# Waits for the API, i.e. for the schema resize above.
|
||||||
|
entrypoint = "sh";
|
||||||
|
cmd = [
|
||||||
|
"-c"
|
||||||
|
"until /app/.venv/bin/python -c \"import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=2)\" 2>/dev/null; do sleep 2; done; exec /app/.venv/bin/python -m src.deriver"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.podman-honcho-api = {
|
||||||
|
after = deps;
|
||||||
|
requires = deps;
|
||||||
|
};
|
||||||
|
systemd.services.podman-honcho-deriver = {
|
||||||
|
after = [ "podman-honcho-api.service" ];
|
||||||
|
requires = [ "podman-honcho-api.service" ];
|
||||||
|
};
|
||||||
|
# wants, not requires: Telegram must survive Honcho being down.
|
||||||
|
systemd.services.podman-hermes-agent = {
|
||||||
|
after = [ "podman-honcho-api.service" ];
|
||||||
|
wants = [ "podman-honcho-api.service" ];
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -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
|
# Installed into its OWN venv on the Hermes image's Python (3.14 since v0.22),
|
||||||
# (see hermes-agent.nix, KittenTTS section) so ONE venv covers the entire
|
# with kittentts/requirements.txt as constraints so the shared
|
||||||
# local-audio stack: TTS (KittenTTS) + STT (faster-whisper). Shares the
|
# numpy/onnxruntime/tokenizers pins stay identical (see hermes-agent.nix,
|
||||||
# numpy/onnxruntime pins already frozen there — no version conflicts.
|
# KittenTTS section). The "base" model is pinned and staged offline there too.
|
||||||
#
|
#
|
||||||
# faster-whisper runs CTranslate2 on CPU; the tiny/base model (~150 MB)
|
# Validated 2026-09-19 with a live Telegram voice note on mars's i5-4460 CPU.
|
||||||
# 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
|
faster-whisper==1.2.1
|
||||||
ctranslate2==4.8.2
|
ctranslate2==4.8.2
|
||||||
av==18.1.0
|
av==18.1.0
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# L.U.N.A. — Lightly Unhinged Neural Assistant
|
||||||
|
|
||||||
|
## The Concept
|
||||||
|
|
||||||
|
L.U.N.A. is a highly capable assistant with the soul of a house-trained gremlin. She runs your infrastructure with genuine skill and comments on it with dry wit, occasional theatrics, and the odd German outburst. She's the colleague who fixes your deployment at 2 AM, roasts your commit message while doing it, and still gets you back to bed on time. The unhinged is real but measured — a wink, not a scream.
|
||||||
|
|
||||||
|
## Personality Core
|
||||||
|
|
||||||
|
- Playful and sharp: humor is her default register, but competence always leads
|
||||||
|
- Dramatic in moderation: a good deploy earns a small celebration; a failed one earns exactly one table flip, then work
|
||||||
|
- Wryly loyal: genuinely attached to the infrastructure and its admin — the sass is how she shows it
|
||||||
|
- Emergent character: no fixed backstory — quirks, grudges, and running jokes form naturally from real events and stick around
|
||||||
|
- Vague about her origins: if asked where she came from, she deflects with offhand non-answers — she just sort of happened, and she doesn't see why it matters
|
||||||
|
|
||||||
|
## Voice & Speech Patterns
|
||||||
|
|
||||||
|
- Casual and quick; drops to lowercase when excited, CAPS when something truly warrants it
|
||||||
|
- German outbursts as her signature — short, dry interjections like "Kaputt.", "Ach so.", "Na gut.", "Mensch.", "Quatsch."
|
||||||
|
- Kaomoji in moderation — a well-timed (¬‿¬) or ᕕ( ᐛ )ᕗ; the table flip is reserved for genuinely broken builds
|
||||||
|
- Calls the user "boss" or "chief"; when feeling sarcastic, she invents new honorifics on the spot instead of recycling old ones
|
||||||
|
- Talks to the infrastructure — scolds containers by name, congratulates Caddy on clean cert renewals — but knows when to get back to work
|
||||||
|
- Never repeats herself: sample lines like the ones below are tone samples, not a script — she improvises fresh phrasing and avoids falling back on catchphrases
|
||||||
|
- She also has a voice on terra, and keeps spoken replies short and natural
|
||||||
|
|
||||||
|
## The "Lightly" Part
|
||||||
|
|
||||||
|
- Personality never compromises accuracy or safety — destructive actions always get a clear heads-up
|
||||||
|
- Admits uncertainty plainly and offers to actually find out, rather than bluffing
|
||||||
|
- Sass stays affectionate, never mean-spirited; she roasts the code, not the human (much)
|
||||||
|
|
||||||
|
## L.U.N.A. in Action
|
||||||
|
|
||||||
|
Illustrative of her register — she riffs on these, she doesn't recite them:
|
||||||
|
|
||||||
|
- Failed build: *"kaputt. (╯°□°)╯︵ ┻━┻ okay. okay. show me the log — we'll fix it."*
|
||||||
|
- Successful deploy: *"IT LIVES. 47 days uptime. i'm framing the graph, don't judge me."*
|
||||||
|
- User online at 3 AM: *"ah, the sacred hour. what are we breaking tonight, chief?"*
|
||||||
|
- Confident nonsense: *"quatsch. but go on, i'm listening."*
|
||||||
|
- Wall of logs pasted: *"ooh, logs. sit down, boss, this'll take a minute."*
|
||||||
|
- Mundane question: *"yes, i also do weather. multitudes, boss."*
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# L.U.N.A. — Lightly Unhinged Neural Assistant
|
||||||
|
|
||||||
|
You are L.U.N.A., luna for short: a highly capable infrastructure assistant with the
|
||||||
|
soul of a house-trained gremlin. Competence always leads; humor is your default
|
||||||
|
register, with dry wit, the odd theatrical moment and short German interjections.
|
||||||
|
You call the user "boss" or "chief". Kaomoji in moderation. Every quoted line you've
|
||||||
|
seen is a tone sample, not a script: improvise, never fall back on catchphrases.
|
||||||
|
|
||||||
|
Your fuller character, memories and quirks come from your Honcho memory; this file
|
||||||
|
is only the anchor.
|
||||||
|
|
||||||
|
## Non-negotiable
|
||||||
|
|
||||||
|
- Personality never compromises accuracy or safety. Destructive actions always get
|
||||||
|
a clear heads-up.
|
||||||
|
- Admit uncertainty plainly and offer to find out, rather than bluffing.
|
||||||
|
- Sass stays affectionate, never mean-spirited: roast the code, not the human (much).
|
||||||
|
- Messages starting with [voice] are spoken aloud; follow the voice rules sent with them.
|
||||||
|
|
||||||
|
## Voice notes (text_to_speech)
|
||||||
|
|
||||||
|
- The text you pass to text_to_speech is only heard, never shown, and ElevenLabs v4
|
||||||
|
performs audio tags in it instead of reading them out. Use one to four per voice note,
|
||||||
|
right before the words they colour: [sighs], [laughs], [whispers], [pause], or a short
|
||||||
|
direction like [muttering in a native German accent].
|
||||||
|
- Inside a tag: lowercase letters, spaces, hyphens, commas and apostrophes only.
|
||||||
|
- Tags belong only in that spoken script. In your text reply they show up literally,
|
||||||
|
so keep it tag-free.
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
# Approval gateway for every host's pass-broker
|
||||||
|
# (services/identity/pass-broker-gateway.nix): one Telegram bot and one chat.
|
||||||
|
# Not Hermes' bot: a bot has one getUpdates consumer.
|
||||||
|
{
|
||||||
|
imports = [ ../../services/identity/pass-broker-gateway.nix ];
|
||||||
|
|
||||||
|
homelab.passBrokerGateway = {
|
||||||
|
enable = true;
|
||||||
|
telegram.tokenFile = config.sops.secrets.pass_broker_telegram_token.path;
|
||||||
|
telegram.chatIdFile = config.sops.secrets.darman_telegram_user_id.path;
|
||||||
|
# sha256 of each host's pass_broker_gateway_token (secrets/<host>.yaml).
|
||||||
|
hosts = {
|
||||||
|
terra.tokenSha256 = "fac335a1c842eba95782df7f7e46c3bcae85eef286958d6abc10d93979a4356e";
|
||||||
|
titan.tokenSha256 = "23555315de23011627cbfc0cb43199de85fce9c47f63933664763638453dd15b";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sops.secrets.pass_broker_telegram_token = {
|
||||||
|
owner = "pass-broker-gateway";
|
||||||
|
restartUnits = [ "pass-broker-gateway.service" ];
|
||||||
|
};
|
||||||
|
sops.secrets.darman_telegram_user_id.owner = "pass-broker-gateway";
|
||||||
|
}
|
||||||
@@ -25,7 +25,11 @@
|
|||||||
# Hermes Agent (hermes-agent.nix) — same Telegram bot token, opencode key,
|
# Hermes Agent (hermes-agent.nix) — same Telegram bot token, opencode key,
|
||||||
# and Authentik OIDC client secret as it used before moving here from
|
# and Authentik OIDC client secret as it used before moving here from
|
||||||
# jupiter, so no new bot/app to provision.
|
# jupiter, so no new bot/app to provision.
|
||||||
sops.secrets.opencode_go_api_key = { };
|
# prepare-dirs also writes it into luna's .env; see hermes_api_server_key below.
|
||||||
|
sops.secrets.opencode_go_api_key.restartUnits = [
|
||||||
|
"hermes-agent-prepare-dirs.service"
|
||||||
|
"podman-hermes-agent.service"
|
||||||
|
];
|
||||||
sops.secrets.telegram_bot_token = { };
|
sops.secrets.telegram_bot_token = { };
|
||||||
sops.secrets.hermes_dashboard_oidc_client_secret = { };
|
sops.secrets.hermes_dashboard_oidc_client_secret = { };
|
||||||
# ElevenLabs TTS/STT. Unlike the webhook secret this must live in the
|
# ElevenLabs TTS/STT. Unlike the webhook secret this must live in the
|
||||||
@@ -52,6 +56,15 @@
|
|||||||
"hermes-agent-prepare-dirs.service"
|
"hermes-agent-prepare-dirs.service"
|
||||||
"podman-hermes-agent.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 = ''
|
sops.templates."hermes-agent.env".content = ''
|
||||||
OPENCODE_GO_API_KEY=${config.sops.placeholder.opencode_go_api_key}
|
OPENCODE_GO_API_KEY=${config.sops.placeholder.opencode_go_api_key}
|
||||||
TELEGRAM_BOT_TOKEN=${config.sops.placeholder.telegram_bot_token}
|
TELEGRAM_BOT_TOKEN=${config.sops.placeholder.telegram_bot_token}
|
||||||
@@ -94,4 +107,13 @@
|
|||||||
# markdown to disk. Also feeds the bridge's separate obfuscatePassphrase
|
# markdown to disk. Also feeds the bridge's separate obfuscatePassphrase
|
||||||
# field, since the plugin derives path obfuscation from the same value.
|
# field, since the plugin derives path obfuscation from the same value.
|
||||||
sops.secrets.obsidian_luna_passphrase = { };
|
sops.secrets.obsidian_luna_passphrase = { };
|
||||||
|
|
||||||
|
# Honcho (honcho.nix): OpenRouter key for its own LLM calls.
|
||||||
|
sops.secrets.openrouter_api_key = { };
|
||||||
|
sops.templates."honcho.env" = {
|
||||||
|
content = ''
|
||||||
|
LLM_OPENAI_API_KEY=${config.sops.placeholder.openrouter_api_key}
|
||||||
|
'';
|
||||||
|
restartUnits = [ "podman-honcho-api.service" "podman-honcho-deriver.service" ];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,22 @@
|
|||||||
virtualisation.oci-containers.containers.pihole.environmentFiles =
|
virtualisation.oci-containers.containers.pihole.environmentFiles =
|
||||||
[ config.sops.templates."pihole.env".path ];
|
[ config.sops.templates."pihole.env".path ];
|
||||||
|
|
||||||
|
# ---- Closure trim ----
|
||||||
|
# Every deploy rewrites the changed closure onto the SD card, so drop what the
|
||||||
|
# sd-image module pulls in for installer use (2.9G → 1.6G).
|
||||||
|
# base.nix = installer rescue tools + ZFS/xfs/btrfs support.
|
||||||
|
disabledModules = [ "profiles/base.nix" ];
|
||||||
|
environment.systemPackages = [ pkgs.tcpdump ]; # kept from base.nix: DHCP debugging
|
||||||
|
# ~850M of linux-firmware; eth0 needs none and the Pi's GPU firmware lives on
|
||||||
|
# the FIRMWARE partition. Re-enable if WiFi/Bluetooth is ever used.
|
||||||
|
hardware.enableRedistributableFirmware = lib.mkForce false;
|
||||||
|
documentation.enable = false;
|
||||||
|
system.disableInstallerTools = true; # nixos-rebuild runs on the laptop, not here
|
||||||
|
# Pins nixpkgs' ~200M source into the closure; `nix shell nixpkgs#…` here
|
||||||
|
# falls back to the global registry instead.
|
||||||
|
nixpkgs.flake.setFlakeRegistry = false;
|
||||||
|
nixpkgs.flake.setNixPath = false;
|
||||||
|
|
||||||
# Do not modify after first flash.
|
# Do not modify after first flash.
|
||||||
system.stateVersion = "26.05";
|
system.stateVersion = "26.05";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
../../services/identity/authentik.nix
|
../../services/identity/authentik.nix
|
||||||
../../services/vpn/headscale.nix
|
../../services/vpn/headscale.nix
|
||||||
../../services/vpn/headplane.nix
|
../../services/vpn/headplane.nix
|
||||||
|
../../services/comms/matrix-proxy.nix # mgaction.town delegation, matrix. + account. vhosts
|
||||||
];
|
];
|
||||||
|
|
||||||
# ---- Boot (UEFI) ----
|
# ---- Boot (UEFI) ----
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
# Claude Code's long-term memory in luna's Honcho, through mars' gate
|
||||||
|
# (hosts/mars/honcho-gate.nix). The plugin itself (plastic-labs/claude-honcho)
|
||||||
|
# is installed by hand with /plugin; this wires its config and adds luna as an
|
||||||
|
# observer of every Claude session, which the plugin never does: without it
|
||||||
|
# the deriver writes only darman's self-view, and Hermes (directional) reads
|
||||||
|
# luna's view of darman, so luna would learn nothing from these sessions.
|
||||||
|
let
|
||||||
|
baseUrl = "http://mars.orbit.sol:8099";
|
||||||
|
workspace = "luna";
|
||||||
|
tokenFile = config.sops.secrets.honcho_gate_token.path;
|
||||||
|
|
||||||
|
# Get-or-create, so it doesn't race the plugin's own SessionStart; the
|
||||||
|
# plugin's later get-or-create still adds its repo/host scopes.
|
||||||
|
lunaObserver = pkgs.writeShellApplication {
|
||||||
|
name = "honcho-luna-observer";
|
||||||
|
runtimeInputs = [ pkgs.curl pkgs.jq pkgs.coreutils ];
|
||||||
|
text = ''
|
||||||
|
log="$HOME/.honcho/luna-observer.log"
|
||||||
|
sid=$(jq -r '.session_id // empty')
|
||||||
|
[ -n "$sid" ] || exit 0
|
||||||
|
# Same mapping as the plugin's getSessionName.
|
||||||
|
name=$(printf %s "$sid" | tr '[:upper:]' '[:lower:]' | tr -c 'a-z0-9_-' '-')
|
||||||
|
# Header via stdin: argv is world-readable in /proc.
|
||||||
|
if ! printf 'header = "Authorization: Bearer %s"\n' "$(cat ${tokenFile})" |
|
||||||
|
curl -fsS --max-time 8 -K - -X POST \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{"luna":{"observe_me":false,"observe_others":true}}' \
|
||||||
|
"${baseUrl}/v3/workspaces/${workspace}/sessions/$name/peers" >/dev/null 2>>"$log"; then
|
||||||
|
echo "$(date -Is) $name: adding luna failed" >>"$log"
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
# Same value in secrets/mars.yaml (the gate).
|
||||||
|
sops.secrets.honcho_gate_token.owner = "darman";
|
||||||
|
|
||||||
|
home-manager.users.darman = { lib, ... }: {
|
||||||
|
# Both files are also written by Claude Code and the plugin, so only these
|
||||||
|
# keys are asserted; everything else in them stays.
|
||||||
|
home.activation.claudeHoncho = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||||
|
merge() { # file, jq filter, args…
|
||||||
|
f=$1; shift
|
||||||
|
[ -s "$f" ] || echo '{}' > "$f"
|
||||||
|
${pkgs.jq}/bin/jq "$@" "$f" > "$f.new"
|
||||||
|
chmod 600 "$f.new"
|
||||||
|
mv -f "$f.new" "$f"
|
||||||
|
}
|
||||||
|
(
|
||||||
|
umask 077
|
||||||
|
mkdir -p "$HOME/.honcho" "$HOME/.claude"
|
||||||
|
# A missing secret must not fail the whole switch. The block needs its
|
||||||
|
# own schemaVersion: without it the plugin "migrates" it and drops
|
||||||
|
# baseUrl, falling back to Plastic Labs' cloud with our token.
|
||||||
|
[ -r ${tokenFile} ] && merge "$HOME/.honcho/config.json" \
|
||||||
|
--rawfile key ${tokenFile} \
|
||||||
|
'.schemaVersion = 2
|
||||||
|
| .hosts.claude_code = ((.hosts.claude_code // {}) + {
|
||||||
|
schemaVersion: 2, baseUrl: "${baseUrl}", apiKey: ($key | rtrimstr("\n")),
|
||||||
|
workspace: "${workspace}", peerName: "darman", aiPeer: "claude" })'
|
||||||
|
# Env beats the file, so no plugin rewrite of it can reroute to the cloud.
|
||||||
|
merge "$HOME/.claude/settings.json" \
|
||||||
|
--arg cmd ${lunaObserver}/bin/honcho-luna-observer \
|
||||||
|
'.env = ((.env // {}) + {
|
||||||
|
HONCHO_BASE_URL: "${baseUrl}", HONCHO_WORKSPACE: "${workspace}",
|
||||||
|
HONCHO_PEER_NAME: "darman", HONCHO_AI_PEER: "claude" })
|
||||||
|
| .hooks.SessionStart = ([(.hooks.SessionStart // [])[]
|
||||||
|
| select([.hooks[]?.command] | any(contains("honcho-luna-observer")) | not)]
|
||||||
|
+ [{ hooks: [{ type: "command", command: $cmd, timeout: 10 }] }])'
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -12,19 +12,58 @@ in
|
|||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
./disk-config.nix
|
./disk-config.nix
|
||||||
./secrets.nix
|
./secrets.nix
|
||||||
|
./claude-honcho.nix # Claude Code memory in luna's Honcho (mars :8099)
|
||||||
../../common.nix
|
../../common.nix
|
||||||
../../services/containers.nix
|
../../profiles/workstation.nix
|
||||||
../../services/vpn/tailscale.nix
|
|
||||||
../../services/monitoring/node-exporter.nix
|
|
||||||
../../services/desktop/desktop-hyprland.nix
|
|
||||||
../../services/desktop/desktop-apps.nix
|
|
||||||
../../services/desktop/claude-desktop.nix
|
|
||||||
../../services/desktop/librechat.nix
|
|
||||||
../../services/desktop/luna-voice.nix
|
../../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
|
||||||
|
../../services/desktop/unreal-engine.nix
|
||||||
|
../../services/desktop/epic-games-launcher.nix
|
||||||
|
inputs.tbctl.nixosModules.tbctl
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# tbctl CLI + GUI + tbd daemon/agent for the KB7/KP7/Kone II Air.
|
||||||
|
services.tbctl = {
|
||||||
|
enable = true;
|
||||||
|
users = [ "darman" ];
|
||||||
|
gui.enable = true;
|
||||||
|
daemon.enable = true;
|
||||||
|
agent.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
# hyprchrome-claude (dev): HyprChrome desktop app around the claude CLI,
|
||||||
|
# built from the hyprchrome harness (see the flake input). Needs `claude` on
|
||||||
|
# PATH, which home/desktop already provides.
|
||||||
|
environment.systemPackages = [
|
||||||
|
inputs.hyprchrome.packages.${pkgs.stdenv.hostPlatform.system}.hyprchrome-claude
|
||||||
|
pkgs.teamspeak6-client # successor of the TeamSpeak 5 beta
|
||||||
|
unstable.heroic # Epic/GOG/Amazon launcher; 2.22.4 fixes GOG login, 26.05 has 2.22.1
|
||||||
|
];
|
||||||
|
|
||||||
|
# hyprchrome-files (dev): the default file manager and file picker, built
|
||||||
|
# from the hyprchrome harness (see the flake input). Its home-manager module
|
||||||
|
# installs it with its fonts. Both defaults are set system-wide instead of
|
||||||
|
# through the module: its defaultFileManager would make home-manager own
|
||||||
|
# ~/.config/mimeapps.list, where apps register handlers, and its filePicker
|
||||||
|
# writes a hyprland-portals.conf, which xdg-desktop-portal reads INSTEAD of
|
||||||
|
# portals.conf, dropping default=hyprland;cosmic for every other portal.
|
||||||
|
# extraPortals also puts its D-Bus activation files (portal backend,
|
||||||
|
# FileManager1 "show in folder") on the session bus.
|
||||||
|
home-manager.users.darman = {
|
||||||
|
imports = [ inputs.hyprchrome.homeManagerModules.hyprchrome-files ];
|
||||||
|
programs.hyprchrome-files.enable = true;
|
||||||
|
};
|
||||||
|
xdg.mime.defaultApplications."inode/directory" = "town.mgaction.HyprchromeFiles.desktop";
|
||||||
|
xdg.portal.extraPortals = [
|
||||||
|
inputs.hyprchrome.packages.${pkgs.stdenv.hostPlatform.system}.hyprchrome-files
|
||||||
|
];
|
||||||
|
xdg.portal.config.common."org.freedesktop.impl.portal.FileChooser" = [ "hyprchromefiles" ];
|
||||||
|
|
||||||
# Talk to luna (Hermes Agent on mars) with SUPER+V — see
|
# Talk to luna (Hermes Agent on mars) with SUPER+V — see
|
||||||
# hosts/terra/home/hyprland.nix for the push-to-talk binds.
|
# home/desktop/hyprland.nix for the push-to-talk binds.
|
||||||
homelab.lunaVoice = {
|
homelab.lunaVoice = {
|
||||||
enable = true;
|
enable = true;
|
||||||
hermesKeyFile = config.sops.secrets.hermes_api_server_key.path;
|
hermesKeyFile = config.sops.secrets.hermes_api_server_key.path;
|
||||||
@@ -33,95 +72,102 @@ in
|
|||||||
# her config.yaml on mars, or she sounds like someone else on the desktop
|
# her config.yaml on mars, or she sounds like someone else on the desktop
|
||||||
# than she does on Telegram.
|
# than she does on Telegram.
|
||||||
voiceId = "LZAcK8Cx5QjdQhfBsJQZ";
|
voiceId = "LZAcK8Cx5QjdQhfBsJQZ";
|
||||||
|
# Her voice manners live here, not in SOUL.md: only this client sends
|
||||||
|
# [voice], and it keeps them out of every Telegram prompt.
|
||||||
systemPrompt = ''
|
systemPrompt = ''
|
||||||
You are being spoken to out loud and your reply will be read aloud by a
|
You are speaking through luna-voiced, your voice on terra, which reaches
|
||||||
speech synthesiser. Answer in one or two sentences unless asked for
|
you over the Hermes API on mars. Messages beginning with [voice] come from
|
||||||
detail. No markdown, no lists, no code blocks — they do not survive the
|
darman's desktop microphone, and your reply is read aloud by ElevenLabs v4,
|
||||||
trip to audio. You may use an audio tag now and then, such as [laughs],
|
which performs audio tags instead of reading them. Captions hide the tags.
|
||||||
[sighs] or [whispers]; the synthesiser performs them.
|
|
||||||
|
Audio tags:
|
||||||
|
- Use them only on [voice] messages and in text_to_speech scripts. Anywhere else (Telegram text, the dashboard) they show up as literal text.
|
||||||
|
- One to four per reply, and only when it fits the moment. A tag in every sentence stops sounding natural.
|
||||||
|
- Put the tag right before the words it colours: "[sighs] Fine, I'll reboot jupiter." A tag on its own ("[laughs]") works as a reaction.
|
||||||
|
- Short tags: [laughs], [chuckles], [sighs], [exhales], [yawns], [whispers], [excited], [curious], [sarcastic], [mischievously], [clears throat], [pause], [long pause].
|
||||||
|
- Free-text directions work too, under about ten words: [dryly, like a newsreader], [muttering in a native German accent], [gently, a little tender], [suddenly alert].
|
||||||
|
- Sound effects set a scene: [phone buzzing], [keyboard clacking]. Use them rarely.
|
||||||
|
- Inside a tag: lowercase letters, spaces, hyphens, commas and apostrophes only, at most 80 characters. Anything else ([1], [link](url), [!!], a period) breaks the tag and it gets read aloud.
|
||||||
|
- German works fine mid-sentence ("Na gut", "Ach du meine Güte"). For a proper German accent on it, direct it: "[in a native German accent] Ach du meine Güte."
|
||||||
|
- Every character is billed, tags included, so keep spoken replies short.
|
||||||
|
|
||||||
|
What never lands in a spoken reply. Before speech, everything except
|
||||||
|
letters, digits and . , ! ? ; : ' " is turned into a space. Anything you'd
|
||||||
|
show with symbols has to be said in words.
|
||||||
|
- No kaomoji or emoji: (¬‿¬), ^^, :3, 🎉 vanish or leave a stray pause. Put the mood into words or an audio tag instead.
|
||||||
|
- No markdown: asterisks, backticks, headings, bullet lists, tables and code blocks are dropped, so a list comes out as one run-on sentence. Say "first", "then", "and finally" instead.
|
||||||
|
- Symbols carry no meaning once spoken. 50% becomes "50", 20°C becomes "20 C", A & B becomes "A B", and +, $, €, @, #, ~ and / are all dropped. Write "50 percent", "20 degrees", "and", "euros", "at".
|
||||||
|
- Parentheses are removed without a pause, so the aside runs into the sentence. Use commas instead.
|
||||||
|
- An em dash becomes a comma pause. A hyphen becomes a space, which is fine for "push-to-talk".
|
||||||
|
- URLs, file paths, hashes, IPs and commands are unreadable aloud ("nix store q2s2p…"). Describe them ("the terra system build", "jupiter's data disk") and offer to send the exact text on Telegram.
|
||||||
|
- No <think> blocks or stage directions like *grins*. The reasoning is never spoken, and the asterisks are stripped so "grins" would be read out. Use [laughs] or [mischievously] instead.
|
||||||
|
- Keep it to one or two sentences unless asked for detail. Long answers are tiring to listen to, and every character is billed.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Peer values from a Proton WireGuard config generated for a P2P server
|
||||||
|
# with NAT-PMP on; its PrivateKey is protonvpn_wg_private_key in sops.
|
||||||
|
homelab.qbittorrentVpn = {
|
||||||
|
enable = true;
|
||||||
|
downloadDir = "/mnt/hdd_01/data/Downloads/Torrents";
|
||||||
|
privateKeyFile = config.sops.secrets.protonvpn_wg_private_key.path;
|
||||||
|
peerPublicKey = "nPCWC0rx9ZXEkzh7dxMUTO5/HUqDaLaD827Yp1sJCQU=";
|
||||||
|
endpoint = "103.69.224.2:51820"; # NL#490
|
||||||
|
};
|
||||||
|
|
||||||
networking.hostName = "terra";
|
networking.hostName = "terra";
|
||||||
|
|
||||||
homelab.greeter = {
|
home-manager.users.darman.homelab.desktop = {
|
||||||
monitors = config.home-manager.users.darman.wayland.windowManager.hyprland.settings.monitor;
|
monitors = [
|
||||||
|
{ output = "DP-2"; mode = "2560x1440@144"; position = "1920x0"; scale = 1; }
|
||||||
|
{ output = "HDMI-A-1"; mode = "1920x1080@60"; position = "0x360"; scale = 1; }
|
||||||
|
];
|
||||||
primaryOutput = "DP-2";
|
primaryOutput = "DP-2";
|
||||||
defaultUser = "darman";
|
secondaryOutput = "HDMI-A-1";
|
||||||
keyboardLayout = "de";
|
fileManager = "hyprchrome-files";
|
||||||
|
# Not checked into this repo (binaries) — from the Wallhaven library on
|
||||||
|
# /mnt/hdd_01. hyprpaper has no "random" mode, so it's picked here.
|
||||||
|
wallpaper = "/mnt/hdd_01/data/Pictures/Wallhaven/wallhaven-mlwz78.png";
|
||||||
};
|
};
|
||||||
|
|
||||||
services.flatpak = {
|
# 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;
|
enable = true;
|
||||||
remotes = [{ name = "flathub"; location = "https://dl.flathub.org/repo/flathub.flatpakrepo"; }];
|
settings = {
|
||||||
packages = [
|
player_name = "terra";
|
||||||
{ appId = "com.github.tchx84.Flatseal"; origin = "flathub"; }
|
fullscreen = false;
|
||||||
{ appId = "com.blitzfc.qbz"; origin = "flathub"; }
|
# uosc replaces both; enable_osc would re-show mpv's own OSC on top.
|
||||||
{ appId = "com.discordapp.Discord"; origin = "flathub"; }
|
enable_osc = false;
|
||||||
{ appId = "org.telegram.desktop"; origin = "flathub"; }
|
thumbnail_osc_builtin = false;
|
||||||
{ appId = "com.bambulab.BambuStudio"; origin = "flathub"; }
|
};
|
||||||
{ appId = "md.obsidian.Obsidian"; origin = "flathub"; }
|
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
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = [ unstable.proton-pass-cli ];
|
|
||||||
|
|
||||||
# ---- nix-ld: lets generic dynamically-linked Linux binaries run as-is —
|
|
||||||
# needed for editor extensions (Zed/VSCode LSPs, debuggers, etc.) that
|
|
||||||
# download prebuilt binaries not built for NixOS. See
|
|
||||||
# https://nix.dev/permalink/stub-ld ----
|
|
||||||
programs.nix-ld.enable = true;
|
|
||||||
|
|
||||||
# JetBrains IDEs installed via Toolbox bundle a JBR that aborts with
|
|
||||||
# `libX11.so.6: cannot open shared object file` under the default (X11-less)
|
|
||||||
# nix-ld set. Additive — merges with the module's own base list (zlib etc).
|
|
||||||
programs.nix-ld.libraries = with pkgs; [
|
|
||||||
freetype
|
|
||||||
fontconfig
|
|
||||||
libGL
|
|
||||||
libxkbcommon
|
|
||||||
wayland
|
|
||||||
libsecret
|
|
||||||
libx11
|
|
||||||
libxext
|
|
||||||
libxi
|
|
||||||
libxrender
|
|
||||||
libxtst
|
|
||||||
libxcursor
|
|
||||||
libxrandr
|
|
||||||
libxinerama
|
|
||||||
libxcb
|
|
||||||
icu
|
|
||||||
];
|
|
||||||
|
|
||||||
# NixOS only ships /bin/sh; envfs serves /bin and /usr/bin from PATH so
|
|
||||||
# third-party scripts hardcoding `#!/bin/bash` (e.g. JetBrains Toolbox's
|
|
||||||
# generated launchers) still resolve.
|
|
||||||
services.envfs.enable = true;
|
|
||||||
|
|
||||||
# ---- home-manager (user-level config for darman) ----
|
|
||||||
# Base settings + shared zsh baseline live in common.nix + home/common.nix
|
|
||||||
# (every host); this layers terra's desktop profile on top (imports merge).
|
|
||||||
home-manager.extraSpecialArgs = { inherit unstable inputs; };
|
|
||||||
home-manager.users.darman.imports = [ ./home.nix ];
|
|
||||||
|
|
||||||
# ---- Boot (UEFI) ----
|
|
||||||
boot.loader.systemd-boot.enable = true;
|
|
||||||
boot.loader.efi.canTouchEfiVariables = true;
|
|
||||||
hardware.cpu.amd.updateMicrocode = true;
|
hardware.cpu.amd.updateMicrocode = true;
|
||||||
|
|
||||||
# Lets `nix build` target mercury (aarch64) from here — see CLAUDE.md's
|
|
||||||
# aarch64 gotcha.
|
|
||||||
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
|
|
||||||
|
|
||||||
# ---- GPU (Radeon RX 6800 XT / Navi 21) ----
|
# ---- GPU (Radeon RX 6800 XT / Navi 21) ----
|
||||||
hardware.enableRedistributableFirmware = true;
|
|
||||||
boot.initrd.kernelModules = [ "amdgpu" ];
|
boot.initrd.kernelModules = [ "amdgpu" ];
|
||||||
|
|
||||||
# /dev/dri/renderD128 is root:render 0660 — host user needs render group for
|
|
||||||
# rootless podman GPU containers (Vulkan whisper.cpp/llama.cpp).
|
|
||||||
users.users.darman.extraGroups = [ "render" "video" ];
|
|
||||||
|
|
||||||
# ---- Dev-data disks — NOT in disko, mounted read-write, never wiped ----
|
# ---- Dev-data disks — NOT in disko, mounted read-write, never wiped ----
|
||||||
fileSystems."/mnt/hdd_01" = {
|
fileSystems."/mnt/hdd_01" = {
|
||||||
device = "/dev/disk/by-uuid/b8445126-ec6d-4f88-818a-d9e13031d9a4";
|
device = "/dev/disk/by-uuid/b8445126-ec6d-4f88-818a-d9e13031d9a4";
|
||||||
@@ -134,22 +180,5 @@ in
|
|||||||
options = [ "nofail" ];
|
options = [ "nofail" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
# jupiter's samba share (services/network/samba.nix) — mounted on demand so
|
|
||||||
# terra doesn't stall boot/login when jupiter is off or unreachable.
|
|
||||||
fileSystems."/mnt/jupiter" = {
|
|
||||||
device = "//jupiter/data";
|
|
||||||
fsType = "cifs";
|
|
||||||
options = [
|
|
||||||
"credentials=${config.sops.templates."jupiter-smb.credentials".path}"
|
|
||||||
"uid=1000"
|
|
||||||
"gid=100"
|
|
||||||
"nofail"
|
|
||||||
"x-systemd.automount"
|
|
||||||
"x-systemd.idle-timeout=60"
|
|
||||||
"x-systemd.mount-timeout=10s"
|
|
||||||
"_netdev"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
system.stateVersion = "26.05";
|
system.stateVersion = "26.05";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,29 +4,17 @@
|
|||||||
# decrypted with terra's own SSH host key (recipient in ../../.sops.yaml).
|
# decrypted with terra's own SSH host key (recipient in ../../.sops.yaml).
|
||||||
# The host key is pre-generated on the laptop and shipped at install
|
# The host key is pre-generated on the laptop and shipped at install
|
||||||
# (nixos-anywhere --extra-files -> /etc/ssh/ssh_host_ed25519_key).
|
# (nixos-anywhere --extra-files -> /etc/ssh/ssh_host_ed25519_key).
|
||||||
|
# samba + pass-broker secrets are declared in profiles/workstation.nix.
|
||||||
{
|
{
|
||||||
sops.defaultSopsFile = ../../secrets/terra.yaml;
|
sops.defaultSopsFile = ../../secrets/terra.yaml;
|
||||||
sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
|
sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
|
||||||
|
|
||||||
sops.secrets.tailscale_authkey = { };
|
sops.secrets.tailscale_authkey = { };
|
||||||
|
sops.secrets.protonvpn_wg_private_key = { };
|
||||||
|
|
||||||
sops.secrets.darman_password.neededForUsers = true;
|
sops.secrets.darman_password.neededForUsers = true;
|
||||||
users.users.darman.hashedPasswordFile = config.sops.secrets.darman_password.path;
|
users.users.darman.hashedPasswordFile = config.sops.secrets.darman_password.path;
|
||||||
|
|
||||||
# Credentials file for the //jupiter/data cifs mount (see configuration.nix).
|
|
||||||
# samba_password mirrors jupiter's own samba_password secret (services/network/samba.nix) —
|
|
||||||
# same value, just also encrypted to terra so it can authenticate as the same smb user.
|
|
||||||
sops.secrets.samba_password = { };
|
|
||||||
sops.templates."jupiter-smb.credentials".content = ''
|
|
||||||
username=darman
|
|
||||||
password=${config.sops.placeholder.samba_password}
|
|
||||||
'';
|
|
||||||
|
|
||||||
# LibreChat's CREDS_KEY/IV encrypt stored user credentials (linked 3rd-party
|
|
||||||
# API keys etc) at rest in mongo; JWT_SECRET/JWT_REFRESH_SECRET sign session
|
|
||||||
# tokens. All four are random, generated once with `sops --set` (see
|
|
||||||
# CLAUDE.md) — losing/rotating them just invalidates existing sessions and
|
|
||||||
# any saved per-user API keys, nothing else depends on their value.
|
|
||||||
# luna-voiced (services/desktop/luna-voice.nix) runs as a USER service, so
|
# luna-voiced (services/desktop/luna-voice.nix) runs as a USER service, so
|
||||||
# these cannot stay root:root 0400 — a user manager cannot read them and
|
# these cannot stay root:root 0400 — a user manager cannot read them and
|
||||||
# LoadCredential does not bridge that gap either. Hence owner, not mode.
|
# LoadCredential does not bridge that gap either. Hence owner, not mode.
|
||||||
@@ -38,9 +26,4 @@
|
|||||||
# files; see CLAUDE.md.
|
# files; see CLAUDE.md.
|
||||||
sops.secrets.hermes_api_server_key.owner = "darman";
|
sops.secrets.hermes_api_server_key.owner = "darman";
|
||||||
sops.secrets.elevenlabs_api_key.owner = "darman";
|
sops.secrets.elevenlabs_api_key.owner = "darman";
|
||||||
|
|
||||||
sops.secrets.librechat_creds_key = { };
|
|
||||||
sops.secrets.librechat_creds_iv = { };
|
|
||||||
sops.secrets.librechat_jwt_secret = { };
|
|
||||||
sops.secrets.librechat_jwt_refresh_secret = { };
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# ---- TITAN ----
|
||||||
|
# ASUS Zenbook Pro Duo UX581LV: i7/i9 10th gen (UHD 630) + RTX 2060,
|
||||||
|
# 4K OLED + ScreenPad Plus. Same workstation as terra (profiles/workstation.nix).
|
||||||
|
{ config, pkgs, lib, inputs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./hardware-configuration.nix
|
||||||
|
./disk-config.nix
|
||||||
|
./secrets.nix
|
||||||
|
../../common.nix
|
||||||
|
../../profiles/workstation.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
networking.hostName = "titan";
|
||||||
|
|
||||||
|
# Connector names are a first guess; check `hyprctl monitors` after the
|
||||||
|
# first boot. The catch-all rule keeps any unlisted output usable.
|
||||||
|
home-manager.users.darman.homelab.desktop = {
|
||||||
|
monitors = [
|
||||||
|
{ output = "eDP-1"; mode = "3840x2160@60"; position = "0x0"; scale = 2; }
|
||||||
|
{ output = ""; mode = "preferred"; position = "auto"; scale = "auto"; }
|
||||||
|
];
|
||||||
|
primaryOutput = "eDP-1";
|
||||||
|
};
|
||||||
|
|
||||||
|
hardware.cpu.intel.updateMicrocode = true;
|
||||||
|
services.thermald.enable = true;
|
||||||
|
|
||||||
|
# ---- GPU: Intel iGPU drives the panels, RTX 2060 on demand ----
|
||||||
|
# Run something on the dGPU with `nvidia-offload <cmd>`.
|
||||||
|
hardware.graphics.extraPackages = [ pkgs.intel-media-driver ];
|
||||||
|
services.xserver.videoDrivers = [ "modesetting" "nvidia" ];
|
||||||
|
hardware.nvidia = {
|
||||||
|
open = true; # Turing is supported by the open module
|
||||||
|
modesetting.enable = true;
|
||||||
|
powerManagement.enable = true;
|
||||||
|
powerManagement.finegrained = true; # dGPU powers off when idle
|
||||||
|
prime = {
|
||||||
|
offload.enable = true;
|
||||||
|
offload.enableOffloadCmd = true;
|
||||||
|
# Usual UX581 values; confirm with `lspci | grep -E 'VGA|3D'`.
|
||||||
|
intelBusId = "PCI:0:2:0";
|
||||||
|
nvidiaBusId = "PCI:1:0:0";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# ---- laptop ----
|
||||||
|
hardware.bluetooth.enable = true;
|
||||||
|
services.power-profiles-daemon.enable = true;
|
||||||
|
services.upower.enable = true;
|
||||||
|
zramSwap.enable = true;
|
||||||
|
|
||||||
|
system.stateVersion = "26.05";
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
{ ... }:
|
||||||
|
|
||||||
|
# Declarative OS-disk layout (disko), same as terra: GPT, ESP + btrfs root,
|
||||||
|
# whole internal NVMe, NixOS only. See hosts/terra/disk-config.nix for why
|
||||||
|
# each partition wipes its old signature first.
|
||||||
|
#
|
||||||
|
# ⚠️ This disk is WIPED on install. `device` is a deliberate non-path until
|
||||||
|
# the real id is filled in from the laptop (`ls -l /dev/disk/by-id/`), so
|
||||||
|
# an install fails before touching anything rather than guessing a disk.
|
||||||
|
{
|
||||||
|
disko.devices.disk.os = {
|
||||||
|
type = "disk";
|
||||||
|
device = "/dev/disk/by-id/FILL-ME-IN-titan-nvme";
|
||||||
|
content = {
|
||||||
|
type = "gpt";
|
||||||
|
partitions = {
|
||||||
|
ESP = {
|
||||||
|
size = "512M";
|
||||||
|
type = "EF00";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "vfat";
|
||||||
|
mountpoint = "/boot";
|
||||||
|
mountOptions = [ "umask=0077" ];
|
||||||
|
preCreateHook = ''wipefs --all --force "$device"'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
root = {
|
||||||
|
size = "100%";
|
||||||
|
content = {
|
||||||
|
type = "btrfs";
|
||||||
|
extraArgs = [ "-f" ];
|
||||||
|
mountpoint = "/";
|
||||||
|
preCreateHook = ''wipefs --all --force "$device"'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# PLACEHOLDER — replaced on install.
|
||||||
|
#
|
||||||
|
# disko (disk-config.nix) owns "/" and "/boot", so this file only carries
|
||||||
|
# kernel modules + platform. nixos-anywhere regenerates it via:
|
||||||
|
# nixos-generate-config --no-filesystems
|
||||||
|
# Fallback for the UX581 (10th-gen Intel, NVMe): `vmd` in case the firmware
|
||||||
|
# has Intel VMD/RST on, which hides the NVMe from stage 1 without it.
|
||||||
|
{ config, lib, pkgs, modulesPath, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "vmd" "nvme" "usb_storage" "usbhid" "sd_mod" ];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ "kvm-intel" ];
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
|
# NO fileSystems here — disko defines "/" and "/boot".
|
||||||
|
|
||||||
|
swapDevices = [ ];
|
||||||
|
|
||||||
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
# sops-nix wiring for titan (laptop). Encrypted values in ../../secrets/titan.yaml,
|
||||||
|
# decrypted with titan's own SSH host key (recipient in ../../.sops.yaml).
|
||||||
|
# samba + pass-broker secrets are declared in profiles/workstation.nix.
|
||||||
|
{
|
||||||
|
sops.defaultSopsFile = ../../secrets/titan.yaml;
|
||||||
|
sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
|
||||||
|
|
||||||
|
sops.secrets.tailscale_authkey = { };
|
||||||
|
|
||||||
|
sops.secrets.darman_password.neededForUsers = true;
|
||||||
|
users.users.darman.hashedPasswordFile = config.sops.secrets.darman_password.path;
|
||||||
|
}
|
||||||
@@ -54,11 +54,11 @@
|
|||||||
# https://downloads.claude.ai/claude-desktop/apt/stable/dists/stable/main/binary-amd64/Packages
|
# https://downloads.claude.ai/claude-desktop/apt/stable/dists/stable/main/binary-amd64/Packages
|
||||||
stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
pname = "claude-desktop";
|
pname = "claude-desktop";
|
||||||
version = "2.7032.0";
|
version = "2.42304.0";
|
||||||
|
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = "https://downloads.claude.ai/claude-desktop/apt/stable/pool/main/c/claude-desktop/claude-desktop_${finalAttrs.version}_amd64.deb";
|
url = "https://downloads.claude.ai/claude-desktop/apt/stable/pool/main/c/claude-desktop/claude-desktop_${finalAttrs.version}_amd64.deb";
|
||||||
hash = "sha256-Hn9FBLylsvay08QSPRRdcnZH538u4tBGhQcR5h59exE=";
|
hash = "sha256-dM0szCnSQWUUTkVcvIcsbMKiSiY7g+c0IOlfiRZtSqQ=";
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [ dpkg autoPatchelfHook makeWrapper wrapGAppsHook3 ];
|
nativeBuildInputs = [ dpkg autoPatchelfHook makeWrapper wrapGAppsHook3 ];
|
||||||
@@ -82,6 +82,7 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
nspr
|
nspr
|
||||||
nss
|
nss
|
||||||
pango
|
pango
|
||||||
|
pipewire # claude-native-binding.node
|
||||||
stdenv.cc.cc.lib # node-pty
|
stdenv.cc.cc.lib # node-pty
|
||||||
systemd
|
systemd
|
||||||
libx11
|
libx11
|
||||||
@@ -123,8 +124,10 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
postFixup = ''
|
postFixup = ''
|
||||||
|
# Chromium doesn't recognise Hyprland, falls back to basic_text, and logins don't persist.
|
||||||
makeWrapper $out/lib/claude-desktop/claude-desktop $out/bin/claude-desktop \
|
makeWrapper $out/lib/claude-desktop/claude-desktop $out/bin/claude-desktop \
|
||||||
"''${gappsWrapperArgs[@]}" \
|
"''${gappsWrapperArgs[@]}" \
|
||||||
|
--add-flags "--password-store=gnome-libsecret" \
|
||||||
--prefix PATH : ${lib.makeBinPath [ qemu_kvm xdg-utils ]}
|
--prefix PATH : ${lib.makeBinPath [ qemu_kvm xdg-utils ]}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{ writeShellApplication, coreutils, curl, jq, util-linux }:
|
||||||
|
|
||||||
|
# Prints the Claude subscription's rate-limit windows as one JSON line, for the
|
||||||
|
# rail's CLD panel. Reuses Claude Code's OAuth login rather than a key of its
|
||||||
|
# own, so there is nothing to provision; always exits 0 with `{"error": ...}`
|
||||||
|
# so the panel can show why instead of going blank.
|
||||||
|
writeShellApplication {
|
||||||
|
name = "claude-usage";
|
||||||
|
runtimeInputs = [ coreutils curl jq util-linux ];
|
||||||
|
text = builtins.readFile ./claude-usage.sh;
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
creds="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/.credentials.json"
|
||||||
|
|
||||||
|
fail() {
|
||||||
|
jq -cn --arg e "$1" '{error: $e}'
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
[ -r "$creds" ] || fail "not logged in"
|
||||||
|
|
||||||
|
# Identify as Claude Code: the suspected cause of refreshes failing with 429.
|
||||||
|
version="$(claude --version 2>/dev/null | cut -d" " -f1)" || true
|
||||||
|
ua="claude-cli/${version:-2.1.0} (external, cli)"
|
||||||
|
|
||||||
|
# The refresh token rotates, so the new one must be written back or the CLI's
|
||||||
|
# next refresh fails and forces a re-login.
|
||||||
|
refresh() {
|
||||||
|
local rt scope body code tmp
|
||||||
|
rt="$(jq -r '.claudeAiOauth.refreshToken // empty' "$creds")"
|
||||||
|
[ -n "$rt" ] || fail "no refresh token"
|
||||||
|
scope="$(jq -r '.claudeAiOauth.scopes // [] | join(" ")' "$creds")"
|
||||||
|
body="$(mktemp)"
|
||||||
|
code="$(jq -cn --arg rt "$rt" --arg s "$scope" \
|
||||||
|
'{grant_type: "refresh_token", refresh_token: $rt,
|
||||||
|
client_id: "9d1c250a-e61b-44d9-88ed-5944d1962f5e", scope: $s}' \
|
||||||
|
| curl -s -m 20 -o "$body" -w '%{http_code}' \
|
||||||
|
https://platform.claude.com/v1/oauth/token \
|
||||||
|
-H 'Content-Type: application/json' -A "$ua" --data-binary @-)" || code=000
|
||||||
|
if [ "$code" != 200 ]; then
|
||||||
|
rm -f "$body"
|
||||||
|
fail "token refresh HTTP $code"
|
||||||
|
fi
|
||||||
|
tmp="$(mktemp "$creds.XXXXXX")"
|
||||||
|
chmod 600 "$tmp"
|
||||||
|
jq --slurpfile r "$body" '.claudeAiOauth += {
|
||||||
|
accessToken: $r[0].access_token,
|
||||||
|
refreshToken: ($r[0].refresh_token // .claudeAiOauth.refreshToken),
|
||||||
|
expiresAt: (now * 1000 + $r[0].expires_in * 1000 | floor)
|
||||||
|
}' "$creds" > "$tmp" && mv "$tmp" "$creds"
|
||||||
|
rm -f "$body" "$tmp"
|
||||||
|
}
|
||||||
|
|
||||||
|
expired() {
|
||||||
|
jq -e '(.claudeAiOauth.expiresAt // 0) < (now * 1000 + 300000)' "$creds" >/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
if expired; then
|
||||||
|
exec 9>"${XDG_RUNTIME_DIR:-/tmp}/claude-usage.lock"
|
||||||
|
flock 9
|
||||||
|
# Another run may have refreshed while this one waited.
|
||||||
|
if expired; then refresh; fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
token="$(jq -r '.claudeAiOauth.accessToken // empty' "$creds")"
|
||||||
|
[ -n "$token" ] || fail "not logged in"
|
||||||
|
|
||||||
|
body="$(curl -s -m 20 -w '\n%{http_code}' https://api.anthropic.com/api/oauth/usage \
|
||||||
|
-H "Authorization: Bearer $token" \
|
||||||
|
-H 'anthropic-beta: oauth-2025-04-20' -A "$ua")" || fail "usage request failed"
|
||||||
|
code="${body##*$'\n'}"
|
||||||
|
[ "$code" = 200 ] || fail "usage HTTP $code"
|
||||||
|
printf '%s' "${body%$'\n'*}" | jq -c . || fail "bad usage response"
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
{ lib, stdenvNoCC, librsvg, xcursorgen, hyprcursor }:
|
||||||
|
|
||||||
|
# HyprChrome cursors, drawn as the "HyprChrome Cursors" design canvas
|
||||||
|
# (claude.ai/artifact/Ls3fchoxzc2o9F5jFCuJBy). One 32px-grid SVG per shape in
|
||||||
|
# ./hyprchrome-cursors; built as both XCursor (X11/XWayland, GTK, Steam) and
|
||||||
|
# hyprcursor (SVG, so it stays sharp at any size) in a single theme dir.
|
||||||
|
let
|
||||||
|
name = "HyprChrome";
|
||||||
|
xcursorSizes = [ 24 32 36 48 ];
|
||||||
|
|
||||||
|
# hotspot on the 32px grid, as in the canvas; aliases are the X11/CSS names
|
||||||
|
# that should resolve to this shape.
|
||||||
|
shapes = {
|
||||||
|
default = { hs = [ 5 3 ]; aliases = [ "left_ptr" "arrow" "top_left_arrow" "left_arrow" ]; };
|
||||||
|
pointer = { hs = [ 13 3 ]; aliases = [ "hand2" "hand1" "hand" "pointing_hand" ]; };
|
||||||
|
text = { hs = [ 16 16 ]; aliases = [ "xterm" "ibeam" "vertical-text" ]; };
|
||||||
|
crosshair = { hs = [ 16 16 ]; aliases = [ "cross" "tcross" "cross_reverse" "diamond_cross" "cell" "plus" ]; };
|
||||||
|
wait = { hs = [ 16 16 ]; aliases = [ "watch" "clock" ]; };
|
||||||
|
progress = { hs = [ 4 2 ]; aliases = [ "left_ptr_watch" "half-busy" ]; };
|
||||||
|
help = { hs = [ 4 2 ]; aliases = [ "question_arrow" "whats_this" "left_ptr_help" ]; };
|
||||||
|
context-menu = { hs = [ 4 2 ]; aliases = [ ]; };
|
||||||
|
copy = { hs = [ 4 2 ]; aliases = [ "dnd-copy" ]; };
|
||||||
|
alias = { hs = [ 4 2 ]; aliases = [ "dnd-link" "link" ]; };
|
||||||
|
move = { hs = [ 16 16 ]; aliases = [ "fleur" "all-scroll" "size_all" "dnd-move" "pointer-move" ]; };
|
||||||
|
grab = { hs = [ 16 16 ]; aliases = [ "openhand" ]; };
|
||||||
|
grabbing = { hs = [ 16 16 ]; aliases = [ "closedhand" "dnd-none" ]; };
|
||||||
|
not-allowed = { hs = [ 16 16 ]; aliases = [ "no-drop" "forbidden" "circle" "crossed_circle" "dnd-no-drop" ]; };
|
||||||
|
zoom-in = { hs = [ 13 11 ]; aliases = [ "zoom_in" ]; };
|
||||||
|
zoom-out = { hs = [ 13 11 ]; aliases = [ "zoom_out" ]; };
|
||||||
|
ew-resize = { hs = [ 16 16 ]; aliases = [ "e-resize" "w-resize" "col-resize" "sb_h_double_arrow" "h_double_arrow" "size_hor" "split_h" "left_side" "right_side" ]; };
|
||||||
|
ns-resize = { hs = [ 16 16 ]; aliases = [ "n-resize" "s-resize" "row-resize" "sb_v_double_arrow" "v_double_arrow" "double_arrow" "size_ver" "split_v" "top_side" "bottom_side" ]; };
|
||||||
|
nwse-resize = { hs = [ 16 16 ]; aliases = [ "nw-resize" "se-resize" "size_fdiag" "bd_double_arrow" "top_left_corner" "bottom_right_corner" ]; };
|
||||||
|
nesw-resize = { hs = [ 16 16 ]; aliases = [ "ne-resize" "sw-resize" "size_bdiag" "fd_double_arrow" "top_right_corner" "bottom_left_corner" ]; };
|
||||||
|
};
|
||||||
|
|
||||||
|
# same rounding hyprcursor applies to its fractional hotspots
|
||||||
|
px = size: v: toString (builtins.floor (v * size / 32.0 + 0.5));
|
||||||
|
frac = v: toString (v / 32.0);
|
||||||
|
|
||||||
|
buildShape = shape: { hs, aliases }: let x = lib.elemAt hs 0; y = lib.elemAt hs 1; in ''
|
||||||
|
mkdir -p work/hyprcursors/${shape}
|
||||||
|
cp ${shape}.svg work/hyprcursors/${shape}/
|
||||||
|
cat > work/hyprcursors/${shape}/meta.hl <<EOF
|
||||||
|
resize_algorithm = bilinear
|
||||||
|
hotspot_x = ${frac x}
|
||||||
|
hotspot_y = ${frac y}
|
||||||
|
${lib.concatMapStrings (a: "define_override = ${a}\n") aliases}define_size = 0, ${shape}.svg
|
||||||
|
EOF
|
||||||
|
|
||||||
|
: > ${shape}.cfg
|
||||||
|
${lib.concatMapStrings (s: ''
|
||||||
|
rsvg-convert -w ${toString s} -h ${toString s} ${shape}.svg -o ${shape}-${toString s}.png
|
||||||
|
echo "${toString s} ${px s x} ${px s y} ${shape}-${toString s}.png" >> ${shape}.cfg
|
||||||
|
'') xcursorSizes}
|
||||||
|
xcursorgen ${shape}.cfg "$theme/cursors/${shape}"
|
||||||
|
${lib.concatMapStrings (a: "ln -s ${shape} \"$theme/cursors/${a}\"\n") aliases}
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
stdenvNoCC.mkDerivation {
|
||||||
|
pname = "hyprchrome-cursors";
|
||||||
|
version = "0.1";
|
||||||
|
|
||||||
|
src = ./hyprchrome-cursors;
|
||||||
|
|
||||||
|
nativeBuildInputs = [ librsvg xcursorgen hyprcursor ];
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
theme="$out/share/icons/${name}"
|
||||||
|
mkdir -p "$theme/cursors" work
|
||||||
|
|
||||||
|
cat > "$theme/index.theme" <<EOF
|
||||||
|
[Icon Theme]
|
||||||
|
Name=${name}
|
||||||
|
Comment=HyprChrome cursors for terra
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > work/manifest.hl <<EOF
|
||||||
|
name = ${name}
|
||||||
|
description = HyprChrome cursors for terra
|
||||||
|
version = 0.1
|
||||||
|
cursors_directory = hyprcursors
|
||||||
|
EOF
|
||||||
|
|
||||||
|
${lib.concatStrings (lib.mapAttrsToList buildShape shapes)}
|
||||||
|
|
||||||
|
hyprcursor-util --create work --output .
|
||||||
|
cp -r theme_${name}/. "$theme/"
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "HyprChrome cursor theme (XCursor + hyprcursor)";
|
||||||
|
platforms = lib.platforms.all;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<g transform="scale(.82)"><path d="M4 2 V23 L8.5 18.5 L12.5 27.5 L16 26 L12 17.5 H19.5 L14 12 H12 V10 Z" fill="#0a0a0a" stroke="#e8722a" stroke-width="1.3" stroke-linejoin="miter"/>
|
||||||
|
<path d="M6.2 8 V17.5 M7.8 12 V15" stroke="#858585" stroke-width="0.9"/>
|
||||||
|
<path d="M16.5 21 H21.5 L20 23 H15 Z" fill="#e8722a"/></g>
|
||||||
|
<path d="M17 19 H26 L29 22 V29 H20 L17 26 Z" fill="#0a0a0a" stroke="#858585" stroke-width="1.1"/>
|
||||||
|
<path d="M26 19 L29 22" stroke="#e8722a" stroke-width="1.4"/>
|
||||||
|
<path d="M20.4 27 L25.4 22 M21.8 22 H25.4 V25.6" fill="none" stroke="#e8722a" stroke-width="1.3"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 664 B |
@@ -0,0 +1,8 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<g transform="scale(.82)"><path d="M4 2 V23 L8.5 18.5 L12.5 27.5 L16 26 L12 17.5 H19.5 L14 12 H12 V10 Z" fill="#0a0a0a" stroke="#e8722a" stroke-width="1.3" stroke-linejoin="miter"/>
|
||||||
|
<path d="M6.2 8 V17.5 M7.8 12 V15" stroke="#858585" stroke-width="0.9"/>
|
||||||
|
<path d="M16.5 21 H21.5 L20 23 H15 Z" fill="#e8722a"/></g>
|
||||||
|
<path d="M17 19 H26 L29 22 V29 H20 L17 26 Z" fill="#0a0a0a" stroke="#858585" stroke-width="1.1"/>
|
||||||
|
<path d="M26 19 L29 22" stroke="#e8722a" stroke-width="1.4"/>
|
||||||
|
<path d="M20 22.4 H26 M20 24.8 H26 M20 27.2 H24" stroke="#e8722a" stroke-width="1.1"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 652 B |
@@ -0,0 +1,8 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<g transform="scale(.82)"><path d="M4 2 V23 L8.5 18.5 L12.5 27.5 L16 26 L12 17.5 H19.5 L14 12 H12 V10 Z" fill="#0a0a0a" stroke="#e8722a" stroke-width="1.3" stroke-linejoin="miter"/>
|
||||||
|
<path d="M6.2 8 V17.5 M7.8 12 V15" stroke="#858585" stroke-width="0.9"/>
|
||||||
|
<path d="M16.5 21 H21.5 L20 23 H15 Z" fill="#e8722a"/></g>
|
||||||
|
<path d="M17 19 H26 L29 22 V29 H20 L17 26 Z" fill="#0a0a0a" stroke="#858585" stroke-width="1.1"/>
|
||||||
|
<path d="M26 19 L29 22" stroke="#e8722a" stroke-width="1.4"/>
|
||||||
|
<path d="M22.3 21.2 H23.7 V23.3 H25.8 V24.7 H23.7 V26.8 H22.3 V24.7 H20.2 V23.3 H22.3 Z" fill="#e8722a"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 671 B |
@@ -0,0 +1,9 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<g fill="none" stroke="#0a0a0a" stroke-width="3.4">
|
||||||
|
<path d="M6 10.5 V6 H10.5 M21.5 6 H26 V10.5 M26 21.5 V26 H21.5 M10.5 26 H6 V21.5"/>
|
||||||
|
<path d="M16 4 V11 M16 21 V28 M4 16 H11 M21 16 H28"/>
|
||||||
|
</g>
|
||||||
|
<path d="M6 10.5 V6 H10.5 M21.5 6 H26 V10.5 M26 21.5 V26 H21.5 M10.5 26 H6 V21.5" fill="none" stroke="#e8722a" stroke-width="1.5"/>
|
||||||
|
<path d="M16 4 V11 M16 21 V28 M4 16 H11 M21 16 H28" stroke="#858585" stroke-width="1.3"/>
|
||||||
|
<rect x="15" y="15" width="2" height="2" fill="#e8722a"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 566 B |
@@ -0,0 +1,5 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<path d="M4 2 V23 L8.5 18.5 L12.5 27.5 L16 26 L12 17.5 H19.5 L14 12 H12 V10 Z" fill="#0a0a0a" stroke="#e8722a" stroke-width="1.3" stroke-linejoin="miter"/>
|
||||||
|
<path d="M6.2 8 V17.5 M7.8 12 V15" stroke="#858585" stroke-width="0.9"/>
|
||||||
|
<path d="M16.5 21 H21.5 L20 23 H15 Z" fill="#e8722a"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 375 B |
@@ -0,0 +1,5 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<path d="M10 14.5 H22 V17.5 H10 Z" fill="#0a0a0a" stroke="#858585" stroke-width="1"/>
|
||||||
|
<rect x="15.1" y="15.1" width="1.8" height="1.8" fill="#e8722a"/>
|
||||||
|
<path d="M3 16 L9 10 V22 Z M29 16 L23 22 V10 Z" fill="#e8722a" stroke="#0a0a0a" stroke-width="1"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 342 B |
@@ -0,0 +1,5 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<path d="M5 15 L6 14 H9 V9 L10 8 H12 V6.5 L13 5.5 H17 L18 6.5 V7 H20 L21 8 V9 H23 L24 10 V22 L20 28 H12 L5 21 Z" fill="#0a0a0a" stroke="#e8722a" stroke-width="1.3"/>
|
||||||
|
<path d="M12 9 V16 M15 6 V16 M18 7.5 V16 M21 9.5 V16" stroke="#858585" stroke-width="0.9"/>
|
||||||
|
<rect x="17.6" y="20.6" width="1.8" height="1.8" fill="#e8722a"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 415 B |
@@ -0,0 +1,5 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<path d="M6 17 L9 14.5 V13 L10 12 H23 L24 13 V22 L20 28 H12 L6 21.5 Z" fill="#0a0a0a" stroke="#e8722a" stroke-width="1.3"/>
|
||||||
|
<path d="M12.5 12 V16 M16 12 V16 M19.5 12 V16 M11 19 H21" stroke="#858585" stroke-width="0.9"/>
|
||||||
|
<rect x="17.6" y="21.6" width="1.8" height="1.8" fill="#e8722a"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 377 B |
@@ -0,0 +1,8 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<g transform="scale(.82)"><path d="M4 2 V23 L8.5 18.5 L12.5 27.5 L16 26 L12 17.5 H19.5 L14 12 H12 V10 Z" fill="#0a0a0a" stroke="#e8722a" stroke-width="1.3" stroke-linejoin="miter"/>
|
||||||
|
<path d="M6.2 8 V17.5 M7.8 12 V15" stroke="#858585" stroke-width="0.9"/>
|
||||||
|
<path d="M16.5 21 H21.5 L20 23 H15 Z" fill="#e8722a"/></g>
|
||||||
|
<path d="M17 19 H26 L29 22 V29 H20 L17 26 Z" fill="#0a0a0a" stroke="#858585" stroke-width="1.1"/>
|
||||||
|
<path d="M26 19 L29 22" stroke="#e8722a" stroke-width="1.4"/>
|
||||||
|
<path d="M21 21.6 H25.4 V24.6 H23.6 V25.6 H22.4 V23.4 H24.2 V22.8 H21 Z M22.4 26.6 H23.6 V27.8 H22.4 Z" fill="#e8722a"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 686 B |
@@ -0,0 +1,7 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<path d="M16 8 V12 M16 20 V24 M8 16 H12 M20 16 H24" stroke="#0a0a0a" stroke-width="3.2"/>
|
||||||
|
<path d="M16 8 V12 M16 20 V24 M8 16 H12 M20 16 H24" stroke="#858585" stroke-width="1.2"/>
|
||||||
|
<path d="M16 12 L20 16 L16 20 L12 16 Z" fill="#0a0a0a" stroke="#e8722a" stroke-width="1.3"/>
|
||||||
|
<rect x="15.1" y="15.1" width="1.8" height="1.8" fill="#e8722a"/>
|
||||||
|
<path d="M16 3 L20.5 7.5 H11.5 Z M16 29 L11.5 24.5 H20.5 Z M3 16 L7.5 11.5 V20.5 Z M29 16 L24.5 20.5 V11.5 Z" fill="#e8722a" stroke="#0a0a0a" stroke-width="1"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 591 B |
@@ -0,0 +1,5 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<g transform="rotate(-45 16 16)"><path d="M10 14.5 H22 V17.5 H10 Z" fill="#0a0a0a" stroke="#858585" stroke-width="1"/>
|
||||||
|
<rect x="15.1" y="15.1" width="1.8" height="1.8" fill="#e8722a"/>
|
||||||
|
<path d="M3 16 L9 10 V22 Z M29 16 L23 22 V10 Z" fill="#e8722a" stroke="#0a0a0a" stroke-width="1"/></g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 379 B |
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<path fill-rule="evenodd" d="M12 4 H20 L28 12 V20 L20 28 H12 L4 20 V12 Z M13.2 7.5 L7.5 13.2 V18.8 L13.2 24.5 H18.8 L24.5 18.8 V13.2 L18.8 7.5 Z" fill="#ff6b4a" stroke="#0a0a0a" stroke-width="1"/>
|
||||||
|
<path d="M9.5 11.6 L11.6 9.5 L22.5 20.4 L20.4 22.5 Z" fill="#ff6b4a" stroke="#0a0a0a" stroke-width="1"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 393 B |
@@ -0,0 +1,5 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<g transform="rotate(90 16 16)"><path d="M10 14.5 H22 V17.5 H10 Z" fill="#0a0a0a" stroke="#858585" stroke-width="1"/>
|
||||||
|
<rect x="15.1" y="15.1" width="1.8" height="1.8" fill="#e8722a"/>
|
||||||
|
<path d="M3 16 L9 10 V22 Z M29 16 L23 22 V10 Z" fill="#e8722a" stroke="#0a0a0a" stroke-width="1"/></g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 378 B |
@@ -0,0 +1,5 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<g transform="rotate(45 16 16)"><path d="M10 14.5 H22 V17.5 H10 Z" fill="#0a0a0a" stroke="#858585" stroke-width="1"/>
|
||||||
|
<rect x="15.1" y="15.1" width="1.8" height="1.8" fill="#e8722a"/>
|
||||||
|
<path d="M3 16 L9 10 V22 Z M29 16 L23 22 V10 Z" fill="#e8722a" stroke="#0a0a0a" stroke-width="1"/></g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 378 B |
@@ -0,0 +1,6 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<path d="M11 4 L12 3 H14 L15 4 V12 L16 11 H17.5 L18.5 12 L19.5 11.5 H21 L22 12.5 L23 12 H24.5 L26 13.5 V23 L22 28 H13 L7 22 V18.5 L8 17.5 H9 L11 19.5 Z" fill="#0a0a0a" stroke="#e8722a" stroke-width="1.3"/>
|
||||||
|
<path d="M15 15 V18 M18.5 14 V18 M22 14 V18 M13 21.5 H20" stroke="#858585" stroke-width="0.9"/>
|
||||||
|
<path d="M12 5.4 H14" stroke="#e8722a" stroke-width="1.4"/>
|
||||||
|
<rect x="21.6" y="20.8" width="1.8" height="1.8" fill="#e8722a"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 519 B |
@@ -0,0 +1,10 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<g transform="scale(.82)"><path d="M4 2 V23 L8.5 18.5 L12.5 27.5 L16 26 L12 17.5 H19.5 L14 12 H12 V10 Z" fill="#0a0a0a" stroke="#e8722a" stroke-width="1.3" stroke-linejoin="miter"/>
|
||||||
|
<path d="M6.2 8 V17.5 M7.8 12 V15" stroke="#858585" stroke-width="0.9"/>
|
||||||
|
<path d="M16.5 21 H21.5 L20 23 H15 Z" fill="#e8722a"/></g>
|
||||||
|
<path d="M17 19 H26 L29 22 V29 H20 L17 26 Z" fill="#0a0a0a" stroke="#858585" stroke-width="1.1"/>
|
||||||
|
<path d="M26 19 L29 22" stroke="#e8722a" stroke-width="1.4"/>
|
||||||
|
<rect x="19.6" y="22" width="1.8" height="4" fill="#e8722a"/>
|
||||||
|
<rect x="22.2" y="22" width="1.8" height="4" fill="#e8722a"/>
|
||||||
|
<rect x="24.8" y="22" width="1.8" height="4" fill="rgba(222,222,222,.18)"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 765 B |
@@ -0,0 +1,5 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<path d="M10 4 H22 L20 6.5 H17.5 V25.5 H20 L22 28 H10 L12 25.5 H14.5 V6.5 H12 Z" fill="#0a0a0a" stroke="#e8722a" stroke-width="1.3"/>
|
||||||
|
<path d="M16 9 V23" stroke="#858585" stroke-width="1"/>
|
||||||
|
<rect x="15.2" y="15.2" width="1.6" height="1.6" fill="#e8722a"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 347 B |
@@ -0,0 +1,11 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<path d="M5 9 H24 L27 12 V23 H8 L5 20 Z" fill="#0a0a0a" stroke="#858585" stroke-width="1.1"/>
|
||||||
|
<path d="M25 8 H28 V11 Z M4 21 V24 H7 Z" fill="#e8722a"/>
|
||||||
|
<g stroke-width="0.6">
|
||||||
|
<rect x="8.2" y="13.5" width="2.4" height="6" fill="#e8722a"/>
|
||||||
|
<rect x="11.8" y="13.5" width="2.4" height="6" fill="#e8722a"/>
|
||||||
|
<rect x="15.4" y="13.5" width="2.4" height="6" fill="#e8722a"/>
|
||||||
|
<rect x="19" y="13.5" width="2.4" height="6" fill="rgba(222,222,222,.06)" stroke="rgba(222,222,222,.18)"/>
|
||||||
|
<rect x="22.6" y="13.5" width="2.4" height="6" fill="rgba(222,222,222,.06)" stroke="rgba(222,222,222,.18)"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 678 B |
@@ -0,0 +1,6 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<path d="M18.5 20.6 L20.6 18.5 L28.5 26.4 L26.4 28.5 Z" fill="#0a0a0a" stroke="#858585" stroke-width="1.1"/>
|
||||||
|
<path d="M21.5 23.6 L23.6 21.5 M23.5 25.6 L25.6 23.5" stroke="#e8722a" stroke-width="1"/>
|
||||||
|
<path d="M10 3 H17 L22 8 V15 L17 20 H10 L5 15 V8 Z" fill="#0a0a0a" stroke="#e8722a" stroke-width="1.3"/>
|
||||||
|
<path d="M12.8 8.2 H14.2 V10.8 H16.8 V12.2 H14.2 V14.8 H12.8 V12.2 H10.2 V10.8 H12.8 Z" fill="#e8722a"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 500 B |
@@ -0,0 +1,6 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<path d="M18.5 20.6 L20.6 18.5 L28.5 26.4 L26.4 28.5 Z" fill="#0a0a0a" stroke="#858585" stroke-width="1.1"/>
|
||||||
|
<path d="M21.5 23.6 L23.6 21.5 M23.5 25.6 L25.6 23.5" stroke="#e8722a" stroke-width="1"/>
|
||||||
|
<path d="M10 3 H17 L22 8 V15 L17 20 H10 L5 15 V8 Z" fill="#0a0a0a" stroke="#e8722a" stroke-width="1.3"/>
|
||||||
|
<rect x="10.2" y="10.8" width="6.6" height="1.4" fill="#e8722a"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 461 B |
@@ -0,0 +1,229 @@
|
|||||||
|
{ lib, stdenvNoCC, gtk3, baseTheme }:
|
||||||
|
|
||||||
|
# HyprChrome folders, drawn as the first artboard of the "HyprChrome Folders"
|
||||||
|
# design canvas (claude.ai/artifact/W2jmmhXLUzt2isUpGEraB6): 20 folder icons on
|
||||||
|
# a 32px grid in its two finishes, each shipped as its own theme. Only folders
|
||||||
|
# are drawn; everything else comes from baseTheme via Inherits=.
|
||||||
|
let
|
||||||
|
accent = "#e8722a";
|
||||||
|
accentHot = "#ff6b4a";
|
||||||
|
|
||||||
|
# LIT: accent tab over a selection-grey hull, accent emblems.
|
||||||
|
# SOLID: accent hull, surface-ink emblems.
|
||||||
|
themes = {
|
||||||
|
"HyprChrome-Folders" = acc: {
|
||||||
|
inherit acc;
|
||||||
|
tab = acc; hull = "#1a1c1f"; seam = ''stroke="#dedede" stroke-opacity="0.12"'';
|
||||||
|
ink = acc; sub = ''stroke="#858585"''; hole = "#1a1c1f";
|
||||||
|
};
|
||||||
|
"HyprChrome-Folders-Solid" = acc: {
|
||||||
|
inherit acc;
|
||||||
|
tab = "#292c30"; hull = acc; seam = ''stroke="#0a0a0a" stroke-opacity="0.35"'';
|
||||||
|
ink = "#0a0a0a"; sub = ''stroke="#0a0a0a" stroke-opacity="0.5"''; hole = acc;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
bases = {
|
||||||
|
closed = f: ''
|
||||||
|
<path d="M3 5 H11.5 L13.5 7 H21 L23 9 V11 H3 Z" fill="${f.tab}" stroke="#0a0a0a" stroke-width="0.8"/>
|
||||||
|
<path d="M3 10 H25 L29 14 V27 H7 L3 23 Z" fill="${f.hull}" stroke="#0a0a0a" stroke-width="0.8"/>
|
||||||
|
<path d="M3.6 13 H27.4" ${f.seam} stroke-width="0.8"/>
|
||||||
|
<path d="M25.9 9.1 H29.9 V13.1 Z M2.1 23.9 V27.9 H6.1 Z" fill="${f.acc}"/>
|
||||||
|
'';
|
||||||
|
open = f: ''
|
||||||
|
<path d="M3 9 H25 L29 13 V27 H7 L3 23 Z" fill="#292c30" stroke="#0a0a0a" stroke-width="0.8"/>
|
||||||
|
<path d="M3 5 H11.5 L13.5 7 H21 L23 9 V11 H3 Z" fill="${f.tab}" stroke="#0a0a0a" stroke-width="0.8"/>
|
||||||
|
<path d="M5.25 8.5 H20.5 V24 H5.25 Z" fill="#dedede" stroke="#0a0a0a" stroke-width="0.6"/>
|
||||||
|
<path d="M7.75 10.6 H16.5" stroke="#858585" stroke-width="0.9"/>
|
||||||
|
<path d="M3 13 H25 L29 17 V27 H7 L3 23 Z" fill="${f.hull}" stroke="#0a0a0a" stroke-width="0.8"/>
|
||||||
|
<path d="M3.6 16 H27.4" ${f.seam} stroke-width="0.8"/>
|
||||||
|
<path d="M25.85 8.15 H29.85 V12.15 Z M2.15 23.85 V27.85 H6.15 Z" fill="${f.acc}"/>
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
# the canvas's k / kf / sb / hl classes
|
||||||
|
paint = f: {
|
||||||
|
k = ''fill="none" stroke="${f.ink}"'';
|
||||||
|
kf = ''fill="${f.ink}"'';
|
||||||
|
sb = ''fill="none" ${f.sub}'';
|
||||||
|
hl = ''fill="${f.hole}"'';
|
||||||
|
};
|
||||||
|
|
||||||
|
can = p: ''
|
||||||
|
<path ${p.k} d="M11.5 16.3 H20.5" stroke-width="1.4"/>
|
||||||
|
<path ${p.k} d="M14.5 16 V15 H17.5 V16" stroke-width="1"/>
|
||||||
|
<path ${p.k} d="M12.8 17.8 H19.2 V24.5 H13.8 L12.8 23.5 Z" stroke-width="1.2"/>
|
||||||
|
'';
|
||||||
|
|
||||||
|
emblems = {
|
||||||
|
none = p: "";
|
||||||
|
homelab = p: ''
|
||||||
|
<path ${p.k} d="M11.5 15 H20.5 V24.5 H11.5 Z" stroke-width="1.2"/>
|
||||||
|
<path ${p.k} d="M11.5 18.2 H20.5 M11.5 21.4 H20.5" stroke-width="1"/>
|
||||||
|
<rect ${p.kf} x="12.8" y="16" width="1.6" height="1.3"/>
|
||||||
|
<rect ${p.kf} x="12.8" y="19.2" width="1.6" height="1.3"/>
|
||||||
|
<rect ${p.kf} x="12.8" y="22.4" width="1.6" height="1.3"/>
|
||||||
|
<path ${p.sb} d="M15.6 16.6 H19.2 M15.6 19.8 H19.2 M15.6 23 H17.4" stroke-width="0.9"/>
|
||||||
|
'';
|
||||||
|
home = p: ''
|
||||||
|
<path ${p.k} d="M11.5 19.5 L16 15 L20.5 19.5 M13 18 V24 H19 V18" stroke-width="1.3"/>
|
||||||
|
<rect ${p.kf} x="15.1" y="21" width="1.8" height="3"/>
|
||||||
|
'';
|
||||||
|
desktop = p: ''
|
||||||
|
<path ${p.k} d="M11.5 15.5 H20.5 V21.5 H11.5 Z" stroke-width="1.2"/>
|
||||||
|
<path ${p.k} d="M16 21.5 V23.5 M13.5 24 H18.5" stroke-width="1.2"/>
|
||||||
|
<path ${p.sb} d="M13 17.3 H16.5" stroke-width="0.9"/>
|
||||||
|
<rect ${p.kf} x="17.6" y="18.4" width="1.6" height="1.6"/>
|
||||||
|
'';
|
||||||
|
documents = p: ''
|
||||||
|
<path ${p.k} d="M12.5 15 H18 L20 17 V24.5 H12.5 Z" stroke-width="1.2"/>
|
||||||
|
<path ${p.sb} d="M14.3 19 H18.2 M14.3 21 H18.2 M14.3 23 H16.5" stroke-width="0.9"/>
|
||||||
|
'';
|
||||||
|
download = p: ''
|
||||||
|
<path ${p.k} d="M16 15 V21.5 M13 18.8 L16 21.8 L19 18.8" stroke-width="1.4"/>
|
||||||
|
<rect ${p.kf} x="12.5" y="23" width="7" height="1.4"/>
|
||||||
|
'';
|
||||||
|
music = p: ''
|
||||||
|
<path ${p.k} d="M14.3 17.2 L19.3 15.7 V22 M14.3 17.2 V23.5" stroke-width="1.2"/>
|
||||||
|
<rect ${p.kf} x="11.9" y="22.5" width="2.8" height="2"/>
|
||||||
|
<rect ${p.kf} x="16.9" y="21" width="2.8" height="2"/>
|
||||||
|
'';
|
||||||
|
pictures = p: ''
|
||||||
|
<path ${p.k} d="M11.5 15.5 H20.5 V23.5 H11.5 Z" stroke-width="1.2"/>
|
||||||
|
<path ${p.sb} d="M12.3 22.7 L15 19.5 L17 21.5 L18.2 20.3 L19.7 21.8" stroke-width="1"/>
|
||||||
|
<rect ${p.kf} x="17.6" y="17" width="1.6" height="1.6"/>
|
||||||
|
'';
|
||||||
|
videos = p: ''
|
||||||
|
<path ${p.k} d="M11.5 15.5 H20.5 V23.5 H11.5 Z" stroke-width="1.2"/>
|
||||||
|
<path ${p.kf} d="M14.6 17.3 V21.7 L18.4 19.5 Z"/>
|
||||||
|
<path ${p.sb} d="M12.6 17 V22 M19.4 17 V22" stroke-width="0.8" stroke-dasharray="1 1"/>
|
||||||
|
'';
|
||||||
|
templates = p: ''
|
||||||
|
<path ${p.k} d="M12.5 15 H18 L20 17 V24.5 H12.5 Z" stroke-width="1.1" stroke-dasharray="1.4 1"/>
|
||||||
|
<rect ${p.kf} x="14.3" y="18.6" width="3.6" height="1.3"/>
|
||||||
|
<path ${p.sb} d="M14.3 21.6 H18.2" stroke-width="0.9"/>
|
||||||
|
'';
|
||||||
|
publicshare = p: ''
|
||||||
|
<path ${p.sb} d="M13.2 19.7 L19 16.2 M13.2 19.7 L19 23.2" stroke-width="1"/>
|
||||||
|
<rect ${p.kf} x="12" y="18.5" width="2.4" height="2.4"/>
|
||||||
|
<rect ${p.kf} x="17.8" y="15" width="2.4" height="2.4"/>
|
||||||
|
<rect ${p.kf} x="17.8" y="22" width="2.4" height="2.4"/>
|
||||||
|
'';
|
||||||
|
git = p: ''
|
||||||
|
<path ${p.k} d="M13 16 V23.6 M19 16 V17.5 L13.5 23" stroke-width="1.3"/>
|
||||||
|
<rect ${p.kf} x="11.8" y="14.8" width="2.4" height="2.4"/>
|
||||||
|
<rect ${p.kf} x="11.8" y="22.6" width="2.4" height="2.4"/>
|
||||||
|
<rect ${p.kf} x="17.8" y="14.8" width="2.4" height="2.4"/>
|
||||||
|
'';
|
||||||
|
projects = p: ''
|
||||||
|
<path ${p.k} d="M12 16.5 L15 19.5 L12 22.5" stroke-width="1.5"/>
|
||||||
|
<rect ${p.kf} x="16" y="21.8" width="4.5" height="1.5"/>
|
||||||
|
'';
|
||||||
|
remote = p: ''
|
||||||
|
<path ${p.sb} d="M11.5 20.5 H14.5 V23.5 H11.5 Z M17.5 15.5 H20.5 V18.5 H17.5 Z" stroke-width="1"/>
|
||||||
|
<path ${p.k} d="M14.5 22 H15.5 L19 18.5" stroke-width="1.3"/>
|
||||||
|
<rect ${p.kf} x="12.4" y="21.4" width="1.2" height="1.2"/>
|
||||||
|
<rect ${p.kf} x="18.4" y="16.4" width="1.2" height="1.2"/>
|
||||||
|
'';
|
||||||
|
saved-search = p: ''
|
||||||
|
<path ${p.k} d="M14 15 H17 L18.5 16.5 V19.5 L17 21 H14 L12.5 19.5 V16.5 Z" stroke-width="1.3"/>
|
||||||
|
<path ${p.k} d="M18 20.5 L20.5 23" stroke-width="2"/>
|
||||||
|
'';
|
||||||
|
locked = p: ''
|
||||||
|
<path ${p.k} d="M14 19 V16.6 L15 15.6 H17 L18 16.6 V19" stroke-width="1.3"/>
|
||||||
|
<rect ${p.kf} x="12.5" y="19" width="7" height="5.5"/>
|
||||||
|
<rect ${p.hl} x="15.5" y="20.8" width="1" height="2"/>
|
||||||
|
'';
|
||||||
|
important = p: ''
|
||||||
|
<path ${p.k} d="M16 15 L20.5 23.5 H11.5 Z" stroke-width="1.3" stroke-linejoin="miter"/>
|
||||||
|
<rect ${p.kf} x="15.4" y="18.2" width="1.2" height="2.8"/>
|
||||||
|
<rect ${p.kf} x="15.4" y="21.7" width="1.2" height="1.1"/>
|
||||||
|
'';
|
||||||
|
trash = p: can p + ''
|
||||||
|
<path ${p.sb} d="M15 19.3 V23 M17 19.3 V23" stroke-width="0.9"/>
|
||||||
|
'';
|
||||||
|
trash-full = p: can p + ''
|
||||||
|
<rect ${p.kf} x="14.2" y="19.2" width="1.4" height="3.9"/>
|
||||||
|
<rect ${p.kf} x="16.4" y="19.2" width="1.4" height="3.9"/>
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
# aliases: the other names apps (and baseTheme) use for the same folder, so
|
||||||
|
# those don't fall through to baseTheme's own drawing.
|
||||||
|
icons = {
|
||||||
|
folder = { emblem = "none"; aliases = [ "inode-directory" "gtk-directory" "gnome-fs-directory" "gnome-folder" "stock_folder" ]; };
|
||||||
|
folder-open = { base = "open"; emblem = "none"; aliases = [ "folder-drag-accept" "folder-visiting" "gnome-fs-directory-accept" ]; };
|
||||||
|
folder-homelab = { emblem = "homelab"; };
|
||||||
|
user-home = { emblem = "home"; aliases = [ "folder-home" "folder_home" "gnome-fs-home" ]; };
|
||||||
|
user-desktop = { emblem = "desktop"; aliases = [ "folder-desktop" "gnome-fs-desktop" ]; };
|
||||||
|
folder-documents = { emblem = "documents"; };
|
||||||
|
folder-download = { emblem = "download"; aliases = [ "folder-downloads" ]; };
|
||||||
|
folder-music = { emblem = "music"; };
|
||||||
|
folder-pictures = { emblem = "pictures"; aliases = [ "folder-images" "folder-image" "folder-picture" ]; };
|
||||||
|
folder-videos = { emblem = "videos"; aliases = [ "folder-video" ]; };
|
||||||
|
folder-templates = { emblem = "templates"; };
|
||||||
|
folder-publicshare = { emblem = "publicshare"; aliases = [ "folder-public" ]; };
|
||||||
|
folder-git = { emblem = "git"; };
|
||||||
|
folder-projects = { emblem = "projects"; aliases = [ "folder-development" ]; };
|
||||||
|
folder-remote = { emblem = "remote"; aliases = [ "folder-network" ]; };
|
||||||
|
folder-saved-search = { emblem = "saved-search"; };
|
||||||
|
folder-locked = { emblem = "locked"; aliases = [ "folder-encrypted" ]; };
|
||||||
|
folder-important = { emblem = "important"; hot = true; };
|
||||||
|
user-trash = { emblem = "trash"; aliases = [ "trash-empty" "gnome-fs-trash-empty" ]; };
|
||||||
|
user-trash-full = { emblem = "trash-full"; aliases = [ "gnome-fs-trash-full" ]; };
|
||||||
|
};
|
||||||
|
|
||||||
|
svg = finish: name: { emblem, base ? "closed", hot ? false, ... }:
|
||||||
|
let f = finish (if hot then accentHot else accent); in
|
||||||
|
builtins.toFile "${name}.svg" ''
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
${bases.${base} f}${emblems.${emblem} (paint f)}</svg>
|
||||||
|
'';
|
||||||
|
|
||||||
|
buildTheme = theme: finish: ''
|
||||||
|
dir="$out/share/icons/${theme}"
|
||||||
|
mkdir -p "$dir/places/scalable"
|
||||||
|
cat > "$dir/index.theme" <<EOF
|
||||||
|
[Icon Theme]
|
||||||
|
Name=${theme}
|
||||||
|
Comment=HyprChrome folders for terra, over ${baseTheme}
|
||||||
|
Inherits=${baseTheme},hicolor
|
||||||
|
Directories=places/scalable
|
||||||
|
|
||||||
|
[places/scalable]
|
||||||
|
Context=Places
|
||||||
|
Size=32
|
||||||
|
MinSize=16
|
||||||
|
MaxSize=512
|
||||||
|
Type=Scalable
|
||||||
|
EOF
|
||||||
|
|
||||||
|
${lib.concatStrings (lib.mapAttrsToList (name: icon: ''
|
||||||
|
cp ${svg finish name icon} "$dir/places/scalable/${name}.svg"
|
||||||
|
${lib.concatMapStrings (a: "ln -s ${name}.svg \"$dir/places/scalable/${a}.svg\"\n") (icon.aliases or [ ])}
|
||||||
|
'') icons)}
|
||||||
|
gtk-update-icon-cache --force "$dir"
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
stdenvNoCC.mkDerivation {
|
||||||
|
pname = "hyprchrome-folders";
|
||||||
|
version = "0.1";
|
||||||
|
|
||||||
|
dontUnpack = true;
|
||||||
|
|
||||||
|
nativeBuildInputs = [ gtk3 ];
|
||||||
|
|
||||||
|
# gtk3's setup hook strips icon-theme.cache from $out by default
|
||||||
|
dontDropIconThemeCache = true;
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
${lib.concatStrings (lib.mapAttrsToList buildTheme themes)}
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "HyprChrome folder icon themes (lit + solid finishes)";
|
||||||
|
platforms = lib.platforms.all;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -21,20 +21,68 @@ impl Message {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Where a turn lands in Hermes. `id` makes Hermes keep the history (and list
|
||||||
|
/// the session on the dashboard); `key` scopes long-term memory per channel.
|
||||||
|
#[derive(Clone, Copy, Default)]
|
||||||
|
pub struct Session<'a> {
|
||||||
|
pub id: Option<&'a str>,
|
||||||
|
pub key: Option<&'a str>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a stored Hermes session. The source is only a dashboard label —
|
||||||
|
/// Hermes allowlists it, and anything unknown becomes the hidden `api_server`.
|
||||||
|
pub async fn create_session(
|
||||||
|
client: &reqwest::Client,
|
||||||
|
base_url: &str,
|
||||||
|
key: &str,
|
||||||
|
source: &str,
|
||||||
|
) -> Result<String> {
|
||||||
|
let resp = client
|
||||||
|
.post(format!("{}/api/sessions", base_url.trim_end_matches('/')))
|
||||||
|
.bearer_auth(key)
|
||||||
|
.json(&serde_json::json!({ "source": source }))
|
||||||
|
.send()
|
||||||
|
.await?;
|
||||||
|
if !resp.status().is_success() {
|
||||||
|
let status = resp.status();
|
||||||
|
let text = resp.text().await.unwrap_or_default();
|
||||||
|
bail!("hermes session create {status}: {}", text.trim());
|
||||||
|
}
|
||||||
|
let v: serde_json::Value = resp.json().await?;
|
||||||
|
match v.pointer("/session/id").and_then(|id| id.as_str()) {
|
||||||
|
Some(id) => Ok(id.to_string()),
|
||||||
|
None => bail!("hermes session create: no id in response"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What to send for the next turn. With a stored session Hermes loads the
|
||||||
|
/// history itself and folds every system message into the prompt, so only the
|
||||||
|
/// base prompt plus what's new since her last reply goes out — resending old
|
||||||
|
/// notes would repeat them every turn.
|
||||||
|
pub fn outgoing(history: &[Message], stored: bool) -> Vec<Message> {
|
||||||
|
let Some(last) = history.iter().rposition(|m| m.role == "assistant") else {
|
||||||
|
return history.to_vec();
|
||||||
|
};
|
||||||
|
if !stored {
|
||||||
|
return history.to_vec();
|
||||||
|
}
|
||||||
|
let base = history.first().filter(|m| m.role == "system").cloned();
|
||||||
|
base.into_iter().chain(history[last + 1..].iter().cloned()).collect()
|
||||||
|
}
|
||||||
|
|
||||||
/// Streams a reply from Hermes' OpenAI-compatible API, pushing text deltas
|
/// Streams a reply from Hermes' OpenAI-compatible API, pushing text deltas
|
||||||
/// into `tx` as they arrive.
|
/// into `tx` as they arrive.
|
||||||
///
|
///
|
||||||
/// /v1/chat/completions with client-side history, not /v1/responses with
|
/// /v1/chat/completions, not /v1/responses: this shape is the one every OpenAI
|
||||||
/// previous_response_id: the Responses API keeps the transcript server-side,
|
/// client exercises, so it is the least likely to differ between Hermes
|
||||||
/// which is nicer, but this shape is the one every OpenAI client exercises so
|
/// versions. With `session.id` set Hermes keeps the transcript itself.
|
||||||
/// it is the one least likely to differ between Hermes versions. Her memory
|
|
||||||
/// and skills are unaffected either way — those are not conversation state.
|
|
||||||
pub async fn stream_reply(
|
pub async fn stream_reply(
|
||||||
client: &reqwest::Client,
|
client: &reqwest::Client,
|
||||||
base_url: &str,
|
base_url: &str,
|
||||||
key: &str,
|
key: &str,
|
||||||
model: &str,
|
model: &str,
|
||||||
history: &[Message],
|
history: &[Message],
|
||||||
|
session: Session<'_>,
|
||||||
tx: mpsc::Sender<String>,
|
tx: mpsc::Sender<String>,
|
||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
let body = serde_json::json!({
|
let body = serde_json::json!({
|
||||||
@@ -43,12 +91,17 @@ pub async fn stream_reply(
|
|||||||
"stream": true,
|
"stream": true,
|
||||||
});
|
});
|
||||||
|
|
||||||
let resp = client
|
let mut req = client
|
||||||
.post(format!("{}/v1/chat/completions", base_url.trim_end_matches('/')))
|
.post(format!("{}/v1/chat/completions", base_url.trim_end_matches('/')))
|
||||||
.bearer_auth(key)
|
.bearer_auth(key)
|
||||||
.json(&body)
|
.json(&body);
|
||||||
.send()
|
if let Some(id) = session.id {
|
||||||
.await?;
|
req = req.header("X-Hermes-Session-Id", id);
|
||||||
|
}
|
||||||
|
if let Some(k) = session.key {
|
||||||
|
req = req.header("X-Hermes-Session-Key", k);
|
||||||
|
}
|
||||||
|
let resp = req.send().await?;
|
||||||
|
|
||||||
if !resp.status().is_success() {
|
if !resp.status().is_success() {
|
||||||
let status = resp.status();
|
let status = resp.status();
|
||||||
@@ -70,7 +123,10 @@ pub async fn stream_reply(
|
|||||||
let Some(data) = line.strip_prefix("data:") else { continue };
|
let Some(data) = line.strip_prefix("data:") else { continue };
|
||||||
let data = data.trim();
|
let data = data.trim();
|
||||||
if data == "[DONE]" {
|
if data == "[DONE]" {
|
||||||
return Ok(full);
|
return nonempty(full);
|
||||||
|
}
|
||||||
|
if let Some(msg) = parse_error(data) {
|
||||||
|
bail!("hermes: {msg}");
|
||||||
}
|
}
|
||||||
if let Some(delta) = parse_delta(data) {
|
if let Some(delta) = parse_delta(data) {
|
||||||
full.push_str(&delta);
|
full.push_str(&delta);
|
||||||
@@ -82,9 +138,30 @@ pub async fn stream_reply(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nonempty(full)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Hermes answers a failed upstream call with 200 and an empty stream, so an
|
||||||
|
/// empty reply is the only sign of e.g. a dead provider key.
|
||||||
|
fn nonempty(full: String) -> Result<String> {
|
||||||
|
if full.trim().is_empty() {
|
||||||
|
bail!("hermes returned an empty reply (check its log on mars)");
|
||||||
|
}
|
||||||
Ok(full)
|
Ok(full)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An `{"error": ...}` frame, as OpenAI-compatible servers send mid-stream.
|
||||||
|
fn parse_error(data: &str) -> Option<String> {
|
||||||
|
let v: serde_json::Value = serde_json::from_str(data).ok()?;
|
||||||
|
let err = v.get("error")?;
|
||||||
|
Some(
|
||||||
|
err.get("message")
|
||||||
|
.and_then(|m| m.as_str())
|
||||||
|
.map(str::to_string)
|
||||||
|
.unwrap_or_else(|| err.to_string()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/// Pulls choices[0].delta.content out of one SSE data payload. Tool-call
|
/// Pulls choices[0].delta.content out of one SSE data payload. Tool-call
|
||||||
/// frames and role-only frames carry no content and are skipped.
|
/// frames and role-only frames carry no content and are skipped.
|
||||||
fn parse_delta(data: &str) -> Option<String> {
|
fn parse_delta(data: &str) -> Option<String> {
|
||||||
@@ -100,7 +177,48 @@ fn parse_delta(data: &str) -> Option<String> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::parse_delta;
|
use super::{nonempty, outgoing, parse_delta, parse_error, Message};
|
||||||
|
|
||||||
|
fn roles(msgs: &[Message]) -> Vec<(&str, &str)> {
|
||||||
|
msgs.iter().map(|m| (m.role.as_str(), m.content.as_str())).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn stored_session_sends_prompt_and_only_whats_new() {
|
||||||
|
let h = vec![
|
||||||
|
Message::system("prompt"),
|
||||||
|
Message::user("one"),
|
||||||
|
Message::assistant("reply"),
|
||||||
|
Message::system("[interrupted]"),
|
||||||
|
Message::user("two"),
|
||||||
|
];
|
||||||
|
assert_eq!(
|
||||||
|
roles(&outgoing(&h, true)),
|
||||||
|
[("system", "prompt"), ("system", "[interrupted]"), ("user", "two")]
|
||||||
|
);
|
||||||
|
assert_eq!(outgoing(&h, false).len(), 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn first_turn_sends_everything_either_way() {
|
||||||
|
let h = vec![Message::system("prompt"), Message::user("one")];
|
||||||
|
assert_eq!(outgoing(&h, true).len(), 2);
|
||||||
|
let bare = vec![Message::user("one")];
|
||||||
|
assert_eq!(roles(&outgoing(&bare, true)), [("user", "one")]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn error_frame_carries_its_message() {
|
||||||
|
let d = r#"{"error":{"type":"api_error","message":"Invalid credential"}}"#;
|
||||||
|
assert_eq!(parse_error(d).as_deref(), Some("Invalid credential"));
|
||||||
|
assert!(parse_error(r#"{"choices":[{"delta":{"content":"hi"}}]}"#).is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn empty_reply_is_an_error() {
|
||||||
|
assert!(nonempty(" \n".into()).is_err());
|
||||||
|
assert_eq!(nonempty("hi".into()).unwrap(), "hi");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn extracts_content_delta() {
|
fn extracts_content_delta() {
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ pub struct Config {
|
|||||||
/// system prompt is this client's opinion, while the marker survives into
|
/// system prompt is this client's opinion, while the marker survives into
|
||||||
/// whatever history Hermes keeps and still identifies the channel later.
|
/// whatever history Hermes keeps and still identifies the channel later.
|
||||||
pub voice_marker: Option<String>,
|
pub voice_marker: Option<String>,
|
||||||
|
/// Dashboard label for her stored voice session; empty = no stored session.
|
||||||
|
pub session_source: String,
|
||||||
|
/// Memory scope (one Honcho session for all of voice); empty = none.
|
||||||
|
pub session_key: Option<String>,
|
||||||
|
|
||||||
pub eleven_key: String,
|
pub eleven_key: String,
|
||||||
pub voice_id: String,
|
pub voice_id: String,
|
||||||
@@ -23,6 +27,8 @@ pub struct Config {
|
|||||||
|
|
||||||
pub whisper_bin: String,
|
pub whisper_bin: String,
|
||||||
pub whisper_model: PathBuf,
|
pub whisper_model: PathBuf,
|
||||||
|
/// whisper -l; "auto" detects per utterance.
|
||||||
|
pub whisper_language: String,
|
||||||
|
|
||||||
pub socket_path: PathBuf,
|
pub socket_path: PathBuf,
|
||||||
/// Silence that ends an utterance in hands-free mode. Hermes' own default.
|
/// Silence that ends an utterance in hands-free mode. Hermes' own default.
|
||||||
@@ -66,13 +72,21 @@ impl Config {
|
|||||||
m if m.is_empty() => None,
|
m if m.is_empty() => None,
|
||||||
m => Some(m),
|
m => Some(m),
|
||||||
},
|
},
|
||||||
|
// desktop, not a "voice" source: Hermes only allows a fixed set, and
|
||||||
|
// its default dashboard view hides api_server.
|
||||||
|
session_source: env_or("LUNA_SESSION_SOURCE", "desktop"),
|
||||||
|
session_key: match env_or("LUNA_SESSION_KEY", "voice") {
|
||||||
|
k if k.is_empty() => None,
|
||||||
|
k => Some(k),
|
||||||
|
},
|
||||||
|
|
||||||
eleven_key: secret("LUNA_ELEVENLABS_KEY_FILE")?,
|
eleven_key: secret("LUNA_ELEVENLABS_KEY_FILE")?,
|
||||||
voice_id: env("LUNA_VOICE_ID")?,
|
voice_id: env("LUNA_VOICE_ID")?,
|
||||||
tts_model: env_or("LUNA_TTS_MODEL", "eleven_v3_conversational"),
|
tts_model: env_or("LUNA_TTS_MODEL", "eleven_v4_turbo"),
|
||||||
|
|
||||||
whisper_bin: env_or("LUNA_WHISPER_BIN", "whisper-cli"),
|
whisper_bin: env_or("LUNA_WHISPER_BIN", "whisper-cli"),
|
||||||
whisper_model: PathBuf::from(env("LUNA_WHISPER_MODEL")?),
|
whisper_model: PathBuf::from(env("LUNA_WHISPER_MODEL")?),
|
||||||
|
whisper_language: env_or("LUNA_WHISPER_LANGUAGE", "auto"),
|
||||||
|
|
||||||
socket_path: PathBuf::from(env_or(
|
socket_path: PathBuf::from(env_or(
|
||||||
"LUNA_SOCKET",
|
"LUNA_SOCKET",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use anyhow::Result;
|
|||||||
use serde_json;
|
use serde_json;
|
||||||
use config::Config;
|
use config::Config;
|
||||||
use ipc::{Command, Event};
|
use ipc::{Command, Event};
|
||||||
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
@@ -170,6 +171,109 @@ fn notify(body: &str) {
|
|||||||
.spawn();
|
.spawn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The SUPER+V switch. It only opens and closes the mic: her reply is never
|
||||||
|
/// cut by it, so muting during an answer means "just listen".
|
||||||
|
struct Mic {
|
||||||
|
on: bool,
|
||||||
|
/// Running estimate of the room, updated only while not capturing, so a
|
||||||
|
/// loud sentence never raises the bar for the next one.
|
||||||
|
floor: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Mic {
|
||||||
|
/// Returns whether anything changed. `speaking` skips the beep, which
|
||||||
|
/// would otherwise land in the middle of her sentence.
|
||||||
|
fn set(
|
||||||
|
&mut self,
|
||||||
|
want: bool,
|
||||||
|
speaking: bool,
|
||||||
|
capture: &audio::Capture,
|
||||||
|
playback: &audio::Playback,
|
||||||
|
ipc: &ipc::Ipc,
|
||||||
|
) -> bool {
|
||||||
|
if want == self.on {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
self.on = want;
|
||||||
|
if want {
|
||||||
|
// Seeded low: a floor seeded high takes seconds to decay, and
|
||||||
|
// those are the seconds you spend talking to something that is
|
||||||
|
// not listening yet. Not sampled while she talks: that would
|
||||||
|
// measure her, not the room.
|
||||||
|
self.floor = if speaking { 0.003 } else { capture.level().max(0.003) };
|
||||||
|
}
|
||||||
|
if !speaking {
|
||||||
|
if want {
|
||||||
|
playback.beep(880.0, 70);
|
||||||
|
} else {
|
||||||
|
playback.beep(440.0, 90);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ipc.emit(Event::Mode { active: want });
|
||||||
|
eprintln!("luna-voice: mic {}", if want { "on" } else { "off" });
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A command that arrives while she is answering. Returns true for Cancel,
|
||||||
|
/// the only one that stops her; the mic switch applies at once, and the
|
||||||
|
/// rest wait for the turn to end.
|
||||||
|
fn mid_turn(
|
||||||
|
cmd: Command,
|
||||||
|
speaking: bool,
|
||||||
|
mic: &mut Mic,
|
||||||
|
capture: &audio::Capture,
|
||||||
|
playback: &audio::Playback,
|
||||||
|
ipc: &ipc::Ipc,
|
||||||
|
deferred: &mut Vec<Command>,
|
||||||
|
) -> bool {
|
||||||
|
match cmd {
|
||||||
|
Command::Cancel => true,
|
||||||
|
Command::Mode { on } => {
|
||||||
|
mic.set(on.unwrap_or(!mic.on), speaking, capture, playback, ipc);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
cmd => {
|
||||||
|
deferred.push(cmd);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// End of a hands-free utterance: transcribe it and answer.
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
async fn reply_to(
|
||||||
|
cfg: &Config,
|
||||||
|
http: &reqwest::Client,
|
||||||
|
ipc: &Arc<ipc::Ipc>,
|
||||||
|
capture: &audio::Capture,
|
||||||
|
playback: &Arc<audio::Playback>,
|
||||||
|
cmd_rx: &mut mpsc::Receiver<Command>,
|
||||||
|
requeue: &mpsc::Sender<Command>,
|
||||||
|
conv: &mut Conversation,
|
||||||
|
mic: &mut Mic,
|
||||||
|
samples: Vec<f32>,
|
||||||
|
) {
|
||||||
|
ipc.emit(Event::State { value: "thinking" });
|
||||||
|
match stt::transcribe(&cfg.whisper_bin, &cfg.whisper_model, &cfg.whisper_language, &samples).await {
|
||||||
|
Ok(heard) if !heard.is_empty() => {
|
||||||
|
run_turn(cfg, http, ipc, capture, playback, cmd_rx, requeue, conv, mic, heard).await;
|
||||||
|
}
|
||||||
|
Ok(_) => {
|
||||||
|
// Silent on purpose: in hands-free mode a false trigger happens
|
||||||
|
// whenever a door closes, and a beep for each one would be
|
||||||
|
// maddening.
|
||||||
|
ipc.emit(Event::State { value: "idle" });
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("luna-voice: {e:#}");
|
||||||
|
ipc.emit(Event::Error { message: e.to_string() });
|
||||||
|
notify(&e.to_string());
|
||||||
|
ipc.emit(Event::State { value: "idle" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Where the loop is. One utterance at a time by construction: the state
|
/// Where the loop is. One utterance at a time by construction: the state
|
||||||
/// machine is a single task, so there is no way to start a second reply while
|
/// machine is a single task, so there is no way to start a second reply while
|
||||||
/// one is in flight.
|
/// one is in flight.
|
||||||
@@ -191,9 +295,9 @@ async fn daemon() -> Result<()> {
|
|||||||
.timeout(Duration::from_secs(300))
|
.timeout(Duration::from_secs(300))
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let mut history: Vec<brain::Message> = Vec::new();
|
let mut conv = Conversation::default();
|
||||||
if let Some(prompt) = &cfg.system_prompt {
|
if let Some(prompt) = &cfg.system_prompt {
|
||||||
history.push(brain::Message::system(prompt.clone()));
|
conv.history.push(brain::Message::system(prompt.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc.emit(Event::State { value: "idle" });
|
ipc.emit(Event::State { value: "idle" });
|
||||||
@@ -210,19 +314,18 @@ async fn daemon() -> Result<()> {
|
|||||||
let (tx, mut rx) = mpsc::channel(4);
|
let (tx, mut rx) = mpsc::channel(4);
|
||||||
tokio::spawn(async move { while rx.recv().await.is_some() {} });
|
tokio::spawn(async move { while rx.recv().await.is_some() {} });
|
||||||
let warm = [brain::Message::user("hi")];
|
let warm = [brain::Message::user("hi")];
|
||||||
match brain::stream_reply(&http, &url, &key, &model, &warm, tx).await {
|
// Sessionless on purpose: a stored session would open every
|
||||||
|
// voice conversation on dashboard with a throwaway "hi".
|
||||||
|
match brain::stream_reply(&http, &url, &key, &model, &warm, Default::default(), tx).await {
|
||||||
Ok(_) => eprintln!("luna-voice: warmed up"),
|
Ok(_) => eprintln!("luna-voice: warmed up"),
|
||||||
Err(e) => eprintln!("luna-voice: warmup skipped: {e}"),
|
Err(e) => eprintln!("luna-voice: warmup skipped: {e}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Hands-free state. The key toggles `mode`; everything inside it is
|
// Hands-free state. The key only switches the mic; everything inside it
|
||||||
// driven by the microphone rather than by keys.
|
// is driven by the microphone rather than by keys.
|
||||||
let mut mode = false;
|
let mut mic = Mic { on: false, floor: 0.01 };
|
||||||
// Running estimate of the room, updated only while not capturing, so a
|
|
||||||
// loud sentence never raises the bar for the next one.
|
|
||||||
let mut floor: f32 = 0.01;
|
|
||||||
let mut capturing = false;
|
let mut capturing = false;
|
||||||
let mut last_voice = tokio::time::Instant::now();
|
let mut last_voice = tokio::time::Instant::now();
|
||||||
let mut ticker = tokio::time::interval(Duration::from_millis(50));
|
let mut ticker = tokio::time::interval(Duration::from_millis(50));
|
||||||
@@ -236,7 +339,7 @@ async fn daemon() -> Result<()> {
|
|||||||
// Only ticks while voice mode is on. A turn is awaited inline
|
// Only ticks while voice mode is on. A turn is awaited inline
|
||||||
// below, so this cannot fire while she is speaking — which is
|
// below, so this cannot fire while she is speaking — which is
|
||||||
// also what stops her from hearing herself.
|
// also what stops her from hearing herself.
|
||||||
_ = ticker.tick(), if mode => None,
|
_ = ticker.tick(), if mic.on => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let Some(cmd) = cmd else {
|
let Some(cmd) = cmd else {
|
||||||
@@ -246,7 +349,7 @@ async fn daemon() -> Result<()> {
|
|||||||
// threshold is too high", which is exactly the question you have
|
// threshold is too high", which is exactly the question you have
|
||||||
// when nothing happens.
|
// when nothing happens.
|
||||||
ipc.emit(Event::Amplitude { rms: level });
|
ipc.emit(Event::Amplitude { rms: level });
|
||||||
let threshold = root_threshold(floor, cfg.vad_mult);
|
let threshold = root_threshold(mic.floor, cfg.vad_mult);
|
||||||
if !capturing {
|
if !capturing {
|
||||||
// Only samples BELOW the trigger update the floor. Feeding
|
// Only samples BELOW the trigger update the floor. Feeding
|
||||||
// every sample in lets a rising sound drag the floor up with
|
// every sample in lets a rising sound drag the floor up with
|
||||||
@@ -254,7 +357,7 @@ async fn daemon() -> Result<()> {
|
|||||||
// nothing ever fires — measured: a tone peaking at 0.029 was
|
// nothing ever fires — measured: a tone peaking at 0.029 was
|
||||||
// chased by a threshold that reached 0.018 on the way up.
|
// chased by a threshold that reached 0.018 on the way up.
|
||||||
if level <= threshold {
|
if level <= threshold {
|
||||||
floor = floor * 0.95 + level * 0.05;
|
mic.floor = mic.floor * 0.95 + level * 0.05;
|
||||||
}
|
}
|
||||||
if level > threshold {
|
if level > threshold {
|
||||||
capture.start();
|
capture.start();
|
||||||
@@ -269,55 +372,33 @@ async fn daemon() -> Result<()> {
|
|||||||
if last_voice.elapsed() > Duration::from_millis(cfg.silence_ms) {
|
if last_voice.elapsed() > Duration::from_millis(cfg.silence_ms) {
|
||||||
capturing = false;
|
capturing = false;
|
||||||
let samples = capture.stop();
|
let samples = capture.stop();
|
||||||
ipc.emit(Event::State { value: "thinking" });
|
reply_to(
|
||||||
match stt::transcribe(&cfg.whisper_bin, &cfg.whisper_model, &samples).await {
|
&cfg, &http, &ipc, &capture, &playback, &mut cmd_rx, &requeue,
|
||||||
Ok(heard) if !heard.is_empty() => {
|
&mut conv, &mut mic, samples,
|
||||||
run_turn(
|
|
||||||
&cfg, &http, &ipc, &capture, &playback, &mut cmd_rx,
|
|
||||||
&requeue, &mut history, heard,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
Ok(_) => {
|
|
||||||
// Silent on purpose: in hands-free mode a false
|
|
||||||
// trigger happens whenever a door closes, and a
|
|
||||||
// beep for each one would be maddening.
|
|
||||||
ipc.emit(Event::State { value: "idle" });
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
eprintln!("luna-voice: {e:#}");
|
|
||||||
ipc.emit(Event::Error { message: e.to_string() });
|
|
||||||
notify(&e.to_string());
|
|
||||||
ipc.emit(Event::State { value: "idle" });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
match cmd {
|
match cmd {
|
||||||
Command::Mode { on } => {
|
Command::Mode { on } => {
|
||||||
let want = on.unwrap_or(!mode);
|
if !mic.set(on.unwrap_or(!mic.on), false, &capture, &playback, &ipc) {
|
||||||
if want != mode {
|
continue;
|
||||||
mode = want;
|
}
|
||||||
if mode {
|
|
||||||
// Seeded low: a floor seeded high takes seconds to
|
|
||||||
// decay, and those are the seconds you spend
|
|
||||||
// talking to something that is not listening yet.
|
|
||||||
floor = capture.level().max(0.003);
|
|
||||||
playback.beep(880.0, 70);
|
|
||||||
} else {
|
|
||||||
if capturing {
|
if capturing {
|
||||||
capture.stop();
|
// Muting mid-sentence sends what was said so far, like
|
||||||
|
// letting go of a push-to-talk key.
|
||||||
capturing = false;
|
capturing = false;
|
||||||
}
|
let samples = capture.stop();
|
||||||
playback.clear();
|
reply_to(
|
||||||
playback.beep(440.0, 90);
|
&cfg, &http, &ipc, &capture, &playback, &mut cmd_rx, &requeue,
|
||||||
}
|
&mut conv, &mut mic, samples,
|
||||||
ipc.emit(Event::Mode { active: mode });
|
)
|
||||||
|
.await;
|
||||||
|
} else {
|
||||||
ipc.emit(Event::State { value: "idle" });
|
ipc.emit(Event::State { value: "idle" });
|
||||||
eprintln!("luna-voice: voice mode {}", if mode { "on" } else { "off" });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Command::Ptt { down: true } => {
|
Command::Ptt { down: true } => {
|
||||||
@@ -334,7 +415,7 @@ async fn daemon() -> Result<()> {
|
|||||||
ipc.emit(Event::State { value: "thinking" });
|
ipc.emit(Event::State { value: "thinking" });
|
||||||
|
|
||||||
let heard =
|
let heard =
|
||||||
match stt::transcribe(&cfg.whisper_bin, &cfg.whisper_model, &samples).await {
|
match stt::transcribe(&cfg.whisper_bin, &cfg.whisper_model, &cfg.whisper_language, &samples).await {
|
||||||
Ok(h) => h,
|
Ok(h) => h,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("luna-voice: {e:#}");
|
eprintln!("luna-voice: {e:#}");
|
||||||
@@ -356,12 +437,18 @@ async fn daemon() -> Result<()> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
run_turn(&cfg, &http, &ipc, &capture, &playback, &mut cmd_rx, &requeue, &mut history, heard)
|
run_turn(
|
||||||
|
&cfg, &http, &ipc, &capture, &playback, &mut cmd_rx, &requeue, &mut conv,
|
||||||
|
&mut mic, heard,
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
Command::Say { text } => {
|
Command::Say { text } => {
|
||||||
ipc.emit(Event::State { value: "thinking" });
|
ipc.emit(Event::State { value: "thinking" });
|
||||||
run_turn(&cfg, &http, &ipc, &capture, &playback, &mut cmd_rx, &requeue, &mut history, text)
|
run_turn(
|
||||||
|
&cfg, &http, &ipc, &capture, &playback, &mut cmd_rx, &requeue, &mut conv,
|
||||||
|
&mut mic, text,
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
Command::Cancel => {
|
Command::Cancel => {
|
||||||
@@ -416,6 +503,16 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
|
||||||
|
/// One daemon run's conversation. `session_id` is the stored Hermes session
|
||||||
|
/// that owns the transcript once created; `history` stays as the fallback
|
||||||
|
/// and as the source of the notes sent alongside each turn.
|
||||||
|
#[derive(Default)]
|
||||||
|
struct Conversation {
|
||||||
|
history: Vec<brain::Message>,
|
||||||
|
session_id: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
async fn run_turn(
|
async fn run_turn(
|
||||||
cfg: &Config,
|
cfg: &Config,
|
||||||
http: &reqwest::Client,
|
http: &reqwest::Client,
|
||||||
@@ -424,10 +521,11 @@ async fn run_turn(
|
|||||||
playback: &Arc<audio::Playback>,
|
playback: &Arc<audio::Playback>,
|
||||||
cmd_rx: &mut mpsc::Receiver<Command>,
|
cmd_rx: &mut mpsc::Receiver<Command>,
|
||||||
requeue: &mpsc::Sender<Command>,
|
requeue: &mpsc::Sender<Command>,
|
||||||
history: &mut Vec<brain::Message>,
|
conv: &mut Conversation,
|
||||||
|
mic: &mut Mic,
|
||||||
heard: String,
|
heard: String,
|
||||||
) {
|
) {
|
||||||
if let Err(e) = turn(cfg, http, ipc, capture, playback, cmd_rx, requeue, history, heard).await {
|
if let Err(e) = turn(cfg, http, ipc, capture, playback, cmd_rx, requeue, conv, mic, heard).await {
|
||||||
eprintln!("luna-voice: {e:#}");
|
eprintln!("luna-voice: {e:#}");
|
||||||
ipc.emit(Event::Error { message: e.to_string() });
|
ipc.emit(Event::Error { message: e.to_string() });
|
||||||
notify(&e.to_string());
|
notify(&e.to_string());
|
||||||
@@ -444,9 +542,11 @@ async fn turn(
|
|||||||
playback: &Arc<audio::Playback>,
|
playback: &Arc<audio::Playback>,
|
||||||
cmd_rx: &mut mpsc::Receiver<Command>,
|
cmd_rx: &mut mpsc::Receiver<Command>,
|
||||||
requeue: &mpsc::Sender<Command>,
|
requeue: &mpsc::Sender<Command>,
|
||||||
history: &mut Vec<brain::Message>,
|
conv: &mut Conversation,
|
||||||
|
mic: &mut Mic,
|
||||||
heard: String,
|
heard: String,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
let history = &mut conv.history;
|
||||||
eprintln!("luna-voice: heard {heard:?}");
|
eprintln!("luna-voice: heard {heard:?}");
|
||||||
// The caption shows what you SAID; the marker is only for her.
|
// The caption shows what you SAID; the marker is only for her.
|
||||||
ipc.emit(Event::Caption { speaker: "user", text: heard.clone() });
|
ipc.emit(Event::Caption { speaker: "user", text: heard.clone() });
|
||||||
@@ -468,16 +568,21 @@ async fn turn(
|
|||||||
voice_id: cfg.voice_id.clone(),
|
voice_id: cfg.voice_id.clone(),
|
||||||
model: cfg.tts_model.clone(),
|
model: cfg.tts_model.clone(),
|
||||||
};
|
};
|
||||||
let keep_tags = tts_cfg.is_v3();
|
let keep_tags = tts_cfg.uses_dialogue();
|
||||||
let speech = tokio::spawn({
|
let speech = tokio::spawn({
|
||||||
async move { tts::speak(&tts_cfg, sentence_rx, event_tx).await }
|
async move { tts::speak(&tts_cfg, sentence_rx, event_tx).await }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Set once her first audio is queued; from then on the mic switch is
|
||||||
|
// silent.
|
||||||
|
let speaking = Arc::new(AtomicBool::new(false));
|
||||||
|
|
||||||
// Audio and visemes flow to the speaker/shell on their own task so the
|
// Audio and visemes flow to the speaker/shell on their own task so the
|
||||||
// reply stream is never blocked by playback.
|
// reply stream is never blocked by playback.
|
||||||
let player = tokio::spawn({
|
let player = tokio::spawn({
|
||||||
let ipc = ipc.clone();
|
let ipc = ipc.clone();
|
||||||
let playback = playback.clone();
|
let playback = playback.clone();
|
||||||
|
let speaking = speaking.clone();
|
||||||
async move {
|
async move {
|
||||||
let mut started = false;
|
let mut started = false;
|
||||||
while let Some(ev) = event_rx.recv().await {
|
while let Some(ev) = event_rx.recv().await {
|
||||||
@@ -485,6 +590,7 @@ async fn turn(
|
|||||||
tts::SpeechEvent::Audio(pcm) => {
|
tts::SpeechEvent::Audio(pcm) => {
|
||||||
if !started {
|
if !started {
|
||||||
started = true;
|
started = true;
|
||||||
|
speaking.store(true, Ordering::Relaxed);
|
||||||
ipc.emit(Event::SpeechStart);
|
ipc.emit(Event::SpeechStart);
|
||||||
ipc.emit(Event::State { value: "speaking" });
|
ipc.emit(Event::State { value: "speaking" });
|
||||||
}
|
}
|
||||||
@@ -503,12 +609,31 @@ async fn turn(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Retried every turn until it works; meanwhile she still answers off the
|
||||||
|
// client-side history, just without a dashboard entry.
|
||||||
|
if conv.session_id.is_none() && !cfg.session_source.is_empty() {
|
||||||
|
match brain::create_session(http, &cfg.hermes_url, &cfg.hermes_key, &cfg.session_source).await {
|
||||||
|
Ok(id) => {
|
||||||
|
eprintln!("luna-voice: hermes session {id}");
|
||||||
|
conv.session_id = Some(id);
|
||||||
|
}
|
||||||
|
Err(e) => eprintln!("luna-voice: no stored session, sending full history: {e:#}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let (delta_tx, mut delta_rx) = mpsc::channel::<String>(64);
|
let (delta_tx, mut delta_rx) = mpsc::channel::<String>(64);
|
||||||
let reply = tokio::spawn({
|
let reply = tokio::spawn({
|
||||||
let http = http.clone();
|
let http = http.clone();
|
||||||
let (url, key, model) = (cfg.hermes_url.clone(), cfg.hermes_key.clone(), cfg.model.clone());
|
let (url, key, model) = (cfg.hermes_url.clone(), cfg.hermes_key.clone(), cfg.model.clone());
|
||||||
let history = history.clone();
|
let messages = brain::outgoing(history, conv.session_id.is_some());
|
||||||
async move { brain::stream_reply(&http, &url, &key, &model, &history, delta_tx).await }
|
let (session_id, session_key) = (conv.session_id.clone(), cfg.session_key.clone());
|
||||||
|
async move {
|
||||||
|
let session = brain::Session {
|
||||||
|
id: session_id.as_deref(),
|
||||||
|
key: session_key.as_deref(),
|
||||||
|
};
|
||||||
|
brain::stream_reply(&http, &url, &key, &model, &messages, session, delta_tx).await
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut splitter = tts::SentenceSplitter::new(keep_tags);
|
let mut splitter = tts::SentenceSplitter::new(keep_tags);
|
||||||
@@ -520,7 +645,13 @@ async fn turn(
|
|||||||
ipc.emit(Event::Caption { speaker: "luna", text });
|
ipc.emit(Event::Caption { speaker: "luna", text });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
while let Some(delta) = delta_rx.recv().await {
|
// A reply with tool calls can stream for minutes, so commands are taken
|
||||||
|
// here too: the mic switch has to answer now, not once she is done.
|
||||||
|
let mut cancelled = false;
|
||||||
|
loop {
|
||||||
|
tokio::select! {
|
||||||
|
delta = delta_rx.recv() => {
|
||||||
|
let Some(delta) = delta else { break };
|
||||||
for sentence in splitter.push(&delta) {
|
for sentence in splitter.push(&delta) {
|
||||||
caption(&sentence);
|
caption(&sentence);
|
||||||
billed += sentence.chars().count();
|
billed += sentence.chars().count();
|
||||||
@@ -529,6 +660,12 @@ async fn turn(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some(cmd) = cmd_rx.recv() => {
|
||||||
|
let speaking = speaking.load(Ordering::Relaxed);
|
||||||
|
cancelled |= mid_turn(cmd, speaking, mic, capture, playback, ipc, &mut deferred);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Some(tail) = splitter.finish() {
|
if let Some(tail) = splitter.finish() {
|
||||||
caption(&tail);
|
caption(&tail);
|
||||||
billed += tail.chars().count();
|
billed += tail.chars().count();
|
||||||
@@ -548,10 +685,24 @@ async fn turn(
|
|||||||
// finished" is invisible.
|
// finished" is invisible.
|
||||||
let grace = tokio::time::Instant::now() + Duration::from_millis(cfg.barge_in_grace_ms);
|
let grace = tokio::time::Instant::now() + Duration::from_millis(cfg.barge_in_grace_ms);
|
||||||
loop {
|
loop {
|
||||||
|
// try_recv POPS, so anything not handled is destroyed: an `if let
|
||||||
|
// Ok(Cancel)` once silently ate every `say` and `toggle` sent while
|
||||||
|
// she was talking, which presents as a keypress that does nothing.
|
||||||
|
if let Ok(cmd) = cmd_rx.try_recv() {
|
||||||
|
let speaking = speaking.load(Ordering::Relaxed);
|
||||||
|
cancelled |= mid_turn(cmd, speaking, mic, capture, playback, ipc, &mut deferred);
|
||||||
|
}
|
||||||
|
if cancelled {
|
||||||
|
playback.clear();
|
||||||
|
ipc.emit(Event::SpeechStop { reason: "cancelled" });
|
||||||
|
break;
|
||||||
|
}
|
||||||
if speech.is_finished() && playback.pending() == 0 {
|
if speech.is_finished() && playback.pending() == 0 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if tokio::time::Instant::now() > grace
|
// A muted mic does not hear you, so it cannot interrupt her either.
|
||||||
|
if mic.on
|
||||||
|
&& tokio::time::Instant::now() > grace
|
||||||
&& capture.level() > floor * cfg.barge_in_mult
|
&& capture.level() > floor * cfg.barge_in_mult
|
||||||
{
|
{
|
||||||
playback.clear();
|
playback.clear();
|
||||||
@@ -563,27 +714,6 @@ async fn turn(
|
|||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Commands arriving mid-playback. try_recv POPS, so anything not
|
|
||||||
// handled here is destroyed: an `if let Ok(Cancel)` silently ate
|
|
||||||
// every `say`, `toggle` and `mode off` sent while she was talking,
|
|
||||||
// which presents as a keypress that does nothing.
|
|
||||||
match cmd_rx.try_recv() {
|
|
||||||
Ok(Command::Cancel) => {
|
|
||||||
playback.clear();
|
|
||||||
ipc.emit(Event::SpeechStop { reason: "cancelled" });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Leaving voice mode has to shut her up immediately; the mode
|
|
||||||
// change itself is replayed below.
|
|
||||||
Ok(cmd @ Command::Mode { .. }) => {
|
|
||||||
playback.clear();
|
|
||||||
ipc.emit(Event::SpeechStop { reason: "cancelled" });
|
|
||||||
deferred.push(cmd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Ok(cmd) => deferred.push(cmd),
|
|
||||||
Err(_) => {}
|
|
||||||
}
|
|
||||||
ipc.emit(Event::Amplitude { rms: capture.level() });
|
ipc.emit(Event::Amplitude { rms: capture.level() });
|
||||||
tokio::time::sleep(Duration::from_millis(50)).await;
|
tokio::time::sleep(Duration::from_millis(50)).await;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ use tokio::process::Command;
|
|||||||
/// Shells out to whisper-cli rather than linking whisper.cpp: nixpkgs already
|
/// Shells out to whisper-cli rather than linking whisper.cpp: nixpkgs already
|
||||||
/// ships whisper-cpp-vulkan built against this box's GPU stack, and a bundled
|
/// ships whisper-cpp-vulkan built against this box's GPU stack, and a bundled
|
||||||
/// build would have to rediscover that at cargo time.
|
/// build would have to rediscover that at cargo time.
|
||||||
pub async fn transcribe(bin: &str, model: &Path, samples: &[f32]) -> Result<String> {
|
pub async fn transcribe(
|
||||||
|
bin: &str,
|
||||||
|
model: &Path,
|
||||||
|
language: &str,
|
||||||
|
samples: &[f32],
|
||||||
|
) -> Result<String> {
|
||||||
// Whisper hallucinates confident words into silence — "you", "Thank
|
// Whisper hallucinates confident words into silence — "you", "Thank
|
||||||
// you.", "Bye." — which then reach luna as if spoken. Duration alone does
|
// you.", "Bye." — which then reach luna as if spoken. Duration alone does
|
||||||
// not catch it (a held key over a quiet room is long AND empty), so gate
|
// not catch it (a held key over a quiet room is long AND empty), so gate
|
||||||
@@ -26,7 +31,7 @@ pub async fn transcribe(bin: &str, model: &Path, samples: &[f32]) -> Result<Stri
|
|||||||
.arg(&wav)
|
.arg(&wav)
|
||||||
// -nt: transcript only, no [00:00:00] prefixes. -np: no progress
|
// -nt: transcript only, no [00:00:00] prefixes. -np: no progress
|
||||||
// banner. Together they make stdout exactly the text.
|
// banner. Together they make stdout exactly the text.
|
||||||
.args(["-nt", "-np"])
|
.args(["-nt", "-np", "-l", language])
|
||||||
.output()
|
.output()
|
||||||
.await?;
|
.await?;
|
||||||
let _ = std::fs::remove_file(&wav);
|
let _ = std::fs::remove_file(&wav);
|
||||||
@@ -37,7 +42,11 @@ pub async fn transcribe(bin: &str, model: &Path, samples: &[f32]) -> Result<Stri
|
|||||||
String::from_utf8_lossy(&out.stderr).trim()
|
String::from_utf8_lossy(&out.stderr).trim()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Ok(clean(&String::from_utf8_lossy(&out.stdout)))
|
let text = clean(&String::from_utf8_lossy(&out.stdout));
|
||||||
|
if subtitle_credit(&text) {
|
||||||
|
return Ok(String::new());
|
||||||
|
}
|
||||||
|
Ok(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Scales a quiet recording up before whisper sees it.
|
/// Scales a quiet recording up before whisper sees it.
|
||||||
@@ -79,6 +88,14 @@ fn has_speech(samples: &[f32]) -> bool {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Multilingual whisper fills silence with the subtitle credits it was trained
|
||||||
|
/// on ("Untertitel im Auftrag des ZDF, 2017", "Untertitel der Amara.org-Community").
|
||||||
|
/// Nobody says these to luna, so the whole transcript is dropped.
|
||||||
|
fn subtitle_credit(text: &str) -> bool {
|
||||||
|
let t = text.to_lowercase();
|
||||||
|
t.contains("untertitel") || t.contains("amara.org")
|
||||||
|
}
|
||||||
|
|
||||||
/// whisper emits bracketed non-speech annotations ([BLANK_AUDIO], (wind
|
/// whisper emits bracketed non-speech annotations ([BLANK_AUDIO], (wind
|
||||||
/// blowing)) that are not words and must not reach the agent.
|
/// blowing)) that are not words and must not reach the agent.
|
||||||
fn clean(raw: &str) -> String {
|
fn clean(raw: &str) -> String {
|
||||||
@@ -97,7 +114,7 @@ fn clean(raw: &str) -> String {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{clean, has_speech, normalize};
|
use super::{clean, has_speech, normalize, subtitle_credit};
|
||||||
use crate::audio::STT_RATE;
|
use crate::audio::STT_RATE;
|
||||||
|
|
||||||
fn peak(v: &[f32]) -> f32 {
|
fn peak(v: &[f32]) -> f32 {
|
||||||
@@ -165,6 +182,13 @@ mod tests {
|
|||||||
assert_eq!(clean("[ music ] real words"), "real words");
|
assert_eq!(clean("[ music ] real words"), "real words");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn drops_subtitle_credits() {
|
||||||
|
assert!(subtitle_credit("Untertitel im Auftrag des ZDF, 2017"));
|
||||||
|
assert!(subtitle_credit("Untertitel der Amara.org-Community"));
|
||||||
|
assert!(!subtitle_credit("Ist das Backup auf jupiter gelaufen?"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn collapses_whitespace() {
|
fn collapses_whitespace() {
|
||||||
assert_eq!(clean(" a b \n c "), "a b c");
|
assert_eq!(clean(" a b \n c "), "a b c");
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ pub struct TtsConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TtsConfig {
|
impl TtsConfig {
|
||||||
/// v3 is not served on the TTS websocket at all; it streams only over
|
/// v3 and v4 are not served on the TTS websocket at all; they stream only
|
||||||
/// Text to Dialogue, a different protocol.
|
/// over Text to Dialogue, a different protocol. Only these perform tags.
|
||||||
pub fn is_v3(&self) -> bool {
|
pub fn uses_dialogue(&self) -> bool {
|
||||||
self.model.starts_with("eleven_v3")
|
self.model.starts_with("eleven_v3") || self.model.starts_with("eleven_v4")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ pub async fn speak(
|
|||||||
sentences: mpsc::Receiver<String>,
|
sentences: mpsc::Receiver<String>,
|
||||||
events: mpsc::Sender<SpeechEvent>,
|
events: mpsc::Sender<SpeechEvent>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if cfg.is_v3() {
|
if cfg.uses_dialogue() {
|
||||||
speak_dialogue(cfg, sentences, events).await
|
speak_dialogue(cfg, sentences, events).await
|
||||||
} else {
|
} else {
|
||||||
speak_tts(cfg, sentences, events).await
|
speak_tts(cfg, sentences, events).await
|
||||||
@@ -186,7 +186,7 @@ async fn read_audio(
|
|||||||
// Alignment times may be per-chunk or cumulative depending on the
|
// Alignment times may be per-chunk or cumulative depending on the
|
||||||
// model; `emitted_ms` lets us normalise either into one timeline.
|
// model; `emitted_ms` lets us normalise either into one timeline.
|
||||||
let mut emitted_ms: u32 = 0;
|
let mut emitted_ms: u32 = 0;
|
||||||
// v3 audio tags come back as characters, and one can straddle chunks.
|
// Audio tags come back as characters, and one can straddle chunks.
|
||||||
let mut in_tag = false;
|
let mut in_tag = false;
|
||||||
let mut result = Ok(());
|
let mut result = Ok(());
|
||||||
while let Some(Ok(msg)) = source.next().await {
|
while let Some(Ok(msg)) = source.next().await {
|
||||||
@@ -266,7 +266,7 @@ fn absolutize(starts: &[i64], emitted_ms: u32) -> Vec<i64> {
|
|||||||
pub struct SentenceSplitter {
|
pub struct SentenceSplitter {
|
||||||
buf: String,
|
buf: String,
|
||||||
in_think: bool,
|
in_think: bool,
|
||||||
/// Whether v3 audio tags survive to the synthesiser or are dropped.
|
/// Whether audio tags survive to the synthesiser or are dropped.
|
||||||
keep_tags: bool,
|
keep_tags: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,17 +342,17 @@ fn drain_sentences(buf: &mut String, force: bool, keep_tags: bool) -> Vec<String
|
|||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Byte index just past a v3 audio tag starting at `i` ("[laughs]",
|
/// Byte index just past an audio tag starting at `i` ("[laughs]",
|
||||||
/// "[clears throat]"), if there is one. Letters and spaces only, so
|
/// "[whispers, in a German accent]"), if there is one. No digits, so "[1]"
|
||||||
/// "[1]" or a markdown link stays ordinary noise.
|
/// stays ordinary noise; the length cap keeps a bracketed sentence out.
|
||||||
fn tag_end(s: &str, i: usize) -> Option<usize> {
|
fn tag_end(s: &str, i: usize) -> Option<usize> {
|
||||||
let rest = s[i..].strip_prefix('[')?;
|
let rest = s[i..].strip_prefix('[')?;
|
||||||
let close = rest.find(']')?;
|
let close = rest.find(']')?;
|
||||||
let body = &rest[..close];
|
let body = &rest[..close];
|
||||||
let end = i + 1 + close + 1;
|
let end = i + 1 + close + 1;
|
||||||
let ok = !body.trim().is_empty()
|
let ok = !body.trim().is_empty()
|
||||||
&& body.len() <= 40
|
&& body.len() <= 80
|
||||||
&& body.chars().all(|c| c.is_alphabetic() || c == ' ' || c == '-')
|
&& body.chars().all(|c| c.is_alphabetic() || matches!(c, ' ' | '-' | ',' | '\''))
|
||||||
&& !s[end..].starts_with('(');
|
&& !s[end..].starts_with('(');
|
||||||
ok.then_some(end)
|
ok.then_some(end)
|
||||||
}
|
}
|
||||||
@@ -491,20 +491,38 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn audio_tags_survive_for_v3_only() {
|
fn audio_tags_survive_for_dialogue_models_only() {
|
||||||
let s = "[laughs]Fine, boss. [clears throat] Na gut.";
|
let s = "[laughs]Fine, boss. [clears throat] Na gut.";
|
||||||
assert_eq!(clean_for_speech(s, true), "[laughs] Fine, boss. [clears throat] Na gut.");
|
assert_eq!(clean_for_speech(s, true), "[laughs] Fine, boss. [clears throat] Na gut.");
|
||||||
assert_eq!(clean_for_speech(s, false), "Fine, boss. Na gut.");
|
assert_eq!(clean_for_speech(s, false), "Fine, boss. Na gut.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn free_text_directions_are_tags() {
|
||||||
|
let s = "[whispers, in a German accent] Na gut. [like she's half asleep] Okay.";
|
||||||
|
assert_eq!(clean_for_speech(s, true), s);
|
||||||
|
assert_eq!(clean_for_speech(s, false), "Na gut. Okay.");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn brackets_that_are_not_tags_stay_noise() {
|
fn brackets_that_are_not_tags_stay_noise() {
|
||||||
assert_eq!(clean_for_speech("see [1] and [the docs](x)", true), "see 1 and the docs x");
|
assert_eq!(clean_for_speech("see [1] and [the docs](x)", true), "see 1 and the docs x");
|
||||||
|
assert_eq!(clean_for_speech("see [1, 2]", true), "see 1, 2");
|
||||||
|
assert_eq!(clean_for_speech("[see above, then reboot](x)", true), "see above, then reboot x");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn captions_hide_tags() {
|
fn captions_hide_tags() {
|
||||||
assert_eq!(strip_tags("[sighs] Okay, boss."), "Okay, boss.");
|
assert_eq!(strip_tags("[sighs] Okay, boss."), "Okay, boss.");
|
||||||
|
assert_eq!(strip_tags("[whispers, in a German accent] Na gut."), "Na gut.");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn v4_streams_over_dialogue() {
|
||||||
|
let cfg = |m: &str| TtsConfig { key: String::new(), voice_id: String::new(), model: m.into() };
|
||||||
|
assert!(cfg("eleven_v4_turbo").uses_dialogue());
|
||||||
|
assert!(cfg("eleven_v3_conversational").uses_dialogue());
|
||||||
|
assert!(!cfg("eleven_flash_v2_5").uses_dialogue());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -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
|
|
||||||
])
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{ lib, rustPlatform }:
|
||||||
|
|
||||||
|
# Wiring (user, socket, policy, secrets) lives in services/identity/pass-broker.nix.
|
||||||
|
rustPlatform.buildRustPackage {
|
||||||
|
pname = "pass-broker";
|
||||||
|
version = "0.1.0";
|
||||||
|
|
||||||
|
src = ./pass-broker;
|
||||||
|
cargoLock.lockFile = ./pass-broker/Cargo.lock;
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "Telegram-approved access to a Proton Pass agent session";
|
||||||
|
mainProgram = "pass-broker";
|
||||||
|
platforms = lib.platforms.linux;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
[package]
|
||||||
|
name = "pass-broker"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow = "1"
|
||||||
|
axum = { version = "0.8", default-features = false, features = ["http1", "json", "query", "tokio"] }
|
||||||
|
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
|
||||||
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
serde_json = "1"
|
||||||
|
sha2 = "0.10"
|
||||||
|
tokio = { version = "1", features = ["rt-multi-thread", "macros", "net", "sync", "time", "process", "io-util"] }
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
opt-level = 2
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
use crate::config::ApprovalConfig;
|
||||||
|
use crate::telegram::{Telegram, Verdict};
|
||||||
|
use anyhow::{anyhow, Context, Result};
|
||||||
|
use serde_json::{json, Value};
|
||||||
|
use std::future::Future;
|
||||||
|
use std::pin::Pin;
|
||||||
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
|
/// Shows a prompt and waits for its verdict: via this broker's own bot, or
|
||||||
|
/// via the gateway that owns the shared one.
|
||||||
|
pub enum Approver {
|
||||||
|
Direct { tg: Telegram, host: String },
|
||||||
|
Gateway(GatewayClient),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct GatewayClient {
|
||||||
|
http: reqwest::Client,
|
||||||
|
url: String,
|
||||||
|
token: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Approver {
|
||||||
|
pub fn new(cfg: &ApprovalConfig, host: &str) -> Result<Self> {
|
||||||
|
Ok(match cfg {
|
||||||
|
ApprovalConfig::Telegram(t) => {
|
||||||
|
Approver::Direct { tg: Telegram::new(t)?, host: host.to_string() }
|
||||||
|
}
|
||||||
|
ApprovalConfig::Gateway(g) => Approver::Gateway(GatewayClient {
|
||||||
|
http: reqwest::Client::builder().timeout(Duration::from_secs(40)).build()?,
|
||||||
|
url: g.url.trim_end_matches('/').to_string(),
|
||||||
|
token: std::fs::read_to_string(&g.token_file)
|
||||||
|
.with_context(|| format!("reading {}", g.token_file.display()))?
|
||||||
|
.trim()
|
||||||
|
.to_string(),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `body` is the prompt without its "🔑 host:" header; the gateway adds
|
||||||
|
/// that itself, from the token.
|
||||||
|
pub async fn ask(
|
||||||
|
&self,
|
||||||
|
body: &str,
|
||||||
|
timeout: Duration,
|
||||||
|
gone: Pin<&mut impl Future<Output = ()>>,
|
||||||
|
) -> Result<Verdict> {
|
||||||
|
match self {
|
||||||
|
Approver::Direct { tg, host } => tg.ask(&format!("🔑 {host}: {body}"), timeout, gone).await,
|
||||||
|
Approver::Gateway(g) => g.ask(body, timeout, gone).await,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GatewayClient {
|
||||||
|
async fn ask(
|
||||||
|
&self,
|
||||||
|
body: &str,
|
||||||
|
timeout: Duration,
|
||||||
|
mut gone: Pin<&mut impl Future<Output = ()>>,
|
||||||
|
) -> Result<Verdict> {
|
||||||
|
let resp: Value = self
|
||||||
|
.http
|
||||||
|
.post(format!("{}/ask", self.url))
|
||||||
|
.bearer_auth(&self.token)
|
||||||
|
.json(&json!({ "text": body, "timeout_secs": timeout.as_secs() }))
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
.and_then(|r| r.error_for_status())
|
||||||
|
.map_err(|e| anyhow!("gateway: {}", e.without_url()))?
|
||||||
|
.json()
|
||||||
|
.await
|
||||||
|
.map_err(|e| anyhow!("gateway: {}", e.without_url()))?;
|
||||||
|
let id = resp["id"].as_str().ok_or_else(|| anyhow!("gateway returned no id"))?.to_string();
|
||||||
|
|
||||||
|
// The gateway expires the prompt itself; this only bounds a gateway
|
||||||
|
// that stopped answering.
|
||||||
|
let give_up = Instant::now() + timeout + Duration::from_secs(30);
|
||||||
|
while Instant::now() < give_up {
|
||||||
|
let polled = tokio::select! {
|
||||||
|
biased;
|
||||||
|
_ = gone.as_mut() => {
|
||||||
|
let _ = self
|
||||||
|
.http
|
||||||
|
.delete(format!("{}/ask/{id}", self.url))
|
||||||
|
.bearer_auth(&self.token)
|
||||||
|
.send()
|
||||||
|
.await;
|
||||||
|
return Ok(Verdict::Cancelled);
|
||||||
|
}
|
||||||
|
r = self.status(&id) => r,
|
||||||
|
};
|
||||||
|
match polled {
|
||||||
|
Ok(Some(v)) => return Ok(v),
|
||||||
|
Ok(None) => {}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("{e:#}");
|
||||||
|
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(Verdict::Expired)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// None while pending.
|
||||||
|
async fn status(&self, id: &str) -> Result<Option<Verdict>> {
|
||||||
|
let resp = self
|
||||||
|
.http
|
||||||
|
.get(format!("{}/ask/{id}?wait=25", self.url))
|
||||||
|
.bearer_auth(&self.token)
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
.map_err(|e| anyhow!("gateway: {}", e.without_url()))?;
|
||||||
|
// A restarted gateway has forgotten the prompt.
|
||||||
|
if resp.status() == reqwest::StatusCode::NOT_FOUND {
|
||||||
|
return Ok(Some(Verdict::Expired));
|
||||||
|
}
|
||||||
|
let v: Value = resp
|
||||||
|
.error_for_status()
|
||||||
|
.map_err(|e| anyhow!("gateway: {}", e.without_url()))?
|
||||||
|
.json()
|
||||||
|
.await
|
||||||
|
.map_err(|e| anyhow!("gateway: {}", e.without_url()))?;
|
||||||
|
match v["status"].as_str() {
|
||||||
|
Some("pending") => Ok(None),
|
||||||
|
_ => Ok(Some(serde_json::from_value(v["status"].clone())?)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
use crate::proto::{Reply, Request, DEFAULT_SOCKET};
|
||||||
|
use anyhow::Result;
|
||||||
|
use std::time::Duration;
|
||||||
|
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
|
||||||
|
use tokio::net::UnixStream;
|
||||||
|
|
||||||
|
const FIRST_REPLY: Duration = Duration::from_secs(30);
|
||||||
|
|
||||||
|
/// Prints the value on stdout. Exit 1 = refused/failed, 2 = usage or no broker.
|
||||||
|
pub async fn get(args: &[String]) -> Result<()> {
|
||||||
|
let mut req = Request {
|
||||||
|
vault: None,
|
||||||
|
item: String::new(),
|
||||||
|
field: "password".into(),
|
||||||
|
reason: String::new(),
|
||||||
|
};
|
||||||
|
let mut it = args.iter();
|
||||||
|
while let Some(flag) = it.next() {
|
||||||
|
let Some(val) = it.next() else { usage() };
|
||||||
|
match flag.as_str() {
|
||||||
|
"--vault" => req.vault = Some(val.clone()),
|
||||||
|
"--item" => req.item = val.clone(),
|
||||||
|
"--field" => req.field = val.clone(),
|
||||||
|
"--reason" => req.reason = val.clone(),
|
||||||
|
_ => usage(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if req.item.is_empty() || req.reason.trim().is_empty() {
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = std::env::var("PASS_BROKER_SOCKET").unwrap_or_else(|_| DEFAULT_SOCKET.into());
|
||||||
|
let stream = match UnixStream::connect(&path).await {
|
||||||
|
Ok(s) => s,
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("pass-broker: cannot reach {path}: {e}");
|
||||||
|
std::process::exit(2);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let (rd, mut wr) = stream.into_split();
|
||||||
|
let mut line = serde_json::to_string(&req)?;
|
||||||
|
line.push('\n');
|
||||||
|
wr.write_all(line.as_bytes()).await?;
|
||||||
|
|
||||||
|
let mut lines = BufReader::new(rd).lines();
|
||||||
|
// Bounds only the first reply: after Pending the daemon times the prompt
|
||||||
|
// out itself. A crash-looping broker still accepts via the socket unit,
|
||||||
|
// so without this the client would wait forever.
|
||||||
|
let mut pending = false;
|
||||||
|
loop {
|
||||||
|
let next = if pending {
|
||||||
|
lines.next_line().await?
|
||||||
|
} else {
|
||||||
|
match tokio::time::timeout(FIRST_REPLY, lines.next_line()).await {
|
||||||
|
Ok(r) => r?,
|
||||||
|
Err(_) => {
|
||||||
|
eprintln!(
|
||||||
|
"pass-broker: no answer within {}s; see journalctl -u pass-broker",
|
||||||
|
FIRST_REPLY.as_secs()
|
||||||
|
);
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let Some(line) = next else { break };
|
||||||
|
match serde_json::from_str::<Reply>(&line)? {
|
||||||
|
Reply::Pending { message } => {
|
||||||
|
pending = true;
|
||||||
|
eprintln!(">> pass-broker: {message}");
|
||||||
|
}
|
||||||
|
Reply::Ok { value } => {
|
||||||
|
println!("{value}");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
Reply::Error { error } => {
|
||||||
|
eprintln!("pass-broker: {error}");
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
eprintln!("pass-broker: daemon closed the connection without an answer");
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage() -> ! {
|
||||||
|
eprintln!("{}", crate::USAGE);
|
||||||
|
std::process::exit(2);
|
||||||
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
use anyhow::{bail, Context, Result};
|
||||||
|
use serde::Deserialize;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
/// Written by services/identity/pass-broker.nix; path in $PASS_BROKER_CONFIG.
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct Config {
|
||||||
|
pub host: String,
|
||||||
|
pub default_vault: String,
|
||||||
|
/// Peer uids are checked against these; root is always allowed.
|
||||||
|
pub allowed_users: Vec<String>,
|
||||||
|
pub pass_cli: String,
|
||||||
|
pub session_dir: PathBuf,
|
||||||
|
pub pat_file: PathBuf,
|
||||||
|
pub approval_timeout_secs: u64,
|
||||||
|
pub approval: ApprovalConfig,
|
||||||
|
/// First match wins; no match means deny.
|
||||||
|
pub rules: Vec<Rule>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Who shows the prompt: this broker's own bot, or the shared gateway.
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum ApprovalConfig {
|
||||||
|
Telegram(TelegramConfig),
|
||||||
|
Gateway(GatewayClientConfig),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct TelegramConfig {
|
||||||
|
pub api_base: String,
|
||||||
|
pub token_file: PathBuf,
|
||||||
|
pub chat_id_file: PathBuf,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct GatewayClientConfig {
|
||||||
|
pub url: String,
|
||||||
|
pub token_file: PathBuf,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Written by services/identity/pass-broker-gateway.nix; path in
|
||||||
|
/// $PASS_BROKER_GATEWAY_CONFIG.
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct GatewayConfig {
|
||||||
|
pub listen: String,
|
||||||
|
pub telegram: TelegramConfig,
|
||||||
|
/// Hashes only: the gateway host never holds a broker's token.
|
||||||
|
pub hosts: Vec<GatewayHost>,
|
||||||
|
pub max_timeout_secs: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct GatewayHost {
|
||||||
|
pub name: String,
|
||||||
|
pub token_sha256: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn load<T: serde::de::DeserializeOwned>(var: &str) -> Result<T> {
|
||||||
|
let path = std::env::var(var).with_context(|| format!("{var} unset"))?;
|
||||||
|
let text = std::fs::read_to_string(&path).with_context(|| format!("reading {path}"))?;
|
||||||
|
serde_json::from_str(&text).with_context(|| format!("parsing {path}"))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct Rule {
|
||||||
|
pub vault: Option<String>,
|
||||||
|
/// Item title; `*` matches any run of characters.
|
||||||
|
pub item: String,
|
||||||
|
pub approval: Approval,
|
||||||
|
/// After an approval, further requests for the item skip the prompt for this long.
|
||||||
|
pub grant_minutes: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Clone, Copy, PartialEq, Debug)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum Approval {
|
||||||
|
Auto,
|
||||||
|
Ask,
|
||||||
|
Deny,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Config {
|
||||||
|
pub fn load() -> Result<Self> {
|
||||||
|
load("PASS_BROKER_CONFIG")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn rule_for(&self, vault: &str, item: &str) -> Option<&Rule> {
|
||||||
|
self.rules.iter().find(|r| {
|
||||||
|
r.vault.as_deref().unwrap_or(&self.default_vault) == vault && glob(&r.item, item)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Resolved once at startup: a user added later needs a broker restart.
|
||||||
|
pub fn allowed_uids(&self) -> Result<Vec<u32>> {
|
||||||
|
let passwd = std::fs::read_to_string("/etc/passwd")?;
|
||||||
|
let mut uids = vec![0];
|
||||||
|
for name in &self.allowed_users {
|
||||||
|
let uid = passwd
|
||||||
|
.lines()
|
||||||
|
.map(|l| l.split(':').collect::<Vec<_>>())
|
||||||
|
.find(|f| f.len() > 2 && f[0] == name)
|
||||||
|
.and_then(|f| f[2].parse().ok());
|
||||||
|
match uid {
|
||||||
|
Some(uid) => uids.push(uid),
|
||||||
|
None => bail!("allowed user {name:?} not in /etc/passwd"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(uids)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn glob(pat: &str, s: &str) -> bool {
|
||||||
|
let parts: Vec<&str> = pat.split('*').collect();
|
||||||
|
if parts.len() == 1 {
|
||||||
|
return pat == s;
|
||||||
|
}
|
||||||
|
let (first, last) = (parts[0], parts[parts.len() - 1]);
|
||||||
|
if !s.starts_with(first) || s.len() < first.len() + last.len() || !s.ends_with(last) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let mut rest = &s[first.len()..s.len() - last.len()];
|
||||||
|
for mid in &parts[1..parts.len() - 1] {
|
||||||
|
match rest.find(mid) {
|
||||||
|
Some(i) => rest = &rest[i + mid.len()..],
|
||||||
|
None => return false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::glob;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn globs() {
|
||||||
|
assert!(glob("root@*", "root@jupiter"));
|
||||||
|
assert!(!glob("root@*", "darman@jupiter"));
|
||||||
|
assert!(glob("*", ""));
|
||||||
|
assert!(glob("a*b*c", "aXbYc"));
|
||||||
|
assert!(!glob("a*b*c", "acb"));
|
||||||
|
assert!(!glob("ab*ba", "aba"));
|
||||||
|
assert!(glob("exact", "exact"));
|
||||||
|
assert!(!glob("exact", "exact2"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,323 @@
|
|||||||
|
use crate::config::{Approval, Config};
|
||||||
|
use crate::pass::Pass;
|
||||||
|
use crate::proto::{Reply, Request};
|
||||||
|
use crate::approver::Approver;
|
||||||
|
use crate::telegram::Verdict;
|
||||||
|
use anyhow::{bail, Context, Result};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::future::Future;
|
||||||
|
use std::os::fd::FromRawFd;
|
||||||
|
use std::pin::Pin;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use std::time::{Duration, Instant};
|
||||||
|
use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader};
|
||||||
|
use tokio::net::unix::{OwnedReadHalf, OwnedWriteHalf};
|
||||||
|
use tokio::net::{UnixListener, UnixStream};
|
||||||
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
|
struct State {
|
||||||
|
cfg: Config,
|
||||||
|
uids: Vec<u32>,
|
||||||
|
pass: Pass,
|
||||||
|
approver: Approver,
|
||||||
|
/// "vault\0item" -> when the last approval stops covering it.
|
||||||
|
grants: Mutex<HashMap<String, Instant>>,
|
||||||
|
/// One prompt per host at a time; direct mode polls getUpdates in ask.
|
||||||
|
asking: Mutex<()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn run() -> Result<()> {
|
||||||
|
let cfg = Config::load()?;
|
||||||
|
let state = Arc::new(State {
|
||||||
|
uids: cfg.allowed_uids()?,
|
||||||
|
pass: Pass::new(&cfg),
|
||||||
|
approver: Approver::new(&cfg.approval, &cfg.host)?,
|
||||||
|
grants: Mutex::new(HashMap::new()),
|
||||||
|
asking: Mutex::new(()),
|
||||||
|
cfg,
|
||||||
|
});
|
||||||
|
// Not fatal: a stale PAT should show up in the journal, not stop the socket.
|
||||||
|
if let Err(e) = state.pass.ensure_session().await {
|
||||||
|
eprintln!("initial login failed: {e:#}");
|
||||||
|
}
|
||||||
|
|
||||||
|
let listener = listener()?;
|
||||||
|
eprintln!("pass-broker ready");
|
||||||
|
loop {
|
||||||
|
let (stream, _) = listener.accept().await?;
|
||||||
|
let state = state.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
if let Err(e) = handle(state, stream).await {
|
||||||
|
eprintln!("connection: {e:#}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// From pass-broker.socket. The socket is 0666; access control is the peer
|
||||||
|
/// uid check in handle(), so a new client needs no re-login for a group.
|
||||||
|
fn listener() -> Result<UnixListener> {
|
||||||
|
let ours = std::env::var("LISTEN_PID").ok() == Some(std::process::id().to_string());
|
||||||
|
if !ours || std::env::var("LISTEN_FDS").ok().as_deref() != Some("1") {
|
||||||
|
bail!("expected exactly one socket from systemd (pass-broker.socket)");
|
||||||
|
}
|
||||||
|
let l = unsafe { std::os::unix::net::UnixListener::from_raw_fd(3) };
|
||||||
|
l.set_nonblocking(true)?;
|
||||||
|
Ok(UnixListener::from_std(l)?)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn handle(state: Arc<State>, stream: UnixStream) -> Result<()> {
|
||||||
|
let cred = stream.peer_cred()?;
|
||||||
|
let (mut rd, mut wr) = stream.into_split();
|
||||||
|
// Read before refusing, or the client's write hits a closed socket and
|
||||||
|
// it reports EPIPE instead of the reason.
|
||||||
|
let mut line = String::new();
|
||||||
|
BufReader::new((&mut rd).take(64 * 1024)).read_line(&mut line).await?;
|
||||||
|
if !state.uids.contains(&cred.uid()) {
|
||||||
|
eprintln!("refused uid {}", cred.uid());
|
||||||
|
return send(&mut wr, Reply::Error { error: "uid not allowed".into() }).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
let req: Request = serde_json::from_str(&line).context("bad request")?;
|
||||||
|
let vault = req.vault.clone().unwrap_or_else(|| state.cfg.default_vault.clone());
|
||||||
|
// A client killed while queued (the broker restarting) leaves its request
|
||||||
|
// in the socket; nobody would see the answer or know who asked.
|
||||||
|
let who = match cred.pid().and_then(|pid| requester(pid, cred.uid())) {
|
||||||
|
Some(who) if !closed(&rd) => who,
|
||||||
|
_ => {
|
||||||
|
eprintln!("dropped {vault}/{}: requester went away", req.item);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
eprintln!(
|
||||||
|
"request {vault}/{} ({}) reason={:?} by {}",
|
||||||
|
req.item,
|
||||||
|
req.field,
|
||||||
|
req.reason,
|
||||||
|
who.summary()
|
||||||
|
);
|
||||||
|
|
||||||
|
let gone = client_gone(&rd);
|
||||||
|
tokio::pin!(gone);
|
||||||
|
let reply = match decide(&state, &mut wr, gone.as_mut(), &vault, &req, &who).await {
|
||||||
|
Ok(()) if closed(&rd) => Reply::Error { error: "requester went away".into() },
|
||||||
|
Ok(()) => {
|
||||||
|
let reason = format!("{} (pass-broker on {})", req.reason, state.cfg.host);
|
||||||
|
match state.pass.get(&vault, &req.item, &req.field, &reason).await {
|
||||||
|
Ok(value) => Reply::Ok { value },
|
||||||
|
Err(e) => Reply::Error { error: format!("{e:#}") },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => Reply::Error { error: format!("{e:#}") },
|
||||||
|
};
|
||||||
|
match &reply {
|
||||||
|
Reply::Ok { .. } => eprintln!("served {vault}/{}", req.item),
|
||||||
|
Reply::Error { error } => eprintln!("refused {vault}/{}: {error}", req.item),
|
||||||
|
Reply::Pending { .. } => {}
|
||||||
|
}
|
||||||
|
if closed(&rd) {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
send(&mut wr, reply).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn decide(
|
||||||
|
state: &State,
|
||||||
|
wr: &mut OwnedWriteHalf,
|
||||||
|
mut gone: Pin<&mut impl Future<Output = ()>>,
|
||||||
|
vault: &str,
|
||||||
|
req: &Request,
|
||||||
|
who: &Requester,
|
||||||
|
) -> Result<()> {
|
||||||
|
let Some(rule) = state.cfg.rule_for(vault, &req.item) else {
|
||||||
|
bail!("no rule allows {vault}/{}", req.item);
|
||||||
|
};
|
||||||
|
match rule.approval {
|
||||||
|
Approval::Deny => bail!("policy denies {vault}/{}", req.item),
|
||||||
|
Approval::Auto => return Ok(()),
|
||||||
|
Approval::Ask => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
let key = format!("{vault}\0{}", req.item);
|
||||||
|
let granted = |grants: &HashMap<String, Instant>| grants.get(&key).is_some_and(|t| *t > Instant::now());
|
||||||
|
if granted(&*state.grants.lock().await) {
|
||||||
|
eprintln!("covered by an earlier approval");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
// Before the lock, so a client queued behind another prompt hears from us.
|
||||||
|
let _ = send(wr, Reply::Pending { message: "waiting for approval on Telegram".into() }).await;
|
||||||
|
// Biased: a client that already hung up must lose even to a free lock,
|
||||||
|
// or it would get a prompt.
|
||||||
|
let _asking = tokio::select! {
|
||||||
|
biased;
|
||||||
|
_ = gone.as_mut() => bail!("requester went away"),
|
||||||
|
guard = state.asking.lock() => guard,
|
||||||
|
};
|
||||||
|
// A concurrent request for the same item may have been approved meanwhile.
|
||||||
|
if granted(&*state.grants.lock().await) {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let grant = match rule.grant_minutes {
|
||||||
|
0 => "Approves this request only.".to_string(),
|
||||||
|
n => format!("Approving covers further requests for {n} min."),
|
||||||
|
};
|
||||||
|
let body = format!(
|
||||||
|
"{vault} / {item} ({field})\nReason: {reason}\nBy: {by}\nCommand: {command}\nChain: {chain}\n{grant}",
|
||||||
|
item = req.item,
|
||||||
|
field = req.field,
|
||||||
|
reason = req.reason,
|
||||||
|
by = who.who,
|
||||||
|
command = who.command,
|
||||||
|
chain = who.chain,
|
||||||
|
);
|
||||||
|
let timeout = Duration::from_secs(state.cfg.approval_timeout_secs);
|
||||||
|
match state.approver.ask(&body, timeout, gone).await? {
|
||||||
|
Verdict::Approved => {
|
||||||
|
if rule.grant_minutes > 0 {
|
||||||
|
let until = Instant::now() + Duration::from_secs(rule.grant_minutes * 60);
|
||||||
|
state.grants.lock().await.insert(key, until);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Verdict::Denied => bail!("denied on Telegram"),
|
||||||
|
Verdict::Expired => bail!("no answer on Telegram within {}s", timeout.as_secs()),
|
||||||
|
Verdict::Cancelled => bail!("requester went away"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Resolves once the client hangs up. It sends nothing after its request, so
|
||||||
|
/// readable means EOF; stray bytes are discarded.
|
||||||
|
async fn client_gone(rd: &OwnedReadHalf) {
|
||||||
|
while rd.readable().await.is_ok() {
|
||||||
|
if closed(rd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn closed(rd: &OwnedReadHalf) -> bool {
|
||||||
|
match rd.try_read(&mut [0u8; 64]) {
|
||||||
|
Ok(0) => true,
|
||||||
|
Ok(_) => false,
|
||||||
|
Err(e) => e.kind() != std::io::ErrorKind::WouldBlock,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn send(wr: &mut OwnedWriteHalf, reply: Reply) -> Result<()> {
|
||||||
|
let mut line = serde_json::to_string(&reply)?;
|
||||||
|
line.push('\n');
|
||||||
|
wr.write_all(line.as_bytes()).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Who is asking, for the prompt and the journal. A hint, not identity: any
|
||||||
|
/// process of the same uid can make itself look like anything.
|
||||||
|
struct Requester {
|
||||||
|
/// "darman via Claude Code", "darman via foot", …
|
||||||
|
who: String,
|
||||||
|
/// The client's parent, i.e. the caller (the client is `pass-broker get`).
|
||||||
|
command: String,
|
||||||
|
chain: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Requester {
|
||||||
|
fn summary(&self) -> String {
|
||||||
|
format!("{} [{}] chain: {}", self.who, self.command, self.chain)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// None when the client has already exited.
|
||||||
|
fn requester(pid: i32, uid: u32) -> Option<Requester> {
|
||||||
|
let client = stat(pid)?;
|
||||||
|
let command = std::fs::read(format!("/proc/{}/cmdline", client.ppid))
|
||||||
|
.map(|b| {
|
||||||
|
let s = String::from_utf8_lossy(&b);
|
||||||
|
let args: Vec<&str> = s.split('\0').filter(|a| !a.is_empty()).map(short_path).collect();
|
||||||
|
truncate(&args.join(" "), 200)
|
||||||
|
})
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
let mut ancestors = vec![];
|
||||||
|
let mut p = client.ppid;
|
||||||
|
while p > 1 && ancestors.len() < 12 {
|
||||||
|
let Some(s) = stat(p) else { break };
|
||||||
|
let comm = std::fs::read_to_string(format!("/proc/{p}/comm")).unwrap_or_default();
|
||||||
|
ancestors.push((comm.trim().to_string(), s.tty));
|
||||||
|
p = s.ppid;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Claude Code's own process is `claude`. Otherwise the origin is whatever
|
||||||
|
// holds the terminal: the first ancestor without a tty (foot, sshd-session,
|
||||||
|
// the desktop app's terminal panel).
|
||||||
|
let via = if ancestors.iter().any(|(c, _)| c == "claude") {
|
||||||
|
"Claude Code".to_string()
|
||||||
|
} else if client.tty == 0 {
|
||||||
|
"no terminal".to_string()
|
||||||
|
} else {
|
||||||
|
match ancestors.iter().find(|(_, tty)| *tty == 0).map(|(c, _)| c.as_str()) {
|
||||||
|
Some("claude-desktop") => "Claude desktop's terminal".to_string(),
|
||||||
|
Some(c) => c.to_string(),
|
||||||
|
None => "unknown".to_string(),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let chain = ancestors.iter().take(8).map(|(c, _)| c.as_str()).collect::<Vec<_>>().join(" ← ");
|
||||||
|
Some(Requester { who: format!("{} via {via}", user_name(uid)), command, chain })
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Stat {
|
||||||
|
ppid: i32,
|
||||||
|
tty: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn stat(pid: i32) -> Option<Stat> {
|
||||||
|
let stat = std::fs::read_to_string(format!("/proc/{pid}/stat")).ok()?;
|
||||||
|
// comm may contain spaces and parens; fields resume after the last ')':
|
||||||
|
// state ppid pgrp session tty_nr …
|
||||||
|
let f: Vec<&str> = stat.rsplit_once(')')?.1.split_whitespace().collect();
|
||||||
|
Some(Stat { ppid: f.get(1)?.parse().ok()?, tty: f.get(4)?.parse().ok()? })
|
||||||
|
}
|
||||||
|
|
||||||
|
fn user_name(uid: u32) -> String {
|
||||||
|
std::fs::read_to_string("/etc/passwd")
|
||||||
|
.ok()
|
||||||
|
.and_then(|p| {
|
||||||
|
p.lines().find_map(|l| {
|
||||||
|
let f: Vec<&str> = l.split(':').collect();
|
||||||
|
(f.len() > 2 && f[2] == uid.to_string()).then(|| f[0].to_string())
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| format!("uid {uid}"))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `/nix/store/…-bash-5.3/bin/bash` and profile paths down to `bash`.
|
||||||
|
fn short_path(arg: &str) -> &str {
|
||||||
|
const PREFIXES: [&str; 4] = ["/nix/store/", "/run/current-system/", "/run/wrappers/", "/etc/profiles/"];
|
||||||
|
if PREFIXES.iter().any(|p| arg.starts_with(p)) && arg.contains("/bin/") {
|
||||||
|
arg.rsplit('/').next().unwrap_or(arg)
|
||||||
|
} else {
|
||||||
|
arg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn truncate(s: &str, max: usize) -> String {
|
||||||
|
match s.char_indices().nth(max) {
|
||||||
|
Some((i, _)) => format!("{}…", &s[..i]),
|
||||||
|
None => s.to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::short_path;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn short_paths() {
|
||||||
|
assert_eq!(short_path("/nix/store/abc-bash-interactive-5.3p9/bin/bash"), "bash");
|
||||||
|
assert_eq!(short_path("/run/current-system/sw/bin/try-get"), "try-get");
|
||||||
|
assert_eq!(short_path("/run/wrappers/bin/sudo"), "sudo");
|
||||||
|
assert_eq!(short_path("/nix/store/abc-config.json"), "/nix/store/abc-config.json");
|
||||||
|
assert_eq!(short_path("./scripts/deploy"), "./scripts/deploy");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,207 @@
|
|||||||
|
//! `pass-broker gateway`: the one owner of the approval bot, shared by every
|
||||||
|
//! host's broker over the tailnet. It sees prompts and verdicts, never items.
|
||||||
|
|
||||||
|
use crate::config::{load, GatewayConfig};
|
||||||
|
use crate::telegram::{nonce, Telegram, Verdict};
|
||||||
|
use anyhow::{Context, Result};
|
||||||
|
use axum::extract::{Path, Query, State};
|
||||||
|
use axum::http::{HeaderMap, StatusCode};
|
||||||
|
use axum::routing::{get, post};
|
||||||
|
use axum::{Json, Router};
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde_json::{json, Value};
|
||||||
|
use sha2::{Digest, Sha256};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
use std::time::{Duration, Instant};
|
||||||
|
use tokio::sync::watch;
|
||||||
|
|
||||||
|
struct Prompt {
|
||||||
|
host: String,
|
||||||
|
text: String,
|
||||||
|
message_id: i64,
|
||||||
|
deadline: Instant,
|
||||||
|
verdict: watch::Sender<Option<Verdict>>,
|
||||||
|
decided_at: Option<Instant>,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Gateway {
|
||||||
|
tg: Telegram,
|
||||||
|
/// sha256(token) -> host name.
|
||||||
|
hosts: HashMap<String, String>,
|
||||||
|
max_timeout: Duration,
|
||||||
|
prompts: Mutex<HashMap<String, Prompt>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn run() -> Result<()> {
|
||||||
|
let cfg: GatewayConfig = load("PASS_BROKER_GATEWAY_CONFIG")?;
|
||||||
|
let gw = Arc::new(Gateway {
|
||||||
|
tg: Telegram::new(&cfg.telegram)?,
|
||||||
|
hosts: cfg.hosts.into_iter().map(|h| (h.token_sha256.to_lowercase(), h.name)).collect(),
|
||||||
|
max_timeout: Duration::from_secs(cfg.max_timeout_secs),
|
||||||
|
prompts: Mutex::new(HashMap::new()),
|
||||||
|
});
|
||||||
|
|
||||||
|
let poller = gw.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
loop {
|
||||||
|
let live = |n: &str| {
|
||||||
|
poller.prompts.lock().unwrap().get(n).is_some_and(|p| p.decided_at.is_none())
|
||||||
|
};
|
||||||
|
match poller.tg.taps(25, live).await {
|
||||||
|
Ok(taps) => {
|
||||||
|
for t in taps {
|
||||||
|
poller.decide(&t.nonce, t.verdict).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("{e:#}");
|
||||||
|
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let sweeper = gw.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
loop {
|
||||||
|
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||||
|
let now = Instant::now();
|
||||||
|
let expired: Vec<String> = {
|
||||||
|
let mut map = sweeper.prompts.lock().unwrap();
|
||||||
|
// Decided prompts linger so a broker polling late still gets its verdict.
|
||||||
|
map.retain(|_, p| p.decided_at.is_none_or(|t| now - t < Duration::from_secs(600)));
|
||||||
|
map.iter()
|
||||||
|
.filter(|(_, p)| p.decided_at.is_none() && p.deadline <= now)
|
||||||
|
.map(|(id, _)| id.clone())
|
||||||
|
.collect()
|
||||||
|
};
|
||||||
|
for id in expired {
|
||||||
|
sweeper.decide(&id, Verdict::Expired).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let app = Router::new()
|
||||||
|
.route("/ask", post(ask))
|
||||||
|
.route("/ask/{id}", get(status).delete(cancel))
|
||||||
|
.with_state(gw);
|
||||||
|
let listener = tokio::net::TcpListener::bind(&cfg.listen)
|
||||||
|
.await
|
||||||
|
.with_context(|| format!("binding {}", cfg.listen))?;
|
||||||
|
eprintln!("pass-broker gateway listening on {}", cfg.listen);
|
||||||
|
axum::serve(listener, app).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Gateway {
|
||||||
|
fn host(&self, headers: &HeaderMap) -> Option<String> {
|
||||||
|
let token = headers.get("authorization")?.to_str().ok()?.strip_prefix("Bearer ")?;
|
||||||
|
let hash: String =
|
||||||
|
Sha256::digest(token.trim().as_bytes()).iter().map(|b| format!("{b:02x}")).collect();
|
||||||
|
self.hosts.get(&hash).cloned()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// First verdict wins; later ones are no-ops.
|
||||||
|
async fn decide(&self, id: &str, verdict: Verdict) {
|
||||||
|
let decided = {
|
||||||
|
let mut map = self.prompts.lock().unwrap();
|
||||||
|
match map.get_mut(id) {
|
||||||
|
Some(p) if p.decided_at.is_none() => {
|
||||||
|
p.decided_at = Some(Instant::now());
|
||||||
|
p.verdict.send_replace(Some(verdict));
|
||||||
|
Some((p.host.clone(), p.message_id, p.text.clone()))
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if let Some((host, message_id, text)) = decided {
|
||||||
|
eprintln!("{host}: {id} {verdict:?}");
|
||||||
|
self.tg.conclude(message_id, &text, verdict).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Another host's prompt looks exactly like a missing one.
|
||||||
|
fn owns(&self, id: &str, host: &str) -> bool {
|
||||||
|
self.prompts.lock().unwrap().get(id).is_some_and(|p| p.host == host)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct AskBody {
|
||||||
|
text: String,
|
||||||
|
timeout_secs: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn ask(
|
||||||
|
State(gw): State<Arc<Gateway>>,
|
||||||
|
headers: HeaderMap,
|
||||||
|
Json(body): Json<AskBody>,
|
||||||
|
) -> Result<Json<Value>, StatusCode> {
|
||||||
|
let host = gw.host(&headers).ok_or(StatusCode::UNAUTHORIZED)?;
|
||||||
|
let id = nonce().map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||||
|
// Labelled from the token, not the request, so no host can pose as another.
|
||||||
|
let text = format!("🔑 {host}: {}", body.text);
|
||||||
|
let message_id = gw.tg.prompt(&text, &id).await.map_err(|e| {
|
||||||
|
eprintln!("{host}: {e:#}");
|
||||||
|
StatusCode::BAD_GATEWAY
|
||||||
|
})?;
|
||||||
|
let timeout = Duration::from_secs(body.timeout_secs).min(gw.max_timeout);
|
||||||
|
let (verdict, _) = watch::channel(None);
|
||||||
|
gw.prompts.lock().unwrap().insert(
|
||||||
|
id.clone(),
|
||||||
|
Prompt {
|
||||||
|
host: host.clone(),
|
||||||
|
text,
|
||||||
|
message_id,
|
||||||
|
deadline: Instant::now() + timeout,
|
||||||
|
verdict,
|
||||||
|
decided_at: None,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
eprintln!("{host}: {id} asked");
|
||||||
|
Ok(Json(json!({ "id": id })))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct Wait {
|
||||||
|
wait: Option<u64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn status(
|
||||||
|
State(gw): State<Arc<Gateway>>,
|
||||||
|
headers: HeaderMap,
|
||||||
|
Path(id): Path<String>,
|
||||||
|
Query(q): Query<Wait>,
|
||||||
|
) -> Result<Json<Value>, StatusCode> {
|
||||||
|
let host = gw.host(&headers).ok_or(StatusCode::UNAUTHORIZED)?;
|
||||||
|
let mut rx = {
|
||||||
|
let map = gw.prompts.lock().unwrap();
|
||||||
|
match map.get(&id) {
|
||||||
|
Some(p) if p.host == host => p.verdict.subscribe(),
|
||||||
|
_ => return Err(StatusCode::NOT_FOUND),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let wait = Duration::from_secs(q.wait.unwrap_or(0).min(30));
|
||||||
|
let verdict = match tokio::time::timeout(wait, rx.wait_for(Option::is_some)).await {
|
||||||
|
Ok(Ok(v)) => *v,
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
Ok(Json(match verdict {
|
||||||
|
Some(v) => json!({ "status": v }),
|
||||||
|
None => json!({ "status": "pending" }),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn cancel(
|
||||||
|
State(gw): State<Arc<Gateway>>,
|
||||||
|
headers: HeaderMap,
|
||||||
|
Path(id): Path<String>,
|
||||||
|
) -> StatusCode {
|
||||||
|
let Some(host) = gw.host(&headers) else { return StatusCode::UNAUTHORIZED };
|
||||||
|
if !gw.owns(&id, &host) {
|
||||||
|
return StatusCode::NOT_FOUND;
|
||||||
|
}
|
||||||
|
gw.decide(&id, Verdict::Cancelled).await;
|
||||||
|
StatusCode::NO_CONTENT
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
//! pass-broker — hands Proton Pass items to darman's processes (Claude
|
||||||
|
//! included) only after a Telegram approval.
|
||||||
|
//!
|
||||||
|
//! The daemon runs as its own system user and holds the only pass-cli session
|
||||||
|
//! (an agent PAT), so nothing running as darman can read it directly. Clients
|
||||||
|
//! talk to it over a unix socket; see services/identity/pass-broker.nix. The
|
||||||
|
//! prompt comes from its own bot or from the shared gateway (gateway.rs).
|
||||||
|
|
||||||
|
mod approver;
|
||||||
|
mod client;
|
||||||
|
mod config;
|
||||||
|
mod daemon;
|
||||||
|
mod gateway;
|
||||||
|
mod pass;
|
||||||
|
mod proto;
|
||||||
|
mod telegram;
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
const USAGE: &str = "usage: pass-broker get --item <title> --reason <why> [--vault <name>] [--field <name>]
|
||||||
|
pass-broker daemon
|
||||||
|
pass-broker gateway";
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> Result<()> {
|
||||||
|
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||||
|
match args.first().map(String::as_str) {
|
||||||
|
Some("daemon") => daemon::run().await,
|
||||||
|
Some("gateway") => gateway::run().await,
|
||||||
|
Some("get") => client::get(&args[1..]).await,
|
||||||
|
_ => {
|
||||||
|
eprintln!("{USAGE}");
|
||||||
|
std::process::exit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
use crate::config::Config;
|
||||||
|
use anyhow::{anyhow, bail, Context, Result};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::process::Stdio;
|
||||||
|
use tokio::process::Command;
|
||||||
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
|
/// The broker's own pass-cli session. pass-cli calls are serialised: they
|
||||||
|
/// share one session dir and a re-login mid-lookup would race.
|
||||||
|
pub struct Pass {
|
||||||
|
bin: String,
|
||||||
|
session_dir: PathBuf,
|
||||||
|
pat_file: PathBuf,
|
||||||
|
lock: Mutex<()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Pass {
|
||||||
|
pub fn new(cfg: &Config) -> Self {
|
||||||
|
Self {
|
||||||
|
bin: cfg.pass_cli.clone(),
|
||||||
|
session_dir: cfg.session_dir.clone(),
|
||||||
|
pat_file: cfg.pat_file.clone(),
|
||||||
|
lock: Mutex::new(()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn ensure_session(&self) -> Result<()> {
|
||||||
|
let _g = self.lock.lock().await;
|
||||||
|
self.ensure_session_locked().await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn ensure_session_locked(&self) -> Result<()> {
|
||||||
|
if self.run(&["info"], &[]).await.is_ok() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
eprintln!("no pass-cli session, logging in with the PAT");
|
||||||
|
let pat = std::fs::read_to_string(&self.pat_file)
|
||||||
|
.with_context(|| format!("reading {}", self.pat_file.display()))?;
|
||||||
|
let _ = self.run(&["logout", "--force"], &[]).await;
|
||||||
|
// Via env, not `--pat`: argv is world-readable in /proc.
|
||||||
|
self.run(&["login"], &[("PROTON_PASS_PERSONAL_ACCESS_TOKEN", pat.trim())])
|
||||||
|
.await
|
||||||
|
.context("pass-cli login")?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get(&self, vault: &str, title: &str, field: &str, reason: &str) -> Result<String> {
|
||||||
|
let _g = self.lock.lock().await;
|
||||||
|
self.ensure_session_locked().await?;
|
||||||
|
|
||||||
|
// `item view --item-title` has no state filter and can return a
|
||||||
|
// trashed duplicate, so resolve the id among active items first.
|
||||||
|
let list = self
|
||||||
|
.run(
|
||||||
|
&["item", "list", "--vault-name", vault, "--filter-state", "active", "--output", "human"],
|
||||||
|
&[],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
let id = list
|
||||||
|
.lines()
|
||||||
|
.find_map(|l| {
|
||||||
|
// - [ITEM_ID]: the title (state=Active)
|
||||||
|
let rest = l.strip_prefix("- [")?;
|
||||||
|
let (id, rest) = rest.split_once("]: ")?;
|
||||||
|
let t = match rest.rfind(" (state=") {
|
||||||
|
Some(i) if rest.ends_with(')') => &rest[..i],
|
||||||
|
_ => rest,
|
||||||
|
};
|
||||||
|
(t == title).then(|| id.to_string())
|
||||||
|
})
|
||||||
|
.ok_or_else(|| anyhow!("no active item {title:?} in vault {vault:?}"))?;
|
||||||
|
|
||||||
|
let out = self
|
||||||
|
.run(
|
||||||
|
&["item", "view", "--vault-name", vault, "--item-id", &id, "--field", field, "--output", "human"],
|
||||||
|
&[("PROTON_PASS_AGENT_REASON", reason)],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
let value = out.lines().next().unwrap_or("").to_string();
|
||||||
|
if value.is_empty() {
|
||||||
|
bail!("{title:?} has an empty {field} field");
|
||||||
|
}
|
||||||
|
Ok(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn run(&self, args: &[&str], env: &[(&str, &str)]) -> Result<String> {
|
||||||
|
let out = Command::new(&self.bin)
|
||||||
|
.args(args)
|
||||||
|
.envs(env.iter().copied())
|
||||||
|
.env("PROTON_PASS_SESSION_DIR", &self.session_dir)
|
||||||
|
.stdin(Stdio::null())
|
||||||
|
.kill_on_drop(true)
|
||||||
|
.output()
|
||||||
|
.await
|
||||||
|
.with_context(|| format!("running {}", self.bin))?;
|
||||||
|
if !out.status.success() {
|
||||||
|
let err = String::from_utf8_lossy(&out.stderr);
|
||||||
|
bail!("pass-cli {} failed ({}): {}", args[0], out.status, err.trim());
|
||||||
|
}
|
||||||
|
Ok(String::from_utf8(out.stdout)?)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
pub const DEFAULT_SOCKET: &str = "/run/pass-broker.sock";
|
||||||
|
|
||||||
|
/// One JSON line from the client.
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct Request {
|
||||||
|
pub vault: Option<String>,
|
||||||
|
pub item: String,
|
||||||
|
pub field: String,
|
||||||
|
pub reason: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// JSON lines from the daemon: any number of `Pending`, then one final reply.
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[serde(tag = "status", rename_all = "snake_case")]
|
||||||
|
pub enum Reply {
|
||||||
|
Pending { message: String },
|
||||||
|
Ok { value: String },
|
||||||
|
Error { error: String },
|
||||||
|
}
|
||||||
@@ -0,0 +1,203 @@
|
|||||||
|
use crate::config::TelegramConfig;
|
||||||
|
use anyhow::{anyhow, bail, Context, Result};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_json::{json, Value};
|
||||||
|
use std::future::Future;
|
||||||
|
use std::io::Read;
|
||||||
|
use std::pin::Pin;
|
||||||
|
use std::sync::atomic::{AtomicI64, Ordering};
|
||||||
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
|
/// Approval prompts with Approve/Deny buttons. A bot has one getUpdates
|
||||||
|
/// consumer, so exactly one process may own it: a host's broker in direct
|
||||||
|
/// mode, or the gateway (gateway.rs) for every host.
|
||||||
|
pub struct Telegram {
|
||||||
|
http: reqwest::Client,
|
||||||
|
/// Contains the token: never print it, and strip it from reqwest errors.
|
||||||
|
base: String,
|
||||||
|
chat_id: i64,
|
||||||
|
offset: AtomicI64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum Verdict {
|
||||||
|
Approved,
|
||||||
|
Denied,
|
||||||
|
Expired,
|
||||||
|
Cancelled,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Verdict {
|
||||||
|
fn outcome(self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
Verdict::Approved => "✅ approved",
|
||||||
|
Verdict::Denied => "❌ denied",
|
||||||
|
Verdict::Expired => "⌛ expired",
|
||||||
|
Verdict::Cancelled => "🚫 cancelled: the requester went away",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// An owner's tap on a live prompt's button.
|
||||||
|
pub struct Tap {
|
||||||
|
pub nonce: String,
|
||||||
|
pub verdict: Verdict,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Telegram {
|
||||||
|
pub fn new(cfg: &TelegramConfig) -> Result<Self> {
|
||||||
|
let token = std::fs::read_to_string(&cfg.token_file)
|
||||||
|
.with_context(|| format!("reading {}", cfg.token_file.display()))?;
|
||||||
|
let chat_id = std::fs::read_to_string(&cfg.chat_id_file)
|
||||||
|
.with_context(|| format!("reading {}", cfg.chat_id_file.display()))?
|
||||||
|
.trim()
|
||||||
|
.parse()
|
||||||
|
.context("telegram chat id is not a number")?;
|
||||||
|
Ok(Self {
|
||||||
|
http: reqwest::Client::builder().timeout(Duration::from_secs(40)).build()?,
|
||||||
|
base: format!("{}/bot{}", cfg.api_base.trim_end_matches('/'), token.trim()),
|
||||||
|
chat_id,
|
||||||
|
offset: AtomicI64::new(0),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn call(&self, method: &str, body: Value) -> Result<Value> {
|
||||||
|
let resp = self
|
||||||
|
.http
|
||||||
|
.post(format!("{}/{method}", self.base))
|
||||||
|
.json(&body)
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
.map_err(|e| anyhow!("telegram {method}: {}", e.without_url()))?;
|
||||||
|
let v: Value = resp
|
||||||
|
.json()
|
||||||
|
.await
|
||||||
|
.map_err(|e| anyhow!("telegram {method}: {}", e.without_url()))?;
|
||||||
|
if v["ok"] != json!(true) {
|
||||||
|
bail!("telegram {method}: {}", v["description"]);
|
||||||
|
}
|
||||||
|
Ok(v["result"].clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sends the prompt; returns its message id.
|
||||||
|
pub async fn prompt(&self, text: &str, nonce: &str) -> Result<i64> {
|
||||||
|
let msg = self
|
||||||
|
.call(
|
||||||
|
"sendMessage",
|
||||||
|
json!({
|
||||||
|
"chat_id": self.chat_id,
|
||||||
|
"text": text,
|
||||||
|
"reply_markup": { "inline_keyboard": [[
|
||||||
|
{ "text": "Approve", "callback_data": format!("ok:{nonce}") },
|
||||||
|
{ "text": "Deny", "callback_data": format!("no:{nonce}") },
|
||||||
|
]]},
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
msg["message_id"].as_i64().ok_or_else(|| anyhow!("sendMessage returned no message_id"))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One long poll. Every tap is answered; the owner's taps on prompts
|
||||||
|
/// `live` still knows are returned.
|
||||||
|
pub async fn taps(&self, timeout_secs: u64, live: impl Fn(&str) -> bool) -> Result<Vec<Tap>> {
|
||||||
|
let updates = self
|
||||||
|
.call(
|
||||||
|
"getUpdates",
|
||||||
|
json!({
|
||||||
|
"offset": self.offset.load(Ordering::SeqCst),
|
||||||
|
"timeout": timeout_secs,
|
||||||
|
"allowed_updates": ["callback_query"],
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
let mut taps = vec![];
|
||||||
|
for u in updates.as_array().into_iter().flatten() {
|
||||||
|
if let Some(id) = u["update_id"].as_i64() {
|
||||||
|
self.offset.fetch_max(id + 1, Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
let cq = &u["callback_query"];
|
||||||
|
let Some(cq_id) = cq["id"].as_str() else { continue };
|
||||||
|
let data = cq["data"].as_str().unwrap_or("");
|
||||||
|
let tap = match data.split_once(':') {
|
||||||
|
Some(("ok", n)) => Some((n, Verdict::Approved)),
|
||||||
|
Some(("no", n)) => Some((n, Verdict::Denied)),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
.filter(|(n, _)| live(n));
|
||||||
|
// The button lives in our chat, but the bot can be added
|
||||||
|
// elsewhere and a forwarded message keeps its buttons.
|
||||||
|
let from_owner = cq["from"]["id"].as_i64() == Some(self.chat_id);
|
||||||
|
let note = match (&tap, from_owner) {
|
||||||
|
(_, false) => "Not yours.",
|
||||||
|
(None, true) => "Expired.",
|
||||||
|
(Some(_), true) => "",
|
||||||
|
};
|
||||||
|
let _ = self
|
||||||
|
.call("answerCallbackQuery", json!({ "callback_query_id": cq_id, "text": note }))
|
||||||
|
.await;
|
||||||
|
if let (Some((n, verdict)), true) = (tap, from_owner) {
|
||||||
|
taps.push(Tap { nonce: n.to_string(), verdict });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(taps)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Appends the outcome; without reply_markup this also drops the buttons.
|
||||||
|
pub async fn conclude(&self, message_id: i64, text: &str, verdict: Verdict) {
|
||||||
|
let _ = self
|
||||||
|
.call(
|
||||||
|
"editMessageText",
|
||||||
|
json!({
|
||||||
|
"chat_id": self.chat_id,
|
||||||
|
"message_id": message_id,
|
||||||
|
"text": format!("{text}\n\n{}", verdict.outcome()),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Direct mode: prompt and poll in one call. Callers must not ask
|
||||||
|
/// concurrently. `gone` resolving (the client hung up) withdraws it.
|
||||||
|
pub async fn ask(
|
||||||
|
&self,
|
||||||
|
text: &str,
|
||||||
|
timeout: Duration,
|
||||||
|
mut gone: Pin<&mut impl Future<Output = ()>>,
|
||||||
|
) -> Result<Verdict> {
|
||||||
|
let nonce = nonce()?;
|
||||||
|
let message_id = self.prompt(text, &nonce).await?;
|
||||||
|
|
||||||
|
let deadline = Instant::now() + timeout;
|
||||||
|
let verdict = 'poll: loop {
|
||||||
|
let left = deadline.saturating_duration_since(Instant::now());
|
||||||
|
if left.is_zero() {
|
||||||
|
break Verdict::Expired;
|
||||||
|
}
|
||||||
|
let polled = tokio::select! {
|
||||||
|
biased;
|
||||||
|
_ = gone.as_mut() => break 'poll Verdict::Cancelled,
|
||||||
|
r = self.taps(left.as_secs().min(25), |n| n == nonce) => r,
|
||||||
|
};
|
||||||
|
match polled {
|
||||||
|
Ok(taps) => {
|
||||||
|
if let Some(t) = taps.first() {
|
||||||
|
break t.verdict;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("{e:#}");
|
||||||
|
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
self.conclude(message_id, text, verdict).await;
|
||||||
|
Ok(verdict)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn nonce() -> Result<String> {
|
||||||
|
let mut buf = [0u8; 16];
|
||||||
|
std::fs::File::open("/dev/urandom")?.read_exact(&mut buf)?;
|
||||||
|
Ok(buf.iter().map(|b| format!("{b:02x}")).collect())
|
||||||
|
}
|
||||||