about summary refs log tree commit diff stats
path: root/hm/soispha/conf/taskwarrior/firefox/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'hm/soispha/conf/taskwarrior/firefox/default.nix')
-rw-r--r--hm/soispha/conf/taskwarrior/firefox/default.nix54
1 files changed, 54 insertions, 0 deletions
diff --git a/hm/soispha/conf/taskwarrior/firefox/default.nix b/hm/soispha/conf/taskwarrior/firefox/default.nix
new file mode 100644
index 00000000..5c6dd314
--- /dev/null
+++ b/hm/soispha/conf/taskwarrior/firefox/default.nix
@@ -0,0 +1,54 @@
+{
+  extensions,
+  userChrome,
+  extraConfig,
+  bookmarks,
+  search,
+  lib,
+  ...
+}: 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 {}));
+
+  mkFirefoxProfile = {
+    name,
+    id,
+  }: {
+    inherit name;
+    value = {
+      isDefault = false;
+      inherit name id extensions userChrome search bookmarks extraConfig;
+    };
+  };
+  projects_id =
+    builtins.map (project: {
+      name = project;
+      id =
+        hexLib.fromHexString
+        (builtins.hashString "sha256" project);
+    })
+    projects;
+  firefoxProfiles = builtins.listToAttrs (builtins.map mkFirefoxProfile projects_id);
+in
+  firefoxProfiles