File tree Expand file tree Collapse file tree 3 files changed +23
-20
lines changed Expand file tree Collapse file tree 3 files changed +23
-20
lines changed Original file line number Diff line number Diff line change 9
9
fs . btrfs = true ;
10
10
dockerDNS = [ "192.168.50.1" ] ;
11
11
yubiauth . lockOnRemove . enable = true ;
12
+
13
+ gpu = {
14
+ enable = true ;
15
+ amd = true ;
16
+ } ;
12
17
} ;
13
18
14
19
desktop = {
Original file line number Diff line number Diff line change 2
2
3
3
let
4
4
inherit ( lib ) mkIf mkEnableOption ;
5
- cfg = config . base ;
5
+ cfg = config . base . gpu ;
6
6
in {
7
7
options . base . gpu = {
8
8
enable = mkEnableOption "GPU support" ;
9
9
10
- amd = { enable = mkEnableOption "AMD GPU support" ; } ;
10
+ amd = mkEnableOption "AMD GPU support" ;
11
+ nvidia = mkEnableOption "NVIDIA GPU support" ;
11
12
} ;
12
13
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 {
15
22
enable = true ;
16
- extraPackages = with stable ; [
23
+ extraPackages = with pkgs ; [
17
24
# ROCm OpenCL ICD
18
25
rocmPackages . clr . icd
19
- ocl-icd
20
-
21
- # ROCm
22
26
rocm-opencl-icd
23
- rocm-runtime-ext
24
27
25
28
# AMDVLK
26
29
amdvlk
Original file line number Diff line number Diff line change 17
17
18
18
web-ui = mkEnableOption "Enable the web UI for Ollama." ;
19
19
lmstudio = mkEnabledOption "Enable LM Studio." ;
20
-
21
- amd = mkEnableOption "Enable AMD ROCM support." ;
22
- nvidia = mkEnableOption "Enable NVIDIA CUDA support." ;
23
20
} ;
24
21
25
22
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
-
32
23
services = {
33
24
ollama = {
34
25
enable = true ;
42
33
in ( lib . concatStringsSep "," origins ) ;
43
34
} ;
44
35
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 ;
47
42
} ;
48
43
49
44
nextjs-ollama-llm-ui = mkIf cfg . web-ui {
You can’t perform that action at this time.
0 commit comments