diff options
| author | seth <[email protected]> | 2024-05-31 06:55:51 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2024-06-01 01:52:42 +0000 |
| commit | 7168a84dc02191dd498ac1fbadb8da945d41477b (patch) | |
| tree | d0bee927edf329f3feb3d647a3480727b593b374 /modules/nixos/traits | |
| parent | c3f803a497cc0212ee361d45f8f4637d2ce1183c (diff) | |
modules: support >= 24.05
Diffstat (limited to 'modules/nixos/traits')
| -rw-r--r-- | modules/nixos/traits/containers.nix | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/modules/nixos/traits/containers.nix b/modules/nixos/traits/containers.nix index 10824eb..5170c34 100644 --- a/modules/nixos/traits/containers.nix +++ b/modules/nixos/traits/containers.nix @@ -6,35 +6,29 @@ ... }: let cfg = config.traits.containers; + enableNvidia = lib.elem "nvidia" (config.services.xserver.videoDrivers or []); in { options.traits.containers = { enable = lib.mkEnableOption "containers support"; }; - config.virtualisation = lib.mkIf cfg.enable ( + config = lib.mkIf cfg.enable ( lib.mkMerge [ { - podman = { - enable = true; - extraPackages = with pkgs; [podman-compose]; - autoPrune.enable = true; - }; + virtualisation = { + 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; - }) + (lib.mkIf enableNvidia { + hardware.nvidia-container-toolkit.enable = true; + }) ] ); } |
