-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
223 lines (198 loc) · 6.67 KB
/
flake.nix
File metadata and controls
223 lines (198 loc) · 6.67 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
{
description = "SimpleS3 – A simple S3 client desktop application";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
let
pkgs = import nixpkgs { inherit system; };
version = "0.1.0";
# -- Native build tools (compilers, pkg-config, cmake, etc.) ----------
nativeBuildDeps = with pkgs; [
pkg-config
cmake # needed by aws-lc-sys
perl # needed by aws-lc-sys build scripts
rustPlatform.bindgenHook
];
# -- Libraries needed at build time (linked via pkg-config) -----------
buildLibs = with pkgs; [
gtk3
glib
cairo
pango
atk
gdk-pixbuf
webkitgtk_4_1
libsoup_3
openssl
dbus # for keyring crate (async-secret-service)
];
# -- Runtime libraries for the wrapped binary -------------------------
runtimeLibs = with pkgs; [
gtk3
glib
cairo
pango
atk
gdk-pixbuf
webkitgtk_4_1
libsoup_3
dbus
mesa
libGL
];
# =====================================================================
# Phase A: Build the frontend (React + Webpack → dist/)
# =====================================================================
frontend = pkgs.stdenv.mkDerivation {
pname = "simples3-frontend";
inherit version;
src = pkgs.lib.fileset.toSource {
root = ./.;
fileset = pkgs.lib.fileset.unions [
./package.json
./package-lock.json
./tsconfig.json
./webpack.config.cjs
./postcss.config.js
./tailwind.config.js
./index.html
./src
];
};
npmDeps = pkgs.fetchNpmDeps {
src = pkgs.lib.fileset.toSource {
root = ./.;
fileset = pkgs.lib.fileset.unions [
./package.json
./package-lock.json
];
};
hash = "sha256-OWVs+L+8keoMaZgOk4SXwpsvBu6S3EQ31kG9Mi0wYEc=";
};
nativeBuildInputs = with pkgs; [
nodejs
npmHooks.npmConfigHook
];
buildPhase = ''
runHook preBuild
npx webpack --mode production
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp -r dist $out
runHook postInstall
'';
};
# =====================================================================
# Phase B: Build the Rust/Tauri binary
# =====================================================================
simples3 = pkgs.rustPlatform.buildRustPackage {
pname = "simples3";
inherit version;
# Include the whole project root so that ../dist resolves correctly
# when tauri_build::build() reads tauri.conf.json's frontendDist.
src = pkgs.lib.fileset.toSource {
root = ./.;
fileset = pkgs.lib.fileset.unions [
./src-tauri/Cargo.toml
./src-tauri/Cargo.lock
./src-tauri/src
./src-tauri/build.rs
./src-tauri/capabilities
./src-tauri/gen
./src-tauri/icons
./src-tauri/tauri.conf.json
./src-tauri/Info.plist
./src-tauri/entitlements.plist
];
};
sourceRoot = "source/src-tauri";
cargoHash = "sha256-gvROZ4JtGo3kZ4PNP/r1pxs9hooPAMmsNsX2WoMmjpE=";
# Enable embedded asset serving (the Tauri CLI passes this
# automatically during `tauri build`, but we use plain cargo).
buildFeatures = [ "custom-protocol" ];
# Place the pre-built frontend where tauri expects it (../dist).
# The source directory may be read-only after unpack, so ensure
# it is writable before creating the symlink.
postUnpack = ''
chmod u+w source
ln -s ${frontend} source/dist
'';
nativeBuildInputs = nativeBuildDeps ++ [ pkgs.wrapGAppsHook3 ];
buildInputs = buildLibs;
# Set NixOS-specific env vars on the wrapper
preFixup = ''
gappsWrapperArgs+=(
--set GDK_BACKEND x11
--set WEBKIT_DISABLE_DMABUF_RENDERER 1
--prefix LD_LIBRARY_PATH : "${pkgs.lib.makeLibraryPath runtimeLibs}"
)
'';
postInstall = ''
# Desktop entry
mkdir -p $out/share/applications
cat > $out/share/applications/simples3.desktop << DESKTOP
[Desktop Entry]
Name=SimpleS3
Comment=A simple S3 client desktop application
Exec=$out/bin/simples3
Icon=simples3
Terminal=false
Type=Application
Categories=Network;FileTransfer;Utility;
DESKTOP
# Icons
for size in 32x32 64x64 128x128; do
if [ -f icons/''${size}.png ]; then
install -Dm644 icons/''${size}.png \
$out/share/icons/hicolor/''${size}/apps/simples3.png
fi
done
if [ -f icons/128x128@2x.png ]; then
install -Dm644 icons/128x128@2x.png \
$out/share/icons/hicolor/256x256/apps/simples3.png
fi
if [ -f icons/icon.png ]; then
install -Dm644 icons/icon.png \
$out/share/icons/hicolor/512x512/apps/simples3.png
fi
if [ -f icons/icon.svg ]; then
install -Dm644 icons/icon.svg \
$out/share/icons/hicolor/scalable/apps/simples3.svg
fi
'';
meta = with pkgs.lib; {
description = "A simple S3 client desktop application";
license = licenses.gpl3Only;
platforms = platforms.linux;
mainProgram = "simples3";
};
};
in {
packages = {
inherit simples3 frontend;
default = simples3;
};
devShells.default = pkgs.mkShell {
inputsFrom = [ simples3 ];
packages = with pkgs; [
cargo-tauri
bun
nodejs
rustc
cargo
clippy
rustfmt
];
shellHook = ''
export GDK_BACKEND=x11
export WEBKIT_DISABLE_DMABUF_RENDERER=1
'';
};
}
);
}