forked from c3d2/nix-config
41 lines
974 B
Nix
41 lines
974 B
Nix
{ config, lib, ... }:
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.hq.yggdrasil;
|
|
hostNameHash = builtins.hashString "sha256" config.networking.hostName;
|
|
hextets = map (i: substring (4 * i) 4 hostNameHash) [ 0 1 2 3 ];
|
|
hostAddr = concatStringsSep ":" hextets;
|
|
in {
|
|
options = with types; {
|
|
hq.yggdrasil = {
|
|
enable =
|
|
mkEnableOption "Configure Yggdrasil access via the Yggdrasil router";
|
|
|
|
interface = mkOption {
|
|
type = nullOr str;
|
|
default = "eth0";
|
|
description = "Network interface to the C3D2 HQ ethernet";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
networking.interfaces = {
|
|
"${cfg.interface}" = {
|
|
"ipv6" = {
|
|
addresses = [{
|
|
address = "310:5217:69c0:9afc:${hostAddr}";
|
|
prefixLength = 64;
|
|
}];
|
|
routes = [{
|
|
address = "200::";
|
|
prefixLength = 7;
|
|
via = "310:5217:69c0:9afc::1";
|
|
}];
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|