diff options
Diffstat (limited to 'systems/zoldene/virtualisation.nix')
-rw-r--r-- | systems/zoldene/virtualisation.nix | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/systems/zoldene/virtualisation.nix b/systems/zoldene/virtualisation.nix new file mode 100644 index 0000000..d2212fe --- /dev/null +++ b/systems/zoldene/virtualisation.nix | |||
@@ -0,0 +1,46 @@ | |||
1 | { pkgs-no-overlay, ... }: | ||
2 | { | ||
3 | boot.kernelModules = [ "nf_nat_ftp" ]; | ||
4 | |||
5 | ### Enable Docker | ||
6 | virtualisation.docker.enable = true; | ||
7 | disko.devices.zpool.zfast.datasets."root/persist/var/lib/docker" = | ||
8 | { type = "zfs_fs"; mountpoint = "/persist/zfast/var/lib/docker"; options.mountpoint = "legacy"; }; | ||
9 | |||
10 | ### Enable LXC | ||
11 | disko.devices.zpool.zfast.datasets."root/persist/var/lib/lxc" = | ||
12 | { type = "zfs_fs"; mountpoint = "/persist/zfast/var/lib/lxc"; options.mountpoint = "legacy"; }; | ||
13 | virtualisation.lxc = { | ||
14 | enable = true; | ||
15 | lxcfs.enable = true; | ||
16 | }; | ||
17 | |||
18 | ### Enable libvirtd | ||
19 | virtualisation.libvirtd = { | ||
20 | enable = true; | ||
21 | qemu.package = pkgs-no-overlay.qemu; | ||
22 | }; | ||
23 | |||
24 | ### Persistence for LXC / Docker | ||
25 | environment.persistence."/persist/zfast".directories = [ | ||
26 | { | ||
27 | directory = "/var/lib/lxc"; | ||
28 | user = "root"; | ||
29 | group = "root"; | ||
30 | mode = "0755"; | ||
31 | } | ||
32 | { | ||
33 | directory = "/var/lib/docker"; | ||
34 | user = "root"; | ||
35 | group = "root"; | ||
36 | mode = "0750"; | ||
37 | } | ||
38 | ]; | ||
39 | |||
40 | # ip forwarding is needed for NAT'ing to work in containers/VMs. | ||
41 | boot.kernel.sysctl = { | ||
42 | "net.ipv4.conf.all.forwarding" = true; | ||
43 | "net.ipv4.conf.default.forwarding" = true; | ||
44 | }; | ||
45 | } | ||
46 | |||