Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions 30-vm-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Testing Nixos VMs

- run `nix run .#vm` to drop down in the VM
- run `sudo poweroff` to exit the VM
- run `nix build .#test` to run tests on the VM
123 changes: 113 additions & 10 deletions 30-vm-test/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 28 additions & 7 deletions 30-vm-test/flake.nix
Original file line number Diff line number Diff line change
@@ -1,26 +1,47 @@
{
description = "Test VM";
inputs = {
nixpkgs.url = "nixpkgs/nixos-24.05";
nixpkgs.url = "nixpkgs/nixos-unstable";
axumServer = {
url = "path:./svc";
};
openglStuff = {
url = "path:./vsiles-gl";
};
};
outputs =
{
self,
nixpkgs,
axumServer,
openglStuff,
}:
let
my_modules = [
./base.nix
./vm.nix
./svc-module.nix
./opengl-module.nix
];
openglStuffOverlay =
final: prev:
{

vsiles-gl = prev.vsiles-gl.overrideAttrs (oldAttrs: {
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ prev.mesa.llvmpipeHook ];
});
};
overlayApply =
pkgs:
((pkgs.extend axumServer.overlays.default).extend openglStuff.overlays.default).extend openglStuffOverlay;
linux-pkgs = overlayApply nixpkgs.legacyPackages.x86_64-linux;
darwin-pkgs = overlayApply nixpkgs.legacyPackages.aarch64-darwin;
linux-guest-pkgs = overlayApply nixpkgs.legacyPackages.aarch64-linux;
myOverlays = [
axumServer.overlays.default
openglStuff.overlays.default
openglStuffOverlay
];
linux-pkgs = nixpkgs.legacyPackages.x86_64-linux.extend axumServer.overlays.default;
darwin-pkgs = nixpkgs.legacyPackages.aarch64-darwin.extend axumServer.overlays.default;
linux-guest-pkgs = nixpkgs.legacyPackages.aarch64-linux.extend axumServer.overlays.default;
tester =
{
host-pkgs,
Expand Down Expand Up @@ -49,7 +70,7 @@
result = machine.succeed("ps aux | grep svc")
print(result)
# Testing GET
result = machine.succeed("${guest-pkgs.curl}/bin/curl http://localhost:3000 -X GET")
result = machine.succeed("${guest-pkgs.curl}/bin/curl -X GET http://localhost:3000")
assert result == "Hello, You!"

'';
Expand All @@ -59,7 +80,7 @@
nixosConfigurations.linuxVM = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
{ nixpkgs.overlays = [ axumServer.overlays.default ]; }
{ nixpkgs.overlays = myOverlays; }
] ++ my_modules;
};
packages.x86_64-linux.vm = self.nixosConfigurations.linuxVM.config.system.build.vm;
Expand All @@ -72,7 +93,7 @@
nixosConfigurations.darwinVM = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = [
{ nixpkgs.overlays = [ axumServer.overlays.default ]; }
{ nixpkgs.overlays = myOverlays; }
# This VM will use the host /nix/store thus avoid 'Exec format error'
{ virtualisation.vmVariant.virtualisation.host.pkgs = darwin-pkgs; }
] ++ my_modules;
Expand Down
19 changes: 19 additions & 0 deletions 30-vm-test/opengl-module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{ config, pkgs, ... }:
let
vsiles-gl = pkgs.vsiles-gl;
vsiles-setup = pkgs.writeShellScriptBin "vsiles-setup" ''
set -x
Xvfb :99 -ac -noreset +extension GLX +extension RANDR +extension RENDER +render -screen 0 3840x2160x24 -nolisten tcp -nolisten unix
'';
in
{
environment.systemPackages = [
vsiles-gl
pkgs.glxinfo
pkgs.xorg.xorgserver
vsiles-setup
];
}

# DISPLAY=:99 glxinfox

2 changes: 1 addition & 1 deletion 30-vm-test/svc/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description = "A Rust server with Axum and a curl script";

inputs = {
nixpkgs.url = "nixpkgs/nixos-24.05";
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
Expand Down
Loading