-
Notifications
You must be signed in to change notification settings - Fork 7
/
flake.nix
117 lines (103 loc) · 3.94 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
{
description = "firefox-nightly";
inputs = {
nixpkgs = { url = "github:nixos/nixpkgs/nixos-unstable"; };
lib-aggregate = { url = "github:nix-community/lib-aggregate"; };
cachix = { url = "github:nixos/nixpkgs/nixos-20.09"; };
mozilla = { url = "github:mozilla/nixpkgs-mozilla"; flake = false; };
flake-compat = { url = "github:nix-community/flake-compat"; };
};
outputs = inputs:
let
inherit (inputs.lib-aggregate) lib;
inherit (inputs) self;
metadata = builtins.fromJSON (builtins.readFile ./latest.json);
mozillaSystemDict = {
"x86_64-linux" = "linux-x86_64";
"aarch64-linux" = "linux-aarch64"; # TODO: doesn't work since Moz doesn't publish 'em
};
# supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; # TODO: still not there
supportedSystems = [ "x86_64-linux" ];
in
lib.flake-utils.eachSystem supportedSystems (system:
let
pkgsFor = pkgs: overlays:
import pkgs {
inherit system;
config.allowUnfree = true;
overlays = [ (import "${inputs.mozilla}/firefox-overlay.nix") ];
};
pkgs_ = lib.genAttrs (builtins.attrNames inputs) (inp: pkgsFor inputs."${inp}" [ ]);
fv = pkgs_.nixpkgs.lib.firefoxOverlay.firefoxVariants;
variants = (builtins.mapAttrs
(n: v:
let
cv = metadata.${system}."variants".${n};
cvi = metadata.${system}."versionInfo".${n};
in
pkgs_.nixpkgs.lib.firefoxOverlay.firefoxVersion (cv // { info = cvi; })
)
(fv)
);
# latest versionInfo outputs for each variant
# impure, but by design. this is stored/recorded and then used purely
impureVariants =
(pkgs_.nixpkgs.lib.firefoxOverlay.firefoxVariants);
impureVersionInfos = (builtins.mapAttrs
(n: v: pkgs_.nixpkgs.lib.firefoxOverlay.versionInfo (v // { system = mozillaSystemDict.${system}; }))
(fv)
);
# https://nixos.org/manual/nixos/unstable/index.html#sec-calling-nixos-tests
nixos-lib = import (inputs.nixpkgs + "/nixos/lib") { };
runNixOSTestFor = pkg: nixos-lib.runTest {
imports = [ ./tests/firefox.nix ];
hostPkgs = pkgs_.nixpkgs;
defaults = {
# reuse the already evaluated nixpkgs
# https://search.nixos.org/options?channel=unstable&show=nixpkgs.pkgs
# with 3.9 s without 4.9 s both with a dirty tree
# `time nix build ".#checks.x86_64-linux.firefox-bin"`
nixpkgs.pkgs = pkgs_.nixpkgs;
# Less dependencies
documentation.enable = false;
};
_module.args.firefoxPackage = pkg;
};
in
{
devShells = {
default = pkgs_.nixpkgs.mkShell {
nativeBuildInputs = [ ]
++ (with pkgs_.cachix; [ cachix ])
++ (with pkgs_.nixpkgs; [
nixVersions.latest
nix-prefetch
nix-build-uncached
bash
cacert
curl
git
jq
mercurial
nushell
openssh
ripgrep
])
;
};
};
packages = ({
default = pkgs_.nixpkgs.linkFarm "firefox-variants" [
{ name = "firefox-bin"; path = variants.firefox-bin; }
{ name = "firefox-esr-bin"; path = variants.firefox-esr-bin; }
{ name = "firefox-nightly-bin"; path = variants.firefox-nightly-bin; }
{ name = "firefox-beta-bin"; path = variants.firefox-beta-bin; }
];
} // variants);
latest = {
variants = impureVariants;
versionInfo = impureVersionInfos;
};
checks = builtins.mapAttrs (_: value: runNixOSTestFor value) (builtins.removeAttrs self.packages.${system} [ "default" ]) /* # is a link farm */ ;
});
}