Nix: build hyprtester along with hyprland

This commit is contained in:
Mihai Fufezan 2025-10-14 21:45:11 +03:00
parent 7f06b7210e
commit 7d22a2df76
Signed by: fufexan
SSH key fingerprint: SHA256:SdnKmEpJrDu1+2UO1QpB/Eg4HKcdDi6n+xSRqFNJVpg
5 changed files with 19 additions and 80 deletions

View file

@ -147,8 +147,8 @@
(pkgsFor.${system}) (pkgsFor.${system})
# hyprland-packages # hyprland-packages
hyprland hyprland
hyprland-with-hyprtester
hyprland-unwrapped hyprland-unwrapped
hyprtester
# hyprland-extras # hyprland-extras
xdg-desktop-portal-hyprland xdg-desktop-portal-hyprland
; ;

View file

@ -45,6 +45,7 @@
commit, commit,
revCount, revCount,
date, date,
withHyprtester ? false,
# deprecated flags # deprecated flags
enableNvidiaPatches ? false, enableNvidiaPatches ? false,
nvidiaPatches ? false, nvidiaPatches ? false,
@ -79,7 +80,7 @@ in
fs.intersection fs.intersection
# allows non-flake builds to only include files tracked by git # allows non-flake builds to only include files tracked by git
(fs.gitTracked ../.) (fs.gitTracked ../.)
(fs.unions [ (fs.unions (flatten [
../assets/hyprland-portals.conf ../assets/hyprland-portals.conf
../assets/install ../assets/install
../hyprctl ../hyprctl
@ -93,7 +94,8 @@ in
(fs.fileFilter (file: file.hasExt "conf" || file.hasExt "desktop") ../example) (fs.fileFilter (file: file.hasExt "conf" || file.hasExt "desktop") ../example)
(fs.fileFilter (file: file.hasExt "sh") ../scripts) (fs.fileFilter (file: file.hasExt "sh") ../scripts)
(fs.fileFilter (file: file.name == "CMakeLists.txt") ../.) (fs.fileFilter (file: file.name == "CMakeLists.txt") ../.)
]); (optional withHyprtester ../hyprtester)
]));
}; };
postPatch = '' postPatch = ''
@ -185,8 +187,15 @@ in
"NO_UWSM" = true; "NO_UWSM" = true;
"NO_HYPRPM" = true; "NO_HYPRPM" = true;
"TRACY_ENABLE" = false; "TRACY_ENABLE" = false;
"BUILD_HYPRTESTER" = withHyprtester;
}; };
preConfigure = ''
substituteInPlace hyprtester/CMakeLists.txt --replace-fail \
"\''${CMAKE_CURRENT_BINARY_DIR}" \
"${placeholder "out"}/bin"
'';
postInstall = '' postInstall = ''
${optionalString wrapRuntimeDeps '' ${optionalString wrapRuntimeDeps ''
wrapProgram $out/bin/Hyprland \ wrapProgram $out/bin/Hyprland \
@ -197,6 +206,9 @@ in
pkgconf pkgconf
]} ]}
''} ''}
'' + optionalString withHyprtester ''
install hyprtester/pointer-warp -t $out/bin
install hyprtester/pointer-scroll -t $out/bin
''; '';
passthru.providedSessions = ["hyprland"]; passthru.providedSessions = ["hyprland"];

View file

@ -1,69 +0,0 @@
{
lib,
stdenv,
stdenvAdapters,
cmake,
pkg-config,
hyprland,
hyprwayland-scanner,
version ? "git",
}: let
inherit (lib.lists) flatten foldl';
inherit (lib.sources) cleanSourceWith cleanSource;
inherit (lib.strings) hasSuffix cmakeBool;
adapters = flatten [
stdenvAdapters.useMoldLinker
stdenvAdapters.keepDebugInfo
];
customStdenv = foldl' (acc: adapter: adapter acc) stdenv adapters;
in
customStdenv.mkDerivation (finalAttrs: {
pname = "hyprtester";
inherit version;
src = cleanSourceWith {
filter = name: _type: let
baseName = baseNameOf (toString name);
in
! (hasSuffix ".nix" baseName);
src = cleanSource ../.;
};
nativeBuildInputs = [
cmake
pkg-config
hyprwayland-scanner
];
buildInputs = hyprland.buildInputs;
preConfigure = ''
substituteInPlace hyprtester/CMakeLists.txt --replace-fail \
"\''${CMAKE_CURRENT_BINARY_DIR}" \
"${placeholder "out"}/bin"
cmake -S . -B .
cmake --build . --target generate-protocol-headers -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
cd hyprtester
'';
postInstall = ''
install pointer-warp -t $out/bin
install pointer-scroll -t $out/bin
'';
cmakeBuildType = "Debug";
cmakeFlags = [(cmakeBool "TESTS" true)];
meta = {
homepage = "https://github.com/hyprwm/Hyprland";
description = "Hyprland testing framework";
license = lib.licenses.bsd3;
platforms = hyprland.meta.platforms;
mainProgram = "hyprtester";
};
})

View file

@ -43,9 +43,7 @@ in {
}; };
hyprland-unwrapped = final.hyprland.override {wrapRuntimeDeps = false;}; hyprland-unwrapped = final.hyprland.override {wrapRuntimeDeps = false;};
hyprtester = final.callPackage ./hyprtester.nix { hyprland-with-hyprtester = final.hyprland.override {withHyprtester = true;};
inherit version;
};
# deprecated packages # deprecated packages
hyprland-legacy-renderer = hyprland-legacy-renderer =

View file

@ -1,14 +1,12 @@
inputs: pkgs: let inputs: pkgs: let
flake = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}; flake = inputs.self.packages.${pkgs.stdenv.hostPlatform.system};
hyprland = flake.hyprland; hyprland = flake.hyprland-with-hyprtester;
in { in {
tests = pkgs.testers.runNixOSTest { tests = pkgs.testers.runNixOSTest {
name = "hyprland-tests"; name = "hyprland-tests";
nodes.machine = {pkgs, ...}: { nodes.machine = {pkgs, ...}: {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
flake.hyprtester
# Programs needed for tests # Programs needed for tests
jq jq
kitty kitty
@ -38,7 +36,7 @@ in {
}; };
# Test configuration # Test configuration
environment.etc."test.conf".source = "${flake.hyprtester}/share/hypr/test.conf"; environment.etc."test.conf".source = "${hyprland}/share/hypr/test.conf";
# Disable portals # Disable portals
xdg.portal.enable = pkgs.lib.mkForce false; xdg.portal.enable = pkgs.lib.mkForce false;
@ -72,7 +70,7 @@ in {
# Run hyprtester testing framework/suite # Run hyprtester testing framework/suite
print("Running hyprtester") print("Running hyprtester")
exit_status, _out = machine.execute("su - alice -c 'hyprtester -b ${hyprland}/bin/Hyprland -c /etc/test.conf -p ${flake.hyprtester}/lib/hyprtestplugin.so 2>&1 | tee /tmp/testerlog; exit ''${PIPESTATUS[0]}'") exit_status, _out = machine.execute("su - alice -c 'hyprtester -b ${hyprland}/bin/Hyprland -c /etc/test.conf -p ${hyprland}/lib/hyprtestplugin.so 2>&1 | tee /tmp/testerlog; exit ''${PIPESTATUS[0]}'")
print(f"Hyprtester exited with {exit_status}") print(f"Hyprtester exited with {exit_status}")
# Copy logs to host # Copy logs to host