about summary refs log tree commit diff stats
path: root/hm/soispha/conf/taskwarrior/hooks/default.nix
diff options
context:
space:
mode:
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 {