New modules/ai/diwan.nix: pulls in the diwan flake's package, requires ai.pi and ai.herdr (diwan's real runtime dependencies, not optional extras), and exposes notesDir (DIWAN_NOTES_DIR, required) / cadence (systemd OnCalendar, default hourly) / user (default the host's primary user) as options, wiring a systemd.timer + oneshot systemd.service that runs 'diwan tick'. diwan.url is a temporary path: input (see the flake.nix TODO) -- switch to a real git remote before deploying to any host that isn't this one. Verified via nix eval against an extended thingvellir config: pi/herdr get force-enabled, cadence flows through to OnCalendar, notesDir flows through to the service environment and WorkingDirectory, ExecStart resolves to the real built diwan package.
58 lines
1.7 KiB
Nix
58 lines
1.7 KiB
Nix
{ config, lib, pkgs, inputs, system, ... }:
|
|
|
|
let
|
|
cfg = config.samfelag.modules.ai.diwan;
|
|
diwanPkg = inputs.diwan.packages.${system}.default;
|
|
in
|
|
{
|
|
options.samfelag.modules.ai.diwan = with lib.types; {
|
|
enable = lib.mkEnableOption "diwan";
|
|
|
|
notesDir = lib.mkOption {
|
|
type = str;
|
|
description = "Path to the content repo diwan ticks against (DIWAN_NOTES_DIR) — notes, not diwan's own code. Required: no default, since there's no sensible one.";
|
|
};
|
|
|
|
cadence = lib.my.mkOpt' str "hourly"
|
|
"systemd OnCalendar expression controlling how often diwan tick runs.";
|
|
|
|
user = lib.my.mkOpt' str config.user.name
|
|
"User diwan tick runs as — needs access to notesDir and the pi/herdr environment.";
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
# diwan dispatches `pi` agents via `herdr`; both are real dependencies,
|
|
# not optional extras a host could forget to turn on.
|
|
samfelag.modules.ai.pi.enable = true;
|
|
samfelag.modules.ai.herdr.enable = true;
|
|
|
|
environment.systemPackages = [
|
|
diwanPkg
|
|
];
|
|
|
|
systemd.timers.diwan-tick = {
|
|
description = "Run diwan tick periodically";
|
|
wantedBy = [ "timers.target" ];
|
|
timerConfig = {
|
|
OnCalendar = cfg.cadence;
|
|
Persistent = true;
|
|
};
|
|
};
|
|
|
|
systemd.services.diwan-tick = {
|
|
description = "diwan tick";
|
|
after = [ "network-online.target" ];
|
|
wants = [ "network-online.target" ];
|
|
environment = {
|
|
DIWAN_NOTES_DIR = cfg.notesDir;
|
|
};
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
User = cfg.user;
|
|
WorkingDirectory = cfg.notesDir;
|
|
ExecStart = "${diwanPkg}/bin/diwan tick";
|
|
};
|
|
};
|
|
};
|
|
}
|