From b764d2de45c545d6a7263350baeaf5da8a183695 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Mon, 7 Apr 2025 14:31:56 -0400 Subject: [PATCH] move optimizeWithFlags --- flake.nix | 16 ++++++++++++++++ services/llama-cpp.nix | 17 +---------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/flake.nix b/flake.nix index 9e088fc..a015c48 100644 --- a/flake.nix +++ b/flake.nix @@ -144,6 +144,22 @@ inputs serviceMountDeps ; + + # stolen from: https://stackoverflow.com/a/42398526 + optimizeWithFlags = + pkg: flags: + nixpkgs.lib.overrideDerivation pkg ( + old: + let + newflags = nixpkgs.lib.foldl' (acc: x: "${acc} ${x}") "" flags; + oldflags = + if (nixpkgs.lib.hasAttr "NIX_CFLAGS_COMPILE" old) then "${old.NIX_CFLAGS_COMPILE}" else ""; + in + { + NIX_CFLAGS_COMPILE = "${oldflags} ${newflags}"; + # stdenv = pkgs.clang19Stdenv; + } + ); }; modules = [ diff --git a/services/llama-cpp.nix b/services/llama-cpp.nix index 9a29016..78eb239 100644 --- a/services/llama-cpp.nix +++ b/services/llama-cpp.nix @@ -3,24 +3,9 @@ service_configs, config, inputs, + optimizeWithFlags, ... }: -let - # stolen from: https://stackoverflow.com/a/42398526 - optimizeWithFlags = - pkg: flags: - pkgs.lib.overrideDerivation pkg ( - old: - let - newflags = pkgs.lib.foldl' (acc: x: "${acc} ${x}") "" flags; - oldflags = if (pkgs.lib.hasAttr "NIX_CFLAGS_COMPILE" old) then "${old.NIX_CFLAGS_COMPILE}" else ""; - in - { - NIX_CFLAGS_COMPILE = "${oldflags} ${newflags}"; - stdenv = pkgs.clang19Stdenv; - } - ); -in { services.llama-cpp = { enable = true;