Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
4a572fc
ci(nix): Add NixOS package distribution
edenreich Dec 1, 2025
c5ebea3
chore: Use pinned versions
edenreich Dec 1, 2025
61d8ac7
fix(nix): Fix build errors and update to modern Nix patterns
edenreich Dec 1, 2025
72be783
fix(ci): Fix ubuntu runner version typo in Build Summary job
edenreich Dec 1, 2025
3b19f58
refactor(nix): Simplify structure following nixpkgs conventions
edenreich Dec 1, 2025
9463c1b
chore(ci): Remove Cachix setup from workflow
edenreich Dec 1, 2025
91aef15
Merge branch 'main' into feat/nixos-package-distribution
edenreich Dec 2, 2025
7eff21e
Merge branch 'main' into feat/nixos-package-distribution
edenreich Dec 2, 2025
84e8ec7
Merge branch 'main' into feat/nixos-package-distribution
edenreich Dec 6, 2025
3199226
Merge branch 'main' into feat/nixos-package-distribution
edenreich Dec 7, 2025
e9e5b17
Merge branch 'main' into feat/nixos-package-distribution
edenreich Dec 10, 2025
530181f
Merge branch 'main' into feat/nixos-package-distribution
edenreich Dec 11, 2025
e31611a
Merge branch 'main' into feat/nixos-package-distribution
edenreich Dec 14, 2025
6bc1074
Merge branch 'main' into feat/nixos-package-distribution
edenreich Dec 19, 2025
110352c
Merge branch 'main' into feat/nixos-package-distribution
edenreich Jan 1, 2026
ee36446
Merge branch 'main' into feat/nixos-package-distribution
edenreich Jan 28, 2026
3851ef1
Merge branch 'main' into feat/nixos-package-distribution
edenreich Mar 6, 2026
06a408b
Merge branch 'main' into feat/nixos-package-distribution
edenreich Apr 9, 2026
1ddd4d1
Merge branch 'main' into feat/nixos-package-distribution
edenreich Apr 16, 2026
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
119 changes: 119 additions & 0 deletions .github/workflows/nix-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Nix Build Verification

on:
pull_request:
branches:
- main
paths:
- 'nix/**'
- 'go.mod'
- 'go.sum'
- '**.go'
- '.github/workflows/nix-build.yml'
push:
branches:
- main
paths:
- 'nix/**'
- 'go.mod'
- 'go.sum'
- '**.go'
- '.github/workflows/nix-build.yml'
workflow_dispatch:

jobs:
nix-build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
platform: linux-amd64
- os: ubuntu-24.04
platform: linux-arm64
- os: macos-15-intel
platform: darwin-amd64
- os: macos-latest
platform: darwin-arm64

steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Install Nix
uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
experimental-features = nix-command flakes
accept-flake-config = true

- name: Build with Nix
run: |
nix-build nix/default.nix --show-trace

- name: Verify binary
run: |
result/bin/infer version
result/bin/infer --help

- name: Check binary size
run: |
ls -lh result/bin/infer
size=$(stat -c%s result/bin/infer 2>/dev/null || stat -f%z result/bin/infer)
echo "Binary size: $(numfmt --to=iec $size 2>/dev/null || echo $size bytes)"

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: infer-${{ matrix.platform }}
path: result/bin/infer
retention-days: 7

nix-fmt-check:
name: Check Nix formatting
runs-on: ubuntu-24.04

steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Install Nix
uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
experimental-features = nix-command flakes

- name: Check Nix formatting
run: |
nix-shell -p nixpkgs-fmt --run "nixpkgs-fmt --check nix/"

- name: Evaluate Nix expression
run: |
nix-instantiate --eval --strict nix/default.nix --show-trace

summary:
name: Build Summary
runs-on: ubuntu-24.04
needs:
- nix-build
- nix-fmt-check
if: always()

steps:
- name: Check build results
run: |
if [ "${{ needs.nix-build.result }}" != "success" ]; then
echo "::error::Nix build failed"
exit 1
fi

if [ "${{ needs.nix-fmt-check.result }}" != "success" ]; then
echo "::error::Nix formatting check failed"
exit 1
fi

echo "✅ All Nix build checks passed!"
147 changes: 147 additions & 0 deletions .github/workflows/nix-version-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: Nix Version Sync

on:
release:
types:
- published
workflow_dispatch:
inputs:
version:
description: 'Version to sync (e.g., 0.76.1)'
required: true
type: string

permissions:
contents: write
pull-requests: write

jobs:
update-nix-version:
name: Update Nix package version
runs-on: ubuntu-24.04

steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Install Nix
uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
experimental-features = nix-command flakes

- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ inputs.version }}"
else
VERSION="${{ github.event.release.tag_name }}"
VERSION="${VERSION#v}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version to sync: $VERSION"

- name: Calculate source hash
id: source-hash
run: |
VERSION="${{ steps.version.outputs.version }}"
URL="https://github.com/inference-gateway/cli/archive/refs/tags/v${VERSION}.tar.gz"

echo "Downloading source from: $URL"
HASH=$(nix-prefetch-url --unpack "$URL")
echo "Source hash: $HASH"
echo "hash=$HASH" >> $GITHUB_OUTPUT

- name: Update version in Nix expression
run: |
VERSION="${{ steps.version.outputs.version }}"
HASH="${{ steps.source-hash.outputs.hash }}"
sed -i "s/version = \"[0-9.]*\";/version = \"$VERSION\";/" nix/infer.nix
sed -i "s|hash = \"sha256-[A-Za-z0-9+/=]*\";|hash = \"sha256-$HASH\";|" nix/infer.nix
echo "Updated nix/infer.nix with version $VERSION"
cat nix/infer.nix | grep -A2 "version ="

- name: Calculate vendor hash
id: vendor-hash
run: |
echo "Attempting build to calculate vendorHash..."
sed -i 's|vendorHash = "sha256-[A-Za-z0-9+/=]*";|vendorHash = "";|' nix/infer.nix
BUILD_OUTPUT=$(nix-build nix/infer.nix 2>&1 || true)
VENDOR_HASH=$(echo "$BUILD_OUTPUT" | grep -oP "got:\s+sha256-\K[A-Za-z0-9+/=]+" | head -1)

if [ -z "$VENDOR_HASH" ]; then
echo "::error::Failed to calculate vendorHash"
echo "$BUILD_OUTPUT"
exit 1
fi

echo "Vendor hash: sha256-$VENDOR_HASH"
echo "hash=$VENDOR_HASH" >> $GITHUB_OUTPUT

- name: Update vendor hash in Nix expression
run: |
VENDOR_HASH="${{ steps.vendor-hash.outputs.hash }}"
sed -i "s|vendorHash = \"[^\"]*\";|vendorHash = \"sha256-$VENDOR_HASH\";|" nix/infer.nix
echo "Updated vendorHash in nix/infer.nix"

- name: Verify build
run: |
echo "Building with updated hashes to verify..."
nix-build nix/infer.nix --show-trace

echo "Verifying binary..."
result/bin/infer version

- name: Format Nix file
run: |
nix-shell -p nixpkgs-fmt --run "nixpkgs-fmt nix/infer.nix"

- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore(nix): Update package to v${{ steps.version.outputs.version }}'
title: 'chore(nix): Update package to v${{ steps.version.outputs.version }}'
body: |
## Automated Nix Package Update

This PR updates the Nix package expression to version **${{ steps.version.outputs.version }}**.

### Changes
- ✅ Updated `version` to `${{ steps.version.outputs.version }}`
- ✅ Updated source `hash` to `sha256-${{ steps.source-hash.outputs.hash }}`
- ✅ Updated `vendorHash` to `sha256-${{ steps.vendor-hash.outputs.hash }}`
- ✅ Verified build succeeds
- ✅ Formatted with nixpkgs-fmt

### Verification
```bash
nix-build nix/infer.nix
result/bin/infer version
```

### Related
- Release: ${{ github.event.release.html_url || 'Manual trigger' }}

---
🤖 Auto-generated by `.github/workflows/nix-version-sync.yml`
branch: chore/nix-update-v${{ steps.version.outputs.version }}
delete-branch: true
labels: |
nix
dependencies
automated

- name: Summary
run: |
echo "## ✅ Nix Package Updated" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Source Hash**: sha256-${{ steps.source-hash.outputs.hash }}" >> $GITHUB_STEP_SUMMARY
echo "- **Vendor Hash**: sha256-${{ steps.vendor-hash.outputs.hash }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "A pull request has been created to merge these changes." >> $GITHUB_STEP_SUMMARY
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ flox.*-linux.*
/.task
infer

# Nix build artifacts
result
result-*
*.drv

# IDE's
.vscode
.idea
Loading
Loading