wip: nixpkgs versions + infra network + monitoring
Signed-off-by: Jeltz <jeltz@federez.net>
This commit is contained in:
parent
01b5a0fe25
commit
a64b34810d
24 changed files with 1363 additions and 513 deletions
11
network/default.nix
Normal file
11
network/default.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{ lib, ... }:
|
||||
|
||||
let
|
||||
result = lib.evalModules {
|
||||
modules = [
|
||||
./options.nix
|
||||
./infra.nix
|
||||
];
|
||||
};
|
||||
in
|
||||
result.config
|
77
network/infra.nix
Normal file
77
network/infra.nix
Normal file
|
@ -0,0 +1,77 @@
|
|||
{ lib, ... }:
|
||||
|
||||
let
|
||||
toStringFixed = k: n: lib.fixedWidthString k "0" (toString n);
|
||||
mkNode = id: let
|
||||
a = id / 256;
|
||||
b = id - 256 * a;
|
||||
suffix = "${toStringFixed 3 a}${toStringFixed 3 b}";
|
||||
suffixA = builtins.substring 0 2 suffix;
|
||||
suffixB = builtins.substring 2 2 suffix;
|
||||
suffixC = builtins.substring 4 2 suffix;
|
||||
in {
|
||||
ipv6 = "fd0a:66d3:1c19:42::${toString a}:${toString b}";
|
||||
ipv4 = "10.42.${toString a}.${toString b}";
|
||||
mac = "42:42:42:${suffixA}:${suffixB}:${suffixC}";
|
||||
id = id;
|
||||
};
|
||||
mkHub = hub: hub // {
|
||||
ipv6 = "fd0a:66d3:1c19:1000::${toString hub.id}";
|
||||
};
|
||||
in {
|
||||
infra = {
|
||||
vxlan = {
|
||||
vni = 42;
|
||||
port = 4789;
|
||||
};
|
||||
cidr = {
|
||||
hubs.ipv6 = 64;
|
||||
nodes = {
|
||||
ipv4 = 16;
|
||||
ipv6 = 64;
|
||||
};
|
||||
};
|
||||
nodes = builtins.mapAttrs (_: mkNode) {
|
||||
vogon = 1;
|
||||
glucagon = 2;
|
||||
ronderu = 3;
|
||||
dodecagon = 4;
|
||||
saigon = 5;
|
||||
harpagon = 6;
|
||||
patagon = 7;
|
||||
wagon = 8;
|
||||
lagon = 9;
|
||||
aragon = 10;
|
||||
pendragon = 11;
|
||||
estragon = 12;
|
||||
carlosgon = 13;
|
||||
memoragon = 14;
|
||||
hendecagon = 15;
|
||||
dragon = 16;
|
||||
perdrigon = 17;
|
||||
martagon = 18;
|
||||
};
|
||||
hubs = builtins.mapAttrs (_: mkHub) {
|
||||
vogon = {
|
||||
id = 1;
|
||||
publicKey = "d5vEJUiTFQh+MPQcU2JTaJ9lcsvzuoZkohxzeOigiVQ=";
|
||||
endpoint = "193.54.193.161:51039";
|
||||
};
|
||||
glucagon = {
|
||||
id = 2;
|
||||
publicKey = "JfTsY3+jPTDgLDrECoSvoYs+6+GpjII0ookjhFhd5SY=";
|
||||
endpoint = "89.234.162.224:51039";
|
||||
};
|
||||
ronderu = {
|
||||
id = 3;
|
||||
publicKey = "nOeLgmE1U6nY3UNxltQKwlID9lD7fvpEwij2XUvEGgg=";
|
||||
endpoint = "137.194.12.129:51039";
|
||||
};
|
||||
saigon = {
|
||||
id = 4;
|
||||
publicKey = "9pGyE4+CQl+f8sFJ/Mkvp14yxDQJ0SJmGnher5Tgzjc=";
|
||||
endpoint = "193.48.225.201:51039";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
127
network/options.nix
Normal file
127
network/options.nix
Normal file
|
@ -0,0 +1,127 @@
|
|||
{ lib, ... }:
|
||||
let
|
||||
nodeSubmodule = lib.types.submodule {
|
||||
options = {
|
||||
id = lib.mkOption {
|
||||
type = lib.types.ints.between 1 65535;
|
||||
description = ''
|
||||
Identifiant du nœud.
|
||||
'';
|
||||
example = 350;
|
||||
};
|
||||
ipv4 = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Adresse IPv4 interne du nœud.
|
||||
'';
|
||||
example = "10.42.1.94";
|
||||
};
|
||||
ipv6 = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Adresse IPv6 interne du nœud.
|
||||
'';
|
||||
example = "fd0a:66d3:1c19:42::1:94";
|
||||
};
|
||||
mac = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Adresse MAC interne du nœud.
|
||||
'';
|
||||
example = "42:42:42:00:10:94";
|
||||
};
|
||||
};
|
||||
};
|
||||
hubSubmodule = lib.types.submodule {
|
||||
options = {
|
||||
id = lib.mkOption {
|
||||
type = lib.types.ints.between 1 254;
|
||||
description = ''
|
||||
Identifiant du concentrateur.
|
||||
'';
|
||||
example = 12;
|
||||
};
|
||||
publicKey = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Clé publique du concentrateur.
|
||||
'';
|
||||
example = "pn8PoOZnlT+CUjI0lyILNhj7/7TMaNr+DmWbtWyj+Bg=";
|
||||
};
|
||||
endpoint = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Adresse et port publics du concentrateur.
|
||||
'';
|
||||
example = "1.2.3.4:54050";
|
||||
};
|
||||
ipv6 = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Adresse IPv6 interne du concentrateur.
|
||||
'';
|
||||
example = "fd0a:66d3:1c19:1000::12";
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
options = {
|
||||
infra = {
|
||||
vxlan = {
|
||||
vni = lib.mkOption {
|
||||
type = lib.types.ints.between 1 16777215;
|
||||
description = ''
|
||||
Identifiant de VXLAN du réseau INFRA.
|
||||
'';
|
||||
example = 42;
|
||||
};
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
description = ''
|
||||
Numéro de port du trafic VXLAN.
|
||||
'';
|
||||
example = 4789;
|
||||
};
|
||||
};
|
||||
cidr = {
|
||||
nodes = {
|
||||
ipv4 = lib.mkOption {
|
||||
type = lib.types.ints.between 1 32;
|
||||
description = ''
|
||||
Taille du réseau IPv4 interne des nœuds INFRA.
|
||||
'';
|
||||
example = 16;
|
||||
};
|
||||
ipv6 = lib.mkOption {
|
||||
type = lib.types.ints.between 1 128;
|
||||
description = ''
|
||||
Taille du réseau IPv6 interne des nœuds INFRA.
|
||||
'';
|
||||
example = 64;
|
||||
};
|
||||
};
|
||||
hubs.ipv6 = lib.mkOption {
|
||||
type = lib.types.ints.between 1 128;
|
||||
description = ''
|
||||
Taille du réseau IPv6 interne des concentrateurs INFRA.
|
||||
'';
|
||||
example = 64;
|
||||
};
|
||||
};
|
||||
nodes = lib.mkOption {
|
||||
type = lib.types.attrsOf nodeSubmodule;
|
||||
default = { };
|
||||
description = ''
|
||||
Nœuds du réseau INFRA.
|
||||
'';
|
||||
};
|
||||
hubs = lib.mkOption {
|
||||
type = lib.types.attrsOf hubSubmodule;
|
||||
default = { };
|
||||
description = ''
|
||||
Concentrateurs du réseau INFRA.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue