Skip to content

Commit 8b780df

Browse files
committed
Appimage refactor - Step 2
.agents/codebase-insights.txt: appimage-scripts/build_appimage2.sh: nix/packages/default.nix: node-packages/yarn-project.nix: result-bin: result-man: Signed-off-by: Tzanko Matev <[email protected]>
1 parent be7afbf commit 8b780df

File tree

3 files changed

+48
-80
lines changed

3 files changed

+48
-80
lines changed

.agents/codebase-insights.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@
2424
- `ct record` verifies that `codetracer_python_recorder` is importable before launching the db backend and prints actionable guidance if the module is missing or broken.
2525
- Sudoku test-program datasets include intentionally invalid boards (e.g., examples #3 and #6) with duplicate digits inside a sub-grid; solvers should detect and report these gracefully.
2626
- `appimage-scripts/build_appimage.sh` assumes a devshell: it invokes `nix build`/`nix eval` directly and runs `npm install`/`npx yarn`, so it needs host network access and the git worktree metadata that a pure derivation build lacks.
27+
- `appimage-scripts/build_appimage2.sh` relies on `packages.${system}.appimageDeps` producing an AppDir-like tree (bin/, lib/), letting the script populate dependencies with a single `cp`.

appimage-scripts/build_appimage2.sh

Lines changed: 4 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -28,80 +28,19 @@ if [ -e "${ROOT_PATH}/CodeTracer.AppImage" ]; then
2828
fi
2929

3030
rm -rf "${APP_DIR}"
31-
mkdir -p "${APP_DIR}/"{bin,src,lib,views}
31+
mkdir -p "${APP_DIR}"
3232

3333
# This environment variable controls where build artifacts and static resources end up.
3434
export NIX_CODETRACER_EXE_DIR="${APP_DIR}"
3535

3636
CURRENT_NIX_SYSTEM=$(nix eval --impure --raw --expr 'builtins.currentSystem')
3737
APPIMAGE_DEPS=$(nix build "${ROOT_PATH}#packages.${CURRENT_NIX_SYSTEM}.appimageDeps" --no-link --print-out-paths | tail -n1)
3838

39-
copy_lib_from_derivation() {
40-
local lib_name=$1
41-
local copied=false
39+
cp -Lr "${APPIMAGE_DEPS}/." "${APP_DIR}/"
4240

43-
if [ -f "${APPIMAGE_DEPS}/lib/${lib_name}" ]; then
44-
cp -L "${APPIMAGE_DEPS}/lib/${lib_name}" "${APP_DIR}/lib/"
45-
copied=true
46-
fi
41+
chmod -R u+rwX "${APP_DIR}"
4742

48-
if [ -f "${APPIMAGE_DEPS}/lib64/${lib_name}" ]; then
49-
cp -L "${APPIMAGE_DEPS}/lib64/${lib_name}" "${APP_DIR}/lib/"
50-
copied=true
51-
fi
52-
53-
if [ "${copied}" = false ]; then
54-
return 1
55-
fi
56-
57-
return 0
58-
}
59-
60-
copy_required_lib() {
61-
local lib_name=$1
62-
if ! copy_lib_from_derivation "${lib_name}"; then
63-
echo "Required library ${lib_name} is missing from ${APPIMAGE_DEPS}" >&2
64-
exit 1
65-
fi
66-
}
67-
68-
copy_optional_lib() {
69-
local lib_name=$1
70-
if ! copy_lib_from_derivation "${lib_name}"; then
71-
echo "Optional library ${lib_name} not found; continuing." >&2
72-
fi
73-
}
74-
75-
copy_binary_from_derivation() {
76-
local binary_name=$1
77-
local destination="${APP_DIR}/bin/${binary_name}"
78-
79-
if [ ! -f "${APPIMAGE_DEPS}/bin/${binary_name}" ]; then
80-
echo "Required binary ${binary_name} is missing from ${APPIMAGE_DEPS}" >&2
81-
exit 1
82-
fi
83-
84-
cp -L "${APPIMAGE_DEPS}/bin/${binary_name}" "${destination}"
85-
}
86-
87-
# Copy shared libraries that were previously fetched via individual nix build/eval calls.
88-
copy_required_lib "libsqlite3.so.0"
89-
copy_optional_lib "libsqlite3.so"
90-
copy_required_lib "libpcre.so.1"
91-
copy_required_lib "libzip.so.5"
92-
copy_required_lib "libssl.so.3"
93-
copy_optional_lib "libssl.so"
94-
copy_required_lib "libcrypto.so.3"
95-
copy_optional_lib "libcrypto.so"
96-
copy_required_lib "libuv.so.1"
97-
98-
# Copy binaries sourced from Nix packages.
99-
copy_binary_from_derivation "wazero"
100-
copy_binary_from_derivation "cargo-stylus"
101-
copy_binary_from_derivation "nargo"
102-
copy_binary_from_derivation "ctags"
103-
copy_binary_from_derivation "curl"
104-
copy_binary_from_derivation "node"
43+
mkdir -p "${APP_DIR}/bin" "${APP_DIR}/src" "${APP_DIR}/views"
10544

10645
# Install Ruby
10746
bash "${ROOT_PATH}/appimage-scripts/install_ruby.sh"

nix/packages/default.nix

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,50 @@
127127
'';
128128
};
129129

130-
appimageDeps = pkgs.symlinkJoin {
131-
name = "codetracer-appimage-deps";
132-
paths = [
133-
sqlite
134-
pcre
135-
libzip
136-
openssl
137-
libuv
138-
cargo-stylus
139-
wazero
140-
noir
141-
pkgs.universal-ctags
142-
pkgs.curl
143-
pkgs.nodejs_20
130+
appimageDeps = pkgs.runCommand "codetracer-appimage-deps" {
131+
nativeBuildInputs = [
132+
pkgs.bashInteractive
133+
pkgs.coreutils
144134
];
145-
};
135+
} ''
136+
set -euo pipefail
137+
shopt -s nullglob
138+
139+
mkdir -p "$out/bin" "$out/lib"
140+
141+
copy_libs() {
142+
for pattern in "$@"; do
143+
for lib in $pattern; do
144+
cp -L "$lib" "$out/lib/"
145+
done
146+
done
147+
}
148+
149+
copy_bins() {
150+
while [ "$#" -gt 0 ]; do
151+
cp -L "$1" "$out/bin/"
152+
shift
153+
done
154+
}
155+
156+
copy_libs \
157+
${sqlite.out}/lib/libsqlite3.so* \
158+
${pcre.out}/lib/libpcre.so* \
159+
${libzip.out}/lib/libzip.so* \
160+
${openssl.out}/lib/libssl.so* \
161+
${openssl.out}/lib/libcrypto.so* \
162+
${libuv.out}/lib/libuv.so*
163+
164+
copy_bins \
165+
${cargo-stylus}/bin/cargo-stylus \
166+
${wazero}/bin/wazero \
167+
${noir}/bin/nargo \
168+
${pkgs.universal-ctags}/bin/ctags \
169+
${pkgs.curl}/bin/curl \
170+
${pkgs.nodejs_20}/bin/node
171+
172+
chmod +x "$out/bin"/*
173+
'';
146174

147175
indexJavascript = stdenv.mkDerivation {
148176
name = "index.js";

0 commit comments

Comments
 (0)