Skip to content
Open
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
38 changes: 38 additions & 0 deletions .github/workflows/update_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

name: Update Flake assets on Release

on:
release:
types: [published] # Triggers when a release is fully published

permissions:
contents: write # Required to push commits back to the repo

jobs:
update-sources:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: true

- name: Run update script
run: |
git checkout ${{github.ref_name}}
chmod +x ./update.sh
./update.sh

- name: Commit and push changes
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply"

# Only commit if sources.json actually changed
if ! git diff --exit-code .; then
git add .
git commit -m "chore: update nix flake assets for ${{ github.event.release.tag_name }}"
git push origin ${{github.ref_name}}
else
echo "No changes detected in sources.json"
fi
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
description = "llama.cpp CUDA binaries from ai-dock (Patched for NixOS)";

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

outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true; # Required for CUDA
};
release = builtins.fromJSON (builtins.readFile "${self}/latest_release.json");
sha256 = builtins.convertHash {
hash = release.hash;
toHashFormat = "sri";
hashAlgo = "sha256";
};
in
{
packages.default =
with release;
pkgs.stdenv.mkDerivation {
pname = "aidock_llama-cpp-cuda";
inherit version;
src = pkgs.fetchurl { inherit url sha256; };
nativeBuildInputs = with pkgs; [ autoPatchelfHook ];
buildInputs = with pkgs; [
stdenv.cc.cc.lib
cudaPackages.cudatoolkit
cudaPackages.nccl
linuxPackages.nvidia_x11
];

appendRunpaths = [
"/run/opengl-driver/lib"
"${pkgs.linuxPackages.nvidia_x11}/lib"
"$out/lib"
];

sourceRoot = ".";

installPhase = ''
mkdir -p $out/bin $out/lib
find . -name "*.so*" -exec cp -vP {} $out/lib/ \;
find . -type f -executable \
! -name "*.so*" \
! -name "*.txt" \
! -name "*.md" \
-exec cp -v {} $out/bin/ \;
[ "$(ls -A $out/bin)" ] || { echo "Error: No binaries found!"; exit 1; }
'';
autoPatchelfIgnoreMissingDeps = false;
};
devShells.default = pkgs.mkShell {
buildInputs = [ self.packages.${system}.default ];
shellHook = ''
export LD_LIBRARY_PATH="/run/opengl-driver/lib:${pkgs.linuxPackages.nvidia_x11}/lib:$LD_LIBRARY_PATH"
'';
};
}
);
}
5 changes: 5 additions & 0 deletions latest_release.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": "b9190",
"hash": "sha256:988920b5fb99250861577bd38a5ee639ff051183ce22cab170001208ae8f481b",
"url": "https://github.com/ai-dock/llama.cpp-cuda/releases/download/b9190/llama.cpp-b9190-cuda-12.8.tar.gz"
}
3 changes: 3 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
curl -s https://api.github.com/repos/ai-dock/llama.cpp-cuda/releases/latest | jq '{version:(.tag_name),hash:(.assets[0].digest),url:(.assets[0].browser_download_url)}' > latest_release.json
nix flake update