From 43a2382df7704e356dfba2aa7725c4135273e507 Mon Sep 17 00:00:00 2001 From: Thibaut Marty Date: Fri, 20 Nov 2020 16:39:01 +0000 Subject: [PATCH 1/4] maintainers: add thibautmarty --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index d376cbecf575..d31a9e6a1594 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -9061,6 +9061,12 @@ githubId = 844343; name = "Thiago K. Okada"; }; + thibautmarty = { + email = "github@thibautmarty.fr"; + github = "ThibautMarty"; + githubId = 3268082; + name = "Thibaut Marty"; + }; thmzlt = { email = "git@thomazleite.com"; github = "thmzlt"; From 5ce3719c437bbbe389debf9aec6f10938b8a9cad Mon Sep 17 00:00:00 2001 From: Thibaut Marty Date: Fri, 20 Nov 2020 16:39:33 +0000 Subject: [PATCH 2/4] herbstluftwm: add maintainership --- pkgs/applications/window-managers/herbstluftwm/default.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/window-managers/herbstluftwm/default.nix b/pkgs/applications/window-managers/herbstluftwm/default.nix index c4bdcb4ca753..2c8d56c77124 100644 --- a/pkgs/applications/window-managers/herbstluftwm/default.nix +++ b/pkgs/applications/window-managers/herbstluftwm/default.nix @@ -38,10 +38,11 @@ stdenv.mkDerivation rec { libXrandr ]; - meta = { + meta = with lib; { description = "A manual tiling window manager for X"; homepage = "https://herbstluftwm.org/"; - license = lib.licenses.bsd2; - platforms = lib.platforms.linux; + license = licenses.bsd2; + platforms = platforms.linux; + maintainers = with maintainers; [ thibautmarty ]; }; } From b1eb0af283167cdd0092f247d9d2db9c518789b8 Mon Sep 17 00:00:00 2001 From: Thibaut Marty Date: Fri, 20 Nov 2020 16:40:08 +0000 Subject: [PATCH 3/4] =?UTF-8?q?herbstluftwm:=200.8.3=20=E2=86=92=200.9.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also enables the packages' tests. The tests need a few patches to fix runtime generated script's shebangs. There is also a fix to pass PATH environment variable to subprocess' calls so that they can find some binaries (like xterm). --- .../window-managers/herbstluftwm/default.nix | 59 +++++++++++++++---- .../herbstluftwm/test-path-environment.patch | 10 ++++ 2 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 pkgs/applications/window-managers/herbstluftwm/test-path-environment.patch diff --git a/pkgs/applications/window-managers/herbstluftwm/default.nix b/pkgs/applications/window-managers/herbstluftwm/default.nix index 2c8d56c77124..116a17bc0ee9 100644 --- a/pkgs/applications/window-managers/herbstluftwm/default.nix +++ b/pkgs/applications/window-managers/herbstluftwm/default.nix @@ -1,35 +1,37 @@ -{ lib, stdenv, fetchurl, cmake, pkgconfig, glib, libX11, libXext, libXinerama, libXrandr -, withDoc ? stdenv.buildPlatform == stdenv.targetPlatform, asciidoc ? null }: +{ lib, stdenv, fetchurl, cmake, pkgconfig, python3, libX11, libXext, libXinerama, libXrandr, asciidoc +, xdotool, xorgserver, xsetroot, xterm, runtimeShell }: # Doc generation is disabled by default when cross compiling because asciidoc -# does not cross compile for now +# dependency is broken when cross compiling for now -assert withDoc -> asciidoc != null; +let + cross = stdenv.buildPlatform != stdenv.targetPlatform; -stdenv.mkDerivation rec { +in stdenv.mkDerivation rec { pname = "herbstluftwm"; - version = "0.8.3"; + version = "0.9.1"; src = fetchurl { url = "https://herbstluftwm.org/tarballs/herbstluftwm-${version}.tar.gz"; - sha256 = "1qmb4pjf2f6g0dvcg11cw9njwmxblhqzd70ai8qnlgqw1iz3nkm1"; + sha256 = "0r4qaklv97qcq8p0pnz4f2zqg69vfai6c2qi1ydi2kz24xqjf5hy"; }; outputs = [ "out" - ] ++ lib.optionals withDoc [ - "doc" + "doc" # share/doc exists with examples even without generated html documentation + ] ++ lib.optionals (!cross) [ "man" ]; cmakeFlags = [ "-DCMAKE_INSTALL_SYSCONF_PREFIX=${placeholder "out"}/etc" - ] ++ lib.optional (!withDoc) "-DWITH_DOCUMENTATION=OFF"; + ] ++ lib.optional cross "-DWITH_DOCUMENTATION=OFF"; nativeBuildInputs = [ cmake pkgconfig - ] ++ lib.optional withDoc asciidoc; + python3 + ] ++ lib.optional (!cross) asciidoc; buildInputs = [ libX11 @@ -38,6 +40,41 @@ stdenv.mkDerivation rec { libXrandr ]; + patches = [ + ./test-path-environment.patch + ]; + + postPatch = '' + patchShebangs doc/gendoc.py + + # fix /etc/xdg/herbstluftwm paths in documentation and scripts + grep -rlZ /etc/xdg/herbstluftwm share/ doc/ scripts/ | while IFS="" read -r -d "" path; do + substituteInPlace "$path" --replace /etc/xdg/herbstluftwm $out/etc/xdg/herbstluftwm + done + + # fix shebang in generated scripts + substituteInPlace tests/conftest.py --replace "/usr/bin/env bash" ${runtimeShell} + substituteInPlace tests/test_herbstluftwm.py --replace "/usr/bin/env bash" ${runtimeShell} + ''; + + doCheck = true; + + checkInputs = [ + (python3.withPackages (ps: with ps; [ ewmh pytest xlib ])) + xdotool + xorgserver + xsetroot + xterm + python3.pkgs.pytestCheckHook + ]; + + # make the package's module avalaible + preCheck = '' + export PYTHONPATH="$PYTHONPATH:../python" + ''; + + pytestFlagsArray = [ "../tests" ]; + meta = with lib; { description = "A manual tiling window manager for X"; homepage = "https://herbstluftwm.org/"; diff --git a/pkgs/applications/window-managers/herbstluftwm/test-path-environment.patch b/pkgs/applications/window-managers/herbstluftwm/test-path-environment.patch new file mode 100644 index 000000000000..dab30d8ac71a --- /dev/null +++ b/pkgs/applications/window-managers/herbstluftwm/test-path-environment.patch @@ -0,0 +1,10 @@ +--- a/tests/conftest.py ++++ b/tests/conftest.py +@@ -43,6 +43,7 @@ + self.next_client_id = 0 + self.env = { + 'DISPLAY': display, ++ 'PATH': os.environ['PATH'] + } + self.env = extend_env_with_whitelist(self.env) + self.hlwm_process = hlwm_process From a6cdb113bd5fa4d136593909456e310c3f457597 Mon Sep 17 00:00:00 2001 From: Thibaut Marty Date: Fri, 27 Nov 2020 19:20:36 +0000 Subject: [PATCH 4/4] herbstluftwm: add NixOS test --- nixos/tests/all-tests.nix | 1 + nixos/tests/herbstluftwm.nix | 38 +++++++++++++++++++ .../window-managers/herbstluftwm/default.nix | 7 +++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 nixos/tests/herbstluftwm.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 7d83b952f948..902c3bbc65e9 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -147,6 +147,7 @@ in haproxy = handleTest ./haproxy.nix {}; hardened = handleTest ./hardened.nix {}; hedgedoc = handleTest ./hedgedoc.nix {}; + herbstluftwm = handleTest ./herbstluftwm.nix {}; installed-tests = pkgs.recurseIntoAttrs (handleTest ./installed-tests {}); oci-containers = handleTestOn ["x86_64-linux"] ./oci-containers.nix {}; # 9pnet_virtio used to mount /nix partition doesn't support diff --git a/nixos/tests/herbstluftwm.nix b/nixos/tests/herbstluftwm.nix new file mode 100644 index 000000000000..2c98cceee6a2 --- /dev/null +++ b/nixos/tests/herbstluftwm.nix @@ -0,0 +1,38 @@ +import ./make-test-python.nix ({ lib, ...} : { + name = "herbstluftwm"; + + meta = { + maintainers = with lib.maintainers; [ thibautmarty ]; + timeout = 30; + }; + + machine = { pkgs, lib, ... }: { + imports = [ ./common/x11.nix ./common/user-account.nix ]; + test-support.displayManager.auto.user = "alice"; + services.xserver.displayManager.defaultSession = lib.mkForce "none+herbstluftwm"; + services.xserver.windowManager.herbstluftwm.enable = true; + environment.systemPackages = [ pkgs.dzen2 ]; # needed for upstream provided panel + }; + + 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("herbstclient --version") + + with subtest("ensure keybindings are set"): + machine.wait_until_succeeds("herbstclient list_keybinds | grep xterm") + + with subtest("ensure panel starts"): + machine.wait_for_window("dzen title") + + with subtest("ensure we can open a new terminal"): + machine.send_key("alt-ret") + machine.wait_for_window(r"alice.*?machine") + machine.sleep(2) + machine.screenshot("terminal") + ''; +}) diff --git a/pkgs/applications/window-managers/herbstluftwm/default.nix b/pkgs/applications/window-managers/herbstluftwm/default.nix index 116a17bc0ee9..1ec1e2e995cc 100644 --- a/pkgs/applications/window-managers/herbstluftwm/default.nix +++ b/pkgs/applications/window-managers/herbstluftwm/default.nix @@ -1,5 +1,6 @@ { lib, stdenv, fetchurl, cmake, pkgconfig, python3, libX11, libXext, libXinerama, libXrandr, asciidoc -, xdotool, xorgserver, xsetroot, xterm, runtimeShell }: +, xdotool, xorgserver, xsetroot, xterm, runtimeShell +, nixosTests }: # Doc generation is disabled by default when cross compiling because asciidoc # dependency is broken when cross compiling for now @@ -75,6 +76,10 @@ in stdenv.mkDerivation rec { pytestFlagsArray = [ "../tests" ]; + passthru = { + tests.herbstluftwm = nixosTests.herbstluftwm; + }; + meta = with lib; { description = "A manual tiling window manager for X"; homepage = "https://herbstluftwm.org/";