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-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-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-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; service-dummy-test = import ./service-dummy-test nixosTestArgs;
wireguard = import ./wireguard 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 let
testDriver = hostPkgs.python3.pkgs.callPackage ./package.nix { testDriver = hostPkgs.callPackage ./package.nix {
inherit (config) extraPythonPackages; inherit (config) extraPythonPackages;
inherit (hostPkgs.pkgs) util-linux systemd nix; inherit (hostPkgs.pkgs) util-linux systemd nix;
}; };

View File

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