aboutsummaryrefslogtreecommitdiff
path: root/default.nix
blob: f986dcccd8cf0bc3d75ecbf668f9c6b801305398 (plain)
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
{ pkgs ? import <nixpkgs> {} }:

with pkgs;

# Where to find documentation:
# http://kb.mozillazine.org/About:config_entries
# https://www.privacy-handbuch.de/download/moderat/user.js
# https://github.com/mozilla/policy-templates, about:policies#documentation

let
  directory = callPackage nix/directory.nix {};
  ffLib = callPackage nix/lib.nix {};
  search = callPackage nix/search.nix {};

  callProfile = p: lib.callPackageWith (pkgs // {
    inherit ffLib;
  }) p {};
in rec {
  profiles = directory.listDirectory callProfile ./profiles;

  disableErrorReporting.preferences = {
    breakpad.reportUrl = "";
  };

  activeProfiles = with profiles; [
    defaults

    addons.disableExtensionSignatureChecking
    addons.privacybadger
    addons.noscriptFork
    addons.qwantjuniorSystem

    minimalConnections
    minimalHome
    noAccounts
    noClutter
    noMedia
    noNormandy
    noUpdates
    noStudies
    noPocket
    noTunnels
    noLocation
    safebrowsing.disableAll
    # restrict
    # distrustUser

    ocsp.disabled

    forgetActivity

    { policies.RequestedLocales = [ "de-DE" "en-US" ]; }
  ];

  config = ffLib.mergeProfiles activeProfiles;
  bundleConfig = {
    inherit (config) policies;
    preferences = ffLib.flattenAttrs config.preferences;

    # This is very hacky, but Firefox really resists setting the default search engine
    # by any other means. Only builtin search engines are allowed to make themselves default
    # without prompting for user consent.
    patchOmniJaCommand =
      let searchEnginesInfo = {
            default = {
              searchDefault = "qwantjunior";
              searchOrder = [ "qwantjunior" "ddg" ];
              visibleDefaultEngines = [ "qwantjunior" "ddg" ];
            };
            regionOverrides = {};
            locales = {};
          };
      in ''
      pushd chrome/browser/search-extensions
      cp -r ${profiles/addons/qwantjunior} ./qwantjunior
      cp ${builtins.toFile "list.json" (builtins.toJSON searchEnginesInfo)} list.json
      popd
    '';
  };

  bundle = ffLib.bundle bundleConfig;
  launcher = ffLib.launcher bundle;

/*
  bundle = profiles.bundle {
    policies = {
      Preferences = profiles.flattenAttrs {
        dom.event.contextmenu.enabled = false;

        extensions = {
          blocklist.enabled = false;
          getAddons.showPane = false;
          htmlaboutaddons.recommendations.enabled = false;
        };

        security.ssl.errorReporting.enabled = false;
      };

      SearchBar = "separate";
    };
  };
  */
}