5 Commits

Author SHA1 Message Date
doloro cf667edfac fix: various linking issues
check / build (push) Failing after 4m26s
check / build (pull_request) Failing after 4m28s
2026-04-21 23:12:18 +01:00
doloro 62e38d5b74 fixed: hash
check / build (push) Failing after 4m25s
check / build (pull_request) Failing after 4m26s
2026-04-20 00:36:04 +01:00
doloro 5594228115 changed: license to be unfree
check / build (push) Failing after 4m23s
check / build (pull_request) Failing after 4m25s
2026-04-20 00:03:00 +01:00
doloro 4836330a2c removed: nixpkgs in inputs && changed hash to be 'correct'
check / build (push) Has been cancelled
check / build (pull_request) Has been cancelled
2026-04-20 00:00:02 +01:00
doloro 0fe89abb1f added: hexagon sdk
check / build (push) Failing after 15s
check / build (pull_request) Failing after 15s
2026-04-19 23:57:05 +01:00
2 changed files with 90 additions and 198 deletions
+90
View File
@@ -0,0 +1,90 @@
{
lib,
pkgs,
stdenvNoCC,
stdenv,
p7zip,
curl,
jq,
cacert,
}:
let
version = "v6.4.0.2";
src = fetchTarball {
url = "https://github.com/snapdragon-toolchain/hexagon-sdk/releases/download/v6.4.0.2/hexagon-sdk-v6.4.0.2-amd64-lnx.tar.xz";
sha256 = "0qadmn84sdqbqh3s837s0amdmln3akb1b01k8x5nha0lkw6a3jwc";
};
gmp_override = pkgs.gmp.overrideAttrs (
final: prev: {
postInstall =
(prev.postInstall or "")
+ "
ls
cd $out
cd lib
ls
rm libgmp.so.10
cp libgmp.so.10.5.0 libgmp.so.10
cp libgmp.so.10.5.0 $out/libgmp.so.10
";
}
);
libs = [
pkgs.stdenv.cc.cc.lib
pkgs.libc
pkgs.libcxx
pkgs.gmp
pkgs.libz
pkgs.libgccjit
# pkgs.zlib
# pkgs.ncurses
];
# we get Nixpkgs to create the library paths for us, so we don't have to wrangle them by hand
libPath = pkgs.lib.makeLibraryPath libs;
in
stdenv.mkDerivation rec {
pname = "hexagon-sdk";
inherit version src;
# dontUnpack = true;
# dontBuild = true;
nativeBuildInputs = [
];
buildInputs = [ pkgs.patchelf ];
runtimeDependencies = with pkgs; [ gmpxx ];
buildPhase = ''
runHook preBuild
# cp $out/opt/tools/HEXAGON_Tools/19.0.04/Tools/lib/libLW.so.3 $out/opt/tools/HEXAGON_Tools/19.0.04/Tools/bin/
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir $out
cp -r ${src} $out/opt
runHook postInstall
chmod +w $out/opt/ipc/fastrpc/qaic/bin/qaic
chmod +w $out/opt/tools/HEXAGON_Tools/19.0.04/Tools/bin/hexagon-clang
chmod +w $out/opt/tools/HEXAGON_Tools/19.0.04/Tools/bin/hexagon-link
patchelf $out/opt/ipc/fastrpc/qaic/bin/qaic --set-interpreter ${pkgs.stdenv.cc.bintools.dynamicLinker} --set-rpath ${libPath}
patchelf $out/opt/tools/HEXAGON_Tools/19.0.04/Tools/bin/hexagon-clang --set-interpreter ${pkgs.stdenv.cc.bintools.dynamicLinker} --set-rpath ${libPath}
lib=${libPath}
lib=$lib:$out/opt/tools/HEXAGON_Tools/19.0.04/Tools/lib
echo $lib
patchelf $out/opt/tools/HEXAGON_Tools/19.0.04/Tools/bin/hexagon-link --set-interpreter ${pkgs.stdenv.cc.bintools.dynamicLinker} --set-rpath $lib
'';
meta = {
description = "Hexagon SDK for working with the Qualcomm NPU/DSP";
homepage = "https://github.com/snapdragon-toolchain/hexagon-sdk";
license = lib.licenses.unfree;
platforms = [
"x86_64-linux"
];
};
}
-198
View File
@@ -1,198 +0,0 @@
{
lib,
autoAddDriverRunpath,
cmake,
fetchFromGitHub,
nix-update-script,
stdenv,
config,
cudaSupport ? config.cudaSupport,
cudaPackages ? { },
rocmSupport ? config.rocmSupport,
rocmPackages ? { },
rocmGpuTargets ? rocmPackages.clr.localGpuTargets or rocmPackages.clr.gpuTargets,
openclSupport ? false,
clblast,
blasSupport ? builtins.all (x: !x) [
cudaSupport
metalSupport
openclSupport
rocmSupport
vulkanSupport
],
blas,
pkg-config,
metalSupport ? stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 && !openclSupport,
vulkanSupport ? false,
rpcSupport ? false,
hexagonSupport ? false,
curl,
llama-cpp,
shaderc,
vulkan-headers,
vulkan-loader,
hexagon-sdk,
ninja,
}:
let
# It's necessary to consistently use backendStdenv when building with CUDA support,
# otherwise we get libstdc++ errors downstream.
# cuda imposes an upper bound on the gcc version
effectiveStdenv = if cudaSupport then cudaPackages.backendStdenv else stdenv;
inherit (lib)
cmakeBool
cmakeFeature
optionals
optionalString
;
cudaBuildInputs = with cudaPackages; [
cuda_cccl # <nv/target>
# A temporary hack for reducing the closure size, remove once cudaPackages
# have stopped using lndir: https://github.com/NixOS/nixpkgs/issues/271792
cuda_cudart
libcublas
];
rocmBuildInputs = with rocmPackages; [
clr
hipblas
rocblas
];
vulkanBuildInputs = [
shaderc
vulkan-headers
vulkan-loader
];
in
effectiveStdenv.mkDerivation (finalAttrs: {
pname = "llama-cpp";
version = "6981";
src = fetchFromGitHub {
owner = "ggml-org";
repo = "llama.cpp";
tag = "b${finalAttrs.version}";
hash = "sha256-0WtiHDlMeb+m2XcMwkPFY1mtwVTwRJUoxQSwzpiRbts=";
leaveDotGit = true;
postFetch = ''
git -C "$out" rev-parse --short HEAD > $out/COMMIT
find "$out" -name .git -print0 | xargs -0 rm -rf
'';
};
nativeBuildInputs = [
cmake
ninja
pkg-config
]
++ optionals cudaSupport [
cudaPackages.cuda_nvcc
autoAddDriverRunpath
];
buildInputs =
optionals cudaSupport cudaBuildInputs
++ optionals openclSupport [ clblast ]
++ optionals rocmSupport rocmBuildInputs
++ optionals blasSupport [ blas ]
++ optionals vulkanSupport vulkanBuildInputs
++ [ curl ];
preConfigure = ''
prependToVar cmakeFlags "-DLLAMA_BUILD_COMMIT:STRING=$(cat COMMIT)"
'';
cmakeFlags = [
# -march=native is non-deterministic; override with platform-specific flags if needed
(cmakeBool "GGML_NATIVE" false)
(cmakeBool "LLAMA_BUILD_EXAMPLES" false)
(cmakeBool "LLAMA_BUILD_SERVER" true)
(cmakeBool "LLAMA_BUILD_TESTS" (finalAttrs.finalPackage.doCheck or false))
(cmakeBool "LLAMA_CURL" true)
(cmakeBool "BUILD_SHARED_LIBS" true)
(cmakeBool "GGML_BLAS" blasSupport)
(cmakeBool "GGML_CLBLAST" openclSupport)
(cmakeBool "GGML_CUDA" cudaSupport)
(cmakeBool "GGML_HIP" rocmSupport)
(cmakeBool "GGML_METAL" metalSupport)
(cmakeBool "GGML_RPC" rpcSupport)
(cmakeBool "GGML_VULKAN" vulkanSupport)
(cmakeBool "GGML_HEXAGON" hexagonSupport)
(cmakeFeature "LLAMA_BUILD_NUMBER" finalAttrs.version)
]
++ optionals cudaSupport [
(cmakeFeature "CMAKE_CUDA_ARCHITECTURES" cudaPackages.flags.cmakeCudaArchitecturesString)
]
++ optionals rocmSupport [
(cmakeFeature "CMAKE_HIP_COMPILER" "${rocmPackages.clr.hipClangPath}/clang++")
(cmakeFeature "CMAKE_HIP_ARCHITECTURES" (builtins.concatStringsSep ";" rocmGpuTargets))
]
++ optionals metalSupport [
(cmakeFeature "CMAKE_C_FLAGS" "-D__ARM_FEATURE_DOTPROD=1")
(cmakeBool "LLAMA_METAL_EMBED_LIBRARY" true)
]
++ optionals rpcSupport [
# This is done so we can move rpc-server out of bin because llama.cpp doesn't
# install rpc-server in their install target.
(cmakeBool "CMAKE_SKIP_BUILD_RPATH" true)
]
++ optionals hexagonSupport [
(cmakeFeature "GGML_HEXAGON_FP32_QUANTIZE_GROUP_SIZE" "128")
(cmakeFeature "HEXAGON_SDK_ROOT" "${hexagon-sdk}/opt/hexagon")
(cmakeFeature "HEXAGON_TOOLS_ROOT" "${hexagon-sdk}/opt/hexagon/tools/HEXAGON_Tools/19.0.04")
];
# upstream plans on adding targets at the cmakelevel, remove those
# additional steps after that
postInstall = ''
# Match previous binary name for this package
ln -sf $out/bin/llama-cli $out/bin/llama
mkdir -p $out/include
cp $src/include/llama.h $out/include/
''
+ optionalString rpcSupport "cp bin/rpc-server $out/bin/llama-rpc-server";
# the tests are failing as of 2025-08
doCheck = false;
passthru = {
tests = lib.optionalAttrs stdenv.hostPlatform.isDarwin {
metal = llama-cpp.override { metalSupport = true; };
};
updateScript = nix-update-script {
attrPath = "llama-cpp";
extraArgs = [
"--version-regex"
"b(.*)"
];
};
};
meta = {
description = "Inference of Meta's LLaMA model (and others) in pure C/C++";
homepage = "https://github.com/ggml-org/llama.cpp";
license = lib.licenses.mit;
mainProgram = "llama";
maintainers = with lib.maintainers; [
booxter
dit7ya
philiptaron
xddxdd
];
platforms = lib.platforms.unix;
badPlatforms = optionals (cudaSupport || openclSupport) lib.platforms.darwin (
hexagonSupport && !effectiveStdenv.hostPlatform.aarch64-linux
);
broken = metalSupport && !effectiveStdenv.hostPlatform.isDarwin;
};
})