about summary refs log tree commit diff stats
path: root/hm/soispha/conf/taskwarrior/hooks/default.nix
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2023-10-03 20:21:04 +0200
committerSoispha <soispha@vhack.eu>2023-10-03 20:21:04 +0200
commit603158c6a7ded34e839353299801ccd34a31a2e0 (patch)
tree749a8d437c1884e224b9a19ac34930cf841c68e1 /hm/soispha/conf/taskwarrior/hooks/default.nix
parentfeat(hm/conf/taskwarrior/projects): Add support for nested projects (diff)
downloadnixos-config-603158c6a7ded34e839353299801ccd34a31a2e0.zip
fix(hm/conf/taskwarrior/hooks/policies): Also check subprojects
Diffstat (limited to 'hm/soispha/conf/taskwarrior/hooks/default.nix')
-rw-r--r--hm/soispha/conf/taskwarrior/hooks/default.nix22
1 files changed, 21 insertions, 1 deletions
diff --git a/hm/soispha/conf/taskwarrior/hooks/default.nix b/hm/soispha/conf/taskwarrior/hooks/default.nix
index 66af5b3b..b1b23f3f 100644
--- a/hm/soispha/conf/taskwarrior/hooks/default.nix
+++ b/hm/soispha/conf/taskwarrior/hooks/default.nix
@@ -1,6 +1,7 @@
 {
   sysLib,
   pkgs,
+  lib,
   ...
 }: let
   enforce_policies = sysLib.writeShellScriptWithLibrary {
@@ -8,7 +9,26 @@
     src = ./scripts/on-add_enforce-policies.sh;
     dependencies = with pkgs; [dash jq taskwarrior gnused gnugrep];
     replacementStrings = let
-      projects = builtins.map (project: project.name) (import ../projects {});
+      mkProject = project: subproject:
+        if builtins.isString subproject
+        then {
+          name = "${project.name}_${subproject}";
+          prefix = null;
+        }
+        else let
+          name = builtins.elemAt (builtins.attrNames subproject) 0;
+        in {
+          name = "${project.name}_${name}";
+          subprojects = builtins.elemAt (builtins.attrValues subproject) 0;
+          prefix = null;
+        };
+
+      mkProjectName = project:
+        if builtins.hasAttr "subprojects" project
+        then lib.lists.flatten ([project.name] ++ (builtins.map mkProjectName
+              (builtins.map (mkProject project) project.subprojects)))
+        else [project.name];
+      projects = lib.lists.flatten (builtins.map mkProjectName (import ../projects {}));
       projects_newline = builtins.concatStringsSep "\n" projects;
       projects_comma = builtins.concatStringsSep ", " projects;
     in {