Skip to content

Commit bd8fb34

Browse files
committed
fix(omp): gate launchd options on Darwin
1 parent 6f564a3 commit bd8fb34

1 file changed

Lines changed: 108 additions & 105 deletions

File tree

modules/agents/omp/default.nix

Lines changed: 108 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -430,120 +430,123 @@ in
430430
};
431431
};
432432

433-
config = mkIf cfg.enable {
434-
user.packages = [
435-
(lib.hiPrio ompPackage)
436-
hassMcpServer
437-
]
438-
++ lib.optional cfg.dailyIntrospection.enable threadIntrospection
439-
++ lib.optional cfg.skilloptSleep.enable skilloptSleepNightly;
440-
441-
home.file.".omp/agent/config.yml" = {
442-
source = ompConfigFile;
443-
force = true;
444-
};
433+
config = mkIf cfg.enable (
434+
{
435+
user.packages = [
436+
(lib.hiPrio ompPackage)
437+
hassMcpServer
438+
]
439+
++ lib.optional cfg.dailyIntrospection.enable threadIntrospection
440+
++ lib.optional cfg.skilloptSleep.enable skilloptSleepNightly;
441+
442+
home.file.".omp/agent/config.yml" = {
443+
source = ompConfigFile;
444+
force = true;
445+
};
445446

446-
home.file.".omp/agent/lsp.json" = {
447-
source = lsp.configFile;
448-
force = true;
449-
};
447+
home.file.".omp/agent/lsp.json" = {
448+
source = lsp.configFile;
449+
force = true;
450+
};
450451

451-
home.file.".omp/agent/models.yml" = mkIf cfg.vibeproxy.enable {
452-
source = "${configDir}/omp/models.yml";
453-
force = true;
454-
};
452+
home.file.".omp/agent/models.yml" = mkIf cfg.vibeproxy.enable {
453+
source = "${configDir}/omp/models.yml";
454+
force = true;
455+
};
455456

456-
home.file.".omp/agent/themes/light-catppuccin-readable.json" = {
457-
source = "${configDir}/omp/themes/light-catppuccin-readable.json";
458-
force = true;
459-
};
457+
home.file.".omp/agent/themes/light-catppuccin-readable.json" = {
458+
source = "${configDir}/omp/themes/light-catppuccin-readable.json";
459+
force = true;
460+
};
460461

461-
home.file.".omp/agent/themes/dark-seqera.json" = {
462-
source = "${configDir}/omp/themes/dark-seqera.json";
463-
force = true;
464-
};
462+
home.file.".omp/agent/themes/dark-seqera.json" = {
463+
source = "${configDir}/omp/themes/dark-seqera.json";
464+
force = true;
465+
};
465466

466-
home.file.".omp/agent/themes/light-seqera.json" = {
467-
source = "${configDir}/omp/themes/light-seqera.json";
468-
force = true;
469-
};
467+
home.file.".omp/agent/themes/light-seqera.json" = {
468+
source = "${configDir}/omp/themes/light-seqera.json";
469+
force = true;
470+
};
470471

471-
home.file.".omp/agent/extensions/permission-policy-guard".source =
472-
"${configDir}/omp/extensions/permission-policy-guard";
473-
home.file.".omp/agent/extensions/pi-permission-system/config.json".source =
474-
"${configDir}/pi/pi-permission-system.jsonc";
475-
476-
launchd.user.agents =
477-
optionalAttrs (isDarwin && cfg.dailyIntrospection.enable) {
478-
omp-thread-introspection = {
479-
command = "${threadIntrospection}/bin/omp-thread-introspection";
480-
serviceConfig = {
481-
StartCalendarInterval = {
482-
Hour = cfg.dailyIntrospection.hour;
483-
Minute = cfg.dailyIntrospection.minute;
484-
};
485-
StandardOutPath = "${config.user.home}/Library/Logs/omp-thread-introspection.log";
486-
StandardErrorPath = "${config.user.home}/Library/Logs/omp-thread-introspection.err.log";
487-
EnvironmentVariables = {
488-
HOME = config.user.home;
489-
};
490-
};
472+
home.file.".omp/agent/extensions/permission-policy-guard".source =
473+
"${configDir}/omp/extensions/permission-policy-guard";
474+
home.file.".omp/agent/extensions/pi-permission-system/config.json".source =
475+
"${configDir}/pi/pi-permission-system.jsonc";
476+
477+
home-manager.users.${config.user.name} =
478+
{ lib, ... }:
479+
{
480+
home.activation.omp-herdr-plugin = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
481+
${ompPackage}/bin/omp plugin link ${lib.escapeShellArg "${herdrPlugin}"} --force --json >/dev/null
482+
'';
483+
484+
home.activation.omp-skillopt-sleep-plugin = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
485+
${ompPackage}/bin/omp plugin uninstall pi-skillopt-sleep --json >/dev/null 2>&1 || true
486+
${ompPackage}/bin/omp plugin link ${lib.escapeShellArg "${skilloptSleepPlugin}"} --force --json >/dev/null
487+
'';
488+
489+
home.activation.omp-ponytail-plugin = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
490+
${ompPackage}/bin/omp plugin link ${lib.escapeShellArg "${ponytailPlugin}"} --force --json >/dev/null
491+
'';
492+
493+
home.activation.omp-mcp-cleanup = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
494+
${pkgs.python3}/bin/python3 <<'PY'
495+
import pathlib
496+
import sqlite3
497+
498+
db_path = pathlib.Path.home() / ".omp" / "agent" / "agent.db"
499+
if db_path.exists():
500+
try:
501+
conn = sqlite3.connect(db_path)
502+
try:
503+
conn.execute("delete from cache where key like 'mcp_tools:%'")
504+
conn.commit()
505+
finally:
506+
conn.close()
507+
except Exception:
508+
pass
509+
510+
PY
511+
'';
491512
};
492-
}
493-
// optionalAttrs (isDarwin && cfg.skilloptSleep.enable) {
494-
omp-skillopt-sleep = {
495-
command = "${skilloptSleepNightly}/bin/omp-skillopt-sleep-nightly";
496-
serviceConfig = {
497-
StartCalendarInterval = {
498-
Hour = cfg.skilloptSleep.hour;
499-
Minute = cfg.skilloptSleep.minute;
513+
}
514+
// optionalAttrs isDarwin {
515+
launchd.user.agents =
516+
optionalAttrs cfg.dailyIntrospection.enable {
517+
omp-thread-introspection = {
518+
command = "${threadIntrospection}/bin/omp-thread-introspection";
519+
serviceConfig = {
520+
StartCalendarInterval = {
521+
Hour = cfg.dailyIntrospection.hour;
522+
Minute = cfg.dailyIntrospection.minute;
523+
};
524+
StandardOutPath = "${config.user.home}/Library/Logs/omp-thread-introspection.log";
525+
StandardErrorPath = "${config.user.home}/Library/Logs/omp-thread-introspection.err.log";
526+
EnvironmentVariables = {
527+
HOME = config.user.home;
528+
};
500529
};
501-
StandardOutPath = "${config.user.home}/Library/Logs/omp-skillopt-sleep.log";
502-
StandardErrorPath = "${config.user.home}/Library/Logs/omp-skillopt-sleep.err.log";
503-
EnvironmentVariables = {
504-
HOME = config.user.home;
505-
PATH = "/etc/profiles/per-user/${config.user.name}/bin:/run/current-system/sw/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin";
506-
SKILLOPT_SLEEP_REPO = "${skilloptSleepSource}";
530+
};
531+
}
532+
// optionalAttrs cfg.skilloptSleep.enable {
533+
omp-skillopt-sleep = {
534+
command = "${skilloptSleepNightly}/bin/omp-skillopt-sleep-nightly";
535+
serviceConfig = {
536+
StartCalendarInterval = {
537+
Hour = cfg.skilloptSleep.hour;
538+
Minute = cfg.skilloptSleep.minute;
539+
};
540+
StandardOutPath = "${config.user.home}/Library/Logs/omp-skillopt-sleep.log";
541+
StandardErrorPath = "${config.user.home}/Library/Logs/omp-skillopt-sleep.err.log";
542+
EnvironmentVariables = {
543+
HOME = config.user.home;
544+
PATH = "/etc/profiles/per-user/${config.user.name}/bin:/run/current-system/sw/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin";
545+
SKILLOPT_SLEEP_REPO = "${skilloptSleepSource}";
546+
};
507547
};
508548
};
509549
};
510-
};
511-
512-
home-manager.users.${config.user.name} =
513-
{ lib, ... }:
514-
{
515-
home.activation.omp-herdr-plugin = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
516-
${ompPackage}/bin/omp plugin link ${lib.escapeShellArg "${herdrPlugin}"} --force --json >/dev/null
517-
'';
518-
519-
home.activation.omp-skillopt-sleep-plugin = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
520-
${ompPackage}/bin/omp plugin uninstall pi-skillopt-sleep --json >/dev/null 2>&1 || true
521-
${ompPackage}/bin/omp plugin link ${lib.escapeShellArg "${skilloptSleepPlugin}"} --force --json >/dev/null
522-
'';
523-
524-
home.activation.omp-ponytail-plugin = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
525-
${ompPackage}/bin/omp plugin link ${lib.escapeShellArg "${ponytailPlugin}"} --force --json >/dev/null
526-
'';
527-
528-
home.activation.omp-mcp-cleanup = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
529-
${pkgs.python3}/bin/python3 <<'PY'
530-
import pathlib
531-
import sqlite3
532-
533-
db_path = pathlib.Path.home() / ".omp" / "agent" / "agent.db"
534-
if db_path.exists():
535-
try:
536-
conn = sqlite3.connect(db_path)
537-
try:
538-
conn.execute("delete from cache where key like 'mcp_tools:%'")
539-
conn.commit()
540-
finally:
541-
conn.close()
542-
except Exception:
543-
pass
544-
545-
PY
546-
'';
547-
};
548-
};
550+
}
551+
);
549552
}

0 commit comments

Comments
 (0)