nixos/ollama: replace gnu parallel with xargs for paralellism
Switch the model pulling mechanism from pkgs.parallel to standard xargs paired with nproc. This removes GNU Parallel (Perl runtime dependency) from system closure. Dynamically limit parallel execution threads to the system core count using nproc.
This commit is contained in:
@@ -306,16 +306,18 @@ in
|
||||
script =
|
||||
let
|
||||
binaryInputs = lib.mapAttrs (_: lib.getExe) {
|
||||
parallel = pkgs.parallel;
|
||||
awk = pkgs.gawk;
|
||||
sed = pkgs.gnused;
|
||||
};
|
||||
|
||||
inherit (binaryInputs)
|
||||
parallel
|
||||
awk
|
||||
sed
|
||||
;
|
||||
|
||||
nproc = lib.getExe' pkgs.coreutils "nproc";
|
||||
xargs = lib.getExe' pkgs.findutils "xargs";
|
||||
|
||||
declaredModelsRegex = lib.pipe cfg.loadModels [
|
||||
(map lib.escapeRegex)
|
||||
(lib.concatStringsSep "|")
|
||||
@@ -344,7 +346,7 @@ in
|
||||
fi
|
||||
''}
|
||||
|
||||
'${parallel}' --tag '${ollama}' pull ::: ${lib.escapeShellArgs cfg.loadModels}
|
||||
printf "%s\0" ${lib.escapeShellArgs cfg.loadModels} | '${xargs}' -0 -r -n 1 -P "$('${nproc}')" '${ollama}' pull
|
||||
'';
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user