System/modules/linux/virtualization.nix

55 lines
1.6 KiB
Nix
Raw Normal View History

2022-11-04 02:26:37 -04:00
{ config, lib, pkgs, inputs, ... }:
let nc = config.nathan.config;
in with lib; {
2022-07-02 02:44:43 -04:00
config = mkMerge [
(mkIf nc.virtualization.qemu {
# Enable the kernel modules
boot.kernelModules = [ "kvm-amd" "kvm-intel" ];
# Enable libvirt
2023-07-01 17:41:02 -04:00
programs.dconf.enable = true;
virtualisation.libvirtd.enable = true;
# Install virt-manager
2023-03-14 12:06:37 -04:00
environment.systemPackages = with pkgs; [ virtmanager virt-viewer ];
})
2022-07-02 02:44:43 -04:00
(mkIf nc.virtualization.docker {
2022-06-23 02:57:41 -04:00
# Enable docker
virtualisation.docker = {
enable = true;
# Automatically prune to keep things lean
autoPrune.enable = true;
};
2022-09-05 20:52:22 -04:00
# Make sure our containers can reach the network
boot.kernel.sysctl."net.ipv4.ip_forward" = true;
2022-07-02 02:44:43 -04:00
})
(mkIf nc.virtualization.lxc {
2022-06-23 02:57:41 -04:00
virtualisation.lxd = {
enable = true;
recommendedSysctlSettings = true;
};
users.users.${nc.user} = mkIf nc.installUser { extraGroups = [ "lxd" ]; };
2022-07-02 02:44:43 -04:00
})
(mkIf nc.virtualization.nixos {
2022-06-23 02:57:41 -04:00
# Setup networking for nixos containers
networking = {
nat = {
enable = true;
internalInterfaces = [ "ve-+" ];
};
};
2022-07-02 02:44:43 -04:00
})
2023-06-23 05:51:13 -04:00
(mkIf nc.virtualization.podman {
virtualisation.podman.enable = true;
environment.systemPackages = with pkgs; [ x11docker ];
})
2022-11-04 02:26:37 -04:00
# (mkIf nc.virtualization.crosvm {
# environment.systemPackages =
# with inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}; [
# crosvm
# libguestfs
# guestfs-tools
# sommelier
# ];
# })
2022-07-02 02:44:43 -04:00
];
2022-06-23 02:57:41 -04:00
}