From a72accde1a4a47db6efee11d4c16cbfa9228a729 Mon Sep 17 00:00:00 2001 From: ltadeu6 Date: Sun, 12 Apr 2026 11:49:34 -0300 Subject: [PATCH] Use unstable ollama-cuda and pin gemma4:e4b --- flake.lock | 19 ++++++++++++++++++- flake.nix | 15 +++++++++++++-- home/ltadeu6.nix | 2 +- hosts/Nixos/configuration.nix | 16 +++++++++++++++- 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 53639fa..2b304bb 100644 --- a/flake.lock +++ b/flake.lock @@ -179,6 +179,22 @@ "type": "github" } }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1775710090, + "narHash": "sha256-ar3rofg+awPB8QXDaFJhJ2jJhu+KqN/PRCXeyuXR76E=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4c1018dae018162ec878d42fec712642d214fdfa", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1767364772, @@ -232,7 +248,8 @@ "agenix": "agenix", "home-manager": "home-manager_2", "nix-openclaw": "nix-openclaw", - "nixpkgs": "nixpkgs_4" + "nixpkgs": "nixpkgs_4", + "nixpkgs-unstable": "nixpkgs-unstable" } }, "systems": { diff --git a/flake.nix b/flake.nix index f4864b9..7f28643 100644 --- a/flake.nix +++ b/flake.nix @@ -3,6 +3,7 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; + nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; home-manager = { url = "github:nix-community/home-manager/release-25.11"; inputs.nixpkgs.follows = "nixpkgs"; @@ -11,7 +12,7 @@ nix-openclaw.url = "github:openclaw/nix-openclaw"; }; - outputs = { self, nixpkgs, home-manager, agenix, nix-openclaw, ... }: + outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, agenix, nix-openclaw, ... }: let system = "x86_64-linux"; in { @@ -21,7 +22,17 @@ modules = [ ./hosts/Nixos/configuration.nix agenix.nixosModules.default - { nixpkgs.overlays = [ nix-openclaw.overlays.default ]; } + { + nixpkgs.overlays = [ + nix-openclaw.overlays.default + (final: prev: { + unstable = import nixpkgs-unstable { + inherit system; + config = prev.config; + }; + }) + ]; + } home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; diff --git a/home/ltadeu6.nix b/home/ltadeu6.nix index e5439e8..5d85277 100644 --- a/home/ltadeu6.nix +++ b/home/ltadeu6.nix @@ -349,7 +349,7 @@ id = "OPENCLAW_GATEWAY_TOKEN"; }; - agents.defaults.model.primary = "ollama/qwen2.5:3b"; + agents.defaults.model.primary = "ollama/gemma4:e4b"; models.providers.ollama = { baseUrl = "http://127.0.0.1:11434"; api = "ollama"; diff --git a/hosts/Nixos/configuration.nix b/hosts/Nixos/configuration.nix index c2ac204..6c19d2c 100644 --- a/hosts/Nixos/configuration.nix +++ b/hosts/Nixos/configuration.nix @@ -43,6 +43,14 @@ }; }; + nix.settings = { + # CUDA builds are heavy; use a binary cache to avoid local compilation. + substituters = lib.mkAfter [ "https://cache.nixos-cuda.org" ]; + trusted-public-keys = lib.mkAfter [ + "cache.nixos-cuda.org:74DUi4Ye579gUqzH4ziL9IyiJBlDpMRn9MBN8oNan9M=" + ]; + }; + powerManagement.cpuFreqGovernor = "performance"; # Bootloader. boot = { @@ -248,10 +256,16 @@ }; ollama = { enable = true; + # Nixpkgs' plain `ollama` is typically CPU-only; use the CUDA variant on NVIDIA. + package = pkgs.unstable.ollama-cuda; acceleration = "cuda"; host = "[::]"; + environmentVariables = { + # Lower default context to keep KV cache smaller (faster + more likely to stay on GPU). + OLLAMA_CONTEXT_LENGTH = "8192"; + }; loadModels = [ - "qwen2.5:3b" + "gemma4:e4b" ]; syncModels = true; # listenAddress = "10.0.0.2:11434";