From 45c65cbac59a8dc63216b938586982ca3bb54873 Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 29 Nov 2019 21:51:20 +0100 Subject: [PATCH] yggdrasil-hq: fix, enable for server7 --- hosts/server7/configuration.nix | 5 +++- hosts/server7/containers/adc/default.nix | 2 +- hosts/server7/containers/yggrasil/default.nix | 3 +-- lib/hq.nix | 5 ++++ lib/yggdrasil-hq.nix | 24 ++++++++++--------- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/hosts/server7/configuration.nix b/hosts/server7/configuration.nix index d3085474..d0a3edbe 100644 --- a/hosts/server7/configuration.nix +++ b/hosts/server7/configuration.nix @@ -7,7 +7,6 @@ ../../lib/emery.nix ./containers ./hardware-configuration.nix - ./yggdrasil-prefix.nix ./hydra.nix ./nix-serve.nix ]; @@ -50,6 +49,10 @@ enp2s0f1.useDHCP = false; }; }; + hq.yggdrasil = { + enable = true; + interface = "br0"; + }; environment.systemPackages = with pkgs; [ tmux htop vim gitMinimal nixfmt ]; diff --git a/hosts/server7/containers/adc/default.nix b/hosts/server7/containers/adc/default.nix index f397892c..cc77d974 100644 --- a/hosts/server7/containers/adc/default.nix +++ b/hosts/server7/containers/adc/default.nix @@ -2,7 +2,7 @@ { imports = [ - ../../../../lib/yggdrasil-hq.nix + ../../../../lib/hq.nix ]; services.uhub = { diff --git a/hosts/server7/containers/yggrasil/default.nix b/hosts/server7/containers/yggrasil/default.nix index 7e87d1da..663f9834 100644 --- a/hosts/server7/containers/yggrasil/default.nix +++ b/hosts/server7/containers/yggrasil/default.nix @@ -4,8 +4,7 @@ imports = [ ../../../../lib/hq.nix - ../../../../lib/yggdrasil.nix - ./yggdrasil-prefix.nix + ../../../../lib/yggdrasil-service.nix ]; networking.interfaces.eth0 = { diff --git a/lib/hq.nix b/lib/hq.nix index c9611109..4182a7da 100644 --- a/lib/hq.nix +++ b/lib/hq.nix @@ -18,5 +18,10 @@ in { ]; }; + # Please import only things that are configurable and OFF BY DEFAULT! + imports = [ + ./yggdrasil-hq.nix + ]; + users.motd = builtins.readFile ./motd; } diff --git a/lib/yggdrasil-hq.nix b/lib/yggdrasil-hq.nix index 1d504b01..ce92f017 100644 --- a/lib/yggdrasil-hq.nix +++ b/lib/yggdrasil-hq.nix @@ -3,7 +3,7 @@ with lib; let cfg = config.hq.yggdrasil; - hostNameHash = hashString "sha256" config.networking.hostName; + hostNameHash = builtins.hashString "sha256" config.networking.hostName; hextets = map (i: substring (4 * i) (4 * (i + 1)) hostNameHash) [ 0 1 2 3 ]; hostAddr = concatStringsSep ":" hextets; in { @@ -22,16 +22,18 @@ in { 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"; - }]; + "${cfg.interface}" = { + "ipv6" = { + addresses = [{ + address = "310:5217:69c0:9afc:${hostAddr}"; + prefixLength = 64; + }]; + routes = [{ + address = "200::"; + prefixLength = 7; + via = "310:5217:69c0:9afc::1"; + }]; + }; }; }; };