diff options
| author | seth <[email protected]> | 2024-02-27 10:35:28 -0500 |
|---|---|---|
| committer | seth <[email protected]> | 2024-02-27 10:35:28 -0500 |
| commit | 82e202287f4f25afe411d93d2f437f0977c52570 (patch) | |
| tree | 08d87fd82db103ed465557f2697d7dd788bad12c /modules/nixos/traits | |
| parent | 4573847f01acd67d4cc3b6accbe797e4c8f58223 (diff) | |
nixos/containers: use new option for nvidia-container-toolkit when possible
Diffstat (limited to 'modules/nixos/traits')
| -rw-r--r-- | modules/nixos/traits/containers.nix | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/modules/nixos/traits/containers.nix b/modules/nixos/traits/containers.nix index 43c748c..e309a89 100644 --- a/modules/nixos/traits/containers.nix +++ b/modules/nixos/traits/containers.nix @@ -1,6 +1,7 @@ { config, lib, + options, pkgs, ... }: let @@ -10,14 +11,28 @@ in { enable = lib.mkEnableOption "containers support"; }; - config.virtualisation = lib.mkIf cfg.enable { - podman = { - enable = true; - enableNvidia = lib.mkDefault (builtins.elem "nvidia" (config.services.xserver.videoDrivers or [])); - extraPackages = with pkgs; [podman-compose]; - autoPrune.enable = true; - }; + config.virtualisation = lib.mkMerge [ + (lib.mkIf cfg.enable { + podman = { + enable = true; + extraPackages = with pkgs; [podman-compose]; + autoPrune.enable = true; + }; - oci-containers.backend = "podman"; - }; + oci-containers.backend = "podman"; + }) + + (let + enable = lib.mkDefault ( + lib.elem "nvidia" (config.services.xserver.videoDrivers or []) + ); + in + if (options.virtualisation.containers ? cdi) + then { + containers.cdi.dynamic.nvidia = {inherit enable;}; + } + else { + podman.enableNvidia = enable; + }) + ]; } |
