Skip to content

Commit 6ab3a7a

Browse files
committed
fix some gpu setting locations
1 parent 4e3017b commit 6ab3a7a

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

hosts/bastion/default.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
fs.btrfs = true;
1010
dockerDNS = [ "192.168.50.1" ];
1111
yubiauth.lockOnRemove.enable = true;
12+
13+
gpu = {
14+
enable = true;
15+
amd = true;
16+
};
1217
};
1318

1419
desktop = {

modules/nixos/base/gpu.nix

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,28 @@
22

33
let
44
inherit (lib) mkIf mkEnableOption;
5-
cfg = config.base;
5+
cfg = config.base.gpu;
66
in {
77
options.base.gpu = {
88
enable = mkEnableOption "GPU support";
99

10-
amd = { enable = mkEnableOption "AMD GPU support"; };
10+
amd = mkEnableOption "AMD GPU support";
11+
nvidia = mkEnableOption "NVIDIA GPU support";
1112
};
1213

13-
config = mkIf cfg.gpu.enable {
14-
hardware.opengl = mkIf cfg.gpu.amd.enable {
14+
config = mkIf cfg.enable {
15+
# ensure only one of amd or nvidia is enabled
16+
assertions = [{
17+
assertion = !(cfg.amd && cfg.nvidia);
18+
message = "Only one of AMD or NVIDIA can be enabled.";
19+
}];
20+
21+
hardware.opengl = mkIf cfg.amd {
1522
enable = true;
16-
extraPackages = with stable; [
23+
extraPackages = with pkgs; [
1724
# ROCm OpenCL ICD
1825
rocmPackages.clr.icd
19-
ocl-icd
20-
21-
# ROCm
2226
rocm-opencl-icd
23-
rocm-runtime-ext
2427

2528
# AMDVLK
2629
amdvlk

modules/nixos/desktop/ai.nix

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,9 @@ in {
1717

1818
web-ui = mkEnableOption "Enable the web UI for Ollama.";
1919
lmstudio = mkEnabledOption "Enable LM Studio.";
20-
21-
amd = mkEnableOption "Enable AMD ROCM support.";
22-
nvidia = mkEnableOption "Enable NVIDIA CUDA support.";
2320
};
2421

2522
config = mkIf (cfg.enable) {
26-
# ensure only one of amd or nvidia is enabled
27-
assertions = [{
28-
assertion = !(cfg.amd && cfg.nvidia);
29-
message = "Only one of AMD or NVIDIA can be enabled.";
30-
}];
31-
3223
services = {
3324
ollama = {
3425
enable = true;
@@ -42,8 +33,12 @@ in {
4233
in (lib.concatStringsSep "," origins);
4334
};
4435

45-
acceleration =
46-
if cfg.amd then "rocm" else if cfg.nvidia then "cuda" else null;
36+
acceleration = if config.base.gpu.amd then
37+
"rocm"
38+
else if config.base.gpu.nvidia then
39+
"cuda"
40+
else
41+
null;
4742
};
4843

4944
nextjs-ollama-llm-ui = mkIf cfg.web-ui {

0 commit comments

Comments
 (0)