-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
275 lines (240 loc) · 8.76 KB
/
flake.nix
File metadata and controls
275 lines (240 loc) · 8.76 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
rust-overlay,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system: let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {
inherit system overlays;
};
in {
devShells.default = pkgs.mkShell {
buildInputs = with pkgs;
[
# System dependencies for reqwest/openssl
pkg-config
openssl
just
# WASM development
# wasm-pack
# nodejs
# nodePackages.npm
# For TUI development
libiconv
# Linux-specific dependencies for GUI applications
]
++ pkgs.lib.optionals pkgs.stdenv.isLinux [
# Tauri dependencies
gtk3
webkitgtk_4_1
librsvg
libsoup_3
libappindicator-gtk3
xdotool
# Linux-specific tools
# Dioxus development tools (only on Linux to avoid webkitgtk issues on macOS)
dioxus-cli
# AppImage tooling
appimage-run
]
++ pkgs.lib.optionals (!pkgs.stdenv.isDarwin) [
# Image processing for icon generation (may not support all platforms)
imagemagick
]
++ [
# GitHub CLI for monitoring releases (cross-platform)
gh
]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
# macOS specific dependencies
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.SystemConfiguration
# Rust toolchain and Dioxus CLI for macOS
(rust-bin.stable.latest.default.override {
extensions = ["rust-src"];
})
dioxus-cli
];
# Environment variables
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
# For OpenSSL on some systems
OPENSSL_DIR = "${pkgs.openssl.dev}";
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include";
WEBKIT_DISABLE_DMABUF_RENDERER = 1;
shellHook = pkgs.lib.optionalString pkgs.stdenv.isLinux ''
# Add library paths for system tray functionality on Linux
export LD_LIBRARY_PATH="${pkgs.libappindicator-gtk3}/lib:${pkgs.gtk3}/lib:$LD_LIBRARY_PATH"
'';
};
# Optional: Define the package itself
packages.scrobble-scrubber = pkgs.rustPlatform.buildRustPackage {
pname = "scrobble-scrubber";
version = "0.1.0";
src = ./scrobble-scrubber;
cargoLock = {
lockFile = ./scrobble-scrubber/Cargo.lock;
};
nativeBuildInputs = with pkgs; [
pkg-config
];
buildInputs = with pkgs;
[
openssl
]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.SystemConfiguration
];
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
};
# Dioxus app package
packages.app = pkgs.rustPlatform.buildRustPackage {
pname = "scrobble-scrubber-app";
version = "0.1.0";
src = let
# Use gitignore.nix to respect .gitignore files
gitignoreSource =
pkgs.nix-gitignore.gitignoreSourcePure [
"*.nix"
"result"
"result-*"
".envrc"
".direnv"
"CLAUDE.md"
]
./.;
in
gitignoreSource;
cargoHash = "sha256-49c94gytQ9Ko1SzP8DMVCgHe+kZF1QgIfPg8AoJUmtU=";
nativeBuildInputs = with pkgs; [
pkg-config
dioxus-cli
ccache
];
buildInputs = with pkgs;
[
openssl
]
++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.SystemConfiguration
darwin.apple_sdk.frameworks.WebKit
darwin.apple_sdk.frameworks.AppKit
]
++ lib.optionals stdenv.isLinux [
gtk3
webkitgtk_4_1
librsvg
libsoup_3
libappindicator-gtk3
xdotool
];
# Skip the default checks
doCheck = false;
# Override the build phase to use platform-specific building
buildPhase = ''
runHook preBuild
# Ensure we're in the app directory
cd app
# Copy assets for bundling
mkdir -p assets
cp -r ${./app/assets}/* assets/
# Platform-specific build
${
if pkgs.stdenv.isDarwin
then ''
# macOS: Use dx bundle to create .app bundle
dx bundle --release --platform macos --package-types macos
''
else if pkgs.stdenv.isLinux
then ''
# Linux: Use dx build to avoid AppImage sandbox issues
dx build --release
''
else ''
# Windows: Use dx bundle for MSI
dx bundle --release --platform windows --package-types msi
''
}
echo "Build phase completed"
# Return to source root
cd ..
runHook postBuild
'';
# Install the platform-specific output
installPhase = ''
runHook preInstall
mkdir -p $out
# Platform-specific installation
${
if pkgs.stdenv.isDarwin
then ''
# macOS: Install the .app bundle
APP_PATH="target/dx/scrobble-scrubber-app/bundle/macos/bundle/macos/ScrobbleScrubberApp.app"
if [ -d "$APP_PATH" ]; then
echo "Found app bundle at: $APP_PATH"
cp -r "$APP_PATH" $out/
# Create a wrapper script for easier execution
mkdir -p $out/bin
echo '#!/bin/sh' > $out/bin/scrobble-scrubber-app
echo 'exec "'"$out"'"/ScrobbleScrubberApp.app/Contents/MacOS/scrobble-scrubber-app" "$@"' >> $out/bin/scrobble-scrubber-app
chmod +x $out/bin/scrobble-scrubber-app
else
echo "ERROR: App bundle not found at expected location: $APP_PATH"
echo "Contents of target directory:"
find target -type d -name "*.app" 2>/dev/null || echo "No target directory found"
exit 1
fi
''
else if pkgs.stdenv.isLinux
then ''
# Linux: Install the binary
BINARY_PATH="target/release/scrobble-scrubber-app"
if [ -f "$BINARY_PATH" ]; then
mkdir -p $out/bin
echo "Found binary at: $BINARY_PATH"
cp "$BINARY_PATH" $out/bin/scrobble-scrubber-app
chmod +x $out/bin/scrobble-scrubber-app
else
echo "ERROR: Binary not found at expected location: $BINARY_PATH"
echo "Contents of target/release directory:"
ls -la target/release/ 2>/dev/null || echo "No target/release directory found"
exit 1
fi
''
else ''
# Windows: Install the MSI
EXE_PATH=$(find target/dx -name "*.exe" -o -name "*.msi" 2>/dev/null | head -1)
if [ -n "$EXE_PATH" ]; then
mkdir -p $out/bin
cp "$EXE_PATH" $out/bin/
else
echo "ERROR: Windows executable not found!"
exit 1
fi
''
}
runHook postInstall
'';
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
OPENSSL_DIR = "${pkgs.openssl.dev}";
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include";
};
packages.default = self.packages.${system}.scrobble-scrubber;
}
);
}