From 53583fc4c7dfa262444934f9f956fe72001e887b Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Fri, 24 May 2024 14:04:57 +0200 Subject: [PATCH] Begin add AI module --- modules/ai.nix | 26 ++++++++++++++++++++++++++ modules/gpuPassthrough/default.nix | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 modules/ai.nix diff --git a/modules/ai.nix b/modules/ai.nix new file mode 100644 index 0000000..842fa22 --- /dev/null +++ b/modules/ai.nix @@ -0,0 +1,26 @@ +{ config, pkgs, lib, ... }: +with lib; +{ + options.customModules.AI = { + enable = mkEnableOption '' + Enable AI + ''; + }; + config = + let + cfg = config.customModules.AI; + nvidiaEnabled = config.hardware.nvidia.modesetting.enable; + in + mkIf cfg.enable { + services.ollama = { + enable = true; + + acceleration = + if nvidiaEnabled then + "cuda" + else + null; + }; + } + // mkIf nvidiaEnabled { environment.systemPackages = with pkgs; [cudatoolkit]; }; +} \ No newline at end of file diff --git a/modules/gpuPassthrough/default.nix b/modules/gpuPassthrough/default.nix index 7c65fdf..6bfa3d0 100644 --- a/modules/gpuPassthrough/default.nix +++ b/modules/gpuPassthrough/default.nix @@ -18,8 +18,8 @@ with lib; hooks.qemu = { is_working = "${pkgs.writeShellScript "testHook.sh" '' -+ touch /tmp/qemu_hook_is_working -+ ''}"; + touch /tmp/qemu_hook_is_working + ''}"; }; }; };