anchor.diff:        '';
       };
   
  +    enableNvidia = mkOption {
  +      type = types.bool;
  +      default = false;
  +      description = ''
  +        Enable use of NVidia GPUs from within podman containers.
  +      '';
  +    };
  +
       extraPackages = mkOption {
         type = with types; listOf package;
         default = [ ];
  
positive.code: { config, lib, pkgs, utils, ... }:
  let
    cfg = config.virtualisation.podman;
  
    inherit (lib) mkOption types;
  
  
negative.code: 
    };
  
    config = lib.mkIf cfg.enable (lib.mkMerge [
      {
        environment.systemPackages = [ cfg.package ]
          ++ lib.optional cfg.dockerCompat dockerCompat;
  
        environment.etc."cni/net.d/87-podman-bridge.conflist".source = utils.copyFile "${pkgs.podman-unwrapped.src}/cni/87-podman-bridge.conflist";
  
        virtualisation.containers = {
          enable = true; # Enable common /etc/containers configuration
          containersConf.extraConfig = lib.optionalString cfg.enableNvidia
            (builtins.readFile (toml.generate "podman.nvidia.containers.conf" {
              engine = {
                conmon_env_vars = [ "PATH=${lib.makeBinPath [ pkgs.nvidia-docker ]}" ];
                runtimes.nvidia = [ "${pkgs.nvidia-docker}/bin/nvidia-container-runtime" ];
              };
            }));
        };
  
        assertions = [
          {
            assertion = cfg.dockerCompat -> !config.virtualisation.docker.enable;
            message = "Option dockerCompat conflicts with docker";
          }
          {
            assertion = cfg.enableNvidia -> !config.virtualisation.docker.enableNvidia;
            message = "Option enableNvidia conflicts with docker.enableNvidia";
          }
        ];
      }
      (lib.mkIf cfg.enableNvidia {
        environment.etc."nvidia-container-runtime/config.toml".source = "${pkgs.nvidia-docker}/etc/podman-config.toml";
      })
    ]);
  }
  