Skip to content

Commit ffe0e54

Browse files
committed
Flake: diversify wrapper and package
- seperated default.nix into two derrivations - default.nix hosting the wrapper and unwrapped.nix with original qs drv - passing non list argument to .withModules now displays an appropriate error message
1 parent a5431dd commit ffe0e54

File tree

3 files changed

+124
-115
lines changed

3 files changed

+124
-115
lines changed

default.nix

Lines changed: 15 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,18 @@
11
{
2+
callPackage,
23
lib,
3-
nix-gitignore,
4-
pkgs,
5-
keepDebugInfo,
6-
buildStdenv ? pkgs.clangStdenv,
7-
8-
pkg-config,
9-
cmake,
10-
ninja,
11-
spirv-tools,
4+
quickshell-unwrapped ? callPackage ./unwrapped.nix {},
125
qt6,
13-
breakpad,
14-
jemalloc,
15-
cli11,
16-
wayland,
17-
wayland-protocols,
18-
wayland-scanner,
19-
xorg,
20-
libdrm,
21-
libgbm ? null,
22-
pipewire,
23-
pam,
24-
25-
gitRev ? (let
26-
headExists = builtins.pathExists ./.git/HEAD;
27-
headContent = builtins.readFile ./.git/HEAD;
28-
in if headExists
29-
then (let
30-
matches = builtins.match "ref: refs/heads/(.*)\n" headContent;
31-
in if matches != null
32-
then builtins.readFile ./.git/refs/heads/${builtins.elemAt matches 0}
33-
else headContent)
34-
else "unknown"),
35-
36-
debug ? false,
37-
withCrashReporter ? true,
38-
withJemalloc ? true, # masks heap fragmentation
39-
withQtSvg ? true,
40-
withWayland ? true,
41-
withX11 ? true,
42-
withPipewire ? true,
43-
withPam ? true,
44-
withHyprland ? true,
45-
withI3 ? true,
466
}: let
47-
unwrapped = buildStdenv.mkDerivation {
48-
pname = "quickshell${lib.optionalString debug "-debug"}";
49-
version = "0.2.0";
50-
src = nix-gitignore.gitignoreSource "/default.nix\n" ./.;
51-
52-
dontWrapQtApps = true; # see wrappers
53-
54-
nativeBuildInputs = [
55-
cmake
56-
ninja
57-
qt6.qtshadertools
58-
spirv-tools
59-
pkg-config
60-
]
61-
++ lib.optional withWayland wayland-scanner;
62-
63-
buildInputs = [
64-
qt6.qtbase
65-
qt6.qtdeclarative
66-
cli11
67-
]
68-
++ lib.optional withQtSvg qt6.qtsvg
69-
++ lib.optional withCrashReporter breakpad
70-
++ lib.optional withJemalloc jemalloc
71-
++ lib.optionals withWayland [ qt6.qtwayland wayland wayland-protocols ]
72-
++ lib.optionals (withWayland && libgbm != null) [ libdrm libgbm ]
73-
++ lib.optional withX11 xorg.libxcb
74-
++ lib.optional withPam pam
75-
++ lib.optional withPipewire pipewire;
76-
77-
cmakeBuildType = if debug then "Debug" else "RelWithDebInfo";
78-
79-
cmakeFlags = [
80-
(lib.cmakeFeature "DISTRIBUTOR" "Official-Nix-Flake")
81-
(lib.cmakeFeature "INSTALL_QML_PREFIX" qt6.qtbase.qtQmlPrefix)
82-
(lib.cmakeBool "DISTRIBUTOR_DEBUGINFO_AVAILABLE" true)
83-
(lib.cmakeFeature "GIT_REVISION" gitRev)
84-
(lib.cmakeBool "CRASH_REPORTER" withCrashReporter)
85-
(lib.cmakeBool "USE_JEMALLOC" withJemalloc)
86-
(lib.cmakeBool "WAYLAND" withWayland)
87-
(lib.cmakeBool "SCREENCOPY" (libgbm != null))
88-
(lib.cmakeBool "SERVICE_PIPEWIRE" withPipewire)
89-
(lib.cmakeBool "SERVICE_PAM" withPam)
90-
(lib.cmakeBool "HYPRLAND" withHyprland)
91-
(lib.cmakeBool "I3" withI3)
92-
];
93-
94-
# How to get debuginfo in gdb from a release build:
95-
# 1. build `quickshell.debug`
96-
# 2. set NIX_DEBUG_INFO_DIRS="<quickshell.debug store path>/lib/debug"
97-
# 3. launch gdb / coredumpctl and debuginfo will work
98-
separateDebugInfo = !debug;
99-
dontStrip = debug;
100-
101-
meta = with lib; {
102-
homepage = "https://quickshell.org";
103-
description = "Flexbile QtQuick based desktop shell toolkit";
104-
license = licenses.lgpl3Only;
105-
platforms = platforms.linux;
106-
mainProgram = "quickshell";
107-
};
108-
};
109-
110-
wrapper = unwrapped.stdenv.mkDerivation {
7+
unwrapped = quickshell-unwrapped;
8+
inherit (unwrapped.stdenv) mkDerivation;
9+
inherit (lib) typeOf asserts;
10+
in
11+
mkDerivation (final: {
11112
inherit (unwrapped) version meta buildInputs;
11213
pname = "${unwrapped.pname}-wrapped";
11314

114-
nativeBuildInputs = unwrapped.nativeBuildInputs ++ [ qt6.wrapQtAppsHook ];
15+
nativeBuildInputs = unwrapped.nativeBuildInputs ++ [qt6.wrapQtAppsHook];
11516

11617
dontUnpack = true;
11718
dontConfigure = true;
@@ -123,10 +24,11 @@
12324
'';
12425

12526
passthru = {
126-
unwrapped = unwrapped;
127-
withModules = modules: wrapper.overrideAttrs (prev: {
128-
buildInputs = prev.buildInputs ++ modules;
129-
});
27+
inherit unwrapped;
28+
withModules = modules:
29+
assert (asserts.assertMsg (typeOf modules == "list") "`modules` must be a list of packages");
30+
final.finalPackage.overrideAttrs (prev: {
31+
buildInputs = prev.buildInputs ++ modules;
32+
});
13033
};
131-
};
132-
in wrapper
34+
})

flake.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
(system: fn system nixpkgs.legacyPackages.${system});
1111
in {
1212
packages = forEachSystem (system: pkgs: rec {
13-
quickshell = pkgs.callPackage ./default.nix {
13+
quickshell-unwrapped = pkgs.callPackage ./unwrapped.nix {
1414
gitRev = self.rev or self.dirtyRev;
1515
};
16-
16+
quickshell = pkgs.callPackage ./default.nix {inherit quickshell-unwrapped;};
1717
default = quickshell;
1818
});
1919

unwrapped.nix

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
lib,
3+
nix-gitignore,
4+
pkgs,
5+
keepDebugInfo,
6+
buildStdenv ? pkgs.clangStdenv,
7+
8+
pkg-config,
9+
cmake,
10+
ninja,
11+
spirv-tools,
12+
qt6,
13+
breakpad,
14+
jemalloc,
15+
cli11,
16+
wayland,
17+
wayland-protocols,
18+
wayland-scanner,
19+
xorg,
20+
libdrm,
21+
libgbm ? null,
22+
pipewire,
23+
pam,
24+
25+
gitRev ? (let
26+
headExists = builtins.pathExists ./.git/HEAD;
27+
headContent = builtins.readFile ./.git/HEAD;
28+
in if headExists
29+
then (let
30+
matches = builtins.match "ref: refs/heads/(.*)\n" headContent;
31+
in if matches != null
32+
then builtins.readFile ./.git/refs/heads/${builtins.elemAt matches 0}
33+
else headContent)
34+
else "unknown"),
35+
36+
debug ? false,
37+
withCrashReporter ? true,
38+
withJemalloc ? true, # masks heap fragmentation
39+
withQtSvg ? true,
40+
withWayland ? true,
41+
withX11 ? true,
42+
withPipewire ? true,
43+
withPam ? true,
44+
withHyprland ? true,
45+
withI3 ? true,
46+
}: buildStdenv.mkDerivation {
47+
pname = "quickshell${lib.optionalString debug "-debug"}";
48+
version = "0.2.0";
49+
src = nix-gitignore.gitignoreSource "/default.nix\n" ./.;
50+
51+
dontWrapQtApps = true; # see wrappers
52+
53+
nativeBuildInputs = [
54+
cmake
55+
ninja
56+
qt6.qtshadertools
57+
spirv-tools
58+
pkg-config
59+
]
60+
++ lib.optional withWayland wayland-scanner;
61+
62+
buildInputs = [
63+
qt6.qtbase
64+
qt6.qtdeclarative
65+
cli11
66+
]
67+
++ lib.optional withQtSvg qt6.qtsvg
68+
++ lib.optional withCrashReporter breakpad
69+
++ lib.optional withJemalloc jemalloc
70+
++ lib.optionals withWayland [ qt6.qtwayland wayland wayland-protocols ]
71+
++ lib.optionals (withWayland && libgbm != null) [ libdrm libgbm ]
72+
++ lib.optional withX11 xorg.libxcb
73+
++ lib.optional withPam pam
74+
++ lib.optional withPipewire pipewire;
75+
76+
cmakeBuildType = if debug then "Debug" else "RelWithDebInfo";
77+
78+
cmakeFlags = [
79+
(lib.cmakeFeature "DISTRIBUTOR" "Official-Nix-Flake")
80+
(lib.cmakeFeature "INSTALL_QML_PREFIX" qt6.qtbase.qtQmlPrefix)
81+
(lib.cmakeBool "DISTRIBUTOR_DEBUGINFO_AVAILABLE" true)
82+
(lib.cmakeFeature "GIT_REVISION" gitRev)
83+
(lib.cmakeBool "CRASH_REPORTER" withCrashReporter)
84+
(lib.cmakeBool "USE_JEMALLOC" withJemalloc)
85+
(lib.cmakeBool "WAYLAND" withWayland)
86+
(lib.cmakeBool "SCREENCOPY" (libgbm != null))
87+
(lib.cmakeBool "SERVICE_PIPEWIRE" withPipewire)
88+
(lib.cmakeBool "SERVICE_PAM" withPam)
89+
(lib.cmakeBool "HYPRLAND" withHyprland)
90+
(lib.cmakeBool "I3" withI3)
91+
];
92+
93+
# How to get debuginfo in gdb from a release build:
94+
# 1. build `quickshell.debug`
95+
# 2. set NIX_DEBUG_INFO_DIRS="<quickshell.debug store path>/lib/debug"
96+
# 3. launch gdb / coredumpctl and debuginfo will work
97+
separateDebugInfo = !debug;
98+
dontStrip = debug;
99+
100+
meta = with lib; {
101+
homepage = "https://quickshell.org";
102+
description = "Flexbile QtQuick based desktop shell toolkit";
103+
license = licenses.lgpl3Only;
104+
platforms = platforms.linux;
105+
mainProgram = "quickshell";
106+
};
107+
}

0 commit comments

Comments
 (0)