|
120 | 120 | version = "0.1.0"; |
121 | 121 | src = ./.; |
122 | 122 |
|
123 | | - npmDepsHash = "sha256-EQrl4cNLxpkv+2s9kqqP5aFrjOmQLGKqghONdM/p7UM="; # Will need to update |
| 123 | + npmDepsHash = "sha256-EQrl4cNLxpkv+2s9kqqP5aFrjOmQLGKqghONdM/p7UM="; |
124 | 124 |
|
125 | 125 | buildPhase = '' |
126 | 126 | npm run build |
|
139 | 139 |
|
140 | 140 | src = ./.; |
141 | 141 |
|
142 | | - # Point to the subdirectory containing Cargo.toml |
143 | 142 | cargoRoot = "src-tauri"; |
144 | 143 |
|
145 | | - # cargoLock must be an attrset with lockFile |
146 | 144 | cargoLock = { |
147 | 145 | lockFile = ./src-tauri/Cargo.lock; |
148 | 146 | }; |
|
151 | 149 | pkgs.pkg-config |
152 | 150 | pkgs.cmake |
153 | 151 | ] ++ 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 |
156 | 154 | ]; |
157 | 155 |
|
158 | 156 | buildInputs = commonDeps ++ darwinDeps ++ linuxDeps ++ [ |
159 | | - pkgs.bzip2 # Required for zip/docx support |
| 157 | + pkgs.bzip2 |
160 | 158 | ]; |
161 | 159 |
|
162 | | - # Skip tests during package build (run separately with cargo test) |
163 | 160 | doCheck = false; |
164 | 161 |
|
165 | | - # Use mold linker on Linux for faster linking |
166 | 162 | RUSTFLAGS = pkgs.lib.optionalString pkgs.stdenv.isLinux "-C linker=clang -C link-arg=-fuse-ld=mold"; |
167 | 163 |
|
168 | | - # Copy pre-built frontend and cd to cargo root |
169 | 164 | preBuild = '' |
170 | | - echo "=== Copying pre-built frontend ===" |
171 | 165 | cp -r ${frontend}/dist ./dist |
172 | | - echo "=== Changing to src-tauri ===" |
173 | 166 | cd src-tauri |
174 | 167 | ''; |
175 | 168 | }; |
176 | 169 |
|
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 | + }; |
180 | 227 |
|
181 | | - # Default package = built binary |
182 | 228 | default = korppi-bin; |
183 | 229 | }; |
184 | 230 |
|
|
0 commit comments