Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
208 lines (193 loc) · 6.87 KB
/
Copy pathflake.nix
File metadata and controls
208 lines (193 loc) · 6.87 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
{
description = "Dove: a suite of configurations & advanced modifications for Mozilla Thunderbird, designed to put the user first - with a focus on privacy, security, freedom, functionality, & usability.";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
phoenix = {
url = "git+https://gitlab.com/celenityy/Phoenix?ref=pages";
flake = false;
};
autoconfig = {
url = "github:thunderbird/autoconfig?ref=prod";
flake = false;
};
};
outputs =
{
self,
nixpkgs,
phoenix,
autoconfig,
}:
let
inherit (nixpkgs) lib;
forAllSystems = lib.genAttrs lib.systems.flakeExposed;
in
{
nixosModules = {
default =
{
pkgs,
config,
lib,
...
}:
{
options.programs.thunderbird.dove = {
enable =
lib.mkEnableOption "Enable privacy and security hardening of Thunderbird using the Dove configs"
// {
default = true;
};
thunderbirdPackages = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [
"thunderbird"
"thunderbird-latest"
];
description = "The name of Thunderbird packages of current pkgs to patch with dove config and policy.";
};
};
config =
let
cfg = config.programs.thunderbird.dove;
in
lib.mkIf cfg.enable {
assertions = [
{
assertion = !pkgs.stdenv.hostPlatform.isDarwin;
message = "Dove module has not been ported to nix-darwin yet. Contributions welcomed.";
}
];
environment.etc."thunderbird/defaults/pref/dove.js".source = "${pkgs.dove}/pref/dove.js";
environment.etc."thunderbird/dove.cfg".source = "${pkgs.dove}/dove.cfg";
environment.etc."thunderbird/dove/assets".source = "${pkgs.dove}/assets";
environment.variables = {
MOZ_CRASHREPORTER = null;
MOZ_CRASHREPORTER_DISABLE = 1;
MOZ_CRASHREPORTER_NO_REPORT = 1;
MOZ_CRASHREPORTER_URL = "data;";
MOZ_DISABLE_ASAN_REPORTER = 1;
MOZ_ENABLE_WAYLAND = 1;
MOZ_GFX_CRASH_MOZ_CRASH = 1;
MOZ_GFX_CRASH_TELEMETRY = null;
PHOENIX_HOST_NIX = 1;
SSLKEYLOGFILE = null;
};
programs.thunderbird.policies =
(builtins.fromJSON (builtins.readFile "${pkgs.dove}/policies.json")).policies;
nixpkgs.overlays = [
self.overlays.default
(
final: prev:
builtins.listToAttrs (
map (p: lib.nameValuePair p (final.withDove prev.${p})) cfg.thunderbirdPackages
)
)
];
};
};
};
packages = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system}.extend self.overlays.default;
in
rec {
default = dove;
inherit (pkgs) dove;
thunderbird = pkgs.withDove pkgs.thunderbird;
thunderbird-latest = pkgs.withDove pkgs.thunderbird-latest;
}
);
overlays = {
default = final: prev: {
dove = final.callPackage (
{
stdenvNoCC,
bashNonInteractive,
coreutils,
python3,
jq,
gnused,
gawk,
...
}:
stdenvNoCC.mkDerivation {
name = "dove";
src = ./.;
nativeBuildInputs = [
(python3.withPackages (ps: [
ps.lxml
]))
bashNonInteractive
coreutils
jq
gnused
gawk
];
buildPhase = ''
runHook preBuild
export DOVE_PHOENIX="$PWD/phoenix"
export DOVE_AUTOCONFIG=${autoconfig}
cp --no-preserve=mode -r ${phoenix} "$DOVE_PHOENIX"
sed -i 's|/bin/bash|${bashNonInteractive}/bin/bash|g' "$DOVE_PHOENIX/scripts/build.sh"
export DOVE_NIX=1
# external tools used during build
export DOVE_AWK="${gawk}/bin/awk"
export DOVE_BASH="${bashNonInteractive}/bin/bash"
export DOVE_CAT="${coreutils}/bin/cat"
export DOVE_CP="${coreutils}/bin/cp"
export DOVE_DIRNAME="${coreutils}/bin/dirname"
export DOVE_JQ="${jq}/bin/jq"
export DOVE_LN="${coreutils}/bin/ln"
export DOVE_MKDIR="${coreutils}/bin/mkdir"
export DOVE_RM="${coreutils}/bin/rm"
export DOVE_SED="${gnused}/bin/sed"
export DOVE_TEE="${coreutils}/bin/tee"
export DOVE_UNAME="${coreutils}/bin/uname"
export DOVE_PYTHON="${python3.withPackages (ps: [ ps.lxml ])}/bin/python"
patchShebangs ./scripts/*.sh
${
if stdenvNoCC.hostPlatform.isDarwin then
''
./scripts/build.sh 'osx'
''
else
''
./scripts/build.sh 'linux'
''
}
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir $out
${
if stdenvNoCC.hostPlatform.isDarwin then
''
cp outputs/osx/* $out/
cp -r outputs/osx/assets $out/assets
''
else
''
cp -r outputs/linux/policies/policies.json outputs/linux/dove.cfg outputs/linux/defaults/pref $out/
cp -r outputs/linux/assets $out/assets
''
}
install -Dm644 README.md $out/share/doc/dove/README.md
install -Dm644 COPYING.txt $out/share/doc/dove/COPYING.txt
runHook postInstall
'';
}
) { };
withDove =
thunderbirdPackage:
thunderbirdPackage.override {
extraPoliciesFiles = [ "${final.dove}/policies.json" ];
extraPrefsFiles = [ "${final.dove}/dove.cfg" ];
};
};
};
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
};
}