From f46e58a38b7edd53361b3a442a94b1af3d088ac2 Mon Sep 17 00:00:00 2001
From: tv <tv@krebsco.de>
Date: Fri, 8 Apr 2016 03:53:34 +0200
Subject: retiolum: don't hardcode routing prefixes

---
 tv/1systems/doppelbock.nix       |  4 ++--
 tv/1systems/mkdir.nix            | 11 +----------
 tv/1systems/rmdir.nix            |  7 +------
 tv/2configs/exim-smarthost.nix   |  2 +-
 tv/3modules/charybdis/config.nix |  9 +++------
 5 files changed, 8 insertions(+), 25 deletions(-)

(limited to 'tv')

diff --git a/tv/1systems/doppelbock.nix b/tv/1systems/doppelbock.nix
index 9a8d5b0..ec85a77 100644
--- a/tv/1systems/doppelbock.nix
+++ b/tv/1systems/doppelbock.nix
@@ -13,8 +13,8 @@ with config.krebs.lib;
   networking = {
     interfaces.enp2s1.ip4 = singleton {
       address = let
-        addr4 = "45.62.237.203";
-      in assert config.krebs.build.host.nets.internet.addrs4 == [addr4]; addr4;
+        addr = "45.62.237.203";
+      in assert config.krebs.build.host.nets.internet.ip4.addr == addr; addr;
       prefixLength = 24;
     };
     defaultGateway = "45.62.237.1";
diff --git a/tv/1systems/mkdir.nix b/tv/1systems/mkdir.nix
index 58a8fdc..f46ed95 100644
--- a/tv/1systems/mkdir.nix
+++ b/tv/1systems/mkdir.nix
@@ -7,12 +7,7 @@ let
   getDefaultGateway = ip:
     concatStringsSep "." (take 3 (splitString "." ip) ++ ["1"]);
 
-
-  primary-addr4 =
-    builtins.elemAt config.krebs.build.host.nets.internet.addrs4 0;
-
-  #secondary-addr4 =
-  #  builtins.elemAt config.krebs.build.host.nets.internet.addrs4 1;
+  primary-addr4 = config.krebs.build.host.nets.internet.ip4.addr;
 in
 
 {
@@ -55,10 +50,6 @@ in
       address = primary-addr4;
       prefixLength = 24;
     }
-    #{
-    #  address = secondary-addr4;
-    #  prefixLength = 24;
-    #}
   ];
 
   # TODO define gateway in krebs/3modules/default.nix
diff --git a/tv/1systems/rmdir.nix b/tv/1systems/rmdir.nix
index c54caa6..25fae2c 100644
--- a/tv/1systems/rmdir.nix
+++ b/tv/1systems/rmdir.nix
@@ -7,12 +7,7 @@ let
   getDefaultGateway = ip:
     concatStringsSep "." (take 3 (splitString "." ip) ++ ["1"]);
 
-
-  primary-addr4 =
-    builtins.elemAt config.krebs.build.host.nets.internet.addrs4 0;
-
-  #secondary-addr4 =
-  #  builtins.elemAt config.krebs.build.host.nets.internet.addrs4 1;
+  primary-addr4 = config.krebs.build.host.nets.internet.ip4.addr;
 in
 
 {
diff --git a/tv/2configs/exim-smarthost.nix b/tv/2configs/exim-smarthost.nix
index 280d857..8a90639 100644
--- a/tv/2configs/exim-smarthost.nix
+++ b/tv/2configs/exim-smarthost.nix
@@ -13,7 +13,7 @@ with config.krebs.lib;
       "shackspace.de"
       "viljetic.de"
     ];
-    relay_from_hosts = concatMap (host: host.nets.retiolum.addrs4) [
+    relay_from_hosts = concatMap (host: host.nets.retiolum.ip4.addr) [
       config.krebs.hosts.nomic
       config.krebs.hosts.wu
       config.krebs.hosts.xu
diff --git a/tv/3modules/charybdis/config.nix b/tv/3modules/charybdis/config.nix
index e4d754f..1b16092 100644
--- a/tv/3modules/charybdis/config.nix
+++ b/tv/3modules/charybdis/config.nix
@@ -56,9 +56,9 @@ in toFile "charybdis.conf" ''
     /* On multi-homed hosts you may need the following. These define
      * the addresses we connect from to other servers. */
     /* for IPv4 */
-    vhost = ${concatMapStringsSep ", " toJSON config.krebs.build.host.nets.retiolum.addrs4};
+    vhost = ${toJSON config.krebs.build.host.nets.retiolum.ip4.addr};
     /* for IPv6 */
-    vhost6 = ${concatMapStringsSep ", " toJSON config.krebs.build.host.nets.retiolum.addrs6};
+    vhost6 = ${toJSON config.krebs.build.host.nets.retiolum.ip6.addr};
 
     /* ssl_private_key: our ssl private key */
     ssl_private_key = ${toJSON cfg.ssl_private_key.path};
@@ -160,10 +160,7 @@ in toFile "charybdis.conf" ''
     /* If you want to listen on a specific IP only, specify host.
      * host definitions apply only to the following port line.
      */
-    # XXX This is stupid because only one host is allowed[?]
-    #host = ''${concatMapStringsSep ", " toJSON (
-    #  config.krebs.build.host.nets.retiolum.addrs
-    #)};
+    #host = ${toJSON config.krebs.build.host.nets.retiolum.ip4.addr};
     port = ${toString cfg.port};
     sslport = ${toString cfg.sslport};
   };
-- 
cgit v1.2.3