-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.nix
53 lines (53 loc) · 1.34 KB
/
test.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
{
sources,
nix,
runCommand,
testers,
writeShellApplication,
writeText,
}:
let
flake-inputs = import sources.flake-inputs;
nixpkgs = (flake-inputs { root = sources.home-manager; }).nixpkgs;
run-test = writeShellApplication {
name = "run-test";
runtimeInputs = [ nix ];
text = ''
nix-shell ${example} -A myMachine -I nixpkgs=${nixpkgs} --run switch
cowsay it works | lolcat
'';
};
example = runCommand "example" { } ''
mkdir -p $out/npins
cp ${./example.nix} $out/default.nix
cp -r ${sources-mock} $out/npins/default.nix
'';
sources-mock = writeText "default.nix" ''
{
home-manager = ${sources.home-manager};
flake-inputs = ${sources.flake-inputs};
home-damager = ${./.};
}
'';
in
testers.runNixOSTest {
name = "home-damager-test";
nodes.machine =
{ config, ... }:
{
environment.systemPackages = [ run-test ];
virtualisation.memorySize = 2048;
virtualisation.additionalPaths = [
# XXX: since all of this runs in a derivation and can't access the internet,
# we need the Nixpkgs source picked up from Home Manager
"${nixpkgs}"
# and the built closure of the desired environmet
(import example { }).myMachine
];
};
testScript =
{ nodes, ... }:
''
machine.succeed("run-test")
'';
}