-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathflake.nix
More file actions
148 lines (132 loc) · 3.73 KB
/
flake.nix
File metadata and controls
148 lines (132 loc) · 3.73 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
{
description = "firefox-nightly";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable-small";
lib-aggregate.url = "github:nix-community/lib-aggregate";
flake-compat.url = "github:nix-community/flake-compat";
};
outputs =
inputs:
let
inherit (inputs.lib-aggregate) lib;
versions = builtins.fromJSON (builtins.readFile ./latest.json);
overlay =
final: prev:
let
mkFirefox =
{
branch,
name,
channel ? "release",
}:
let
inherit (final.stdenv.hostPlatform) system;
# map nixpkgs systems to mozilla
mozSystem =
{
"x86_64-linux" = "linux-x86_64";
"aarch64-linux" = "linux-aarch64";
}
.${system};
data = versions.${mozSystem}.${branch};
unwrapped =
if isNull data then
throw "${name} is not available on ${system}!"
else
final.callPackage (import ./package.nix {
inherit name branch;
version = data.version;
src = final.fetchurl {
inherit (data) url hash;
};
}) { };
in
final.wrapFirefox unwrapped ({
pname = "${unwrapped.binaryName}-bin";
});
in
{
firefox-bin = mkFirefox {
branch = "release";
name = "Firefox";
};
firefox-esr-bin = mkFirefox {
branch = "esr";
name = "Firefox ESR";
};
firefox-beta-bin = mkFirefox {
branch = "beta";
name = "Firefox Beta";
channel = "beta";
};
firefox-devedition-bin = mkFirefox {
branch = "devedition";
name = "Firefox Developer Edition";
channel = "developer-edition";
};
firefox-nightly-bin = mkFirefox {
branch = "nightly";
name = "Firefox Nightly";
channel = "nightly";
};
};
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
];
in
{
overlays.default = overlay;
}
// (lib.flake-utils.eachSystem supportedSystems (
system:
let
pkgs = import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
};
firefoxPkgs = overlay pkgs pkgs;
# https://nixos.org/manual/nixos/unstable/index.html#sec-calling-nixos-tests
runNixOSTestFor =
pkg:
pkgs.testers.runNixOSTest {
imports = [ ./tests/firefox.nix ];
defaults = {
# Less dependencies
documentation.enable = false;
};
_module.args.firefoxPackage = pkg;
};
in
{
devShells = {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
cachix
nixVersions.latest
nix-prefetch
nix-build-uncached
bash
cacert
curl
git
jq
mercurial
nushell
openssh
ripgrep
];
};
};
packages = firefoxPkgs // {
default = pkgs.linkFarm "firefox-variants" (
lib.mapAttrsToList (name: value: {
inherit name;
path = value;
}) firefoxPkgs
);
};
checks = builtins.mapAttrs (_: value: runNixOSTestFor value) firefoxPkgs;
}
));
}