1{
2 runCommand,
3 fetchFromGitLab,
4 wrapFirefox,
5 firefox-unwrapped,
6}:
7
8let
9 pkg = fetchFromGitLab {
10 domain = "gitlab.postmarketos.org";
11 owner = "postmarketOS";
12 repo = "mobile-config-firefox";
13 rev = "4.6.0";
14 hash = "sha256-tISfxN/04spgtKStkkn+zlCtFU6GbtwuZubqpGN2olA=";
15 };
16 mobileConfigDir = runCommand "mobile-config-firefox" { } ''
17 mkdir -p $out/mobile-config-firefox/{common,userChrome,userContent}
18
19 cp ${pkg}/src/common/*.css $out/mobile-config-firefox/common/
20 cp ${pkg}/src/userChrome/*.css $out/mobile-config-firefox/userChrome/
21 cp ${pkg}/src/userContent/*.css $out/mobile-config-firefox/userContent/
22
23 (cd $out/mobile-config-firefox && find common -name "*.css" | sort) >> $out/mobile-config-firefox/userChrome.files
24 (cd $out/mobile-config-firefox && find common -name "*.css" | sort) >> $out/mobile-config-firefox/userContent.files
25
26 (cd $out/mobile-config-firefox && find userChrome -name "*.css" | sort) > $out/mobile-config-firefox/userChrome.files
27 (cd $out/mobile-config-firefox && find userContent -name "*.css" | sort) > $out/mobile-config-firefox/userContent.files
28
29 '';
30
31 mobileConfigAutoconfig = runCommand "mobile-config-autoconfig.js" { } ''
32 substitute ${pkg}/src/mobile-config-autoconfig.js $out \
33 --replace "/etc/mobile-config-firefox" "${mobileConfigDir}/mobile-config-firefox"
34 '';
35
36 mobileConfigPrefs = runCommand "mobile-config-prefs.js" { } ''
37 # Remove the autoconfig setup lines since we handle that through extraPrefsFiles
38 grep -v "general.config.filename" ${pkg}/src/mobile-config-prefs.js | \
39 grep -v "general.config.obscure_value" | \
40 grep -v "general.config.sandbox_enabled" > $out
41 '';
42in
43wrapFirefox firefox-unwrapped {
44 extraPrefsFiles = [
45 mobileConfigAutoconfig
46 mobileConfigPrefs
47 ];
48
49 extraPoliciesFiles = [
50 "${pkg}/src/policies.json"
51 ];
52}