Hi!
I’m trying to write a nixos test for a custom nixos home-manager module.
Here is my nixos module test:
{
pkgs,
home-manager,
nixos,
...
}: let
nixos-lib = import (pkgs.path + "/nixos/lib") {};
in
# runTest: https://github.com/NixOS/nixpkgs/blob/a9c0720daf7f166918002e6b2fcc272615c95ae0/nixos/lib/testing/default.nix
# derivation: https://github.com/NixOS/nixpkgs/blob/a9c0720daf7f166918002e6b2fcc272615c95ae0/nixos/lib/testing/run.nix
nixos-lib.runTest {
name = "homemanager-module_proton-bridge";
hostPkgs = pkgs;
node = nixos.lib.optionalAttrs pkgs.stdenv.isDarwin {
pkgs = import nixos {
system = builtins.replaceStrings ["darwin"] ["linux"] pkgs.stdenv.hostPlatform.system;
};
};
nodes.machine = {...}: {
imports = [home-manager.nixosModules.home-manager];
virtualisation.host = nixos.lib.optionalAttrs pkgs.stdenv.isDarwin {inherit pkgs;};
users.users.alice = {
isNormalUser = true;
};
home-manager.users.alice = {
imports = [../default.nix];
home = {
stateVersion = "23.11";
};
services.protonmail-bridge.enable = true;
};
};
testScript = _: ''
machine.wait_for_unit("default.target")
machine.succeed("su -- alice -c 'which protonmail-bridge'")
machine.fail("su -- root -c 'which protonmail-bridge'")
'';
}
to avoid the error: assertion '(stdenv).isLinux' failed
issue, I needed to override the node pkgs from aarch64-darwin to aarch64-linux, as seen on line 15
Here is the flake’s output declaration
packages.aarch64-darwin.foo = let
pkgs = import nixos {system = "aarch64-darwin";};
in import ./nix/home-manager/modules/proton-bridge/tests (self.inputs // { inherit pkgs; });
running nix build .#foo
work as expected and I get my test success without issues. Cool.
When I try to build nix build .#foo.driver
(or the driverInteractive version) it produce the expect output ./result/bin/nixos-test-driver
which can be executed but is failing with this output:
a lot of errors like
machine # [ 1.729347] (sd-execu[476]: /nix/store/kq7xjfgy6186gw0v9qacmxm5dhp7vyrx-systemd-254.3/lib/systemd/system-generators/systemd-bless-boot-generator failed with exit status 127.
machine # [ 1.729888] (sd-execu[476]: /nix/store/kq7xjfgy6186gw0v9qacmxm5dhp7vyrx-systemd-254.3/lib/systemd/system-generators/systemd-fstab-generator failed with exit status 127.
machine # [ 1.730311] (sd-execu[476]: /nix/store/kq7xjfgy6186gw0v9qacmxm5dhp7vyrx-systemd-254.3/lib/systemd/system-generators/systemd-hibernate-resume-generator failed with exit status 127.
machine # [ 1.730858] (sd-execu[476]: /nix/store/kq7xjfgy6186gw0v9qacmxm5dhp7vyrx-systemd-254.3/lib/systemd/system-generators/systemd-debug-generator failed with exit status 127.
machine # [ 1.731336] (sd-execu[476]: /nix/store/kq7xjfgy6186gw0v9qacmxm5dhp7vyrx-systemd-254.3/lib/systemd/system-generators/systemd-system-update-generator failed with exit status 127.
machine # [ 1.731805] (sd-execu[476]: /nix/store/kq7xjfgy6186gw0v9qacmxm5dhp7vyrx-systemd-254.3/lib/systemd/system-generators/systemd-getty-generator failed with exit status 127.
machine # [ 1.732353] (sd-execu[476]: /nix/store/kq7xjfgy6186gw0v9qacmxm5dhp7vyrx-systemd-254.3/lib/systemd/system-generators/systemd-integritysetup-generator failed with exit status 127.
machine # [ 1.732853] (sd-execu[476]: /nix/store/kq7xjfgy6186gw0v9qacmxm5dhp7vyrx-systemd-254.3/lib/systemd/system-generators/systemd-run-generator failed with exit status 127.
machine # [ 1.733347] (sd-execu[476]: /nix/store/kq7xjfgy6186gw0v9qacmxm5dhp7vyrx-systemd-254.3/lib/systemd/system-generators/systemd-veritysetup-generator failed with exit status 127.
machine # [ 1.733816] (sd-execu[476]: /nix/store/kq7xjfgy6186gw0v9qacmxm5dhp7vyrx-systemd-254.3/lib/systemd/system-generators/systemd-gpt-auto-generator failed with exit status 127.
or errors like
machine # [ 2.330438] systemd[1]: Failed to read symlink /etc/systemd/system/<path>: Too many open files
I’ve tried to find example of producing the interactive test version on darwin (which is why I try to build the .driver version so I can have faster iterations when I’m writing the test assertions), I’ve found multiple links like:
- Integration testing with NixOS virtual machines — nix.dev documentation
- Run NixOS tests on Darwin · Issue #64578 · NixOS/nixpkgs · GitHub
- Documentation: NixOS VM tests on macOS · Issue #254552 · NixOS/nixpkgs · GitHub
but Im still not able to understand what is the problem in my example.
Thank you by advance for your time and help