Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/mesa-git: add DM env; add half-baked virgl-based VM nixosTest #292

Merged
merged 8 commits into from
Aug 28, 2023
Merged
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
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
result
result-*
/.env
/.nixos-test-history
/result
/result-*
39 changes: 23 additions & 16 deletions modules/nixos/mesa-git.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,31 @@ let
];
};

methodBackend = {
hardware.opengl = with lib; {
enable = mkForce true;
package = mkForce pkgs.mesa_git.drivers;
package32 = mkForce pkgs.mesa32_git.drivers;
extraPackages = mkForce (cfg.extraPackages ++ [ pkgs.mesa_git.gbm ]);
extraPackages32 = mkForce cfg.extraPackages32;
driSupport = mkForce true;
driSupport32Bit = mkForce has32;
setLdLibraryPath = mkForce false;
};
methodBackend =
let
variables = {
GBM_BACKENDS_PATH = "/run/opengl-driver/lib/gbm";
GBM_BACKEND = pkgs.mesa_git.gbmBackend;
};
in
{
hardware.opengl = with lib; {
enable = mkForce true;
package = mkForce pkgs.mesa_git.drivers;
package32 = mkForce pkgs.mesa32_git.drivers;
extraPackages = mkForce (cfg.extraPackages ++ [ pkgs.mesa_git.gbm ]);
extraPackages32 = mkForce cfg.extraPackages32;
driSupport = mkForce true;
driSupport32Bit = mkForce has32;
setLdLibraryPath = mkForce false;
};

environment.sessionVariables = {
GBM_BACKENDS_PATH = "/run/opengl-driver/lib/gbm";
GBM_BACKEND = pkgs.mesa_git.gbmBackend;
LD_PRELOAD = [ "${pkgs.mesa_git}/lib/libglapi.so.0" ]; # TODO: find a better solution
systemd.services.display-manager.environment = variables;

environment.sessionVariables = variables // {
LD_PRELOAD = [ "${pkgs.mesa_git}/lib/libglapi.so.0" ]; # TODO: find a better solution
};
};
};

chosenMethod =
lib.mkIf (cfg.method == "replaceRuntimeDependencies") methodReplace
Expand Down
24 changes: 18 additions & 6 deletions pkgs/mesa-git/default.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
{ final, flakes, nyxUtils, prev, gbmDriver ? false, gbmBackend ? "dri_git", meson ? final.meson, ... }:
{ final
, flakes
, nyxUtils
, prev
, gbmDriver ? false
, gbmBackend ? "dri_git"
, meson ? final.meson
, mesaTestAttrs ? final
, ...
}:

nyxUtils.multiOverride prev.mesa { inherit meson; } (prevAttrs: {
version = builtins.substring 0 (builtins.stringLength prevAttrs.version) flakes.mesa-git-src.rev;
src = flakes.mesa-git-src;
buildInputs = prevAttrs.buildInputs ++ (with final; [ libunwind lm_sensors ]);
mesonFlags =
(builtins.map
builtins.map
(builtins.replaceStrings [ "virtio-experimental" ] [ "virtio" ])
prevAttrs.mesonFlags
) ++ [
"-Dandroid-libbacktrace=disabled"
];
prevAttrs.mesonFlags;
patches =
(nyxUtils.removeByBaseName
"disk_cache-include-dri-driver-path-in-cache-key.patch"
Expand Down Expand Up @@ -47,5 +53,11 @@ nyxUtils.multiOverride prev.mesa { inherit meson; } (prevAttrs: {
'' else prevAttrs.postInstall;
passthru = prevAttrs.passthru // {
inherit gbmBackend;
tests.smoke-test = import ./test.nix
{
inherit (flakes) nixpkgs;
chaotic = flakes.self;
}
mesaTestAttrs;
};
})
51 changes: 51 additions & 0 deletions pkgs/mesa-git/test.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{ nixpkgs
, chaotic
, testingDM ? "gdm" # "sddm"
, testingDE ? "gnome" # "plasma5"
, testingSession ? "gnome" # "plasma"
}:

import "${nixpkgs}/nixos/tests/make-test-python.nix" ({ pkgs, ... }: {
name = "mesa-git";
meta.maintainers = with pkgs.lib.maintainers; [ pedrohlc ];

nodes.machine = { pkgs, ... }: {
imports = [
chaotic.nixosModules.default
"${nixpkgs}/nixos/tests/common/user-account.nix"
];
chaotic.mesa-git.enable = true;

virtualisation.qemu.options = [
"-m 16G"
"-vga none"
"-device virtio-vga-gl"
"-display gtk,gl=on"
];

environment.systemPackages = with pkgs; [
vulkan-tools
mesa-demos
alacritty
];

services.xserver = {
enable = true;
displayManager = {
"${testingDM}".enable = true;
autoLogin = {
enable = true;
user = "alice";
};
defaultSession = testingSession;
};
desktopManager.${testingDE}.enable = true;
};
};

# TODO: TODO
testScript = _:
''
start_all()
'';
})