From fae831109185e5a2d0d78f1c7c62b36185b0657e Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Wed, 8 Mar 2023 22:06:51 +0100 Subject: [PATCH 1/3] qtile: fix pulsevolume widget --- pkgs/applications/window-managers/qtile/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/applications/window-managers/qtile/default.nix b/pkgs/applications/window-managers/qtile/default.nix index 1279397cccc2..71c7a63671c6 100644 --- a/pkgs/applications/window-managers/qtile/default.nix +++ b/pkgs/applications/window-managers/qtile/default.nix @@ -11,6 +11,7 @@ , wayland , wlroots , xcbutilcursor +, pulseaudio }: let @@ -60,6 +61,7 @@ let pywayland pywlroots xkbcommon + pulseaudio ]; buildInputs = [ From edc62383e460f56f1050d65d20d578b8dca631b2 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Mon, 13 Mar 2023 16:19:06 +0100 Subject: [PATCH 2/3] qtile: add myself as maintainer --- pkgs/applications/window-managers/qtile/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/window-managers/qtile/default.nix b/pkgs/applications/window-managers/qtile/default.nix index 71c7a63671c6..bfe88ed694c3 100644 --- a/pkgs/applications/window-managers/qtile/default.nix +++ b/pkgs/applications/window-managers/qtile/default.nix @@ -83,7 +83,7 @@ let license = licenses.mit; description = "A small, flexible, scriptable tiling window manager written in Python"; platforms = platforms.linux; - maintainers = with maintainers; [ kamilchm ]; + maintainers = with maintainers; [ kamilchm arjan-s ]; }; }; in From 1addf91b0b24b8c8556bf5c484a7382f6fd4a6e8 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Mon, 13 Mar 2023 16:22:18 +0100 Subject: [PATCH 3/3] qtile: add more options and expose unwrapped package --- .../services/x11/window-managers/qtile.nix | 46 +++++- .../window-managers/qtile/default.nix | 147 ++++++++---------- .../window-managers/qtile/wrapper.nix | 9 ++ .../python-modules/qtile-extras/default.nix | 4 +- pkgs/top-level/all-packages.nix | 3 +- 5 files changed, 124 insertions(+), 85 deletions(-) create mode 100644 pkgs/applications/window-managers/qtile/wrapper.nix diff --git a/nixos/modules/services/x11/window-managers/qtile.nix b/nixos/modules/services/x11/window-managers/qtile.nix index fc27566d49ee..cc24522970f3 100644 --- a/nixos/modules/services/x11/window-managers/qtile.nix +++ b/nixos/modules/services/x11/window-managers/qtile.nix @@ -1,23 +1,63 @@ -{ config, lib, pkgs, ... }: +{ config, pkgs, lib, ... }: with lib; let cfg = config.services.xserver.windowManager.qtile; + pyEnv = pkgs.python3.withPackages (p: [ (cfg.package.unwrapped or cfg.package) ] ++ (cfg.extraPackages p)); in { options.services.xserver.windowManager.qtile = { enable = mkEnableOption (lib.mdDoc "qtile"); - package = mkPackageOptionMD pkgs "qtile" { }; + package = mkPackageOptionMD pkgs "qtile-unwrapped" { }; + + configFile = mkOption { + type = with types; nullOr path; + default = null; + example = literalExpression "./your_config.py"; + description = lib.mdDoc '' + Path to the qtile configuration file. + If null, $XDG_CONFIG_HOME/qtile/config.py will be used. + ''; + }; + + backend = mkOption { + type = types.enum [ "x11" "wayland" ]; + default = "x11"; + description = lib.mdDoc '' + Backend to use in qtile: + or . + ''; + }; + + extraPackages = mkOption { + type = types.functionTo (types.listOf types.package); + default = _: []; + defaultText = literalExpression '' + python3Packages: with python3Packages; []; + ''; + description = lib.mdDoc '' + Extra Python packages available to Qtile. + An example would be to include `python3Packages.qtile-extras` + for additional unoffical widgets. + ''; + example = literalExpression '' + python3Packages: with python3Packages; [ + qtile-extras + ]; + ''; + }; }; config = mkIf cfg.enable { services.xserver.windowManager.session = [{ name = "qtile"; start = '' - ${cfg.package}/bin/qtile start & + ${pyEnv}/bin/qtile start -b ${cfg.backend} \ + ${optionalString (cfg.configFile != null) + "--config \"${cfg.configFile}\""} & waitPID=$! ''; }]; diff --git a/pkgs/applications/window-managers/qtile/default.nix b/pkgs/applications/window-managers/qtile/default.nix index bfe88ed694c3..173dc919c74e 100644 --- a/pkgs/applications/window-managers/qtile/default.nix +++ b/pkgs/applications/window-managers/qtile/default.nix @@ -14,85 +14,74 @@ , pulseaudio }: -let - unwrapped = python3Packages.buildPythonPackage rec { - pname = "qtile"; - version = "0.22.1"; +python3Packages.buildPythonPackage rec { + pname = "qtile"; + version = "0.22.1"; - src = fetchFromGitHub { - owner = "qtile"; - repo = "qtile"; - rev = "v${version}"; - hash = "sha256-HOyExVKOqZ4OeNM1/AiXQeiUV+EbSJLEjWEibm07ff8="; - }; - - patches = [ - ./fix-restart.patch # https://github.com/NixOS/nixpkgs/issues/139568 - ]; - - postPatch = '' - substituteInPlace libqtile/pangocffi.py \ - --replace libgobject-2.0.so.0 ${glib.out}/lib/libgobject-2.0.so.0 \ - --replace libpangocairo-1.0.so.0 ${pango.out}/lib/libpangocairo-1.0.so.0 \ - --replace libpango-1.0.so.0 ${pango.out}/lib/libpango-1.0.so.0 - substituteInPlace libqtile/backend/x11/xcursors.py \ - --replace libxcb-cursor.so.0 ${xcbutilcursor.out}/lib/libxcb-cursor.so.0 - ''; - - SETUPTOOLS_SCM_PRETEND_VERSION = version; - - nativeBuildInputs = [ - pkg-config - ] ++ (with python3Packages; [ - setuptools-scm - ]); - - propagatedBuildInputs = with python3Packages; [ - xcffib - (cairocffi.override { withXcffib = true; }) - setuptools - python-dateutil - dbus-python - dbus-next - mpd2 - psutil - pyxdg - pygobject3 - pywayland - pywlroots - xkbcommon - pulseaudio - ]; - - buildInputs = [ - libinput - wayland - wlroots - libxkbcommon - ]; - - # for `qtile check`, needs `stubtest` and `mypy` commands - makeWrapperArgs = [ - "--suffix PATH : ${lib.makeBinPath [ mypy ]}" - ]; - - doCheck = false; # Requires X server #TODO this can be worked out with the existing NixOS testing infrastructure. - - meta = with lib; { - homepage = "http://www.qtile.org/"; - license = licenses.mit; - description = "A small, flexible, scriptable tiling window manager written in Python"; - platforms = platforms.linux; - maintainers = with maintainers; [ kamilchm arjan-s ]; - }; + src = fetchFromGitHub { + owner = "qtile"; + repo = "qtile"; + rev = "v${version}"; + hash = "sha256-HOyExVKOqZ4OeNM1/AiXQeiUV+EbSJLEjWEibm07ff8="; }; -in -(python3.withPackages (_: [ unwrapped ])).overrideAttrs (_: { - # otherwise will be exported as "env", this restores `nix search` behavior - name = "${unwrapped.pname}-${unwrapped.version}"; - # export underlying qtile package - passthru = { inherit unwrapped; }; - # restore original qtile attrs - inherit (unwrapped) pname version meta; -}) + patches = [ + ./fix-restart.patch # https://github.com/NixOS/nixpkgs/issues/139568 + ]; + + postPatch = '' + substituteInPlace libqtile/pangocffi.py \ + --replace libgobject-2.0.so.0 ${glib.out}/lib/libgobject-2.0.so.0 \ + --replace libpangocairo-1.0.so.0 ${pango.out}/lib/libpangocairo-1.0.so.0 \ + --replace libpango-1.0.so.0 ${pango.out}/lib/libpango-1.0.so.0 + substituteInPlace libqtile/backend/x11/xcursors.py \ + --replace libxcb-cursor.so.0 ${xcbutilcursor.out}/lib/libxcb-cursor.so.0 + ''; + + SETUPTOOLS_SCM_PRETEND_VERSION = version; + + nativeBuildInputs = [ + pkg-config + ] ++ (with python3Packages; [ + setuptools-scm + ]); + + propagatedBuildInputs = with python3Packages; [ + xcffib + (cairocffi.override { withXcffib = true; }) + setuptools + python-dateutil + dbus-python + dbus-next + mpd2 + psutil + pyxdg + pygobject3 + pywayland + pywlroots + xkbcommon + pulseaudio + ]; + + buildInputs = [ + libinput + wayland + wlroots + libxkbcommon + ]; + + # for `qtile check`, needs `stubtest` and `mypy` commands + makeWrapperArgs = [ + "--suffix PATH : ${lib.makeBinPath [ mypy ]}" + ]; + + doCheck = false; # Requires X server #TODO this can be worked out with the existing NixOS testing infrastructure. + + meta = with lib; { + homepage = "http://www.qtile.org/"; + license = licenses.mit; + description = "A small, flexible, scriptable tiling window manager written in Python"; + platforms = platforms.linux; + maintainers = with maintainers; [ kamilchm arjan-s ]; + }; +} diff --git a/pkgs/applications/window-managers/qtile/wrapper.nix b/pkgs/applications/window-managers/qtile/wrapper.nix new file mode 100644 index 000000000000..8cb5596a8446 --- /dev/null +++ b/pkgs/applications/window-managers/qtile/wrapper.nix @@ -0,0 +1,9 @@ +{ python3, qtile-unwrapped }: +(python3.withPackages (_: [ qtile-unwrapped ])).overrideAttrs (_: { + # otherwise will be exported as "env", this restores `nix search` behavior + name = "${qtile-unwrapped.pname}-${qtile-unwrapped.version}"; + # export underlying qtile package + passthru = { unwrapped = qtile-unwrapped; }; + # restore original qtile attrs + inherit (qtile-unwrapped) pname version meta; +}) diff --git a/pkgs/development/python-modules/qtile-extras/default.nix b/pkgs/development/python-modules/qtile-extras/default.nix index 76962bb49671..3ba8f9487d58 100644 --- a/pkgs/development/python-modules/qtile-extras/default.nix +++ b/pkgs/development/python-modules/qtile-extras/default.nix @@ -6,7 +6,7 @@ , xorgserver , pulseaudio , pytest-asyncio -, qtile +, qtile-unwrapped , keyring , requests , stravalib @@ -34,7 +34,7 @@ buildPythonPackage rec { ]; checkInputs = [ pytest-asyncio - qtile.unwrapped + qtile-unwrapped pulseaudio keyring requests diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c33c8bba2220..38369eeacfe6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -34077,7 +34077,8 @@ with pkgs; qpdfview = libsForQt5.callPackage ../applications/office/qpdfview { }; - qtile = callPackage ../applications/window-managers/qtile { }; + qtile-unwrapped = callPackage ../applications/window-managers/qtile { }; + qtile = callPackage ../applications/window-managers/qtile/wrapper.nix { }; vimgolf = callPackage ../games/vimgolf { };