From 93c1ae56d8bb70706d68a35c7161e6b607649db3 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Wed, 23 Oct 2024 19:47:31 +0300 Subject: [PATCH] Ollama: Use pkgsUnstable. --- flake.lock | 17 +++++++++++++++++ flake.nix | 10 +++++++++- module/Ollama.nix | 20 +++++++++----------- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/flake.lock b/flake.lock index 84d8b21..d796a8a 100644 --- a/flake.lock +++ b/flake.lock @@ -363,6 +363,22 @@ "type": "github" } }, + "nixpkgsUnstable": { + "locked": { + "lastModified": 1729413321, + "narHash": "sha256-I4tuhRpZFa6Fu6dcH9Dlo5LlH17peT79vx1y1SpeKt0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1997e4aa514312c1af7e2bda7fad1644e778ff26", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1717298511, @@ -752,6 +768,7 @@ "nixpkgsJobber": "nixpkgsJobber", "nixpkgsMaster": "nixpkgsMaster", "nixpkgsStable": "nixpkgsStable", + "nixpkgsUnstable": "nixpkgsUnstable", "nvimAlign": "nvimAlign", "nvimAutoclose": "nvimAutoclose", "nvimBufferline": "nvimBufferline", diff --git a/flake.nix b/flake.nix index d120e29..a57dd35 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,7 @@ # Manual: https://nixos.org/manual/nixos/stable # Search: https://search.nixos.org/packages and https://search.nixos.org/options nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgsUnstable.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgsStable.url = "github:nixos/nixpkgs/nixos-24.05"; nixpkgsMaster.url = "github:nixos/nixpkgs/master"; @@ -120,6 +121,7 @@ { self, nixpkgs, + nixpkgsUnstable, nixpkgsStable, nixpkgsMaster, nix-on-droid, @@ -221,6 +223,7 @@ pkgsJobber = nixpkgsJobber.legacyPackages.${system}.pkgs; pkgsStable = nixpkgsStable.legacyPackages.${system}.pkgs; + pkgsUnstable = nixpkgsUnstable.legacyPackages.${system}.pkgs; pkgsMaster = nixpkgsMaster.legacyPackages.${system}.pkgs; secret = import ./secret { }; # Secrets (public keys). @@ -265,6 +268,7 @@ let pkgs = nixpkgs.legacyPackages.${system}; pkgsStable = nixpkgsStable.legacyPackages.${system}; + pkgsUnstable = nixpkgsUnstable.legacyPackages.${system}; pkgsMaster = nixpkgsMaster.legacyPackages.${system}; in { @@ -327,9 +331,13 @@ # Android. nixOnDroidConfigurations.default = let + system = "aarch64-linux"; config = self.nixOnDroidConfigurations.default.config; lib = nixpkgs.lib; - pkgs = nixpkgs.legacyPackages."aarch64-linux".pkgs; + pkgs = nixpkgs.legacyPackages.${system}.pkgs; + pkgsStable = nixpkgsStable.legacyPackages.${system}.pkgs; + pkgsUnstable = nixpkgsUnstable.legacyPackages.${system}.pkgs; + pkgsMaster = nixpkgsMaster.legacyPackages.${system}.pkgs; in nix-on-droid.lib.nixOnDroidConfiguration { modules = [ diff --git a/module/Ollama.nix b/module/Ollama.nix index 207053c..40cba44 100644 --- a/module/Ollama.nix +++ b/module/Ollama.nix @@ -1,31 +1,29 @@ # SRC: https://github.com/ollama/ollama { - pkgsStable, + pkgsUnstable, lib, config, ... }: -with lib; let - pkgs = pkgsStable; cfg = config.module.ollama; in { options = { module.ollama = { - enable = mkEnableOption "Local LLM server"; - primaryModel = mkOption { + enable = lib.mkEnableOption "Local LLM server"; + primaryModel = lib.mkOption { default = "llama3.2"; - type = types.str; + type = lib.types.str; }; - models = mkOption { + models = lib.mkOption { default = [ cfg.primaryModel ]; - type = types.listOf types.str; + type = with lib.types; listOf str; }; }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment = { # Specify default model. variables.OLLAMA_MODEL = cfg.primaryModel; @@ -38,7 +36,7 @@ in wantedBy = [ "multi-user.target" ]; serviceConfig.Type = "simple"; script = '' - HOME=/root ${getExe pkgs.ollama} serve + HOME=/root ${lib.getExe pkgsUnstable.ollama} serve ''; }; @@ -57,7 +55,7 @@ in serviceConfig.Type = "simple"; script = '' sleep 5 - ${getExe pkgs.ollama} pull ${concatStringsSep " " cfg.models} + ${lib.getExe pkgsUnstable.ollama} pull ${lib.concatStringsSep " " cfg.models} ''; }; };