nixos-config/profiles/virtualisation.nix

60 lines
1.5 KiB
Nix
Raw Normal View History

2021-10-24 23:15:08 +03:00
{ config, lib, pkgs, ... }:
with config.deviceSpecific; {
2022-02-01 05:17:22 +03:00
config = lib.mkIf enableVirtualisation {
virtualisation.docker = {
2022-09-23 21:26:59 +03:00
enable = true;
2022-10-08 04:32:18 +03:00
storageDriver = if (devInfo.fileSystem == "zfs") then
"zfs"
else if (devInfo.fileSystem == "btrfs") then
"btrfs"
else
"overlay2";
2022-02-01 05:17:22 +03:00
};
2022-03-22 06:01:10 +03:00
virtualisation.oci-containers.backend = "docker";
2021-02-07 02:38:11 +03:00
2022-02-01 05:17:22 +03:00
virtualisation.libvirtd = {
enable = !isServer;
qemu = {
ovmf.enable = true;
runAsRoot = true;
package = pkgs.qemu;
};
onBoot = "ignore";
onShutdown = "shutdown";
2021-10-27 15:19:41 +03:00
};
2021-02-07 02:38:11 +03:00
2022-10-08 04:32:18 +03:00
virtualisation.lxd = {
enable = !isContainer;
2022-10-08 04:32:18 +03:00
zfsSupport = (devInfo.fileSystem == "zfs");
recommendedSysctlSettings = true;
};
virtualisation.lxc = {
enable = !isContainer;
lxcfs.enable = !isContainer;
2022-10-08 04:32:18 +03:00
systemConfig = ''
lxc.lxcpath = /var/lib/lxd/containers
${if devInfo.fileSystem == "zfs" then ''
lxc.bdev.zfs.root = rpool/lxd
'' else ""}
'';
defaultConfig = ''
lxc.idmap = u 0 100000 65535
lxc.idmap = g 0 100000 65535
lxc.include = ${pkgs.lxcfs}/share/lxc/config/common.conf.d/00-lxcfs.conf
'';
};
2022-02-01 05:17:22 +03:00
virtualisation.spiceUSBRedirection.enable = true;
networking.nat = {
enable = true;
internalInterfaces = [ "ve-+" ];
};
2021-09-15 18:37:21 +03:00
2022-03-22 06:01:10 +03:00
environment.systemPackages = with pkgs; if isServer then [
2022-02-01 05:17:22 +03:00
] else [
2022-09-23 21:26:59 +03:00
docker-compose
2022-02-01 05:17:22 +03:00
virt-manager
];
2021-09-15 18:37:21 +03:00
};
2021-02-07 02:38:11 +03:00
}