Skip to content

Commit fb72b47

Browse files
committed
nix: split quickshell into quickshell-unwrapped and quickshell (wrapper)
1 parent 9662234 commit fb72b47

File tree

3 files changed

+133
-134
lines changed

3 files changed

+133
-134
lines changed

default.nix

Lines changed: 23 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,26 @@
11
{
2-
lib,
3-
nix-gitignore,
4-
pkgs,
5-
stdenv,
6-
keepDebugInfo,
7-
8-
pkg-config,
9-
cmake,
10-
ninja,
11-
spirv-tools,
2+
callPackage,
3+
quickshell-unwrapped ? callPackage ./unwrapped.nix {},
124
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-
}: let
47-
unwrapped = stdenv.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-
spirv-tools
58-
pkg-config
59-
]
60-
++ lib.optionals withWayland [
61-
qt6.qtwayland # qtwaylandscanner required at build time
62-
wayland-scanner
63-
];
64-
65-
buildInputs = [
66-
qt6.qtbase
67-
qt6.qtdeclarative
68-
cli11
69-
]
70-
++ lib.optional withQtSvg qt6.qtsvg
71-
++ lib.optional withCrashReporter breakpad
72-
++ lib.optional withJemalloc jemalloc
73-
++ lib.optionals withWayland [ qt6.qtwayland wayland wayland-protocols ]
74-
++ lib.optionals (withWayland && libgbm != null) [ libdrm libgbm ]
75-
++ lib.optional withX11 xorg.libxcb
76-
++ lib.optional withPam pam
77-
++ lib.optional withPipewire pipewire;
78-
79-
cmakeBuildType = if debug then "Debug" else "RelWithDebInfo";
80-
81-
cmakeFlags = [
82-
(lib.cmakeFeature "DISTRIBUTOR" "Official-Nix-Flake")
83-
(lib.cmakeFeature "INSTALL_QML_PREFIX" qt6.qtbase.qtQmlPrefix)
84-
(lib.cmakeBool "DISTRIBUTOR_DEBUGINFO_AVAILABLE" true)
85-
(lib.cmakeFeature "GIT_REVISION" gitRev)
86-
(lib.cmakeBool "CRASH_REPORTER" withCrashReporter)
87-
(lib.cmakeBool "USE_JEMALLOC" withJemalloc)
88-
(lib.cmakeBool "WAYLAND" withWayland)
89-
(lib.cmakeBool "SCREENCOPY" (libgbm != null))
90-
(lib.cmakeBool "SERVICE_PIPEWIRE" withPipewire)
91-
(lib.cmakeBool "SERVICE_PAM" withPam)
92-
(lib.cmakeBool "HYPRLAND" withHyprland)
93-
(lib.cmakeBool "I3" withI3)
94-
];
95-
96-
# How to get debuginfo in gdb from a release build:
97-
# 1. build `quickshell.debug`
98-
# 2. set NIX_DEBUG_INFO_DIRS="<quickshell.debug store path>/lib/debug"
99-
# 3. launch gdb / coredumpctl and debuginfo will work
100-
separateDebugInfo = !debug;
101-
dontStrip = debug;
102-
103-
meta = with lib; {
104-
homepage = "https://quickshell.org";
105-
description = "Flexbile QtQuick based desktop shell toolkit";
106-
license = licenses.lgpl3Only;
107-
platforms = platforms.linux;
108-
mainProgram = "quickshell";
109-
};
110-
};
111-
112-
wrapper = unwrapped.stdenv.mkDerivation {
113-
inherit (unwrapped) version meta buildInputs;
114-
pname = "${unwrapped.pname}-wrapped";
115-
116-
nativeBuildInputs = unwrapped.nativeBuildInputs ++ [ qt6.wrapQtAppsHook ];
117-
118-
dontUnpack = true;
119-
dontConfigure = true;
120-
dontBuild = true;
121-
122-
installPhase = ''
123-
mkdir -p $out
124-
cp -r ${unwrapped}/* $out
125-
'';
126-
127-
passthru = {
128-
unwrapped = unwrapped;
129-
withModules = modules: wrapper.overrideAttrs (prev: {
130-
buildInputs = prev.buildInputs ++ modules;
131-
});
132-
};
5+
}: quickshell-unwrapped.stdenv.mkDerivation (final: {
6+
inherit (quickshell-unwrapped) version meta buildInputs;
7+
pname = "${quickshell-unwrapped.pname}-wrapped";
8+
9+
nativeBuildInputs = quickshell-unwrapped.nativeBuildInputs ++ [ qt6.wrapQtAppsHook ];
10+
11+
dontUnpack = true;
12+
dontConfigure = true;
13+
dontBuild = true;
14+
15+
installPhase = ''
16+
mkdir -p $out
17+
cp -r ${quickshell-unwrapped}/* $out
18+
'';
19+
20+
passthru = {
21+
unwrapped = quickshell-unwrapped;
22+
withModules = modules: final.finalPackage.overrideAttrs (prev: {
23+
buildInputs = prev.buildInputs ++ modules;
24+
});
13325
};
134-
in wrapper
26+
})

overlay.nix

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{ rev ? null }: (final: prev: {
2-
quickshell = final.callPackage ./default.nix {
3-
gitRev = rev;
4-
};
2+
quickshell-unwrapped = final.callPackage ./unwrapped.nix { gitRev = rev; };
3+
quickshell = final.callPackage ./default.nix {};
54
})

unwrapped.nix

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{
2+
lib,
3+
nix-gitignore,
4+
stdenv,
5+
keepDebugInfo,
6+
7+
pkg-config,
8+
cmake,
9+
ninja,
10+
spirv-tools,
11+
qt6,
12+
breakpad,
13+
jemalloc,
14+
cli11,
15+
wayland,
16+
wayland-protocols,
17+
wayland-scanner,
18+
xorg,
19+
libdrm,
20+
libgbm ? null,
21+
pipewire,
22+
pam,
23+
24+
gitRev ? (let
25+
headExists = builtins.pathExists ./.git/HEAD;
26+
headContent = builtins.readFile ./.git/HEAD;
27+
in if headExists
28+
then (let
29+
matches = builtins.match "ref: refs/heads/(.*)\n" headContent;
30+
in if matches != null
31+
then builtins.readFile ./.git/refs/heads/${builtins.elemAt matches 0}
32+
else headContent)
33+
else "unknown"),
34+
35+
debug ? false,
36+
withCrashReporter ? true,
37+
withJemalloc ? true, # masks heap fragmentation
38+
withQtSvg ? true,
39+
withWayland ? true,
40+
withX11 ? true,
41+
withPipewire ? true,
42+
withPam ? true,
43+
withHyprland ? true,
44+
withI3 ? true,
45+
}: stdenv.mkDerivation {
46+
pname = "quickshell${lib.optionalString debug "-debug"}";
47+
version = "0.2.0";
48+
src = nix-gitignore.gitignoreSource "/default.nix\n" ./.;
49+
50+
dontWrapQtApps = true; # see wrappers
51+
52+
nativeBuildInputs = [
53+
cmake
54+
ninja
55+
spirv-tools
56+
pkg-config
57+
]
58+
++ lib.optionals withWayland [
59+
qt6.qtwayland # qtwaylandscanner required at build time
60+
wayland-scanner
61+
];
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+
}

0 commit comments

Comments
 (0)