create single function to optimize for system

This commit is contained in:
Simon Gardling 2025-04-07 14:33:34 -04:00
parent b764d2de45
commit 3653e06c7d
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
2 changed files with 14 additions and 10 deletions

View File

@ -135,7 +135,7 @@
{ {
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style; formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;
nixosConfigurations.${hostname} = nixpkgs.lib.nixosSystem { nixosConfigurations.${hostname} = nixpkgs.lib.nixosSystem {
specialArgs = { specialArgs = rec {
inherit inherit
username username
hostname hostname
@ -160,6 +160,14 @@
# stdenv = pkgs.clang19Stdenv; # stdenv = pkgs.clang19Stdenv;
} }
); );
optimizePackage =
pkg:
optimizeWithFlags pkg [
"-O3"
"-march=znver2"
"-mtune=znver2"
];
}; };
modules = modules =
[ [

View File

@ -3,7 +3,7 @@
service_configs, service_configs,
config, config,
inputs, inputs,
optimizeWithFlags, optimizePackage,
... ...
}: }:
{ {
@ -22,17 +22,13 @@
port = service_configs.ports.llama_cpp; port = service_configs.ports.llama_cpp;
host = "0.0.0.0"; host = "0.0.0.0";
package = ( package = (
optimizeWithFlags optimizePackage (
(inputs.llamacpp.packages.${pkgs.system}.default.overrideAttrs (old: { inputs.llamacpp.packages.${pkgs.system}.default.overrideAttrs (old: {
cmakeFlags = old.cmakeFlags ++ [ cmakeFlags = old.cmakeFlags ++ [
"-DGGML_AVX2=ON" "-DGGML_AVX2=ON"
]; ];
})) })
[ )
"-O3"
"-march=znver2"
"-mtune=znver2"
]
); );
extraFlags = [ extraFlags = [
"--flash-attn" "--flash-attn"