lib/test/container-test-driver: Fix extraPythonPackages support

Fix `extraPythonPackages` support in the container test driver.

It triggered the following warning from `nixpkgs`:
```
python3Packages = throw "do not use python3Packages when building Python packages, specify each used package as a separate argument"; # do not remove
```

The following `callPackage` usage triggered the `throw`:

```
hostPackages.python3.pkgs.callPackage
```

The change to a regular `callPackage` i`nvocation fixes this issue.

Added a container test with a popular package to ensure compatibility in the future.

Closes: #5459
This commit is contained in:
a-kenji
2025-10-09 11:43:11 +02:00
parent e2f20b5ffc
commit 137d505c3b
4 changed files with 32 additions and 9 deletions

View File

@@ -97,6 +97,7 @@ in
nixos-test-container = self.clanLib.test.containerTest ./container nixosTestArgs;
nixos-test-user-firewall-iptables = self.clanLib.test.containerTest ./user-firewall/iptables.nix nixosTestArgs;
nixos-test-user-firewall-nftables = self.clanLib.test.containerTest ./user-firewall/nftables.nix nixosTestArgs;
nixos-test-extra-python-packages = self.clanLib.test.containerTest ./test-extra-python-packages nixosTestArgs;
service-dummy-test = import ./service-dummy-test nixosTestArgs;
wireguard = import ./wireguard nixosTestArgs;

View File

@@ -0,0 +1,26 @@
(
{ ... }:
{
name = "test-extra-python-packages";
extraPythonPackages = ps: [ ps.numpy ];
nodes.machine =
{ ... }:
{
networking.hostName = "machine";
};
testScript = ''
import numpy as np
start_all()
machine.wait_for_unit("multi-user.target")
# Test availability of numpy
arr = np.array([1, 2, 3])
print(f"Numpy array: {arr}")
assert len(arr) == 3
'';
}
)

View File

@@ -5,7 +5,7 @@
...
}:
let
testDriver = hostPkgs.python3.pkgs.callPackage ./package.nix {
testDriver = hostPkgs.callPackage ./package.nix {
inherit (config) extraPythonPackages;
inherit (hostPkgs.pkgs) util-linux systemd nix;
};

View File

@@ -2,28 +2,24 @@
extraPythonPackages ? (_ps: [ ]),
python3Packages,
python3,
buildPythonApplication,
setuptools,
util-linux,
systemd,
nix,
colorama,
junit-xml,
mkShell,
}:
let
package = buildPythonApplication {
package = python3Packages.buildPythonApplication {
pname = "test-driver";
version = "0.0.1";
propagatedBuildInputs = [
util-linux
systemd
colorama
junit-xml
python3Packages.colorama
python3Packages.junit-xml
nix
]
++ extraPythonPackages python3Packages;
nativeBuildInputs = [ setuptools ];
nativeBuildInputs = [ python3Packages.setuptools ];
format = "pyproject";
src = ./.;
passthru.devShell = mkShell {