1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-09 17:46:29 +09:00
nixpkgs/nixos/tests/nix/misc.nix
Alois Wohlschlager 9685bc5a05 lixPackageSets.*.lix: test the correct Lix in passthru.tests
Previously always the top-level lix package would be used, which is obviously
not what we want.
2025-05-16 17:55:05 +02:00

68 lines
1.9 KiB
Nix

# Miscellaneous small tests that don't warrant their own VM run.
{ pkgs, ... }:
let
inherit (pkgs) lib;
tests.default = testsForPackage { nixPackage = pkgs.nix; };
testsForPackage = args: {
# If the attribute is not named 'test'
# You will break all the universe on the release-*.nix side of things.
# `discoverTests` relies on `test` existence to perform a `callTest`.
test = testMiscFeatures args // {
passthru.override = args': (testsForPackage (args // args')).test;
};
};
testMiscFeatures =
{ nixPackage, ... }:
pkgs.testers.nixosTest (
let
foo = pkgs.writeText "foo" "Hello World";
in
{
name = "${nixPackage.pname}-misc";
meta.maintainers = with lib.maintainers; [
raitobezarius
artturin
];
nodes.machine =
{ lib, ... }:
{
system.extraDependencies = [ foo ];
nix.package = nixPackage;
};
testScript = ''
import json
def get_path_info(path):
result = machine.succeed(f"nix --option experimental-features nix-command path-info --json {path}")
parsed = json.loads(result)
return parsed
with subtest("nix-db"):
out = "${foo}"
info = get_path_info(out)
print(info)
pathinfo = info[0] if isinstance(info, list) else info[out]
if (
pathinfo["narHash"]
!= "sha256-BdMdnb/0eWy3EddjE83rdgzWWpQjfWPAj3zDIFMD3Ck="
):
raise Exception("narHash not set")
if pathinfo["narSize"] != 128:
raise Exception("narSize not set")
with subtest("nix-db"):
machine.succeed("nix-store -qR /run/current-system | grep nixos-")
'';
}
);
in
tests