Skip to content

Commit 1addf91

Browse files
committed
qtile: add more options and expose unwrapped package
1 parent edc6238 commit 1addf91

5 files changed

Lines changed: 116 additions & 77 deletions

File tree

nixos/modules/services/x11/window-managers/qtile.nix

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,63 @@
1-
{ config, lib, pkgs, ... }:
1+
{ config, pkgs, lib, ... }:
22

33
with lib;
44

55
let
66
cfg = config.services.xserver.windowManager.qtile;
7+
pyEnv = pkgs.python3.withPackages (p: [ (cfg.package.unwrapped or cfg.package) ] ++ (cfg.extraPackages p));
78
in
89

910
{
1011
options.services.xserver.windowManager.qtile = {
1112
enable = mkEnableOption (lib.mdDoc "qtile");
1213

13-
package = mkPackageOptionMD pkgs "qtile" { };
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+
};
1452
};
1553

1654
config = mkIf cfg.enable {
1755
services.xserver.windowManager.session = [{
1856
name = "qtile";
1957
start = ''
20-
${cfg.package}/bin/qtile start &
58+
${pyEnv}/bin/qtile start -b ${cfg.backend} \
59+
${optionalString (cfg.configFile != null)
60+
"--config \"${cfg.configFile}\""} &
2161
waitPID=$!
2262
'';
2363
}];

pkgs/applications/window-managers/qtile/default.nix

Lines changed: 60 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -14,85 +14,74 @@
1414
, pulseaudio
1515
}:
1616

17-
let
18-
unwrapped = python3Packages.buildPythonPackage rec {
19-
pname = "qtile";
20-
version = "0.22.1";
17+
python3Packages.buildPythonPackage rec {
18+
pname = "qtile";
19+
version = "0.22.1";
2120

22-
src = fetchFromGitHub {
23-
owner = "qtile";
24-
repo = "qtile";
25-
rev = "v${version}";
26-
hash = "sha256-HOyExVKOqZ4OeNM1/AiXQeiUV+EbSJLEjWEibm07ff8=";
27-
};
21+
src = fetchFromGitHub {
22+
owner = "qtile";
23+
repo = "qtile";
24+
rev = "v${version}";
25+
hash = "sha256-HOyExVKOqZ4OeNM1/AiXQeiUV+EbSJLEjWEibm07ff8=";
26+
};
2827

29-
patches = [
30-
./fix-restart.patch # https://github.com/NixOS/nixpkgs/issues/139568
31-
];
28+
patches = [
29+
./fix-restart.patch # https://github.com/NixOS/nixpkgs/issues/139568
30+
];
3231

33-
postPatch = ''
34-
substituteInPlace libqtile/pangocffi.py \
35-
--replace libgobject-2.0.so.0 ${glib.out}/lib/libgobject-2.0.so.0 \
36-
--replace libpangocairo-1.0.so.0 ${pango.out}/lib/libpangocairo-1.0.so.0 \
37-
--replace libpango-1.0.so.0 ${pango.out}/lib/libpango-1.0.so.0
38-
substituteInPlace libqtile/backend/x11/xcursors.py \
39-
--replace libxcb-cursor.so.0 ${xcbutilcursor.out}/lib/libxcb-cursor.so.0
40-
'';
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+
'';
4140

42-
SETUPTOOLS_SCM_PRETEND_VERSION = version;
41+
SETUPTOOLS_SCM_PRETEND_VERSION = version;
4342

44-
nativeBuildInputs = [
45-
pkg-config
46-
] ++ (with python3Packages; [
47-
setuptools-scm
48-
]);
43+
nativeBuildInputs = [
44+
pkg-config
45+
] ++ (with python3Packages; [
46+
setuptools-scm
47+
]);
4948

50-
propagatedBuildInputs = with python3Packages; [
51-
xcffib
52-
(cairocffi.override { withXcffib = true; })
53-
setuptools
54-
python-dateutil
55-
dbus-python
56-
dbus-next
57-
mpd2
58-
psutil
59-
pyxdg
60-
pygobject3
61-
pywayland
62-
pywlroots
63-
xkbcommon
64-
pulseaudio
65-
];
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+
];
6665

67-
buildInputs = [
68-
libinput
69-
wayland
70-
wlroots
71-
libxkbcommon
72-
];
66+
buildInputs = [
67+
libinput
68+
wayland
69+
wlroots
70+
libxkbcommon
71+
];
7372

74-
# for `qtile check`, needs `stubtest` and `mypy` commands
75-
makeWrapperArgs = [
76-
"--suffix PATH : ${lib.makeBinPath [ mypy ]}"
77-
];
73+
# for `qtile check`, needs `stubtest` and `mypy` commands
74+
makeWrapperArgs = [
75+
"--suffix PATH : ${lib.makeBinPath [ mypy ]}"
76+
];
7877

79-
doCheck = false; # Requires X server #TODO this can be worked out with the existing NixOS testing infrastructure.
78+
doCheck = false; # Requires X server #TODO this can be worked out with the existing NixOS testing infrastructure.
8079

81-
meta = with lib; {
82-
homepage = "http://www.qtile.org/";
83-
license = licenses.mit;
84-
description = "A small, flexible, scriptable tiling window manager written in Python";
85-
platforms = platforms.linux;
86-
maintainers = with maintainers; [ kamilchm arjan-s ];
87-
};
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 ];
8886
};
89-
in
90-
(python3.withPackages (_: [ unwrapped ])).overrideAttrs (_: {
91-
# otherwise will be exported as "env", this restores `nix search` behavior
92-
name = "${unwrapped.pname}-${unwrapped.version}";
93-
# export underlying qtile package
94-
passthru = { inherit unwrapped; };
95-
96-
# restore original qtile attrs
97-
inherit (unwrapped) pname version meta;
98-
})
87+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
})

pkgs/development/python-modules/qtile-extras/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
, xorgserver
77
, pulseaudio
88
, pytest-asyncio
9-
, qtile
9+
, qtile-unwrapped
1010
, keyring
1111
, requests
1212
, stravalib
@@ -34,7 +34,7 @@ buildPythonPackage rec {
3434
];
3535
checkInputs = [
3636
pytest-asyncio
37-
qtile.unwrapped
37+
qtile-unwrapped
3838
pulseaudio
3939
keyring
4040
requests

pkgs/top-level/all-packages.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34077,7 +34077,8 @@ with pkgs;
3407734077

3407834078
qpdfview = libsForQt5.callPackage ../applications/office/qpdfview { };
3407934079

34080-
qtile = callPackage ../applications/window-managers/qtile { };
34080+
qtile-unwrapped = callPackage ../applications/window-managers/qtile { };
34081+
qtile = callPackage ../applications/window-managers/qtile/wrapper.nix { };
3408134082

3408234083
vimgolf = callPackage ../games/vimgolf { };
3408334084

0 commit comments

Comments
 (0)