Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,16 @@ jobs:
ls -la $(nix path-info .#default)/ || echo "result directory contents"
echo "Checking $out/bin directory:"
ls -la $(nix path-info .#default)/bin/ || echo "$out/bin not found"

# Verify static binary
BINARY_PATH="$(nix path-info .#default)/bin/godon_cli"
echo "=== Binary information ==="
file "$BINARY_PATH"
echo "=== Dynamic libraries check (should show 'not a dynamic executable' or similar) ==="
ldd "$BINARY_PATH" || echo "✅ Binary appears to be statically linked (ldd failed as expected)"

echo "Testing compiled binary with direct path..."
$(nix path-info .#default)/bin/godon_cli --help
"$BINARY_PATH" --help

- name: Start Prism mock container
run: |
Expand Down
25 changes: 19 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
let
pkgs = nixpkgs.legacyPackages.${system};

# Build using nimble following the godon-api pattern
# Build static binary using glibc with proper static libraries
godon-cli = { version ? (if builtins.getEnv "GODON_VERSION" == "" then "DEV_BUILD" else builtins.getEnv "GODON_VERSION") }: pkgs.stdenv.mkDerivation {
pname = "godon-cli";
inherit version;
Expand All @@ -22,7 +22,12 @@
nim2
nimble
git
pkg-config
];

buildInputs = with pkgs; [
openssl.dev
libgcc
];

env = {
Expand All @@ -36,21 +41,29 @@
'';

buildPhase = ''
echo "Building godon-cli version: ${version}"
echo "Building godon-cli version: ${version} (static binary)"

# Refresh package list and install dependencies only
nimble refresh --verbose
# Install yaml dependency without building our package
nimble install -y --depsOnly --verbose

# Build the CLI
# Build the CLI with static linking using glibc
mkdir -p bin
nim c --hints:on --path:src -d:release -d:VERSION="${version}" -o:bin/godon_cli src/godon_cli.nim || {
nim c --hints:on --path:src -d:release -d:ssl -d:VERSION="${version}" \
--passL:"-static-libgcc" \
-o:bin/godon_cli src/godon_cli.nim || {
echo "Compilation failed"
exit 1
}

echo "Build completed successfully!"
echo "Static build completed successfully!"

# Verify the binary is statically linked
echo "=== Binary information ==="
file bin/godon_cli
echo "=== Dynamic libraries check (should show 'not a dynamic executable' or similar) ==="
ldd bin/godon_cli || echo "Binary appears to be statically linked (ldd failed as expected)"
'';

installPhase = ''
Expand All @@ -64,7 +77,7 @@
meta = with pkgs.lib; {
description = "CLI for the Godon API";
license = licenses.agpl3Only;
platforms = platforms.all;
platforms = platforms.linux;
};
};

Expand Down