nixos/tests/qtile: test extraPackages and qtile-extras

Changed files
+89 -35
nixos
+1 -1
nixos/tests/all-tests.nix
···
qgis = handleTest ./qgis.nix { qgisPackage = pkgs.qgis; };
qgis-ltr = handleTest ./qgis.nix { qgisPackage = pkgs.qgis-ltr; };
qownnotes = handleTest ./qownnotes.nix {};
-
qtile = handleTestOn ["x86_64-linux" "aarch64-linux"] ./qtile.nix {};
+
qtile = handleTestOn ["x86_64-linux" "aarch64-linux"] ./qtile/default.nix {};
quake3 = handleTest ./quake3.nix {};
quicktun = handleTest ./quicktun.nix {};
quickwit = handleTest ./quickwit.nix {};
-34
nixos/tests/qtile.nix
···
-
import ./make-test-python.nix ({ lib, ...} : {
-
name = "qtile";
-
-
meta = {
-
maintainers = with lib.maintainers; [ sigmanificient ];
-
};
-
-
nodes.machine = { pkgs, lib, ... }: {
-
imports = [ ./common/x11.nix ./common/user-account.nix ];
-
test-support.displayManager.auto.user = "alice";
-
-
services.xserver.windowManager.qtile.enable = true;
-
services.displayManager.defaultSession = lib.mkForce "qtile";
-
-
environment.systemPackages = [ pkgs.kitty ];
-
};
-
-
testScript = ''
-
with subtest("ensure x starts"):
-
machine.wait_for_x()
-
machine.wait_for_file("/home/alice/.Xauthority")
-
machine.succeed("xauth merge ~alice/.Xauthority")
-
-
with subtest("ensure client is available"):
-
machine.succeed("qtile --version")
-
-
with subtest("ensure we can open a new terminal"):
-
machine.sleep(2)
-
machine.send_key("meta_l-ret")
-
machine.wait_for_window(r"alice.*?machine")
-
machine.sleep(2)
-
machine.screenshot("terminal")
-
'';
-
})
+19
nixos/tests/qtile/add-widget.patch
···
+
--- a/config.py 2024-05-31 14:49:23.852287845 +0200
+
+++ b/config.py 2024-05-31 14:51:00.935182266 +0200
+
@@ -29,6 +29,8 @@
+
from libqtile.lazy import lazy
+
from libqtile.utils import guess_terminal
+
+
+from qtile_extras import widget
+
+
+
mod = "mod4"
+
terminal = guess_terminal()
+
+
@@ -162,6 +164,7 @@
+
# NB Systray is incompatible with Wayland, consider using StatusNotifier instead
+
# widget.StatusNotifier(),
+
widget.Systray(),
+
+ widget.AnalogueClock(),
+
widget.Clock(format="%Y-%m-%d %a %I:%M %p"),
+
widget.QuickExit(),
+
],
+24
nixos/tests/qtile/config.nix
···
+
{ stdenvNoCC, fetchurl }:
+
stdenvNoCC.mkDerivation {
+
name = "qtile-config";
+
version = "0.0.1";
+
+
src = fetchurl {
+
url = "https://raw.githubusercontent.com/qtile/qtile/v0.28.1/libqtile/resources/default_config.py";
+
hash = "sha256-Y5W277CWVNSi4BdgEW/f7Px/MMjnN9W9TDqdOncVwPc=";
+
};
+
+
prePatch = ''
+
cp $src config.py
+
'';
+
+
patches = [ ./add-widget.patch ];
+
+
dontUnpack = true;
+
dontBuild = true;
+
+
installPhase = ''
+
mkdir -p $out
+
cp config.py $out/config.py
+
'';
+
}
+45
nixos/tests/qtile/default.nix
···
+
import ../make-test-python.nix ({ lib, ...} : {
+
name = "qtile";
+
+
meta = {
+
maintainers = with lib.maintainers; [ sigmanificient ];
+
};
+
+
nodes.machine = { pkgs, lib, ... }: let
+
# We create a custom Qtile configuration file that adds a widget from
+
# qtile-extras to the bar. This ensure that the qtile-extras package
+
# also works, and that extraPackages behave as expected.
+
+
config-deriv = pkgs.callPackage ./config.nix { };
+
in {
+
imports = [ ../common/x11.nix ../common/user-account.nix ];
+
test-support.displayManager.auto.user = "alice";
+
+
services.xserver.windowManager.qtile = {
+
enable = true;
+
configFile = "${config-deriv}/config.py";
+
extraPackages = ps: [ ps.qtile-extras ];
+
};
+
+
services.displayManager.defaultSession = lib.mkForce "qtile";
+
+
environment.systemPackages = [ pkgs.kitty ];
+
};
+
+
testScript = ''
+
with subtest("ensure x starts"):
+
machine.wait_for_x()
+
machine.wait_for_file("/home/alice/.Xauthority")
+
machine.succeed("xauth merge ~alice/.Xauthority")
+
+
with subtest("ensure client is available"):
+
machine.succeed("qtile --version")
+
+
with subtest("ensure we can open a new terminal"):
+
machine.sleep(2)
+
machine.send_key("meta_l-ret")
+
machine.wait_for_window(r"alice.*?machine")
+
machine.sleep(2)
+
machine.screenshot("terminal")
+
'';
+
})