Skip to content

Commit afbf31d

Browse files
committed
test: Install standard metapackage
1 parent 26ddd60 commit afbf31d

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

flake.nix

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
description = "MIT Athena packaging for Nix";
3+
34
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
5+
46
outputs = { self, nixpkgs }:
57
let
68
systems = [
@@ -14,9 +16,32 @@
1416
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
1517
in
1618
{
17-
legacyPackages = forAllSystems (system: import ./default.nix {
19+
legacyPackages = forAllSystems (system: let
1820
pkgs = import nixpkgs { inherit system; };
21+
in (import ./default.nix {
22+
pkgs = import nixpkgs { inherit system; };
23+
}) // rec {
24+
# This lets you pick the driver function
25+
test-infra = {
26+
metaStandardTest = pkgs.callPackage ./test/meta-standard.nix { inherit self system; };
27+
};
28+
# This is what should actually get run
29+
test = {
30+
# `nix run '.#test.meta-standard'` to run this test
31+
# It requires network (for hesiod and AFS access), so we can't run
32+
# it in `checks` and need to explicitly choose `.driver` -- the
33+
# default apparently blocks network.
34+
meta-standard = test-infra.metaStandardTest.driver;
35+
};
1936
});
2037
packages = forAllSystems (system: nixpkgs.lib.filterAttrs (_: v: nixpkgs.lib.isDerivation v) self.legacyPackages.${system});
38+
39+
40+
checks = forAllSystems (system: let
41+
pkgs = nixpkgs.legacyPackages.${system};
42+
in {
43+
# Add things here if we ever get anything that doesn't need network
44+
}
45+
);
2146
};
2247
}

test/meta-standard.nix

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# From https://blakesmith.me/2024/03/02/running-nixos-tests-with-flakes.html
2+
{ self, pkgs, system, }:
3+
4+
let
5+
nixathena = self.legacyPackages.${system};
6+
in
7+
8+
pkgs.nixosTest {
9+
name = "meta-standard";
10+
nodes.machine = { config, pkgs, ... }: {
11+
imports = [
12+
nixathena.modules.meta.standard
13+
];
14+
nixathena.meta.standard.enable = true;
15+
};
16+
17+
testScript = ''
18+
machine.wait_for_unit("pyhesiodfs.service")
19+
# network-online.service is too long to wait
20+
# afsd.service is (seemingly) long enough to have network
21+
machine.wait_for_unit("afsd.service")
22+
machine.succeed("ping -c1 ipv4.google.com")
23+
[status, out] = machine.execute("ping -c1 google.com")
24+
print(out)
25+
machine.succeed('ls /afs/athena.mit.edu/')
26+
machine.succeed('test -e /mit/sipb/README')
27+
'';
28+
}

0 commit comments

Comments
 (0)