nixos/tips/how_to_test_pr.md
Florian RICHER e8fca43d0c
All checks were successful
check / check (push) Successful in 30s
tips(how_to_test_pr): Add content in nix block code
2024-07-01 19:29:30 +02:00

912 B

Example for ollama

{ config, pkgs, lib, ... }:

with lib;
let
  cfg = config.modules.system.server.ollama;
  nvidiaEnabled = config.modules.system.hardware.nvidia.enable;
  nixpkgsPr = builtins.fetchTarball {
    url = "https://github.com/abysssol/nixpkgs/archive/ollama-driver-runpath.tar.gz";
    sha256 = "1ixfvdpi2v4r9yrkvqnfk9whs8lyjhrkdph47bcznh8ak9aipr8p";
  };
in
{
  disabledModules = [ "services/misc/ollama.nix" ];
  imports = [
    (import "${nixpkgsPr}/nixos/modules/services/misc/ollama.nix")
  ];

  options.modules.system.server.ollama = {
    enable = mkEnableOption ''
      Enable ollama with my custom configurations
    '';
  };
  config = mkIf cfg.enable {
    services.ollama = {
      enable = true;

      package = (import nixpkgsPr { inherit (pkgs) system; config.allowUnfree = true; }).ollama;

      acceleration = if nvidiaEnabled then "cuda" else null;
    };
  };
}