From 1f115f8738de2449ba8cf682f3c55821edda4f13 Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Fri, 22 May 2026 10:27:12 +0200 Subject: [PATCH] feat(taskwarrior): add enable option --- home/hosts/andromache/default.nix | 1 - home/hosts/astyanax/default.nix | 1 + home/hosts/work/default.nix | 1 + home/modules/taskwarrior/default.nix | 128 ++++++++++++++------------- modules/taskwarrior/default.nix | 7 +- 5 files changed, 74 insertions(+), 64 deletions(-) diff --git a/home/hosts/andromache/default.nix b/home/hosts/andromache/default.nix index fce04dfb..697fed5f 100644 --- a/home/hosts/andromache/default.nix +++ b/home/hosts/andromache/default.nix @@ -63,7 +63,6 @@ bash.addBinToPath = true; }; anki.enable = true; - anki.enable = true; k8s.k9s.enable = true; taskwarrior.enable = true; audio.enable = true; diff --git a/home/hosts/astyanax/default.nix b/home/hosts/astyanax/default.nix index 2b8d596f..be86243d 100644 --- a/home/hosts/astyanax/default.nix +++ b/home/hosts/astyanax/default.nix @@ -61,6 +61,7 @@ anki.enable = true; k8s.k9s.enable = true; taskwarrior.enable = true; + secrets.enable = true; my.yubikey.enable = true; audio.enable = true; ssh.enable = true; diff --git a/home/hosts/work/default.nix b/home/hosts/work/default.nix index 1e0cef18..8e8cbaed 100644 --- a/home/hosts/work/default.nix +++ b/home/hosts/work/default.nix @@ -90,6 +90,7 @@ redis.enable = true; }; anki.enable = true; + taskwarrior.enable = true; k8s.enable = true; shell.enable = true; my.stylix.enable = true; diff --git a/home/modules/taskwarrior/default.nix b/home/modules/taskwarrior/default.nix index f6958ec5..579f2687 100644 --- a/home/modules/taskwarrior/default.nix +++ b/home/modules/taskwarrior/default.nix @@ -10,70 +10,76 @@ }: let + cfg = config.taskwarrior; sops = myUtils.sopsAvailability config osConfig; standalone = osConfig == null; in -lib.optionalAttrs standalone { - sops = { - secrets = myUtils.mkSopsSecrets "${toString inputs.nix-secrets}/secrets" null { - taskwarrior = [ - "sync-server-url" - "sync-server-client-id" - "sync-encryption-secret" +{ + options.taskwarrior.enable = lib.mkEnableOption "taskwarrior"; + + config = lib.mkIf cfg.enable ( + lib.optionalAttrs standalone { + sops = { + secrets = myUtils.mkSopsSecrets "${toString inputs.nix-secrets}/secrets" null { + taskwarrior = [ + "sync-server-url" + "sync-server-client-id" + "sync-encryption-secret" + ]; + }; + + templates."taskrc.d/sync" = { + content = '' + sync.server.url=${config.sops.placeholder."taskwarrior/sync-server-url"} + sync.server.client_id=${config.sops.placeholder."taskwarrior/sync-server-client-id"} + sync.encryption_secret=${config.sops.placeholder."taskwarrior/sync-encryption-secret"} + ''; + }; + }; + } + // { + warnings = + lib.optional (!sops.available) + "taskwarrior is enabled, but sops templates are not available. taskwarrior sync will not be configured."; + + home.packages = with pkgs; [ + libnotify + taskopen + python3 ]; - }; - templates."taskrc.d/sync" = { - content = '' - sync.server.url=${config.sops.placeholder."taskwarrior/sync-server-url"} - sync.server.client_id=${config.sops.placeholder."taskwarrior/sync-server-client-id"} - sync.encryption_secret=${config.sops.placeholder."taskwarrior/sync-encryption-secret"} - ''; - }; - }; -} -// { - - warnings = - lib.optional (!sops.available && config.programs.taskwarrior.enable) - "taskwarrior is enabled, but sops templates are not available. taskwarrior sync will not be configured."; - - home.packages = with pkgs; [ - libnotify - taskopen - python3 - ]; - - home.file = { - ".config/task/taskrc" = { - force = true; - source = dotsPath + "/.config/task/taskrc"; - }; - ".config/task/taskrc.d/aliases".source = dotsPath + "/.config/task/taskrc.d/aliases"; - ".config/task/taskrc.d/colors".source = dotsPath + "/.config/task/taskrc.d/colors"; - ".config/task/taskrc.d/contexts".source = dotsPath + "/.config/task/taskrc.d/contexts"; - ".config/task/taskrc.d/reports".source = dotsPath + "/.config/task/taskrc.d/reports"; - ".config/task/taskrc.d/udas".source = dotsPath + "/.config/task/taskrc.d/udas"; - ".config/task/taskrc.d/urgency".source = dotsPath + "/.config/task/taskrc.d/urgency"; - ".local/share/task/hooks/on-exit.sync.py" = { - source = dotsPath + "/.local/share/task/hooks/on-exit.sync.py"; - }; - ".local/share/task/scripts/sync-and-notify.sh" = { - source = dotsPath + "/.local/share/task/scripts/sync-and-notify.sh"; - executable = true; - }; - }; - - programs.taskwarrior = with pkgs; { - enable = true; - package = taskwarrior3; - colorTheme = "dark-256"; - config = { - recurrence = "off"; - reserved.lines = 3; # without this I would have to scroll up 3 lines - }; - extraConfig = lib.optionalString sops.available '' - include ${sops.templates."taskrc.d/sync".path} - ''; - }; + home.file = { + ".config/task/taskrc" = { + force = true; + source = dotsPath + "/.config/task/taskrc"; + }; + ".config/task/taskrc.d/aliases".source = dotsPath + "/.config/task/taskrc.d/aliases"; + ".config/task/taskrc.d/colors".source = dotsPath + "/.config/task/taskrc.d/colors"; + ".config/task/taskrc.d/contexts".source = dotsPath + "/.config/task/taskrc.d/contexts"; + ".config/task/taskrc.d/reports".source = dotsPath + "/.config/task/taskrc.d/reports"; + ".config/task/taskrc.d/udas".source = dotsPath + "/.config/task/taskrc.d/udas"; + ".config/task/taskrc.d/urgency".source = dotsPath + "/.config/task/taskrc.d/urgency"; + ".local/share/task/hooks/on-exit.sync.py" = { + source = dotsPath + "/.local/share/task/hooks/on-exit.sync.py"; + }; + ".local/share/task/scripts/sync-and-notify.sh" = { + source = dotsPath + "/.local/share/task/scripts/sync-and-notify.sh"; + executable = true; + }; + }; + + programs.taskwarrior = with pkgs; { + enable = true; + package = taskwarrior3; + colorTheme = "dark-256"; + config = { + recurrence = "off"; + reserved.lines = 3; + }; + extraConfig = lib.optionalString sops.available '' + include ${sops.templates."taskrc.d/sync".path} + ''; + }; + } + ); } diff --git a/modules/taskwarrior/default.nix b/modules/taskwarrior/default.nix index af178b6b..7a9b99c7 100644 --- a/modules/taskwarrior/default.nix +++ b/modules/taskwarrior/default.nix @@ -1,10 +1,13 @@ -{ config, ... }: +{ lib, config, ... }: let + cfg = config.taskwarrior; inherit (config.secrets) owner; in { - config = { + options.taskwarrior.enable = lib.mkEnableOption "taskwarrior"; + + config = lib.mkIf cfg.enable { secrets.groups.taskwarrior = [ "sync-server-url" "sync-server-client-id"