46 lines
1.2 KiB
Nix
46 lines
1.2 KiB
Nix
{ 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}:${hextet0}:${hextet1}:c3d2/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;
|
|
|
|
imports = [ ../../../lib/lxc ];
|
|
lxc.containers = {
|
|
trivial = {
|
|
nixos-config = "/tmp/trivial.nix";
|
|
};
|
|
};
|
|
}
|