3
0
Fork 0
forked from mirrors/nixpkgs

qtile: add more options and expose unwrapped package

This commit is contained in:
Arjan Schrijver 2023-03-13 16:22:18 +01:00
parent edc62383e4
commit 1addf91b0b
5 changed files with 124 additions and 85 deletions

View file

@ -1,23 +1,63 @@
{ config, lib, pkgs, ... }: { config, pkgs, lib, ... }:
with lib; with lib;
let let
cfg = config.services.xserver.windowManager.qtile; cfg = config.services.xserver.windowManager.qtile;
pyEnv = pkgs.python3.withPackages (p: [ (cfg.package.unwrapped or cfg.package) ] ++ (cfg.extraPackages p));
in in
{ {
options.services.xserver.windowManager.qtile = { options.services.xserver.windowManager.qtile = {
enable = mkEnableOption (lib.mdDoc "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:
<option>x11</option> or <option>wayland</option>.
'';
};
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 { config = mkIf cfg.enable {
services.xserver.windowManager.session = [{ services.xserver.windowManager.session = [{
name = "qtile"; name = "qtile";
start = '' start = ''
${cfg.package}/bin/qtile start & ${pyEnv}/bin/qtile start -b ${cfg.backend} \
${optionalString (cfg.configFile != null)
"--config \"${cfg.configFile}\""} &
waitPID=$! waitPID=$!
''; '';
}]; }];

View file

@ -14,85 +14,74 @@
, pulseaudio , pulseaudio
}: }:
let python3Packages.buildPythonPackage rec {
unwrapped = python3Packages.buildPythonPackage rec { pname = "qtile";
pname = "qtile"; version = "0.22.1";
version = "0.22.1";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "qtile"; owner = "qtile";
repo = "qtile"; repo = "qtile";
rev = "v${version}"; rev = "v${version}";
hash = "sha256-HOyExVKOqZ4OeNM1/AiXQeiUV+EbSJLEjWEibm07ff8="; 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 ];
};
}; };
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 patches = [
inherit (unwrapped) pname version meta; ./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 ];
};
}

View file

@ -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;
})

View file

@ -6,7 +6,7 @@
, xorgserver , xorgserver
, pulseaudio , pulseaudio
, pytest-asyncio , pytest-asyncio
, qtile , qtile-unwrapped
, keyring , keyring
, requests , requests
, stravalib , stravalib
@ -34,7 +34,7 @@ buildPythonPackage rec {
]; ];
checkInputs = [ checkInputs = [
pytest-asyncio pytest-asyncio
qtile.unwrapped qtile-unwrapped
pulseaudio pulseaudio
keyring keyring
requests requests

View file

@ -34077,7 +34077,8 @@ with pkgs;
qpdfview = libsForQt5.callPackage ../applications/office/qpdfview { }; 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 { }; vimgolf = callPackage ../games/vimgolf { };