Commit 16e1a3a

HPCesia <me@hpcesia.com>
2026-09-13 15:07:07
goose: init
1 parent 2177ee9
Changed files (2)
modules
dev
agents
users
hpcesia
modules/dev/agents/goose.nix
@@ -0,0 +1,89 @@
+{den, ...}: {
+  den.aspects.dev.agents.goose = {
+    includes = [den.aspects.dev.agents];
+
+    persistHome = {config, ...}: {
+      directories = [
+        "${config.xdg.config.directory}/goose"
+      ];
+    };
+
+    cacheHome = {config, ...}: {
+      directories = [
+        "${config.xdg.state.directory}/goose"
+      ];
+    };
+
+    hjem = {
+      pkgs,
+      lib,
+      config,
+      ...
+    }: let
+      goose-cli = pkgs.goose-cli.overrideAttrs (oldAttrs: {
+        nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [pkgs.installShellFiles];
+        postInstall = ''
+          installShellCompletion --cmd goose \
+            --bash <($out/bin/goose completion bash) \
+            --fish <($out/bin/goose completion fish) \
+            --nushell <($out/bin/goose completion nu) \
+            --zsh <($out/bin/goose completion zsh)
+        '';
+      });
+
+      configPath = "${config.xdg.config.directory}/goose/config.yaml";
+
+      desiredConfig = (pkgs.formats.yaml {}).generate "goose-config.yaml" {
+        GOOSE_TELEMETRY_ENABLED = false;
+        GOOSE_MODE = "smart_approve";
+      };
+    in {
+      packages = [
+        goose-cli
+      ];
+
+      xdg.config.files."goose/permission.yaml" = {
+        type = "copy";
+        permissions = "0644";
+        generator = (pkgs.formats.yaml {}).generate "goose-permission.yaml";
+        value = {
+          user = {
+            always_allow = [
+              "tree"
+              "todo__todo_write"
+            ];
+            ask_before = [
+              "write"
+              "edit"
+            ];
+            never_allow = [
+            ];
+          };
+        };
+      };
+
+      systemd.services.goose-config = {
+        description = "Merge the Nix-managed Goose config into the existing config";
+
+        wantedBy = ["default.target"];
+        restartTriggers = [desiredConfig];
+        path = [pkgs.coreutils pkgs.yq-go];
+
+        serviceConfig = {
+          Type = "oneshot";
+          RemainAfterExit = true;
+          UMask = "0077";
+        };
+
+        script = ''
+          mkdir -p "$(dirname ${lib.escapeShellArg configPath})"
+          touch ${lib.escapeShellArg configPath}
+          yq eval-all '. as $item ireduce ({}; . * $item)' \
+            ${lib.escapeShellArg configPath} ${desiredConfig} \
+            > ${lib.escapeShellArg configPath}.tmp
+          mv ${lib.escapeShellArg configPath}.tmp ${lib.escapeShellArg configPath}
+        '';
+      };
+    };
+  };
+}
modules/users/hpcesia/dev.nix
@@ -34,6 +34,7 @@ in {
       ]))
       ++ (includeWhen ({host, ...}: (host.hasAspect den.aspects.dev) && (host.hasAspect den.aspects.desktop)) (with den.aspects; [
         dev.agents.crush
+        dev.agents.goose
         dev.agents.opencode
         dev.agents.pi
       ]));