Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
306 lines (271 loc) · 11.8 KB
/
Copy pathflake.nix
File metadata and controls
306 lines (271 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
{
description = "CyShell Desktop";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-compat = {
url = "github:NixOS/flake-compat";
flake = false;
};
dank-qml-common = {
url = "github:Cytech-Team/CyShell-QML-Common/cyshell-dev";
flake = false;
};
};
outputs =
{
self,
nixpkgs,
dank-qml-common,
...
}:
let
goModVersion =
let
content = builtins.readFile ./core/go.mod;
lines = builtins.filter builtins.isString (builtins.split "\n" content);
goLines = builtins.filter (l: builtins.match "go [0-9]+\\..*" l != null) lines;
matched =
if goLines != [ ] then builtins.match "go ([0-9]+)\\.([0-9]+).*" (builtins.head goLines) else null;
in
if matched != null then
{
major = builtins.elemAt matched 0;
minor = builtins.elemAt matched 1;
}
else
{
major = "1";
minor = "25";
};
goForPkgs = pkgs: pkgs.${"go_${goModVersion.major}_${goModVersion.minor}"};
forEachSystem =
fn:
nixpkgs.lib.genAttrs [ "aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux" ] (
system: fn system nixpkgs.legacyPackages.${system}
);
forEachLinuxSystem =
fn:
nixpkgs.lib.genAttrs [ "aarch64-linux" "x86_64-linux" ] (
system: fn system nixpkgs.legacyPackages.${system}
);
mkModuleWithCyShellPkgs =
modulePath:
args@{ pkgs, ... }:
{
imports = [
(import modulePath (args // { cyShellPkgs = buildCyShellPkgs pkgs; }))
];
};
mkQmlImportPath =
pkgs: qmlPkgs:
pkgs.lib.concatStringsSep ":" (map (o: "${o}/${pkgs.qt6.qtbase.qtQmlPrefix}") qmlPkgs);
mkQtPluginPath =
pkgs: qtPkgs:
pkgs.lib.concatStringsSep ":" (map (o: "${o}/${pkgs.qt6.qtbase.qtPluginPrefix}") qtPkgs);
qmlPkgs =
pkgs: with pkgs.kdePackages; [
kirigami.unwrapped
sonnet
qtmultimedia
qtimageformats
kimageformats
];
# Allows downstream modules to provide their own 'pkgs' (with overlays)
# instead of being forced to use the flake's locked nixpkgs.
mkCyShell =
pkgs:
let
mkDate =
longDate:
pkgs.lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
];
version =
let
rawVersion = pkgs.lib.removePrefix "v" (pkgs.lib.trim (builtins.readFile ./quickshell/VERSION));
cleanVersion = builtins.replaceStrings [ " " ] [ "" ] rawVersion;
dateSuffix = "+date=" + mkDate (self.lastModifiedDate or "19700101");
revSuffix = "_" + (self.shortRev or "dirty");
in
"${cleanVersion}${dateSuffix}${revSuffix}";
in
pkgs.lib.makeOverridable (
{
extraQtPackages ? [ ],
}:
(pkgs.buildGoModule.override { go = goForPkgs pkgs; }) (
let
rootSrc = ./.;
qtPackages = (qmlPkgs pkgs) ++ extraQtPackages;
in
{
inherit version;
pname = "cyshell";
src = ./core;
vendorHash = "sha256-eZBP7+9NLdJ88qizCZ+mTmcQO+FHthqQSmNtUErfKv4=";
subPackages = [ "cmd/cyshell" ];
ldflags = [
"-s"
"-w"
"-X 'main.Version=${version}'"
];
nativeBuildInputs = with pkgs; [
installShellFiles
makeWrapper
];
postInstall = ''
mkdir -p $out/share/quickshell/cyshell
tar -C ${rootSrc}/quickshell --mode=u+w --exclude-from=${rootSrc}/scripts/shell-test-excludes.txt -cf - . \
| tar -C $out/share/quickshell/cyshell -xf -
rm -f $out/share/quickshell/cyshell/CyCommon $out/share/quickshell/cyshell/DankCommon
tar -C ${dank-qml-common} --mode=u+w --exclude-from=${rootSrc}/scripts/shell-test-excludes.txt -cf - CyCommon \
| tar -C $out/share/quickshell/cyshell -xf -
ln -s CyCommon $out/share/quickshell/cyshell/DankCommon
echo "${version}" > $out/share/quickshell/cyshell/VERSION
# Install desktop file and icon
install -D ${rootSrc}/assets/cyshell-open.desktop \
$out/share/applications/cyshell-open.desktop
install -D ${rootSrc}/assets/com.cytechteam.cyshell.desktop \
$out/share/applications/com.cytechteam.cyshell.desktop
install -D ${rootSrc}/assets/com.cytechteam.cyshell.notepad.desktop \
$out/share/applications/com.cytechteam.cyshell.notepad.desktop
install -D ${rootSrc}/assets/com.cytechteam.cyshell.png \
$out/share/icons/hicolor/512x512/apps/com.cytechteam.cyshell.png
# Snapshot pre-wrap Qt paths so launched apps get their own, not DMS's pins.
wrapProgram $out/bin/cyshell \
--add-flags "-c $out/share/quickshell/cyshell" \
--run 'export CYSHELL_ORIG_NIXPKGS_QT6_QML_IMPORT_PATH="''${NIXPKGS_QT6_QML_IMPORT_PATH:-}"' \
--run 'export CYSHELL_ORIG_QT_PLUGIN_PATH="''${QT_PLUGIN_PATH:-}"' \
--prefix "NIXPKGS_QT6_QML_IMPORT_PATH" ":" "${mkQmlImportPath pkgs qtPackages}" \
--prefix "QT_PLUGIN_PATH" ":" "${mkQtPluginPath pkgs qtPackages}"
mkdir -p $out/lib/systemd/user
for unit in ${rootSrc}/assets/systemd/cyshell*.service; do
name="$(basename "$unit")"
install -Dm644 "$unit" "$out/lib/systemd/user/$name"
substituteInPlace "$out/lib/systemd/user/$name" \
--replace-fail /usr/bin/cyshell $out/bin/cyshell
done
substituteInPlace $out/share/quickshell/cyshell/assets/pam/fprint \
--replace-fail pam_fprintd.so ${pkgs.fprintd}/lib/security/pam_fprintd.so \
--replace-fail pam_deny.so ${pkgs.pam}/lib/security/pam_deny.so \
--replace-fail pam_permit.so ${pkgs.pam}/lib/security/pam_permit.so
substituteInPlace $out/share/quickshell/cyshell/assets/pam/u2f \
--replace-fail pam_u2f.so ${pkgs.pam_u2f}/lib/security/pam_u2f.so \
--replace-fail pam_deny.so ${pkgs.pam}/lib/security/pam_deny.so \
--replace-fail pam_permit.so ${pkgs.pam}/lib/security/pam_permit.so
substituteInPlace $out/share/quickshell/cyshell/assets/pam/other \
--replace-fail pam_deny.so ${pkgs.pam}/lib/security/pam_deny.so
installShellCompletion --cmd cyshell \
--bash <($out/bin/cyshell completion bash) \
--fish <($out/bin/cyshell completion fish) \
--zsh <($out/bin/cyshell completion zsh)
'';
meta = {
description = "CyShell Desktop: Labwc desktop shell built with Quickshell and Go";
homepage = "https://github.com/Cytech-Team/CyShell-Desktop";
changelog = "https://github.com/Cytech-Team/CyShell-Desktop/releases/tag/v${version}";
license = pkgs.lib.licenses.mit;
mainProgram = "cyshell";
platforms = pkgs.lib.platforms.linux;
};
}
)
) { };
buildCyShellPkgs = pkgs: {
cyshell = mkCyShell pkgs;
dms-shell = builtins.warn "CyShell: package name dms-shell is deprecated; use cyshell" (mkCyShell pkgs);
};
in
{
packages = forEachSystem (
system: pkgs: {
cyshell = mkCyShell pkgs;
dms-shell = builtins.warn "CyShell: package name dms-shell is deprecated; use cyshell" self.packages.${system}.cyshell;
default = self.packages.${system}.cyshell;
quickshell = builtins.warn "CyShell does not bundle Quickshell as a separate package; use nixpkgs or the upstream Quickshell flake." pkgs.quickshell;
}
);
lib = { inherit mkCyShell buildCyShellPkgs; };
homeModules.cyshell = mkModuleWithCyShellPkgs ./distro/nix/home.nix;
homeModules.default = self.homeModules.cyshell;
homeModules.dank-material-shell = builtins.warn "CyShell: homeModules.dank-material-shell is deprecated; use homeModules.cyshell" self.homeModules.cyshell;
homeModules.dankMaterialShell.default = builtins.warn "CyShell: homeModules.dankMaterialShell.default is deprecated; use homeModules.cyshell" self.homeModules.cyshell;
# Kept only as a migration surface for old Niri configurations; CyShell itself targets Labwc.
homeModules.niri = import ./distro/nix/niri.nix;
homeModules.dankMaterialShell.niri = builtins.warn "CyShell: the legacy Niri module is compatibility-only" self.homeModules.niri;
nixosModules.cyshell = mkModuleWithCyShellPkgs ./distro/nix/nixos.nix;
nixosModules.default = self.nixosModules.cyshell;
nixosModules.dank-material-shell = builtins.warn "CyShell: nixosModules.dank-material-shell is deprecated; use nixosModules.cyshell" self.nixosModules.cyshell;
nixosModules.dankMaterialShell = builtins.warn "CyShell: nixosModules.dankMaterialShell is deprecated; use nixosModules.cyshell" self.nixosModules.cyshell;
nixosModules.greeter = builtins.warn "CyShell Greeter is managed separately; the legacy dms-greeter integration remains external compatibility" { };
devShells = forEachSystem (
system: pkgs:
let
devQmlPkgs = with pkgs;
[
quickshell
kdePackages.qtdeclarative
]
++ (qmlPkgs pkgs);
# the surface fixtures run niri on winit/X11, which dlopens these
niriForTests = pkgs.symlinkJoin {
name = "niri-x11";
paths = [ pkgs.niri ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/niri --prefix LD_LIBRARY_PATH : ${
pkgs.lib.makeLibraryPath [
(pkgs.libx11 or pkgs.xorg.libX11)
(pkgs.libxcb or pkgs.xorg.libxcb)
(pkgs.libxcursor or pkgs.xorg.libXcursor)
(pkgs.libxi or pkgs.xorg.libXi)
]
}
'';
};
in
{
default = pkgs.mkShell {
buildInputs =
with pkgs;
[
(goForPkgs pkgs)
go-mockery
gopls
delve
go-tools
gnumake
nodejs
(python3.withPackages (ps: [ ps.dbus-next ]))
prek
uv # for prek
shellcheck
# Nix development tools
nixd
nil
]
++ devQmlPkgs
++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [ niriForTests pkgs.xvfb pkgs.dbus ];
shellHook = ''
touch quickshell/.qmlls.ini 2>/dev/null
if [ ! -f .git/hooks/pre-commit ]; then prek install; fi
'';
QML2_IMPORT_PATH = mkQmlImportPath pkgs devQmlPkgs;
QT_PLUGIN_PATH = mkQtPluginPath pkgs devQmlPkgs;
};
}
);
nixosTests = forEachLinuxSystem (
system: pkgs:
import ./distro/nix/tests {
inherit
self
pkgs
;
lib = pkgs.lib;
}
);
};
}