Skip to content

Commit 0f21a20

Browse files
committed
trying nix bundle
1 parent 03be1ff commit 0f21a20

File tree

2 files changed

+75
-30
lines changed

2 files changed

+75
-30
lines changed

.github/workflows/release.yml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,33 @@ jobs:
2929
- name: Install Nix
3030
uses: DeterminateSystems/determinate-nix-action@v3
3131

32-
- uses: Swatinem/rust-cache@v2
33-
with:
34-
workspaces: src-tauri
35-
cache-on-failure: true
36-
3732
- name: Setup swap space
3833
uses: actionhippie/swap-space@v1
3934
with:
4035
size: 8G
4136

42-
- name: Build with Tauri (in Nix shell)
37+
- name: Build with Nix
38+
run: nix build .#packages.${{ matrix.system }}.default --accept-flake-config
39+
40+
- name: Create portable bundle
4341
run: |
44-
nix develop .# --impure --accept-flake-config -c \
45-
bash -c "npm install && npm run tauri build"
42+
# Create a self-contained bundle with all Nix dependencies
43+
nix bundle .#packages.${{ matrix.system }}.default --accept-flake-config -o korppi-bundle
44+
ls -la korppi-bundle* || true
4645
47-
- name: Upload AppImage
46+
- name: Upload bundle
4847
uses: actions/upload-artifact@v4
4948
with:
50-
name: korppi-${{ matrix.system }}-appimage
51-
path: src-tauri/target/release/bundle/appimage/*.AppImage
49+
name: korppi-${{ matrix.system }}-bundle
50+
path: korppi-bundle*
5251
if-no-files-found: warn
5352

54-
- name: Upload deb
53+
- name: Upload binary (for NixOS)
5554
uses: actions/upload-artifact@v4
5655
with:
57-
name: korppi-${{ matrix.system }}-deb
58-
path: src-tauri/target/release/bundle/deb/*.deb
59-
if-no-files-found: warn
56+
name: korppi-${{ matrix.system }}-nix
57+
path: result/bin/*
58+
if-no-files-found: error
6059

6160

6261
# ─────────────────────────────────────────────

flake.nix

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
version = "0.1.0";
121121
src = ./.;
122122

123-
npmDepsHash = "sha256-EQrl4cNLxpkv+2s9kqqP5aFrjOmQLGKqghONdM/p7UM="; # Will need to update
123+
npmDepsHash = "sha256-EQrl4cNLxpkv+2s9kqqP5aFrjOmQLGKqghONdM/p7UM=";
124124

125125
buildPhase = ''
126126
npm run build
@@ -139,10 +139,8 @@
139139

140140
src = ./.;
141141

142-
# Point to the subdirectory containing Cargo.toml
143142
cargoRoot = "src-tauri";
144143

145-
# cargoLock must be an attrset with lockFile
146144
cargoLock = {
147145
lockFile = ./src-tauri/Cargo.lock;
148146
};
@@ -151,34 +149,82 @@
151149
pkgs.pkg-config
152150
pkgs.cmake
153151
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [
154-
pkgs.mold # Fast linker for Linux
155-
pkgs.clang # Needed for mold integration
152+
pkgs.mold
153+
pkgs.clang
156154
];
157155

158156
buildInputs = commonDeps ++ darwinDeps ++ linuxDeps ++ [
159-
pkgs.bzip2 # Required for zip/docx support
157+
pkgs.bzip2
160158
];
161159

162-
# Skip tests during package build (run separately with cargo test)
163160
doCheck = false;
164161

165-
# Use mold linker on Linux for faster linking
166162
RUSTFLAGS = pkgs.lib.optionalString pkgs.stdenv.isLinux "-C linker=clang -C link-arg=-fuse-ld=mold";
167163

168-
# Copy pre-built frontend and cd to cargo root
169164
preBuild = ''
170-
echo "=== Copying pre-built frontend ==="
171165
cp -r ${frontend}/dist ./dist
172-
echo "=== Changing to src-tauri ==="
173166
cd src-tauri
174167
'';
175168
};
176169

177-
# AppImage is just the binary for now
178-
# TODO: Proper AppImage bundling can be added later
179-
appimage = korppi-bin;
170+
# Create AppImage using nix-bundle approach
171+
appimage = pkgs.stdenv.mkDerivation {
172+
pname = "korppi-appimage";
173+
version = "0.1.0";
174+
175+
nativeBuildInputs = [ pkgs.appimage-run pkgs.squashfsTools ];
176+
177+
# No source needed, we're wrapping an existing derivation
178+
dontUnpack = true;
179+
180+
buildPhase = ''
181+
# Create a wrapper script that sets up the Nix environment
182+
mkdir -p AppDir/usr/bin
183+
184+
# Copy the binary
185+
cp ${korppi-bin}/bin/korppi-prototype AppDir/usr/bin/korppi
186+
187+
# Create desktop file
188+
cat > AppDir/korppi.desktop <<EOF
189+
[Desktop Entry]
190+
Name=Korppi
191+
Exec=korppi
192+
Type=Application
193+
Categories=Utility;Office;
194+
Icon=korppi
195+
Terminal=false
196+
EOF
197+
198+
# Create minimal icon
199+
mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps
200+
echo '' > AppDir/usr/share/icons/hicolor/256x256/apps/korppi.png
201+
202+
# Create AppRun that sets library paths
203+
cat > AppDir/AppRun <<'APPRUN'
204+
#!/bin/bash
205+
SELF=$(readlink -f "$0")
206+
HERE=$(dirname "$SELF")
207+
export PATH="$HERE/usr/bin:$PATH"
208+
export LD_LIBRARY_PATH="$HERE/usr/lib:$LD_LIBRARY_PATH"
209+
exec "$HERE/usr/bin/korppi" "$@"
210+
APPRUN
211+
chmod +x AppDir/AppRun
212+
213+
# Copy all required libraries from Nix store
214+
mkdir -p AppDir/usr/lib
215+
for lib in $(ldd ${korppi-bin}/bin/korppi-prototype | grep "=> /nix" | awk '{print $3}'); do
216+
cp -L "$lib" AppDir/usr/lib/ 2>/dev/null || true
217+
done
218+
'';
219+
220+
installPhase = ''
221+
mkdir -p $out
222+
cp -r AppDir $out/
223+
# The actual AppImage creation would need appimagetool
224+
# For now, output the AppDir which can be run directly
225+
'';
226+
};
180227
181-
# Default package = built binary
182228
default = korppi-bin;
183229
};
184230

0 commit comments

Comments
 (0)