System/modules/linux/virtualization.nix

50 lines
1.4 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
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
})
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
}