From 5fbdffc22319914cc1e03a439b4b37a55cfd6878 Mon Sep 17 00:00:00 2001 From: John Titor <50095635+JohnRTitor@users.noreply.github.com> Date: Wed, 1 Jul 2026 18:26:07 +0530 Subject: [PATCH] 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. --- nixos/modules/services/misc/ollama.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/misc/ollama.nix b/nixos/modules/services/misc/ollama.nix index bc1693f1902e..4ba0ccb6db7d 100644 --- a/nixos/modules/services/misc/ollama.nix +++ b/nixos/modules/services/misc/ollama.nix @@ -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 ''; };