From debec946daf90174801d9cedbb52c084efb095b5 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Fri, 22 Aug 2025 17:04:38 -0500 Subject: [PATCH] nix vm tests: refactor to make gnome vm node builder reusable --- nix/tests.nix | 94 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 31 deletions(-) diff --git a/nix/tests.nix b/nix/tests.nix index 51fafad3e..33902d4d0 100644 --- a/nix/tests.nix +++ b/nix/tests.nix @@ -37,6 +37,65 @@ return "${pink_value}" in text ''; + mkNodeGnome = { + config, + pkgs, + settings, + sshPort ? null, + ... + }: { + imports = [ + ./vm/wayland-gnome.nix + settings + ]; + + virtualisation = { + forwardPorts = pkgs.lib.optionals (sshPort != null) [ + { + from = "host"; + host.port = sshPort; + guest.port = 22; + } + ]; + + vmVariant = { + virtualisation.host.pkgs = pkgs; + }; + }; + + services.openssh = { + enable = true; + settings = { + PermitRootLogin = "yes"; + PermitEmptyPasswords = "yes"; + }; + }; + + security.pam.services.sshd.allowNullPassword = true; + + users.groups.ghostty = { + gid = 1000; + }; + + users.users.ghostty = { + uid = 1000; + }; + + home-manager = { + users = { + ghostty = { + home = { + username = config.users.users.ghostty.name; + homeDirectory = config.users.users.ghostty.home; + stateVersion = nixos-version; + }; + }; + }; + }; + + system.stateVersion = nixos-version; + }; + mkTestGnome = { name, settings, @@ -59,38 +118,11 @@ config, pkgs, ... - }: { - imports = [ - ./vm/wayland-gnome.nix - settings - ]; - - virtualisation.vmVariant = { - virtualisation.host.pkgs = pkgs; + }: + mkNodeGnome { + inherit config pkgs settings; + sshPort = 2222; }; - - users.groups.ghostty = { - gid = 1000; - }; - - users.users.ghostty = { - uid = 1000; - }; - - home-manager = { - users = { - ghostty = { - home = { - username = config.users.users.ghostty.name; - homeDirectory = config.users.users.ghostty.home; - stateVersion = nixos-version; - }; - }; - }; - }; - - system.stateVersion = nixos-version; - }; }; testScript = testScript;