blob: 7d9fd799ed34f7039de7e97cc4a3fea93d5199b1 (
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
|
let
profile = "default";
prf = ".mozilla/firefox/${profile}";
extstorage = "${prf}/browser-extension-data";
in
{
config,
inputs,
pkgs,
lib,
...
}: {
home-manager.users.tzlil = let
firefox-addons = pkgs.callPackage (pkgs.applyPatches {
src = inputs.firefox-addons;
patches = [./addons-passthru.patch];
name = "firefox-addons-patched";
}) {};
mozlz4 = n: x:
pkgs.runCommand "${n}.lz4" {buildInputs = [pkgs.mozlz4a];} ''
mozlz4a ${pkgs.writeTextFile {name=n; text=builtins.toJSON x;}} $out
'';
cfg = config.home-manager.users.tzlil.programs;
addons = cfg.firefox.profiles.${profile}.extensions;
extensionPath = "extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
addonStartupData = builtins.fromJSON (builtins.readFile (pkgs.runCommand "addonStartup.json" {buildInputs = [ pkgs.xvfb-run pkgs.mozlz4a pkgs.jq (pkgs.firefox.override {
extraPolicies.Extensions.Install = map (x: x.src.outPath) addons;
})];} ''
HOME=$(mktemp -d)
export FONTCONFIG_FILE=${pkgs.makeFontsConf { fontDirectories = [ pkgs.roboto ]; }}
mkdir -p $HOME/.mozilla/firefox/default
cat >> $HOME/.mozilla/firefox/profiles.ini<< EOF
[Profile0]
Default=1
IsRelative=1
Name=default
Path=default
EOF
echo user_pref\(\"browser.region.network.url\", \"\"\) > $HOME/.mozilla/firefox/default/user.js
xvfb-run firefox --screenshot about:blank
mozlz4a -d $HOME/.mozilla/firefox/default/addonStartup.json.lz4 /dev/stdout | jq .\"app-profile\".addons > $out
''));
in {
# these come from the HM module
home.file."${prf}/extension-preferences.json".source = pkgs.emptyFile;
home.file."${prf}/extension-preferences.json.tmp".source = pkgs.emptyFile;
home.file."${prf}/extension-settings.json".source = pkgs.emptyFile;
home.file."${prf}/extension-settings.json.tmp".source = pkgs.emptyFile;
home.file."${prf}/search.json.mozlz4".source = pkgs.emptyFile;
home.file."${prf}/search.json.mozlz4.tmp".source = pkgs.emptyFile;
home.file."${prf}/extensions".source = lib.mkForce ("${pkgs.symlinkJoin {
name = "extensions";
paths = addons;
}}/share/mozilla/${extensionPath}");
home.file."${prf}/storage".source = pkgs.emptyDirectory;
home.file."${prf}/crashes".source = pkgs.emptyDirectory;
home.file."${prf}/datareporting".source = pkgs.emptyDirectory;
home.file."${prf}/saved-telemetry-pings".source = pkgs.emptyDirectory;
home.file."${prf}/addonStartup.json.lz4".source = mozlz4 "addonStartup.json" {"app-profile".addons = addonStartupData;};
home.file."${prf}/addonStartup.json.lz4.tmp".source = pkgs.emptyFile;
home.file."${prf}/addons.json".source = pkgs.emptyFile;
home.file."${prf}/addons.json.tmp".source = pkgs.emptyFile;
home.file."${prf}/extensions.json".source = pkgs.emptyFile;
home.file."${prf}/extensions.json.tmp".source = pkgs.emptyFile;
# tries to access W_OK it forever
# home.file."${prf}/prefs.js".source = pkgs.emptyFile;
# home.file."${prf}/prefs-1.js".source = pkgs.emptyFile;
programs.firefox = {
enable = true;
profiles.${profile} = {
extensions = with firefox-addons; [
kristofferhagen-nord-theme
];
settings = {
"extensions.activeThemeID" = "{e410fec2-1cbd-4098-9944-e21e708418af}";
"browser.search.hiddenOneOffs" = "Google,Bing,Amazon.com,eBay,Twitter,Wikipedia (en)";
};
};
};
};
}
|