From d5f4eaef68b46f1d091b7eef410f40275cb1ec16 Mon Sep 17 00:00:00 2001 From: lostbean Date: Wed, 31 Jan 2024 11:01:21 -0300 Subject: [PATCH] add testing VM --- internal_testsuites/flake.lock | 25 ++++++++++++++++++ internal_testsuites/flake.nix | 46 ++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 internal_testsuites/flake.lock create mode 100644 internal_testsuites/flake.nix diff --git a/internal_testsuites/flake.lock b/internal_testsuites/flake.lock new file mode 100644 index 0000000000..278ea44830 --- /dev/null +++ b/internal_testsuites/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1706487304, + "narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/internal_testsuites/flake.nix b/internal_testsuites/flake.nix new file mode 100644 index 0000000000..95a21d4ada --- /dev/null +++ b/internal_testsuites/flake.nix @@ -0,0 +1,46 @@ +{ + outputs = { self, nixpkgs, }: { + nixosModules.vm = { ... }: { + # Make VM output to the terminal instead of a separate window + virtualisation.vmVariant.virtualisation.graphics = false; + }; + + nixosModules.base = { pkgs, ... }: { + system.stateVersion = "23.11"; + + # Configure networking + networking.useDHCP = false; + networking.interfaces.eth0.useDHCP = true; + + # Create user "test" + services.getty.autologinUser = "tester"; + users.users.test.isNormalUser = true; + + # Enable passwordless ‘sudo’ for the "test" user + users.users.test.extraGroups = [ "wheel" ]; + security.sudo.wheelNeedsPassword = false; + }; + + nixosConfigurations.linuxVM = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ self.nixosModules.base self.nixosModules.vm ]; + }; + packages.x86_64-linux.linuxVM = + self.nixosConfigurations.linuxVM.config.system.build.vm; + + nixosConfigurations.darwinVM = nixpkgs.lib.nixosSystem { + system = "aarch64-linux"; + modules = [ + self.nixosModules.base + self.nixosModules.vm + { + virtualisation.vmVariant.virtualisation.host.pkgs = + nixpkgs.legacyPackages.aarch64-darwin; + } + ]; + }; + packages.aarch64-darwin.darwinVM = + self.nixosConfigurations.darwinVM.config.system.build.vm; + + }; +}