about summary refs log tree commit diff stats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--hm/soispha/conf/firefox/default.nix1
-rw-r--r--hm/soispha/conf/taskwarrior/firefox/default.nix24
-rw-r--r--hm/soispha/conf/taskwarrior/hooks/default.nix74
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;
+  };
 }