-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
148 lines (138 loc) · 4.36 KB
/
flake.nix
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
{
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://codeberg.org/celenity/Phoenix";
flake = false;
};
};
outputs =
{
self,
nixpkgs,
phoenix,
}:
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 & 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.isDarwin;
message = "Dove module has not been ported to nix-darwin yet. Contributions welcomed.";
}
];
environment.etc."thunderbird/defaults/pref/dove.js".source = "${pkgs.dove}/prefs/dove.js";
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,
python3,
jq,
zip,
...
}:
stdenvNoCC.mkDerivation {
name = "dove";
src = ./.;
nativeBuildInputs = [
python3
jq
zip
];
buildPhase = ''
runHook preBuild
export phoenix_dir=${phoenix}
patchShebangs ./build/*.sh
./build/build.sh
sed -i '/general.config.filename/d' prefs/dove.js
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir $out
${
if stdenvNoCC.isDarwin then
''
cp macos/* $out/
''
else
''
cp -r policies.json dove.cfg prefs $out/
''
}
install -Dm644 README.md $out/share/doc/dove/README.md
install -Dm644 COPYING $out/share/doc/dove/COPYING
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);
};
}