Merge pull request #220450 from arjan-s/qtile-options

qtile: add more options to NixOS module and expose unwrapped package

authored by Lily Foster and committed by GitHub 6f07da72 0ef1c25e

+117 -76
+43 -3
nixos/modules/services/x11/window-managers/qtile.nix
··· 1 - { config, lib, pkgs, ... }: 2 3 with lib; 4 5 let 6 cfg = config.services.xserver.windowManager.qtile; 7 in 8 9 { 10 options.services.xserver.windowManager.qtile = { 11 enable = mkEnableOption (lib.mdDoc "qtile"); 12 13 - package = mkPackageOptionMD pkgs "qtile" { }; 14 }; 15 16 config = mkIf cfg.enable { 17 services.xserver.windowManager.session = [{ 18 name = "qtile"; 19 start = '' 20 - ${cfg.package}/bin/qtile start & 21 waitPID=$! 22 ''; 23 }];
··· 1 + { config, pkgs, lib, ... }: 2 3 with lib; 4 5 let 6 cfg = config.services.xserver.windowManager.qtile; 7 + pyEnv = pkgs.python3.withPackages (p: [ (cfg.package.unwrapped or cfg.package) ] ++ (cfg.extraPackages p)); 8 in 9 10 { 11 options.services.xserver.windowManager.qtile = { 12 enable = mkEnableOption (lib.mdDoc "qtile"); 13 14 + package = mkPackageOptionMD pkgs "qtile-unwrapped" { }; 15 + 16 + configFile = mkOption { 17 + type = with types; nullOr path; 18 + default = null; 19 + example = literalExpression "./your_config.py"; 20 + description = lib.mdDoc '' 21 + Path to the qtile configuration file. 22 + If null, $XDG_CONFIG_HOME/qtile/config.py will be used. 23 + ''; 24 + }; 25 + 26 + backend = mkOption { 27 + type = types.enum [ "x11" "wayland" ]; 28 + default = "x11"; 29 + description = lib.mdDoc '' 30 + Backend to use in qtile: 31 + <option>x11</option> or <option>wayland</option>. 32 + ''; 33 + }; 34 + 35 + extraPackages = mkOption { 36 + type = types.functionTo (types.listOf types.package); 37 + default = _: []; 38 + defaultText = literalExpression '' 39 + python3Packages: with python3Packages; []; 40 + ''; 41 + description = lib.mdDoc '' 42 + Extra Python packages available to Qtile. 43 + An example would be to include `python3Packages.qtile-extras` 44 + for additional unoffical widgets. 45 + ''; 46 + example = literalExpression '' 47 + python3Packages: with python3Packages; [ 48 + qtile-extras 49 + ]; 50 + ''; 51 + }; 52 }; 53 54 config = mkIf cfg.enable { 55 services.xserver.windowManager.session = [{ 56 name = "qtile"; 57 start = '' 58 + ${pyEnv}/bin/qtile start -b ${cfg.backend} \ 59 + ${optionalString (cfg.configFile != null) 60 + "--config \"${cfg.configFile}\""} & 61 waitPID=$! 62 ''; 63 }];
+61 -70
pkgs/applications/window-managers/qtile/default.nix
··· 11 , wayland 12 , wlroots 13 , xcbutilcursor 14 }: 15 16 - let 17 - unwrapped = python3Packages.buildPythonPackage rec { 18 - pname = "qtile"; 19 - version = "0.22.1"; 20 21 - src = fetchFromGitHub { 22 - owner = "qtile"; 23 - repo = "qtile"; 24 - rev = "v${version}"; 25 - hash = "sha256-HOyExVKOqZ4OeNM1/AiXQeiUV+EbSJLEjWEibm07ff8="; 26 - }; 27 28 - patches = [ 29 - ./fix-restart.patch # https://github.com/NixOS/nixpkgs/issues/139568 30 - ]; 31 32 - postPatch = '' 33 - substituteInPlace libqtile/pangocffi.py \ 34 - --replace libgobject-2.0.so.0 ${glib.out}/lib/libgobject-2.0.so.0 \ 35 - --replace libpangocairo-1.0.so.0 ${pango.out}/lib/libpangocairo-1.0.so.0 \ 36 - --replace libpango-1.0.so.0 ${pango.out}/lib/libpango-1.0.so.0 37 - substituteInPlace libqtile/backend/x11/xcursors.py \ 38 - --replace libxcb-cursor.so.0 ${xcbutilcursor.out}/lib/libxcb-cursor.so.0 39 - ''; 40 41 - SETUPTOOLS_SCM_PRETEND_VERSION = version; 42 43 - nativeBuildInputs = [ 44 - pkg-config 45 - ] ++ (with python3Packages; [ 46 - setuptools-scm 47 - ]); 48 49 - propagatedBuildInputs = with python3Packages; [ 50 - xcffib 51 - (cairocffi.override { withXcffib = true; }) 52 - setuptools 53 - python-dateutil 54 - dbus-python 55 - dbus-next 56 - mpd2 57 - psutil 58 - pyxdg 59 - pygobject3 60 - pywayland 61 - pywlroots 62 - xkbcommon 63 - ]; 64 65 - buildInputs = [ 66 - libinput 67 - wayland 68 - wlroots 69 - libxkbcommon 70 - ]; 71 72 - # for `qtile check`, needs `stubtest` and `mypy` commands 73 - makeWrapperArgs = [ 74 - "--suffix PATH : ${lib.makeBinPath [ mypy ]}" 75 - ]; 76 77 - doCheck = false; # Requires X server #TODO this can be worked out with the existing NixOS testing infrastructure. 78 79 - meta = with lib; { 80 - homepage = "http://www.qtile.org/"; 81 - license = licenses.mit; 82 - description = "A small, flexible, scriptable tiling window manager written in Python"; 83 - platforms = platforms.linux; 84 - maintainers = with maintainers; [ kamilchm ]; 85 - }; 86 }; 87 - in 88 - (python3.withPackages (_: [ unwrapped ])).overrideAttrs (_: { 89 - # otherwise will be exported as "env", this restores `nix search` behavior 90 - name = "${unwrapped.pname}-${unwrapped.version}"; 91 - # export underlying qtile package 92 - passthru = { inherit unwrapped; }; 93 - 94 - # restore original qtile attrs 95 - inherit (unwrapped) pname version meta; 96 - })
··· 11 , wayland 12 , wlroots 13 , xcbutilcursor 14 + , pulseaudio 15 }: 16 17 + python3Packages.buildPythonPackage rec { 18 + pname = "qtile"; 19 + version = "0.22.1"; 20 21 + src = fetchFromGitHub { 22 + owner = "qtile"; 23 + repo = "qtile"; 24 + rev = "v${version}"; 25 + hash = "sha256-HOyExVKOqZ4OeNM1/AiXQeiUV+EbSJLEjWEibm07ff8="; 26 + }; 27 28 + patches = [ 29 + ./fix-restart.patch # https://github.com/NixOS/nixpkgs/issues/139568 30 + ]; 31 32 + postPatch = '' 33 + substituteInPlace libqtile/pangocffi.py \ 34 + --replace libgobject-2.0.so.0 ${glib.out}/lib/libgobject-2.0.so.0 \ 35 + --replace libpangocairo-1.0.so.0 ${pango.out}/lib/libpangocairo-1.0.so.0 \ 36 + --replace libpango-1.0.so.0 ${pango.out}/lib/libpango-1.0.so.0 37 + substituteInPlace libqtile/backend/x11/xcursors.py \ 38 + --replace libxcb-cursor.so.0 ${xcbutilcursor.out}/lib/libxcb-cursor.so.0 39 + ''; 40 41 + SETUPTOOLS_SCM_PRETEND_VERSION = version; 42 43 + nativeBuildInputs = [ 44 + pkg-config 45 + ] ++ (with python3Packages; [ 46 + setuptools-scm 47 + ]); 48 49 + propagatedBuildInputs = with python3Packages; [ 50 + xcffib 51 + (cairocffi.override { withXcffib = true; }) 52 + setuptools 53 + python-dateutil 54 + dbus-python 55 + dbus-next 56 + mpd2 57 + psutil 58 + pyxdg 59 + pygobject3 60 + pywayland 61 + pywlroots 62 + xkbcommon 63 + pulseaudio 64 + ]; 65 66 + buildInputs = [ 67 + libinput 68 + wayland 69 + wlroots 70 + libxkbcommon 71 + ]; 72 73 + # for `qtile check`, needs `stubtest` and `mypy` commands 74 + makeWrapperArgs = [ 75 + "--suffix PATH : ${lib.makeBinPath [ mypy ]}" 76 + ]; 77 78 + doCheck = false; # Requires X server #TODO this can be worked out with the existing NixOS testing infrastructure. 79 80 + meta = with lib; { 81 + homepage = "http://www.qtile.org/"; 82 + license = licenses.mit; 83 + description = "A small, flexible, scriptable tiling window manager written in Python"; 84 + platforms = platforms.linux; 85 + maintainers = with maintainers; [ kamilchm arjan-s ]; 86 }; 87 + }
+9
pkgs/applications/window-managers/qtile/wrapper.nix
···
··· 1 + { python3, qtile-unwrapped }: 2 + (python3.withPackages (_: [ qtile-unwrapped ])).overrideAttrs (_: { 3 + # otherwise will be exported as "env", this restores `nix search` behavior 4 + name = "${qtile-unwrapped.pname}-${qtile-unwrapped.version}"; 5 + # export underlying qtile package 6 + passthru = { unwrapped = qtile-unwrapped; }; 7 + # restore original qtile attrs 8 + inherit (qtile-unwrapped) pname version meta; 9 + })
+2 -2
pkgs/development/python-modules/qtile-extras/default.nix
··· 6 , xorgserver 7 , pulseaudio 8 , pytest-asyncio 9 - , qtile 10 , keyring 11 , requests 12 , stravalib ··· 34 ]; 35 checkInputs = [ 36 pytest-asyncio 37 - qtile.unwrapped 38 pulseaudio 39 keyring 40 requests
··· 6 , xorgserver 7 , pulseaudio 8 , pytest-asyncio 9 + , qtile-unwrapped 10 , keyring 11 , requests 12 , stravalib ··· 34 ]; 35 checkInputs = [ 36 pytest-asyncio 37 + qtile-unwrapped 38 pulseaudio 39 keyring 40 requests
+2 -1
pkgs/top-level/all-packages.nix
··· 34113 34114 qpdfview = libsForQt5.callPackage ../applications/office/qpdfview { }; 34115 34116 - qtile = callPackage ../applications/window-managers/qtile { }; 34117 34118 vimgolf = callPackage ../games/vimgolf { }; 34119
··· 34113 34114 qpdfview = libsForQt5.callPackage ../applications/office/qpdfview { }; 34115 34116 + qtile-unwrapped = callPackage ../applications/window-managers/qtile { }; 34117 + qtile = callPackage ../applications/window-managers/qtile/wrapper.nix { }; 34118 34119 vimgolf = callPackage ../games/vimgolf { }; 34120