-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.nix
35 lines (35 loc) · 919 Bytes
/
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
{ pkgs }:
let
run-test = pkgs.writeShellApplication {
name = "run-test";
runtimeInputs = with pkgs; [ nix ];
text = ''
nix-shell ${example} -A myMachine --run switch
cowsay it works | lolcat
'';
};
example = pkgs.runCommand "example" { } ''
mkdir -p $out/npins
cp ${./example.nix} $out/default.nix
cp -r ${sources-mock} $out/npins/default.nix
'';
sources-mock = pkgs.writeText "default.nix" ''
{
nixpkgs = ${pkgs.path};
home-damager = ${./.};
}
'';
in
pkgs.nixosTest {
name = "home-damager-test";
nodes.machine = { config, pkgs, ... }:
{
environment.systemPackages = [ run-test ];
virtualisation.memorySize = 2048;
virtualisation.mountHostNixStore = true;
};
testScript = { nodes, ... }: ''
# this won't actually work because of the impure `fetchTarball`
machine.succeed("${run-test}/bin/run-test")
'';
}