about summary refs log tree commit diff stats
path: root/modules/home.legacy/conf/firefox/default.nix
blob: f2ccfc994127ea78259770bc80628e687adfc7d4 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{
  config,
  pkgs,
  lib,
  user_js,
  ...
}: let
  extensions =
    builtins.fromJSON (builtins.readFile ./config/extensions/extensions.json);

  userChrome = builtins.readFile ./config/chrome/userChrome.css;
  bookmarks = (import ./config/bookmarks/default.nix) {
    inherit
      pkgs
      lib
      ;
  };
  engines = (import ./config/search/engines) {inherit pkgs;};

  native_messaging_hosts = (import ./config/extensions/native_messaging_hosts/default.nix) {inherit pkgs;};

  policies = (import ./config/policies) {inherit config extensions;};

  search = {
    default = "Brave Search";
    privateDefault = "Brave Search";
    force = true;
    order = [
      # DEFAULT
      "Brave Search"

      # NIX
      "Nix Packages"
      "Nix Options"
      "Nixpkgs issues"
      "Homemanager Options"
      "NixOS Wiki"
      "Nixpkgs Pull Request Tracker"

      # RUST
      "Rust std"
      "Rust tokio"

      # OTHER
      "Google Scholar"
      "Wikipedia"
      "Arch Wiki"
    ];

    inherit engines;
  };

  prefConfig = builtins.readFile "${
    (import ./config/prefs) {inherit pkgs lib config bookmarks user_js;}
  }/user.js";

  # Package {{{
  package = import ./package.nix {
    inherit config lib pkgs;
    extraPolicies = policies;
    extraNativeMessagingHosts = native_messaging_hosts;
  };
  # }}}

  # Profiles {{{
  profiles = {
    "default" = {
      inherit search userChrome;
      isDefault = true;
      id = 0;
      name = "default";
      extraConfig = prefConfig;
    };
  };

  taskwarriorProfiles = import ../taskwarrior/firefox {
    inherit
      config
      lib
      # options
      
      prefConfig
      search
      userChrome
      ;
    profile_size = builtins.length (builtins.attrNames profiles);
  };
  # }}}
in {
  options.soispha.firefox = {
    package = lib.mkOption {
      type = lib.types.package;
      default = pkgs.firefox;
      description = "Firefox package to use.";
      defaultText = lib.literalExpression "pkgs.firefox";
      relatedPackages = [
        "firefox"
        "firefox-beta-bin"
        "firefox-bin"
        "firefox-devedition-bin"
        "firefox-esr"
      ];
    };
    package_version = lib.mkOption {
      type = lib.types.str;
      default = pkgs.firefox.version;
      description = "Firefox version to use";
    };
  };

  config = {
    soispha.firefox.package = package;
    soispha.firefox.package_version = pkgs.firefox.version;
    home.sessionVariables = {
      # improve touch input & make scrolling smother
      MOZ_USE_XINPUT2 = "1";

      # improve wayland support
      MOZ_ENABLE_WAYLAND = 1;

      # tell gtk to use portals
      GTK_USE_PORTAL = 1;

      BROWSER = "firefox";
    };
    programs.firefox = {
      enable = true;
      inherit (config.soispha.firefox) package;
      profiles =
        profiles
        // taskwarriorProfiles;
    };
  };
}