diff options
author | Soispha <soispha@vhack.eu> | 2023-10-20 21:46:27 +0200 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-10-20 21:46:27 +0200 |
commit | 4f0dec5f86efeb0ac764dc89e6bace1db1979697 (patch) | |
tree | 02f0f81604912b3080f48917eddeeb8b64710194 | |
parent | feat(hm/conf/taswarrior): Generate a firefox profile per project (diff) | |
download | nixos-config-4f0dec5f86efeb0ac764dc89e6bace1db1979697.tar.gz nixos-config-4f0dec5f86efeb0ac764dc89e6bace1db1979697.zip |
refactor(hm/conf/taskwarrior/projects): Store the parsed projects in a attr
Diffstat (limited to '')
-rw-r--r-- | hm/soispha/conf/firefox/default.nix | 1 | ||||
-rw-r--r-- | hm/soispha/conf/taskwarrior/firefox/default.nix | 24 | ||||
-rw-r--r-- | hm/soispha/conf/taskwarrior/hooks/default.nix | 74 |
3 files changed, 44 insertions, 55 deletions
diff --git a/hm/soispha/conf/firefox/default.nix b/hm/soispha/conf/firefox/default.nix index 567c0676..1f3b7062 100644 --- a/hm/soispha/conf/firefox/default.nix +++ b/hm/soispha/conf/firefox/default.nix @@ -30,6 +30,7 @@ bookmarks search lib + config ; }; diff --git a/hm/soispha/conf/taskwarrior/firefox/default.nix b/hm/soispha/conf/taskwarrior/firefox/default.nix index 5c6dd314..494d269a 100644 --- a/hm/soispha/conf/taskwarrior/firefox/default.nix +++ b/hm/soispha/conf/taskwarrior/firefox/default.nix @@ -5,31 +5,11 @@ bookmarks, search, lib, + config, ... }: let hexLib = import ./lib.nix {inherit lib;}; - 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 {})); + inherit (config.soispha.taskwarrior.projects) projects; mkFirefoxProfile = { name, diff --git a/hm/soispha/conf/taskwarrior/hooks/default.nix b/hm/soispha/conf/taskwarrior/hooks/default.nix index f8927cd1..75f9abe7 100644 --- a/hm/soispha/conf/taskwarrior/hooks/default.nix +++ b/hm/soispha/conf/taskwarrior/hooks/default.nix @@ -5,36 +5,36 @@ config, ... }: let + 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; + enforce_policies = sysLib.writeShellScriptWithLibrary { name = "bin"; src = ./scripts/on-add_enforce-policies.sh; dependencies = with pkgs; [dash jq taskwarrior gnused gnugrep]; - replacementStrings = let - 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 { + replacementStrings = { PROJECTS_NEWLINE = projects_newline; PROJECTS_COMMA = projects_comma; }; @@ -79,11 +79,19 @@ builtins.listToAttrs (builtins.map mkSyncGitRepo ["on-add" "on-modify"]); hookPath = config.programs.taskwarrior.config.hooks.location; in { - home.file = - { - "${hookPath}/on-add_enforce-policies".source = "${enforce_policies}/bin/bin"; - "${hookPath}/on-modify_track-timewarrior".source = "${track_timewarrior}/bin/bin"; - "${hookPath}/on-modify_track-total-active-time".source = "${track_total_active_time}/bin/bin"; - } - // sync_git_repos; + options.soispha.taskwarrior.projects = lib.mkOption { + type = lib.types.attrs; + }; + config = { + soispha.taskwarrior.projects = { + inherit projects_newline projects_comma projects; + }; + home.file = + { + "${hookPath}/on-add_enforce-policies".source = "${enforce_policies}/bin/bin"; + "${hookPath}/on-modify_track-timewarrior".source = "${track_timewarrior}/bin/bin"; + "${hookPath}/on-modify_track-total-active-time".source = "${track_total_active_time}/bin/bin"; + } + // sync_git_repos; + }; } |