fix(ai-tools): adopt 'taskwarrior' home manager secrets approach

This commit is contained in:
2026-10-12 23:44:18 +02:00
parent 034a010547
commit 622a2ae3da
2 changed files with 49 additions and 38 deletions
+27 -15
View File
@@ -2,29 +2,40 @@
config, config,
lib, lib,
pkgs, pkgs,
myUtils,
osConfig ? null,
inputs ? null,
... ...
}: }:
let let
cfg = config.ai-tools.opencode; sops = myUtils.sopsAvailability config osConfig;
standalone = osConfig == null;
in in
{ {
config = lib.mkIf cfg.enable { config = lib.mkIf config.ai-tools.opencode.enable (
secrets.files.opencode = [ "api-key" ]; lib.optionalAttrs standalone {
secrets.templates."opencode/auth.json" = { sops = {
path = ".local/share/opencode/auth.json"; secrets = myUtils.mkSopsSecrets "${toString inputs.nix-secrets}/secrets" {
content = '' opencode = [ "api-key" ];
{
"zai-coding-plan": {
"type": "api",
"key": "${config.sops.placeholder."opencode/api-key"}"
}
}
'';
}; };
templates."opencode/auth.json" = {
path = "${config.home.homeDirectory}/.local/share/opencode/auth.json";
content = builtins.toJSON {
zai-coding-plan = {
type = "api";
key = config.sops.placeholder."opencode/api-key";
};
};
};
};
}
// {
warnings =
lib.optional (!sops.available)
"opencode is enabled, but sops templates are not available. the opencode API key will not be configured.";
home.packages = [ pkgs.opencode ]; home.packages = [ pkgs.opencode ];
home.file.".config/opencode/opencode.json".text = builtins.toJSON { home.file.".config/opencode/opencode.json".text = builtins.toJSON {
"$schema" = "https://opencode.ai/config.json"; "$schema" = "https://opencode.ai/config.json";
permission = { permission = {
@@ -46,5 +57,6 @@ in
}; };
plugin = [ "@mohak34/opencode-notifier@latest" ]; plugin = [ "@mohak34/opencode-notifier@latest" ];
}; };
}; }
);
} }
+1 -2
View File
@@ -9,7 +9,6 @@
}: }:
let let
cfg = config.taskwarrior;
sops = myUtils.sopsAvailability config osConfig; sops = myUtils.sopsAvailability config osConfig;
standalone = osConfig == null; standalone = osConfig == null;
@@ -62,7 +61,7 @@ in
{ {
options.taskwarrior.enable = lib.mkEnableOption "taskwarrior"; options.taskwarrior.enable = lib.mkEnableOption "taskwarrior";
config = lib.mkIf cfg.enable ( config = lib.mkIf config.taskwarrior.enable (
lib.optionalAttrs standalone { lib.optionalAttrs standalone {
sops = { sops = {
secrets = myUtils.mkSopsSecrets "${toString inputs.nix-secrets}/secrets" { secrets = myUtils.mkSopsSecrets "${toString inputs.nix-secrets}/secrets" {