about summary refs log tree commit diff stats
path: root/hm/soispha/conf/taskwarrior/firefox/default.nix
blob: 5c6dd3143ce30cf0038aef5e414a77e249687162 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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