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 {
|
2023-03-26 19:24:28 +03:00
|
|
|
virtualisation = {
|
|
|
|
oci-containers.backend = lib.mkForce "podman";
|
|
|
|
docker = {
|
|
|
|
enable = true;
|
|
|
|
daemon.settings = {
|
|
|
|
features = { buildkit = true; };
|
|
|
|
};
|
|
|
|
storageDriver = "overlay2";
|
2022-10-21 13:57:17 +03:00
|
|
|
};
|
2023-03-26 19:24:28 +03:00
|
|
|
podman = {
|
|
|
|
enable = true;
|
|
|
|
defaultNetwork.settings.dns_enabled = true;
|
2023-01-26 00:23:55 +03:00
|
|
|
};
|
2023-03-26 19:24:28 +03:00
|
|
|
containers.registries.search = [
|
|
|
|
"docker.io" "gcr.io" "quay.io"
|
|
|
|
];
|
|
|
|
containers.storage.settings = {
|
|
|
|
storage = {
|
|
|
|
driver = "overlay2";
|
|
|
|
graphroot = "/var/lib/containers/storage";
|
|
|
|
runroot = "/run/containers/storage";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
lxd = lib.mkIf (!isContainer) {
|
|
|
|
enable = true;
|
|
|
|
zfsSupport = devInfo.fileSystem == "zfs";
|
|
|
|
recommendedSysctlSettings = true;
|
|
|
|
};
|
|
|
|
lxc = {
|
|
|
|
enable = true;
|
|
|
|
lxcfs.enable = true;
|
|
|
|
systemConfig = ''
|
|
|
|
lxc.lxcpath = /var/lib/lxd/containers
|
|
|
|
${if devInfo.fileSystem == "zfs" then ''
|
|
|
|
lxc.bdev.zfs.root = rpool/persistent/lxd
|
|
|
|
'' else ""}
|
|
|
|
'';
|
2023-03-27 20:57:06 +03:00
|
|
|
# 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
|
|
|
};
|
2023-03-26 19:24:28 +03:00
|
|
|
libvirtd = {
|
|
|
|
enable = true;
|
|
|
|
qemu = {
|
|
|
|
ovmf.enable = true;
|
|
|
|
ovmf.packages = [
|
|
|
|
pkgs.OVMFFull.fd
|
|
|
|
pkgs.pkgsCross.aarch64-multiplatform.OVMF.fd
|
|
|
|
];
|
|
|
|
runAsRoot = false;
|
|
|
|
};
|
|
|
|
onBoot = "ignore";
|
|
|
|
onShutdown = "shutdown";
|
|
|
|
};
|
|
|
|
|
|
|
|
spiceUSBRedirection.enable = true;
|
2021-10-27 15:19:41 +03:00
|
|
|
};
|
2021-02-07 02:38:11 +03:00
|
|
|
|
2023-03-26 19:24:28 +03:00
|
|
|
security.unprivilegedUsernsClone = true;
|
|
|
|
|
2022-12-10 22:34:39 +03:00
|
|
|
home-manager.users.${config.mainuser} = {
|
2023-03-26 19:24:28 +03:00
|
|
|
home.file.".config/containers/storage.conf".text = ''
|
|
|
|
[storage]
|
|
|
|
driver = "overlay2"
|
|
|
|
'';
|
2022-10-08 04:32:18 +03:00
|
|
|
};
|
|
|
|
|
2023-03-27 20:57:06 +03:00
|
|
|
# users.users.${config.mainuser} = {
|
|
|
|
# subUidRanges = [{
|
|
|
|
# count = 1000;
|
|
|
|
# startUid = 10000;
|
|
|
|
# }];
|
|
|
|
# subGidRanges = [{
|
|
|
|
# count = 1000;
|
|
|
|
# startGid = 10000;
|
|
|
|
# }];
|
|
|
|
# };
|
2022-02-01 05:17:22 +03:00
|
|
|
|
2023-03-26 19:24:28 +03:00
|
|
|
programs.extra-container.enable = true;
|
2022-12-14 23:46:25 +03:00
|
|
|
|
2023-03-27 16:00:57 +03:00
|
|
|
persist.state.homeDirectories = [
|
|
|
|
".config/containers"
|
|
|
|
];
|
|
|
|
|
2023-03-26 19:24:28 +03:00
|
|
|
persist.state.directories = lib.mkIf (devInfo.fileSystem != "zfs") [
|
2022-12-14 23:46:25 +03:00
|
|
|
"/var/lib/docker"
|
|
|
|
"/var/lib/libvirt"
|
2023-03-26 19:24:28 +03:00
|
|
|
"/var/lib/containers"
|
|
|
|
"/var/lib/lxd"
|
2022-12-14 23:46:25 +03:00
|
|
|
];
|
2021-09-15 18:37:21 +03:00
|
|
|
};
|
2023-03-26 19:24:28 +03:00
|
|
|
}
|