diff options
author | Soispha <soispha@vhack.eu> | 2023-10-03 09:30:28 +0200 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-10-03 20:10:11 +0200 |
commit | 6f38b0129a8ea13f988fd8e7175c06a0171b2e24 (patch) | |
tree | e382b95563ff285c87a204fee3884fb669eedb78 | |
parent | fix(hm/conf/taskwarrior/projects): Add further projects (diff) | |
download | nixos-config-6f38b0129a8ea13f988fd8e7175c06a0171b2e24.tar.gz nixos-config-6f38b0129a8ea13f988fd8e7175c06a0171b2e24.zip |
feat(hm/conf/taskwarrior/projects): Add support for nested projects
-rw-r--r-- | hm/soispha/conf/taskwarrior/default.nix | 53 | ||||
-rw-r--r-- | hm/soispha/conf/taskwarrior/projects/default.nix | bin | 764 -> 928 bytes |
2 files changed, 43 insertions, 10 deletions
diff --git a/hm/soispha/conf/taskwarrior/default.nix b/hm/soispha/conf/taskwarrior/default.nix index 8753aa7b..7482efa8 100644 --- a/hm/soispha/conf/taskwarrior/default.nix +++ b/hm/soispha/conf/taskwarrior/default.nix @@ -1,5 +1,6 @@ { nixosConfig, + lib, ... }: { imports = [ @@ -11,17 +12,49 @@ }; programs.taskwarrior = let - mkContext = project: { - inherit (project) name; - value = { - read = "project:${project.name}"; - write = "project:${project.name}"; - rc = { - neorg_path = "${project.prefix}/${project.name}/index.norg"; - }; + projects = import ./projects {}; + + mkContext = project: + if builtins.hasAttr "subprojects" project + then + lib.lists.flatten ( + (builtins.map mkContext (builtins.map (mkProject project) project.subprojects)) + ++ (mkContext (builtins.removeAttrs project ["subprojects"])) + ) + else [ + { + inherit (project) name; + value = { + read = "project:${project.name}"; + write = "project:${project.name}"; + rc = { + neorg_path = + if builtins.hasAttr "neorg_path" project + then project.neorg_path + else "${project.prefix}/${project.name}/index.norg"; + }; + }; + } + ]; + mkProject = project: subproject: + if builtins.isString subproject + then { + name = "${project.name}.${subproject}"; + neorg_path = + if builtins.hasAttr "neorg_path_prefix" project + then "${project.neorg_path_prefix}/${subproject}/index.norg" + else "${project.prefix}/${project.name}/${subproject}/index.norg"; + } + else let + name = builtins.elemAt (builtins.attrNames subproject) 0; + in { + name = "${project.name}.${name}"; + neorg_path_prefix = "${project.prefix}/${project.name}/${name}"; + subprojects = builtins.elemAt (builtins.attrValues subproject) 0; }; - }; - context = builtins.listToAttrs (builtins.map mkContext (import ./projects {})); + + context = + builtins.listToAttrs (lib.lists.flatten (builtins.map mkContext projects)); in { enable = true; colorTheme = ./nord.theme; diff --git a/hm/soispha/conf/taskwarrior/projects/default.nix b/hm/soispha/conf/taskwarrior/projects/default.nix index de9c18dc..0b22e55a 100644 --- a/hm/soispha/conf/taskwarrior/projects/default.nix +++ b/hm/soispha/conf/taskwarrior/projects/default.nix Binary files differ |