about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--hm/soispha/conf/taskwarrior/default.nix4
-rw-r--r--hm/soispha/conf/taskwarrior/hooks/default.nix22
-rwxr-xr-xhm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh2
3 files changed, 24 insertions, 4 deletions
diff --git a/hm/soispha/conf/taskwarrior/default.nix b/hm/soispha/conf/taskwarrior/default.nix
index 7482efa8..f2ca65a9 100644
--- a/hm/soispha/conf/taskwarrior/default.nix
+++ b/hm/soispha/conf/taskwarrior/default.nix
@@ -39,7 +39,7 @@
     mkProject = project: subproject:
       if builtins.isString subproject
       then {
-        name = "${project.name}.${subproject}";
+        name = "${project.name}_${subproject}";
         neorg_path =
           if builtins.hasAttr "neorg_path_prefix" project
           then "${project.neorg_path_prefix}/${subproject}/index.norg"
@@ -48,7 +48,7 @@
       else let
         name = builtins.elemAt (builtins.attrNames subproject) 0;
       in {
-        name = "${project.name}.${name}";
+        name = "${project.name}_${name}";
         neorg_path_prefix = "${project.prefix}/${project.name}/${name}";
         subprojects = builtins.elemAt (builtins.attrValues subproject) 0;
       };
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 {
diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh b/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh
index 84322e6d..1adc4b33 100755
--- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh
+++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh
@@ -22,7 +22,7 @@ enforce_project() {
     project="$(jq '.project' "$(ptmp "$1")")";
     [ "$project" = "null" ] && die "No project supplied!"
 
-    if grep -q "^$(echo "$project" | sed 's|"\([a-z0-9_-]*\).*"|\1|')\$" "$(ptmp "%PROJECTS_NEWLINE")"; then
+    if grep -q "^$(echo "$project" | sed 's|"\(.*\)"|\1|')\$" "$(ptmp "%PROJECTS_NEWLINE")"; then
         dbg "project('$project') is a valid part of %PROJECTS_COMMA";
     else
         die "The project '$(echo "$project" | sed 's|"||g')' is not registered with the nix config, registered projects: %PROJECTS_COMMA";