refactor notability ingest stack

This commit is contained in:
2026-03-25 17:53:32 +00:00
parent 4eefa6b337
commit 49fa4d623e
7 changed files with 285 additions and 477 deletions

View File

@@ -1,29 +1,33 @@
{
config,
inputs',
lib,
pkgs,
...
}: let
homeDir = "/home/cschmatzler";
notabilityScripts = ./notability;
webdavRoot = "/home/cschmatzler/.local/share/notability-ingest/webdav-root";
dataRoot = "/home/cschmatzler/.local/share/notability-ingest";
stateRoot = "/home/cschmatzler/.local/state/notability-ingest";
notesRoot = "/home/cschmatzler/Notes";
commonPath = [
inputs'.llm-agents.packages.pi
pkgs.qmd
pkgs.coreutils
pkgs.inotify-tools
pkgs.nushell
pkgs.poppler-utils
pkgs.rclone
pkgs.sqlite
pkgs.util-linux
pkgs.zk
dataRoot = "${homeDir}/.local/share/notability-ingest";
stateRoot = "${homeDir}/.local/state/notability-ingest";
notesRoot = "${homeDir}/Notes";
webdavRoot = "${dataRoot}/webdav-root";
userPackages = with pkgs; [
qmd
poppler-utils
rclone
sqlite
zk
];
commonPath = with pkgs;
[
inputs'.llm-agents.packages.pi
coreutils
inotify-tools
nushell
util-linux
]
++ userPackages;
commonEnvironment = {
HOME = "/home/cschmatzler";
HOME = homeDir;
NOTABILITY_ARCHIVE_ROOT = "${dataRoot}/archive";
NOTABILITY_DATA_ROOT = dataRoot;
NOTABILITY_DB_PATH = "${stateRoot}/db.sqlite";
@@ -33,7 +37,28 @@
NOTABILITY_STATE_ROOT = stateRoot;
NOTABILITY_TRANSCRIPT_ROOT = "${stateRoot}/transcripts";
NOTABILITY_WEBDAV_ROOT = webdavRoot;
XDG_CONFIG_HOME = "/home/cschmatzler/.config";
XDG_CONFIG_HOME = "${homeDir}/.config";
};
mkTmpDirRule = path: "d ${path} 0755 cschmatzler users -";
mkNotabilityService = {
description,
script,
after ? [],
requires ? [],
environment ? {},
}: {
inherit after description requires;
wantedBy = ["multi-user.target"];
path = commonPath;
environment = commonEnvironment // environment;
serviceConfig = {
ExecStart = "${pkgs.nushell}/bin/nu ${notabilityScripts}/${script}";
Group = "users";
Restart = "always";
RestartSec = 5;
User = "cschmatzler";
WorkingDirectory = homeDir;
};
};
in {
sops.secrets.tahani-notability-webdav-password = {
@@ -44,13 +69,7 @@ in {
};
home-manager.users.cschmatzler = {
home.packages = [
pkgs.qmd
pkgs.poppler-utils
pkgs.rclone
pkgs.sqlite
pkgs.zk
];
home.packages = userPackages;
home.file.".config/qmd/index.yml".text = ''
collections:
notes:
@@ -59,22 +78,23 @@ in {
'';
};
systemd.tmpfiles.rules = [
"d ${notesRoot} 0755 cschmatzler users -"
"d ${dataRoot} 0755 cschmatzler users -"
"d ${webdavRoot} 0755 cschmatzler users -"
"d ${dataRoot}/archive 0755 cschmatzler users -"
"d ${dataRoot}/rendered-pages 0755 cschmatzler users -"
"d ${stateRoot} 0755 cschmatzler users -"
"d ${stateRoot}/jobs 0755 cschmatzler users -"
"d ${stateRoot}/jobs/queued 0755 cschmatzler users -"
"d ${stateRoot}/jobs/running 0755 cschmatzler users -"
"d ${stateRoot}/jobs/failed 0755 cschmatzler users -"
"d ${stateRoot}/jobs/done 0755 cschmatzler users -"
"d ${stateRoot}/jobs/results 0755 cschmatzler users -"
"d ${stateRoot}/sessions 0755 cschmatzler users -"
"d ${stateRoot}/transcripts 0755 cschmatzler users -"
];
systemd.tmpfiles.rules =
builtins.map mkTmpDirRule [
notesRoot
dataRoot
webdavRoot
"${dataRoot}/archive"
"${dataRoot}/rendered-pages"
stateRoot
"${stateRoot}/jobs"
"${stateRoot}/jobs/queued"
"${stateRoot}/jobs/running"
"${stateRoot}/jobs/failed"
"${stateRoot}/jobs/done"
"${stateRoot}/jobs/results"
"${stateRoot}/sessions"
"${stateRoot}/transcripts"
];
services.caddy.virtualHosts."tahani.manticore-hippocampus.ts.net".extraConfig = ''
tls {
@@ -85,43 +105,24 @@ in {
}
'';
systemd.services.notability-webdav = {
description = "Notability WebDAV landing zone";
wantedBy = ["multi-user.target"];
after = ["network.target"];
path = commonPath;
environment =
commonEnvironment
// {
systemd.services.notability-webdav =
mkNotabilityService {
description = "Notability WebDAV landing zone";
script = "webdav.nu";
after = ["network.target"];
environment = {
NOTABILITY_WEBDAV_ADDR = "127.0.0.1:9980";
NOTABILITY_WEBDAV_BASEURL = "/notability";
NOTABILITY_WEBDAV_PASSWORD_FILE = config.sops.secrets.tahani-notability-webdav-password.path;
NOTABILITY_WEBDAV_USER = "notability";
};
serviceConfig = {
ExecStart = "${pkgs.nushell}/bin/nu ${notabilityScripts}/webdav.nu";
Group = "users";
Restart = "always";
RestartSec = 5;
User = "cschmatzler";
WorkingDirectory = "/home/cschmatzler";
};
};
systemd.services.notability-watch = {
description = "Watch and ingest Notability WebDAV uploads";
wantedBy = ["multi-user.target"];
after = ["notability-webdav.service"];
requires = ["notability-webdav.service"];
path = commonPath;
environment = commonEnvironment;
serviceConfig = {
ExecStart = "${pkgs.nushell}/bin/nu ${notabilityScripts}/watch.nu";
Group = "users";
Restart = "always";
RestartSec = 5;
User = "cschmatzler";
WorkingDirectory = "/home/cschmatzler";
systemd.services.notability-watch =
mkNotabilityService {
description = "Watch and ingest Notability WebDAV uploads";
script = "watch.nu";
after = ["notability-webdav.service"];
requires = ["notability-webdav.service"];
};
};
}