diff options
author | Soispha <soispha@vhack.eu> | 2023-10-03 20:21:04 +0200 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-10-03 20:21:04 +0200 |
commit | 603158c6a7ded34e839353299801ccd34a31a2e0 (patch) | |
tree | 749a8d437c1884e224b9a19ac34930cf841c68e1 /hm/soispha/conf/taskwarrior/hooks/default.nix | |
parent | feat(hm/conf/taskwarrior/projects): Add support for nested projects (diff) | |
download | nixos-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.nix | 22 |
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 { |