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
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build and Test Godon CLI

on:
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-25.11
extra_nix_config: |
sandbox = false
sandbox-paths = /etc/ssl/certs/ca-bundle.crt
experimental-features = nix-command flakes

- name: Configure Nix daemon SSL certificates
run: |
# Find and symlink SSL certificates for Nix daemon
sudo mkdir -p /etc/ssl/certs
CERT_BUNDLE=$(find /nix/store -name "ca-bundle.crt" | head -1)
echo "Found certificate bundle: $CERT_BUNDLE"
sudo ln -sf "$CERT_BUNDLE" /etc/ssl/certs/ca-bundle.crt
sudo ln -sf "$CERT_BUNDLE" /etc/ssl/certs/ca-certificates.crt

# Set environment variables for this session
export SSL_CERT_FILE="/etc/ssl/certs/ca-bundle.crt"
export NIX_SSL_CERT_FILE="/etc/ssl/certs/ca-bundle.crt"
export CURL_CA_BUNDLE="/etc/ssl/certs/ca-bundle.crt"

# Add to nix.conf for daemon
echo "ssl-cert-file = /etc/ssl/certs/ca-bundle.crt" | sudo tee -a /etc/nix/nix.conf

echo "SSL certificates configured for Nix daemon"

- name: Build with Nix
run: |
export SSL_CERT_FILE="/etc/ssl/certs/ca-bundle.crt"
export NIX_SSL_CERT_FILE="/etc/ssl/certs/ca-bundle.crt"
export CURL_CA_BUNDLE="/etc/ssl/certs/ca-bundle.crt"
nix --experimental-features "nix-command flakes" build --verbose

- name: Test binary
run: |
echo "Checking build output..."
echo "Result path:"
nix path-info .#default
echo "Contents of result directory:"
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"
echo "Testing compiled binary with direct path..."
$(nix path-info .#default)/bin/godon_cli --help
91 changes: 91 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
description = "Godon CLI - Nim-based CLI for Godon API";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};

# Build using nimble following the godon-api pattern
godon-cli = { version ? "DEV_BUILD" }: pkgs.stdenv.mkDerivation {
pname = "godon-cli";
inherit version;
src = ./.;

nativeBuildInputs = with pkgs; [
cacert
nim2
nimble
git
openssl.dev
];

env = {
SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
NIX_SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
CURL_CA_BUNDLE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
};

configurePhase = ''
export HOME=$TMPDIR
'';

buildPhase = ''
echo "Building godon-cli version: ${version}"

# Refresh package list and build
nimble refresh

# Build the CLI
mkdir -p bin
nim c --hints:on --path:src -d:release -d:VERSION="${version}" -o:bin/godon_cli src/godon_cli.nim || {
echo "Compilation failed"
exit 1
}

echo "Build completed successfully!"
'';

installPhase = ''
mkdir -p $out/bin

# Install the binary
cp bin/godon_cli $out/bin/godon_cli
chmod +x $out/bin/godon_cli
'';

meta = with pkgs.lib; {
description = "CLI for the Godon API";
license = licenses.agpl3Only;
platforms = platforms.all;
};
};

in {
packages.default = godon-cli { };
packages.godon-cli = godon-cli;

# Allow building with custom version
packages.godon-cli-custom = version: godon-cli { inherit version; };

# Development shell with Nim and build tools
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
nim2
nimble
git
];

shellHook = ''
echo "Godon CLI development environment"
echo "Nim: $(nim --version | head -n1)"
echo "Nimble: $(nimble --version | head -n1)"
'';
};
});
}
38 changes: 38 additions & 0 deletions godon_cli.nimble
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Package information

version = "0.1.0"
author = "Matthias Tafelmeier"
description = "CLI for the Godon API"
license = "AGPL-3.0"

# Dependencies

requires "nim >= 2.0.0"

# Task definitions

task build, "Build the CLI":
exec "nim c -d:release -o:bin/godon_cli src/godon_cli.nim"

task build_debug, "Build the CLI with debug symbols":
exec "nim c -g -o:bin/godon_cli src/godon_cli.nim"

task clean, "Clean build artifacts":
exec "rm -rf bin"

task test, "Run tests":
exec "nim c -r tests/test_all.nim"

task docker_build, "Build Docker image":
exec "docker build -t godon-cli:latest ."

task docker_run, "Run Docker image":
exec "docker run --rm -it godon-cli:latest --help"

# Binary definition
bin = @["godon_cli"]

# Install script (when installed via nimble)
installDirs = @["bin"]
installFiles = @["bin/godon_cli"]
installExt = @[]
186 changes: 0 additions & 186 deletions maskfile.md

This file was deleted.

Loading