{ config, lib, pkgs, ... }: let yggaddr = import ../yggaddr.nix; containerFunc = name: # Generate a container expression from the directory at `name`. with builtins; let hash = hashString "sha256" name; hextet0 = substring 0 4 hash; hextet1 = substring 4 4 hash; in { inherit name; value = { # These are attributes common to each container # from the perspective of the host. autoStart = true; privateNetwork = true; hostBridge = "br0"; localAddress6 = "${yggaddr.prefix}:c3d2:${hextet0}:${hextet1}/64"; # Generate a deterministic IPv6 address for the container. # This address is accessible within HQ and Yggdrasil but not from ARPANET. config = import (./. + "/${name}"); }; }; containerDir = builtins.readDir ../containers; containerSubdirs = lib.filterAttrs (_: kind: kind == "directory") containerDir; containerNames = builtins.attrNames containerSubdirs; containers = builtins.listToAttrs (map containerFunc containerNames); in { boot.enableContainers = true; inherit containers; }