summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2021-10-17 22:02:46 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2021-10-17 22:02:46 +0200
commit2f7fec4ddb2c2573346ebece927a8da13bfe448f (patch)
treecff794f12a5713543cfaefd47998712d99efa432 /modules
parent7085030e4ad9c1d723a2afbff73bb9d0798c2370 (diff)
downloadnixos-2f7fec4ddb2c2573346ebece927a8da13bfe448f.tar
nixos-2f7fec4ddb2c2573346ebece927a8da13bfe448f.tar.gz
nixos-2f7fec4ddb2c2573346ebece927a8da13bfe448f.tar.bz2
nixos-2f7fec4ddb2c2573346ebece927a8da13bfe448f.tar.xz
nixos-2f7fec4ddb2c2573346ebece927a8da13bfe448f.zip
yggdrasil-wg: ...
Diffstat (limited to 'modules')
-rw-r--r--modules/yggdrasil-wg/default.nix8
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/yggdrasil-wg/default.nix b/modules/yggdrasil-wg/default.nix
index 86e2b98a..6e49214e 100644
--- a/modules/yggdrasil-wg/default.nix
+++ b/modules/yggdrasil-wg/default.nix
@@ -80,15 +80,12 @@ let
80 linkToGreNetwork = ix: opts@{from, to, ...}: 80 linkToGreNetwork = ix: opts@{from, to, ...}:
81 let 81 let
82 other = if from == hostName then to else from; 82 other = if from == hostName then to else from;
83 hexIx = let
84 hexIx' = toHexString ix;
85 in if (stringLength hexIx' < 2) then "0${hexIx'}" else hexIx';
86 in nameValuePair "yggre-${other}" { 83 in nameValuePair "yggre-${other}" {
87 matchConfig = { 84 matchConfig = {
88 Name = "yggre-${other}"; 85 Name = "yggre-${other}";
89 }; 86 };
90 linkConfig = { 87 linkConfig = {
91 MACAddress = "${greHostMACPrefixes.${hostName}}:${hexIx}"; 88 MACAddress = "${greHostMACPrefixes.${hostName}}:${toHexByte ix}";
92 RequiredForOnline = false; 89 RequiredForOnline = false;
93 }; 90 };
94 networkConfig = { 91 networkConfig = {
@@ -104,6 +101,9 @@ let
104 withoutOpts = listToAttrs (map (nv: nameValuePair nv.name (removeAttrs nv.value [optName])) (filter (x: !(x.value.${optName} or false)) (imap0 (ix: nameValuePair (toString ix)) xs))); 101 withoutOpts = listToAttrs (map (nv: nameValuePair nv.name (removeAttrs nv.value [optName])) (filter (x: !(x.value.${optName} or false)) (imap0 (ix: nameValuePair (toString ix)) xs)));
105 in genList (ix: withOpts.${toString ix} or withoutOpts.${toString ix}) (length xs); 102 in genList (ix: withOpts.${toString ix} or withoutOpts.${toString ix}) (length xs);
106 mkLinks = optIx "udp2raw"; 103 mkLinks = optIx "udp2raw";
104 toHexByte = n: let
105 hex = toHexString n;
106 in if (stringLength hex < 2) then "0${hex}" else hex;
107in { 107in {
108 config = { 108 config = {
109 assertions = [ 109 assertions = [