-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
279 lines (254 loc) · 9.25 KB
/
flake.nix
File metadata and controls
279 lines (254 loc) · 9.25 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
{
description = "QuickShell Configuration";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
quickshell = {
url = "github:quickshell-mirror/quickshell";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
quickshell,
...
}:
let
forAllSystems = nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
];
nixpkgsFor = forAllSystems (
system:
import nixpkgs {
inherit system;
}
);
in
{
packages = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
quickshellPkg = quickshell.packages.${system}.default;
# Function to replace Stylix placeholders in QML files (similar to stylix-css)
replaceStylixPlaceholders =
content: stylix:
if stylix == null then
content
else
builtins.replaceStrings
[
"@base00@"
"@base01@"
"@base02@"
"@base03@"
"@base04@"
"@base05@"
"@base06@"
"@base07@"
"@base08@"
"@base09@"
"@base0A@"
"@base0B@"
"@base0C@"
"@base0D@"
"@base0E@"
"@base0F@"
"@monoFont@"
"@sansFont@"
]
[
stylix.base00
stylix.base01
stylix.base02
stylix.base03
stylix.base04
stylix.base05
stylix.base06
stylix.base07
stylix.base08
stylix.base09
stylix.base0A
stylix.base0B
stylix.base0C
stylix.base0D
stylix.base0E
stylix.base0F
(stylix.monoFont)
(stylix.sansFont)
]
content;
# Function to create quickshell config with optional commands files
mkQuickshellConfig =
{
commandsPath ? null,
sessionCommandsPath ? null,
interactiveCommandsPath ? null,
stylix ? null,
excludedAppsPath ? null,
keepassPath ? null,
}:
pkgs.stdenv.mkDerivation rec {
pname = "quickshell-config";
version = "0.1.0";
src = ./.;
nativeBuildInputs = [ pkgs.makeWrapper ];
buildInputs = [
quickshellPkg
pkgs.material-symbols
];
installPhase = ''
# Copy all configuration files
mkdir -p $out/share/quickshell-config
cp -r ds modules services shell $out/share/quickshell-config/ 2>/dev/null || true
cp shell.qml $out/share/quickshell-config/
# Process Foundations.qml with Stylix replacement if available
${
if stylix != null then
''
# Use template and replace placeholders
cat > $out/share/quickshell-config/ds/Foundations.qml << 'EOF'
${replaceStylixPlaceholders (builtins.readFile ./ds/Foundations.qml.template) stylix}
EOF
''
else
''
# Use original Foundations.qml as fallback
[ -f ds/Foundations.qml ] && cp ds/Foundations.qml $out/share/quickshell-config/ds/
''
}
# Copy JSON files (use provided paths or default from source)
${
if commandsPath != null then
''cp ${commandsPath} $out/share/quickshell-config/commands.json''
else
''
if [ -f commands.json ]; then
cp commands.json $out/share/quickshell-config/commands.json
else
echo '{"commands":[]}' > $out/share/quickshell-config/commands.json
fi
''
}
${
if sessionCommandsPath != null then
''cp ${sessionCommandsPath} $out/share/quickshell-config/session-commands.json''
else
''
if [ -f session-commands.json ]; then
cp session-commands.json $out/share/quickshell-config/session-commands.json
else
echo '{"commands":[]}' > $out/share/quickshell-config/session-commands.json
fi
''
}
${
if interactiveCommandsPath != null then
''cp ${interactiveCommandsPath} $out/share/quickshell-config/interactive-commands.json''
else
''
if [ -f interactive-commands.json ]; then
cp interactive-commands.json $out/share/quickshell-config/interactive-commands.json
else
echo '{"commands":[]}' > $out/share/quickshell-config/interactive-commands.json
fi
''
}
${
if excludedAppsPath != null then
''cp ${excludedAppsPath} $out/share/quickshell-config/excluded-apps.json''
else
''
if [ -f excluded-apps.json ]; then
cp excluded-apps.json $out/share/quickshell-config/excluded-apps.json
else
echo '{"excludedApps":[]}' > $out/share/quickshell-config/excluded-apps.json
fi
''
}
${
if keepassPath != null then
''cp ${keepassPath} $out/share/quickshell-config/keepass.json''
else
''
if [ -f keepass.json ]; then
cp keepass.json $out/share/quickshell-config/keepass.json
else
echo '{}' > $out/share/quickshell-config/keepass.json
fi
''
}
# Create wrapper scripts
mkdir -p $out/bin
# Create fonts directory and symlink the fonts
mkdir -p $out/share/fonts
ln -s ${pkgs.material-symbols}/share/fonts/TTF $out/share/fonts/
# Main quickshell wrapper
makeWrapper ${quickshellPkg}/bin/quickshell $out/bin/quickshell-config \
--add-flags "--config $out/share/quickshell-config" \
--prefix QML2_IMPORT_PATH : "${quickshellPkg}/lib/qt-6/qml" \
--prefix XDG_DATA_DIRS : "$out/share:${pkgs.material-symbols}/share"
# Launcher toggle script
cat > $out/bin/qs-toggle-launcher << EOF
#!/usr/bin/env bash
${quickshellPkg}/bin/quickshell -c $out/share/quickshell-config ipc call drawers toggle launcher
EOF
chmod +x $out/bin/qs-toggle-launcher
'';
meta = with pkgs.lib; {
description = "Personal QuickShell configuration";
platforms = platforms.linux;
};
};
in
{
default = self.packages.${system}.quickshell-config;
quickshell-config = mkQuickshellConfig { };
# Function to create config with custom commands
withCommands = commandsPath: mkQuickshellConfig { inherit commandsPath; };
# Function to create config with both commands and session commands
withAllCommands =
{
commandsPath ? null,
sessionCommandsPath ? null,
interactiveCommandsPath ? null,
stylix ? null,
excludedAppsPath ? null,
keepassPath ? null,
}:
mkQuickshellConfig {
inherit
commandsPath
sessionCommandsPath
interactiveCommandsPath
stylix
excludedAppsPath
keepassPath
;
};
}
);
# Home Manager module
homeManagerModules.default =
{
config,
lib,
pkgs,
...
}:
{
options.programs.quickshell-config = {
enable = lib.mkEnableOption "quickshell-config";
};
config = lib.mkIf config.programs.quickshell-config.enable {
home.packages = [ self.packages.${pkgs.system}.quickshell-config ];
};
};
# Overlay for easier integration
overlays.default = final: prev: {
quickshell-config = self.packages.${final.system}.quickshell-config;
};
};
}