From fb72b478885e31665a957a5a05b6c117a7b8087e Mon Sep 17 00:00:00 2001 From: Rexiel Scarlet <37258415+Rexcrazy804@users.noreply.github.com> Date: Wed, 1 Oct 2025 15:23:19 +0400 Subject: [PATCH 1/3] nix: split quickshell into quickshell-unwrapped and quickshell (wrapper) --- default.nix | 154 ++++++++------------------------------------------ overlay.nix | 5 +- unwrapped.nix | 108 +++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+), 134 deletions(-) create mode 100644 unwrapped.nix diff --git a/default.nix b/default.nix index 3908e3c9..28bb5308 100644 --- a/default.nix +++ b/default.nix @@ -1,134 +1,26 @@ { - lib, - nix-gitignore, - pkgs, - stdenv, - keepDebugInfo, - - pkg-config, - cmake, - ninja, - spirv-tools, + callPackage, + quickshell-unwrapped ? callPackage ./unwrapped.nix {}, qt6, - breakpad, - jemalloc, - cli11, - wayland, - wayland-protocols, - wayland-scanner, - xorg, - libdrm, - libgbm ? null, - pipewire, - pam, - - gitRev ? (let - headExists = builtins.pathExists ./.git/HEAD; - headContent = builtins.readFile ./.git/HEAD; - in if headExists - then (let - matches = builtins.match "ref: refs/heads/(.*)\n" headContent; - in if matches != null - then builtins.readFile ./.git/refs/heads/${builtins.elemAt matches 0} - else headContent) - else "unknown"), - - debug ? false, - withCrashReporter ? true, - withJemalloc ? true, # masks heap fragmentation - withQtSvg ? true, - withWayland ? true, - withX11 ? true, - withPipewire ? true, - withPam ? true, - withHyprland ? true, - withI3 ? true, -}: let - unwrapped = stdenv.mkDerivation { - pname = "quickshell${lib.optionalString debug "-debug"}"; - version = "0.2.0"; - src = nix-gitignore.gitignoreSource "/default.nix\n" ./.; - - dontWrapQtApps = true; # see wrappers - - nativeBuildInputs = [ - cmake - ninja - spirv-tools - pkg-config - ] - ++ lib.optionals withWayland [ - qt6.qtwayland # qtwaylandscanner required at build time - wayland-scanner - ]; - - buildInputs = [ - qt6.qtbase - qt6.qtdeclarative - cli11 - ] - ++ lib.optional withQtSvg qt6.qtsvg - ++ lib.optional withCrashReporter breakpad - ++ lib.optional withJemalloc jemalloc - ++ lib.optionals withWayland [ qt6.qtwayland wayland wayland-protocols ] - ++ lib.optionals (withWayland && libgbm != null) [ libdrm libgbm ] - ++ lib.optional withX11 xorg.libxcb - ++ lib.optional withPam pam - ++ lib.optional withPipewire pipewire; - - cmakeBuildType = if debug then "Debug" else "RelWithDebInfo"; - - cmakeFlags = [ - (lib.cmakeFeature "DISTRIBUTOR" "Official-Nix-Flake") - (lib.cmakeFeature "INSTALL_QML_PREFIX" qt6.qtbase.qtQmlPrefix) - (lib.cmakeBool "DISTRIBUTOR_DEBUGINFO_AVAILABLE" true) - (lib.cmakeFeature "GIT_REVISION" gitRev) - (lib.cmakeBool "CRASH_REPORTER" withCrashReporter) - (lib.cmakeBool "USE_JEMALLOC" withJemalloc) - (lib.cmakeBool "WAYLAND" withWayland) - (lib.cmakeBool "SCREENCOPY" (libgbm != null)) - (lib.cmakeBool "SERVICE_PIPEWIRE" withPipewire) - (lib.cmakeBool "SERVICE_PAM" withPam) - (lib.cmakeBool "HYPRLAND" withHyprland) - (lib.cmakeBool "I3" withI3) - ]; - - # How to get debuginfo in gdb from a release build: - # 1. build `quickshell.debug` - # 2. set NIX_DEBUG_INFO_DIRS="/lib/debug" - # 3. launch gdb / coredumpctl and debuginfo will work - separateDebugInfo = !debug; - dontStrip = debug; - - meta = with lib; { - homepage = "https://quickshell.org"; - description = "Flexbile QtQuick based desktop shell toolkit"; - license = licenses.lgpl3Only; - platforms = platforms.linux; - mainProgram = "quickshell"; - }; - }; - - wrapper = unwrapped.stdenv.mkDerivation { - inherit (unwrapped) version meta buildInputs; - pname = "${unwrapped.pname}-wrapped"; - - nativeBuildInputs = unwrapped.nativeBuildInputs ++ [ qt6.wrapQtAppsHook ]; - - dontUnpack = true; - dontConfigure = true; - dontBuild = true; - - installPhase = '' - mkdir -p $out - cp -r ${unwrapped}/* $out - ''; - - passthru = { - unwrapped = unwrapped; - withModules = modules: wrapper.overrideAttrs (prev: { - buildInputs = prev.buildInputs ++ modules; - }); - }; +}: quickshell-unwrapped.stdenv.mkDerivation (final: { + inherit (quickshell-unwrapped) version meta buildInputs; + pname = "${quickshell-unwrapped.pname}-wrapped"; + + nativeBuildInputs = quickshell-unwrapped.nativeBuildInputs ++ [ qt6.wrapQtAppsHook ]; + + dontUnpack = true; + dontConfigure = true; + dontBuild = true; + + installPhase = '' + mkdir -p $out + cp -r ${quickshell-unwrapped}/* $out + ''; + + passthru = { + unwrapped = quickshell-unwrapped; + withModules = modules: final.finalPackage.overrideAttrs (prev: { + buildInputs = prev.buildInputs ++ modules; + }); }; -in wrapper +}) diff --git a/overlay.nix b/overlay.nix index d8ea1375..8c86a148 100644 --- a/overlay.nix +++ b/overlay.nix @@ -1,5 +1,4 @@ { rev ? null }: (final: prev: { - quickshell = final.callPackage ./default.nix { - gitRev = rev; - }; + quickshell-unwrapped = final.callPackage ./unwrapped.nix { gitRev = rev; }; + quickshell = final.callPackage ./default.nix {}; }) diff --git a/unwrapped.nix b/unwrapped.nix new file mode 100644 index 00000000..21601ee5 --- /dev/null +++ b/unwrapped.nix @@ -0,0 +1,108 @@ +{ + lib, + nix-gitignore, + stdenv, + keepDebugInfo, + + pkg-config, + cmake, + ninja, + spirv-tools, + qt6, + breakpad, + jemalloc, + cli11, + wayland, + wayland-protocols, + wayland-scanner, + xorg, + libdrm, + libgbm ? null, + pipewire, + pam, + + gitRev ? (let + headExists = builtins.pathExists ./.git/HEAD; + headContent = builtins.readFile ./.git/HEAD; + in if headExists + then (let + matches = builtins.match "ref: refs/heads/(.*)\n" headContent; + in if matches != null + then builtins.readFile ./.git/refs/heads/${builtins.elemAt matches 0} + else headContent) + else "unknown"), + + debug ? false, + withCrashReporter ? true, + withJemalloc ? true, # masks heap fragmentation + withQtSvg ? true, + withWayland ? true, + withX11 ? true, + withPipewire ? true, + withPam ? true, + withHyprland ? true, + withI3 ? true, +}: stdenv.mkDerivation { + pname = "quickshell${lib.optionalString debug "-debug"}"; + version = "0.2.0"; + src = nix-gitignore.gitignoreSource "/default.nix\n" ./.; + + dontWrapQtApps = true; # see wrappers + + nativeBuildInputs = [ + cmake + ninja + spirv-tools + pkg-config + ] + ++ lib.optionals withWayland [ + qt6.qtwayland # qtwaylandscanner required at build time + wayland-scanner + ]; + + buildInputs = [ + qt6.qtbase + qt6.qtdeclarative + cli11 + ] + ++ lib.optional withQtSvg qt6.qtsvg + ++ lib.optional withCrashReporter breakpad + ++ lib.optional withJemalloc jemalloc + ++ lib.optionals withWayland [ qt6.qtwayland wayland wayland-protocols ] + ++ lib.optionals (withWayland && libgbm != null) [ libdrm libgbm ] + ++ lib.optional withX11 xorg.libxcb + ++ lib.optional withPam pam + ++ lib.optional withPipewire pipewire; + + cmakeBuildType = if debug then "Debug" else "RelWithDebInfo"; + + cmakeFlags = [ + (lib.cmakeFeature "DISTRIBUTOR" "Official-Nix-Flake") + (lib.cmakeFeature "INSTALL_QML_PREFIX" qt6.qtbase.qtQmlPrefix) + (lib.cmakeBool "DISTRIBUTOR_DEBUGINFO_AVAILABLE" true) + (lib.cmakeFeature "GIT_REVISION" gitRev) + (lib.cmakeBool "CRASH_REPORTER" withCrashReporter) + (lib.cmakeBool "USE_JEMALLOC" withJemalloc) + (lib.cmakeBool "WAYLAND" withWayland) + (lib.cmakeBool "SCREENCOPY" (libgbm != null)) + (lib.cmakeBool "SERVICE_PIPEWIRE" withPipewire) + (lib.cmakeBool "SERVICE_PAM" withPam) + (lib.cmakeBool "HYPRLAND" withHyprland) + (lib.cmakeBool "I3" withI3) + ]; + + # How to get debuginfo in gdb from a release build: + # 1. build `quickshell.debug` + # 2. set NIX_DEBUG_INFO_DIRS="/lib/debug" + # 3. launch gdb / coredumpctl and debuginfo will work + separateDebugInfo = !debug; + dontStrip = debug; + + meta = with lib; { + homepage = "https://quickshell.org"; + description = "Flexbile QtQuick based desktop shell toolkit"; + license = licenses.lgpl3Only; + platforms = platforms.linux; + mainProgram = "quickshell"; + }; +} From 200fed2ff54ce7a9fe40c248b974df9a2273a6fd Mon Sep 17 00:00:00 2001 From: Rexiel Scarlet <37258415+Rexcrazy804@users.noreply.github.com> Date: Wed, 1 Oct 2025 15:34:19 +0400 Subject: [PATCH 2/3] nix: correctly override qs in devShell --- flake.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 8edda2cd..815413e2 100644 --- a/flake.nix +++ b/flake.nix @@ -23,9 +23,11 @@ devShells = forEachSystem (system: pkgs: rec { default = import ./shell.nix { inherit pkgs; - quickshell = self.packages.${system}.quickshell.override { - stdenv = pkgs.clangStdenv; - }; + quickshell = self.packages.${system}.quickshell.override (prev: { + quickshell-unwrapped = prev.quickshell-unwrapped.override { + stdenv = pkgs.clangStdenv; + }; + }); }; }); }; From ab6c42d1b8369614c767c138eca175d75622988c Mon Sep 17 00:00:00 2001 From: Rexiel Scarlet <37258415+Rexcrazy804@users.noreply.github.com> Date: Wed, 1 Oct 2025 15:39:08 +0400 Subject: [PATCH 3/3] ci: corrected override --- ci/matrix.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ci/matrix.nix b/ci/matrix.nix index dd20fa5b..94dac409 100644 --- a/ci/matrix.nix +++ b/ci/matrix.nix @@ -5,7 +5,9 @@ checkouts = import ./nix-checkouts.nix; nixpkgs = checkouts.${builtins.replaceStrings ["."] ["_"] qtver}; compilerOverride = (nixpkgs.callPackage ./variations.nix {}).${compiler}; - pkg = (nixpkgs.callPackage ../default.nix {}).override (compilerOverride // { - wayland-protocols = checkouts.latest.wayland-protocols; - }); + quickshell-unwrapped = nixpkgs.callPackage ../unwrapped.nix ( + compilerOverride // + {inherit (checkouts.latest) wayland-protocols;} + ); + pkg = (nixpkgs.callPackage ../default.nix {inherit quickshell-unwrapped;}); in pkg