Skip to content

Commit 9767466

Browse files
committed
modules/nixpkgs: test overlays option
1 parent 2cbd270 commit 9767466

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

tests/default.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
self, # This flake
3+
system,
24
lib ? pkgs.lib,
35
helpers,
46
pkgs,
@@ -16,6 +18,11 @@ let
1618
module = {
1719
_file = file;
1820
imports = [ module ];
21+
_module.args = {
22+
# Give tests access to the flake
23+
inherit self system;
24+
inherit (self) inputs;
25+
};
1926
};
2027
pkgs = pkgsUnfree;
2128
};
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
# TODO: expect not setting `nixpkgs.pkgs` to throw
3+
4+
overlays =
5+
{ pkgs, ... }:
6+
{
7+
test.runNvim = false;
8+
9+
nixpkgs.overlays = [
10+
(final: prev: {
11+
foobar = "foobar";
12+
})
13+
];
14+
15+
assertions = [
16+
{
17+
assertion = pkgs.foobar or null == "foobar";
18+
message = ''
19+
Expected `pkgs.foobar` to be "foobar"
20+
'';
21+
}
22+
];
23+
};
24+
25+
# Test that overlays from both `nixpkgs.pkgs` _and_ `nixpkgs.overlays` are applied
26+
stacked_overlays =
27+
{
28+
inputs,
29+
system,
30+
pkgs,
31+
...
32+
}:
33+
{
34+
test.runNvim = false;
35+
36+
nixpkgs.pkgs = import inputs.nixpkgs {
37+
inherit system;
38+
overlays = [
39+
(final: prev: {
40+
foobar = "foobar";
41+
conflict = "a";
42+
})
43+
];
44+
};
45+
46+
nixpkgs.overlays = [
47+
(final: prev: {
48+
hello = "world";
49+
conflict = "b";
50+
})
51+
];
52+
53+
assertions = [
54+
{
55+
assertion = pkgs.foobar or null == "foobar";
56+
message = ''
57+
Expected `pkgs.foobar` to be "foobar"
58+
'';
59+
}
60+
{
61+
assertion = pkgs.hello or null == "world";
62+
message = ''
63+
Expected `pkgs.hello` to be "world"
64+
'';
65+
}
66+
{
67+
assertion = pkgs.conflict or null == "b";
68+
message = ''
69+
Expected `pkgs.conflict` to be "b"
70+
'';
71+
}
72+
];
73+
};
74+
}

0 commit comments

Comments
 (0)