infrastructure/meta/nodes/liminix.nix

98 lines
2.3 KiB
Nix
Raw Normal View History

# SPDX-FileCopyrightText: 2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>
# SPDX-FileContributor: Ryan Lahfa <ryan.lahfa@dgnum.eu>
#
# SPDX-License-Identifier: EUPL-1.2
2024-12-09 10:20:44 +01:00
###
# File specifying all the deployement options for the nodes administrated by the dgnum.
#
# Node metadata template is:
#
# NODE_NAME = {
# adminGroups = []; # List of groups that have root access
# admins = []; # List of individuals that have root access
# deployment = {}; # Colmena deployment options
# nixpkgs = "unstable" or "22.11"; # nixpkgs version
# }
2025-02-04 21:53:21 +01:00
let
nix-lib = import ../../lib/nix-lib;
inherit (nix-lib) mapFuse;
2024-12-09 10:20:44 +01:00
mkAP' = building: floor: ap-no: {
2025-02-04 21:53:21 +01:00
"ap-v01-${builtins.toString building}-${builtins.toString floor}-${builtins.toString ap-no}" = {
site = "unknown";
adminGroups = [ "fai" ];
2024-12-09 10:20:44 +01:00
2025-02-04 21:53:21 +01:00
hashedPassword = "$y$j9T$DMOQEWOYFHjNS0myrXp4x/$MG33VSdXGvib.99eN.AbvyVdNNJw4ERjAwK4.ULJe/A";
2024-12-09 10:20:44 +01:00
2025-02-04 21:53:21 +01:00
stateVersion = null;
nodeDir = "ap-v01";
2025-02-04 21:53:21 +01:00
nixpkgs = {
system = "zyxel-nwa50ax";
version = "24.05";
};
deployment = {
tags = [ "ap-dev" ];
targetHost = "10.0.253.1"; # TODO
};
2025-02-04 21:53:21 +01:00
extraNodeSettings = {
inherit building floor ap-no;
vendor-mac = null;
};
2024-12-09 10:20:44 +01:00
};
};
/*
Generate all APs nodes for a building. It takes a building definition and returns
an attributes set containing all nodes of the AP for the building.
Building definition:
* building-no is the index of the building
* floors is the range {from, to{ of floors that contains an AP
* ap-nos is the range [from, to{ of AP numbers
Type: AttrSet -> AttrSet
*/
mkAPs-building =
{
building-no,
floors,
ap-nos,
}:
mapFuse (f: mapFuse (mkAP' building-no f) (mkRange ap-nos)) (mkRange floors);
APs = {
hypnos-1 = {
building-no = 0;
floors = {
from = 0;
to = 3;
};
ap-nos = {
from = 1;
to = 7;
};
};
hypnos-2 = {
building-no = 1;
floors = {
from = 0;
to = 3;
};
ap-nos = {
from = 1;
to = 3;
};
};
};
mkRange = { from, to }: builtins.genList (x: x + from) (to - from);
2025-02-04 21:53:21 +01:00
in
{ }
// builtins.foldl' (nodes: building: nodes // mkAPs-building building) { } (builtins.attrValues APs)