Skip to content

Commit ef5abe4

Browse files
committed
regenerate cli to nimlang and add nix build
1 parent e4dde84 commit ef5abe4

File tree

8 files changed

+576
-186
lines changed

8 files changed

+576
-186
lines changed

.github/workflows/ci.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Build and Test Godon CLI
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Install Nix
16+
uses: cachix/install-nix-action@v25
17+
with:
18+
nix_path: nixpkgs=channel:nixos-25.11
19+
extra_nix_config: |
20+
sandbox = false
21+
sandbox-paths = /etc/ssl/certs/ca-bundle.crt
22+
experimental-features = nix-command flakes
23+
24+
- name: Configure Nix daemon SSL certificates
25+
run: |
26+
# Find and symlink SSL certificates for Nix daemon
27+
sudo mkdir -p /etc/ssl/certs
28+
CERT_BUNDLE=$(find /nix/store -name "ca-bundle.crt" | head -1)
29+
echo "Found certificate bundle: $CERT_BUNDLE"
30+
sudo ln -sf "$CERT_BUNDLE" /etc/ssl/certs/ca-bundle.crt
31+
sudo ln -sf "$CERT_BUNDLE" /etc/ssl/certs/ca-certificates.crt
32+
33+
# Set environment variables for this session
34+
export SSL_CERT_FILE="/etc/ssl/certs/ca-bundle.crt"
35+
export NIX_SSL_CERT_FILE="/etc/ssl/certs/ca-bundle.crt"
36+
export CURL_CA_BUNDLE="/etc/ssl/certs/ca-bundle.crt"
37+
38+
# Add to nix.conf for daemon
39+
echo "ssl-cert-file = /etc/ssl/certs/ca-bundle.crt" | sudo tee -a /etc/nix/nix.conf
40+
41+
echo "SSL certificates configured for Nix daemon"
42+
43+
- name: Build with Nix
44+
run: |
45+
export SSL_CERT_FILE="/etc/ssl/certs/ca-bundle.crt"
46+
export NIX_SSL_CERT_FILE="/etc/ssl/certs/ca-bundle.crt"
47+
export CURL_CA_BUNDLE="/etc/ssl/certs/ca-bundle.crt"
48+
nix --experimental-features "nix-command flakes" build --verbose
49+
50+
- name: Test binary
51+
run: |
52+
echo "Checking build output..."
53+
echo "Result path:"
54+
nix path-info .#default
55+
echo "Contents of result directory:"
56+
ls -la $(nix path-info .#default)/ || echo "result directory contents"
57+
echo "Checking $out/bin directory:"
58+
ls -la $(nix path-info .#default)/bin/ || echo "$out/bin not found"
59+
echo "Testing compiled binary with direct path..."
60+
$(nix path-info .#default)/bin/godon_cli --help

flake.nix

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
description = "Godon CLI - Nim-based CLI for Godon API";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils }:
10+
flake-utils.lib.eachDefaultSystem (system:
11+
let
12+
pkgs = nixpkgs.legacyPackages.${system};
13+
14+
# Build using nimble following the godon-api pattern
15+
godon-cli = { version ? "DEV_BUILD" }: pkgs.stdenv.mkDerivation {
16+
pname = "godon-cli";
17+
inherit version;
18+
src = ./.;
19+
20+
nativeBuildInputs = with pkgs; [
21+
cacert
22+
nim2
23+
nimble
24+
git
25+
openssl.dev
26+
];
27+
28+
env = {
29+
SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
30+
NIX_SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
31+
CURL_CA_BUNDLE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
32+
};
33+
34+
configurePhase = ''
35+
export HOME=$TMPDIR
36+
'';
37+
38+
buildPhase = ''
39+
echo "Building godon-cli version: ${version}"
40+
41+
# Refresh package list and build
42+
nimble refresh
43+
44+
# Build the CLI
45+
mkdir -p bin
46+
nim c --hints:on --path:src -d:release -d:VERSION="${version}" -o:bin/godon_cli src/godon_cli.nim || {
47+
echo "Compilation failed"
48+
exit 1
49+
}
50+
51+
echo "Build completed successfully!"
52+
'';
53+
54+
installPhase = ''
55+
mkdir -p $out/bin
56+
57+
# Install the binary
58+
cp bin/godon_cli $out/bin/godon_cli
59+
chmod +x $out/bin/godon_cli
60+
'';
61+
62+
meta = with pkgs.lib; {
63+
description = "CLI for the Godon API";
64+
license = licenses.agpl3Only;
65+
platforms = platforms.all;
66+
};
67+
};
68+
69+
in {
70+
packages.default = godon-cli { };
71+
packages.godon-cli = godon-cli;
72+
73+
# Allow building with custom version
74+
packages.godon-cli-custom = version: godon-cli { inherit version; };
75+
76+
# Development shell with Nim and build tools
77+
devShells.default = pkgs.mkShell {
78+
buildInputs = with pkgs; [
79+
nim2
80+
nimble
81+
git
82+
];
83+
84+
shellHook = ''
85+
echo "Godon CLI development environment"
86+
echo "Nim: $(nim --version | head -n1)"
87+
echo "Nimble: $(nimble --version | head -n1)"
88+
'';
89+
};
90+
});
91+
}

godon_cli.nimble

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Package information
2+
3+
version = "0.1.0"
4+
author = "Matthias Tafelmeier"
5+
description = "CLI for the Godon API"
6+
license = "AGPL-3.0"
7+
8+
# Dependencies
9+
10+
requires "nim >= 2.0.0"
11+
12+
# Task definitions
13+
14+
task build, "Build the CLI":
15+
exec "nim c -d:release -o:bin/godon_cli src/godon_cli.nim"
16+
17+
task build_debug, "Build the CLI with debug symbols":
18+
exec "nim c -g -o:bin/godon_cli src/godon_cli.nim"
19+
20+
task clean, "Clean build artifacts":
21+
exec "rm -rf bin"
22+
23+
task test, "Run tests":
24+
exec "nim c -r tests/test_all.nim"
25+
26+
task docker_build, "Build Docker image":
27+
exec "docker build -t godon-cli:latest ."
28+
29+
task docker_run, "Run Docker image":
30+
exec "docker run --rm -it godon-cli:latest --help"
31+
32+
# Binary definition
33+
bin = @["godon_cli"]
34+
35+
# Install script (when installed via nimble)
36+
installDirs = @["bin"]
37+
installFiles = @["bin/godon_cli"]
38+
installExt = @[]

maskfile.md

Lines changed: 0 additions & 186 deletions
This file was deleted.

0 commit comments

Comments
 (0)