Skip to content

Commit 6106b90

Browse files
committed
build: split derivation for extensible wrapper
1 parent 6572a7f commit 6106b90

File tree

1 file changed

+83
-54
lines changed

1 file changed

+83
-54
lines changed

default.nix

Lines changed: 83 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -43,64 +43,93 @@
4343
withPam ? true,
4444
withHyprland ? true,
4545
withI3 ? true,
46-
}: buildStdenv.mkDerivation {
47-
pname = "quickshell${lib.optionalString debug "-debug"}";
48-
version = "0.1.0";
49-
src = nix-gitignore.gitignoreSource [] ./.;
46+
}: let
47+
unwrapped = buildStdenv.mkDerivation {
48+
pname = "quickshell${lib.optionalString debug "-debug"}";
49+
version = "0.1.0";
50+
src = nix-gitignore.gitignoreSource "/default.nix\n" ./.;
5051

51-
nativeBuildInputs = [
52-
cmake
53-
ninja
54-
qt6.qtshadertools
55-
spirv-tools
56-
qt6.wrapQtAppsHook
57-
pkg-config
58-
]
59-
++ lib.optional withWayland wayland-scanner;
52+
dontWrapQtApps = true; # see wrappers
6053

61-
buildInputs = [
62-
qt6.qtbase
63-
qt6.qtdeclarative
64-
cli11
65-
]
66-
++ lib.optional withQtSvg qt6.qtsvg
67-
++ lib.optional withCrashReporter breakpad
68-
++ lib.optional withJemalloc jemalloc
69-
++ lib.optionals withWayland [ qt6.qtwayland wayland wayland-protocols ]
70-
++ lib.optionals (withWayland && libgbm != null) [ libdrm libgbm ]
71-
++ lib.optional withX11 xorg.libxcb
72-
++ lib.optional withPam pam
73-
++ lib.optional withPipewire pipewire;
54+
nativeBuildInputs = [
55+
cmake
56+
ninja
57+
qt6.qtshadertools
58+
spirv-tools
59+
pkg-config
60+
]
61+
++ lib.optional withWayland wayland-scanner;
7462

75-
cmakeBuildType = if debug then "Debug" else "RelWithDebInfo";
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;
7676

77-
cmakeFlags = [
78-
(lib.cmakeFeature "DISTRIBUTOR" "Official-Nix-Flake")
79-
(lib.cmakeFeature "INSTALL_QML_PREFIX" qt6.qtbase.qtQmlPrefix)
80-
(lib.cmakeBool "DISTRIBUTOR_DEBUGINFO_AVAILABLE" true)
81-
(lib.cmakeFeature "GIT_REVISION" gitRev)
82-
(lib.cmakeBool "CRASH_REPORTER" withCrashReporter)
83-
(lib.cmakeBool "USE_JEMALLOC" withJemalloc)
84-
(lib.cmakeBool "WAYLAND" withWayland)
85-
(lib.cmakeBool "SCREENCOPY" (libgbm != null))
86-
(lib.cmakeBool "SERVICE_PIPEWIRE" withPipewire)
87-
(lib.cmakeBool "SERVICE_PAM" withPam)
88-
(lib.cmakeBool "HYPRLAND" withHyprland)
89-
(lib.cmakeBool "I3" withI3)
90-
];
77+
cmakeBuildType = if debug then "Debug" else "RelWithDebInfo";
9178

92-
# How to get debuginfo in gdb from a release build:
93-
# 1. build `quickshell.debug`
94-
# 2. set NIX_DEBUG_INFO_DIRS="<quickshell.debug store path>/lib/debug"
95-
# 3. launch gdb / coredumpctl and debuginfo will work
96-
separateDebugInfo = !debug;
97-
dontStrip = debug;
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+
];
9893

99-
meta = with lib; {
100-
homepage = "https://quickshell.outfoxxed.me";
101-
description = "Flexbile QtQuick based desktop shell toolkit";
102-
license = licenses.lgpl3Only;
103-
platforms = platforms.linux;
104-
mainProgram = "quickshell";
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 {
111+
inherit (unwrapped) version meta buildInputs;
112+
pname = "${unwrapped.pname}-wrapped";
113+
114+
nativeBuildInputs = unwrapped.nativeBuildInputs ++ [ qt6.wrapQtAppsHook ];
115+
116+
dontUnpack = true;
117+
dontConfigure = true;
118+
dontBuild = true;
119+
120+
installPhase = ''
121+
mkdir -p $out/bin
122+
# cp will create .quickshell-wrapped in path, ln will not. It is occasionally useful.
123+
cp -r ${unwrapped}/bin/* $out/bin
124+
ln -s ${unwrapped}/share $out/share
125+
# not /lib
126+
'';
127+
128+
passthru = {
129+
unwrapped = unwrapped;
130+
withModules = modules: wrapper.overrideAttrs (prev: {
131+
buildInputs = prev.buildInputs ++ modules;
132+
});
133+
};
105134
};
106-
}
135+
in wrapper

0 commit comments

Comments
 (0)