System/modules/linux/virtualization.nix

55 lines
1.6 KiB
Nix

{ config, lib, pkgs, inputs, ... }:
let nc = config.nathan.config;
in with lib; {
config = mkMerge [
(mkIf nc.virtualization.qemu {
# Enable the kernel modules
boot.kernelModules = [ "kvm-amd" "kvm-intel" ];
# Enable libvirt
programs.dconf.enable = true;
virtualisation.libvirtd.enable = true;
# Install virt-manager
environment.systemPackages = with pkgs; [ virtmanager virt-viewer ];
})
(mkIf nc.virtualization.docker {
# Enable docker
virtualisation.docker = {
enable = true;
# Automatically prune to keep things lean
autoPrune.enable = true;
};
# Make sure our containers can reach the network
boot.kernel.sysctl."net.ipv4.ip_forward" = true;
})
(mkIf nc.virtualization.lxc {
virtualisation.lxd = {
enable = true;
recommendedSysctlSettings = true;
};
users.users.${nc.user} = mkIf nc.installUser { extraGroups = [ "lxd" ]; };
})
(mkIf nc.virtualization.nixos {
# Setup networking for nixos containers
networking = {
nat = {
enable = true;
internalInterfaces = [ "ve-+" ];
};
};
})
(mkIf nc.virtualization.podman {
virtualisation.podman.enable = true;
environment.systemPackages = with pkgs; [ x11docker ];
})
# (mkIf nc.virtualization.crosvm {
# environment.systemPackages =
# with inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}; [
# crosvm
# libguestfs
# guestfs-tools
# sommelier
# ];
# })
];
}