nfsroot: init

This commit is contained in:
Astro 2022-06-07 20:15:09 +02:00
parent db98e62e31
commit 4d960bbd95
3 changed files with 88 additions and 1 deletions

View File

@ -595,6 +595,13 @@
];
};
nfsroot = nixosSystem' {
modules = [
microvm.nixosModules.microvm
./hosts/containers/nfsroot
];
};
};
nixosModule = self.nixosModules.c3d2;

View File

@ -0,0 +1,80 @@
{ zentralwerk, config, pkgs, ... }:
{
microvm = {
hypervisor = "qemu";
mem = 1024;
shares = [ {
source = "/nix/store";
mountPoint = "/nix/.ro-store";
tag = "store";
proto = "virtiofs";
socket = "store.socket";
} ] ++ map (dir: {
source = "/var/lib/microvms/${config.networking.hostName}/${dir}";
mountPoint = "/${dir}";
tag = dir;
proto = "virtiofs";
socket = "${dir}.socket";
}) [ "etc" "home" "var" "var/lib/nfsroot/dacbert" "var/lib/nfsroot/riscbert" ];
interfaces = [ {
type = "tap";
id = "nfsroot";
mac = "00:de:fa:c8:28:9c";
} ];
};
networking = {
hostName = "nfsroot";
useDHCP = false;
interfaces.eth0 = {
useDHCP = false;
ipv4.addresses = [ {
address = netConfig.hosts4.${config.networking.hostName};
prefixLength = netConfig.subnet4Len;
} ];
};
defaultGateway = netConfig.hosts4.serv-gw;
nameservers = [
netConfig.hosts4.dnscache "9.9.9.9"
];
firewall.enable = false;
};
system.stateVersion = "22.05";
services.nfs.server = {
enable = true;
exports =
let
allowed = [
"172.22.99.0/24"
"172.20.72.0/21"
"30c:c3d2:b946:76d0::/64"
"2a00:8180:2c00:200::/56"
"fd23:42:c3d2:500::/56"
];
opts = o: fsid:
lib.concatStringsSep "," [
o "async"
"no_subtree_check" "no_root_squash"
"fsid=${toString fsid}"
];
in ''
/var/lib/nfsroot/dacbert ${
lib.concatMapStringsSep " " (subnet:
"${subnet}(${opts "rw" 1})"
) allowed
}
/var/lib/nfsroot/riscbert ${
lib.concatMapStringsSep " " (subnet:
"${subnet}(${opts "rw" 1})"
) allowed
}
'';
};
}

View File

@ -1,7 +1,7 @@
{
microvm.autostart = [ "oparl" ];
c3d2.server.bridgePorts = {
serv = [ "oparl" "leon" ];
serv = [ "oparl" "leon" "nfsroot" ];
};
nix = {