nix-config/nixos/_mixins/virt/podman.nix

35 lines
867 B
Nix
Raw Normal View History

2023-10-16 18:46:06 +00:00
{ config, desktop, lib, pkgs, ... }:
let
dockerEnabled = config.virtualisation.docker.enable;
in
{
# https://nixos.wiki/wiki/Podman
environment.systemPackages = with pkgs; [
unstable.distrobox
podman-compose
podman-tui
] ++ lib.optionals (desktop != null) [
unstable.pods
podman-desktop
];
virtualisation.podman = {
enable = true;
dockerCompat = !dockerEnabled;
dockerSocket.enable = !dockerEnabled;
defaultNetwork.settings.dns_enabled = true;
enableNvidia = lib.elem "nvidia" config.services.xserver.videoDrivers;
};
virtualisation.oci-containers.backend = lib.mkIf (!dockerEnabled) "podman";
environment.extraInit = lib.mkIf (!dockerEnabled)
''
if [ -z "$DOCKER_HOST" -a -n "$XDG_RUNTIME_DIR" ]; then
export DOCKER_HOST="unix://$XDG_RUNTIME_DIR/podman/podman.sock"
fi
'';
}