diff --git a/overlays/overrides.nix b/overlays/overrides.nix index c4cf485..12b55bd 100644 --- a/overlays/overrides.nix +++ b/overlays/overrides.nix @@ -15,4 +15,5 @@ channels: final: prev: { hydrus ; + qtile = final.qtile-unstable; } diff --git a/pkgs/_sources/generated.json b/pkgs/_sources/generated.json index 5652224..6ec9e5c 100644 --- a/pkgs/_sources/generated.json +++ b/pkgs/_sources/generated.json @@ -17,5 +17,24 @@ "type": "github" }, "version": "v0.1.0" + }, + "qtile": { + "cargoLocks": null, + "extract": null, + "name": "qtile", + "passthru": null, + "pinned": false, + "src": { + "deepClone": false, + "fetchSubmodules": false, + "leaveDotGit": false, + "name": null, + "owner": "qtile", + "repo": "qtile", + "rev": "62b9e5951d5d9c2f5e9c9a1fcb595696ed16d71d", + "sha256": "sha256-wlfmTUtdvj6akzXj8JK/950cRQkv/z/fRKqCff4GvmE=", + "type": "github" + }, + "version": "62b9e5951d5d9c2f5e9c9a1fcb595696ed16d71d" } } \ No newline at end of file diff --git a/pkgs/_sources/generated.nix b/pkgs/_sources/generated.nix index 1d4e4d1..d85d6e2 100644 --- a/pkgs/_sources/generated.nix +++ b/pkgs/_sources/generated.nix @@ -12,4 +12,15 @@ sha256 = "sha256-9CV6B7fRHXl73uI2JRv3RiaFczLHHBOd7/8UoCAwK6w="; }); }; + qtile = { + pname = "qtile"; + version = "62b9e5951d5d9c2f5e9c9a1fcb595696ed16d71d"; + src = fetchFromGitHub ({ + owner = "qtile"; + repo = "qtile"; + rev = "62b9e5951d5d9c2f5e9c9a1fcb595696ed16d71d"; + fetchSubmodules = false; + sha256 = "sha256-wlfmTUtdvj6akzXj8JK/950cRQkv/z/fRKqCff4GvmE="; + }); + }; } diff --git a/pkgs/default.nix b/pkgs/default.nix index 1cedab5..1782be5 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -8,4 +8,6 @@ final: prev: { frei = final.callPackage ./frei.nix { source = final.sources.frei; }; nix-modrinth-prefetch = final.callPackage ./nix-modrinth-prefetch.nix { }; + + qtile-unstable = final.callPackage ./qtile.nix { source = final.sources.qtile; }; } diff --git a/pkgs/patches/qtile-fix-restart.patch b/pkgs/patches/qtile-fix-restart.patch new file mode 100644 index 0000000..eca4f08 --- /dev/null +++ b/pkgs/patches/qtile-fix-restart.patch @@ -0,0 +1,22 @@ +diff --git a/libqtile/core/lifecycle.py b/libqtile/core/lifecycle.py +index 0d4d119d..c37d1799 100644 +--- a/libqtile/core/lifecycle.py ++++ b/libqtile/core/lifecycle.py +@@ -25,7 +25,7 @@ class LifeCycle: + + def _atexit(self) -> None: + if self.behavior is Behavior.RESTART: +- argv = [sys.executable] + sys.argv ++ argv = sys.argv + if "--no-spawn" not in argv: + argv.append("--no-spawn") + argv = [s for s in argv if not s.startswith("--with-state")] +@@ -33,7 +33,7 @@ class LifeCycle: + argv.append("--with-state=" + self.state_file) + logger.warning("Restarting Qtile with os.execv(...)") + # No other code will execute after the following line does +- os.execv(sys.executable, argv) ++ os.execv(sys.argv[0], argv) + elif self.behavior is Behavior.TERMINATE: + logger.warning("Qtile will now terminate") + elif self.behavior is Behavior.NONE: diff --git a/pkgs/qtile.nix b/pkgs/qtile.nix new file mode 100644 index 0000000..1f8e951 --- /dev/null +++ b/pkgs/qtile.nix @@ -0,0 +1,89 @@ +{ lib +, fetchFromGitHub +, python3 +, python3Packages +, mypy +, glib +, pango +, pkg-config +, libinput +, libxkbcommon +, wayland +, wlroots +, xcbutilcursor +, source +}: + +let + unwrapped = python3Packages.buildPythonPackage rec { + inherit (source) pname version src; + + patches = [ + ./patches/qtile-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 + ]; + + 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 ]; + }; + }; +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; +}) diff --git a/pkgs/sources.toml b/pkgs/sources.toml index f879aef..7fd076b 100644 --- a/pkgs/sources.toml +++ b/pkgs/sources.toml @@ -2,3 +2,7 @@ [frei] src.github = "alexcoder04/frei" fetch.github = "alexcoder04/frei" + +[qtile] +src.git = "https://github.com/qtile/qtile.git" +fetch.github = "qtile/qtile"