buildStatic variable to toggle static builds

This commit is contained in:
hutli 2024-03-01 14:29:03 +01:00
parent 51ec91b93a
commit 498e998cd7

View file

@ -1,6 +1,6 @@
{ {
pkgs,
lib, lib,
glibc,
config, config,
stdenv, stdenv,
mkShell, mkShell,
@ -31,6 +31,7 @@
useRocm ? config.rocmSupport, useRocm ? config.rocmSupport,
useVulkan ? false, useVulkan ? false,
llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake
buildStatic ? false,
}@inputs: }@inputs:
let let
@ -161,7 +162,6 @@ effectiveStdenv.mkDerivation (
ninja ninja
pkg-config pkg-config
git git
pkgs.glibc.static
] ]
++ optionals useCuda [ ++ optionals useCuda [
cudaPackages.cuda_nvcc cudaPackages.cuda_nvcc
@ -169,6 +169,9 @@ effectiveStdenv.mkDerivation (
# TODO: Replace with autoAddDriverRunpath # TODO: Replace with autoAddDriverRunpath
# once https://github.com/NixOS/nixpkgs/pull/275241 has been merged # once https://github.com/NixOS/nixpkgs/pull/275241 has been merged
cudaPackages.autoAddOpenGLRunpathHook cudaPackages.autoAddOpenGLRunpathHook
]
++ optionals buildStatic [
glibc.static
]; ];
buildInputs = buildInputs =
@ -183,7 +186,7 @@ effectiveStdenv.mkDerivation (
[ [
(cmakeBool "LLAMA_NATIVE" false) (cmakeBool "LLAMA_NATIVE" false)
(cmakeBool "LLAMA_BUILD_SERVER" true) (cmakeBool "LLAMA_BUILD_SERVER" true)
(cmakeBool "BUILD_SHARED_LIBS" false) (cmakeBool "BUILD_SHARED_LIBS" !buildStatic)
(cmakeBool "CMAKE_SKIP_BUILD_RPATH" true) (cmakeBool "CMAKE_SKIP_BUILD_RPATH" true)
(cmakeBool "LLAMA_BLAS" useBlas) (cmakeBool "LLAMA_BLAS" useBlas)
(cmakeBool "LLAMA_CLBLAST" useOpenCL) (cmakeBool "LLAMA_CLBLAST" useOpenCL)
@ -192,7 +195,7 @@ effectiveStdenv.mkDerivation (
(cmakeBool "LLAMA_METAL" useMetalKit) (cmakeBool "LLAMA_METAL" useMetalKit)
(cmakeBool "LLAMA_MPI" useMpi) (cmakeBool "LLAMA_MPI" useMpi)
(cmakeBool "LLAMA_VULKAN" useVulkan) (cmakeBool "LLAMA_VULKAN" useVulkan)
(cmakeBool "LLAMA_STATIC" true) (cmakeBool "LLAMA_STATIC" buildStatic)
] ]
++ optionals useCuda [ ++ optionals useCuda [
( (