Remove useless piece of code

Ids must start at 100 because of Proxmox.
This commit is contained in:
Nicolas Jeannerod 2024-11-14 12:46:53 +01:00
parent 1c614ff3b8
commit 95389bb615
Signed by untrusted user: Niols
GPG key ID: 35DB9EC8886E1CB8
2 changed files with 7 additions and 31 deletions

View file

@ -1,18 +1,6 @@
{ inputs, self, ... }: { inputs, self, ... }:
let let
vmIdTo03d =
id:
let
sid = toString id;
in
if id >= 0 && id <= 9 then
"00${sid}"
else if id >= 10 && id <= 99 then
"0${sid}"
else
sid;
allVmIds = # 100 -- 255 allVmIds = # 100 -- 255
let let
allVmIdsFrom = x: if x > 255 then [ ] else [ x ] ++ allVmIdsFrom (x + 1); allVmIdsFrom = x: if x > 255 then [ ] else [ x ] ++ allVmIdsFrom (x + 1);
@ -38,7 +26,7 @@ in
in in
listToAttrs ( listToAttrs (
map (vmid: { map (vmid: {
name = "fedi${vmIdTo03d vmid}"; name = "fedi${toString vmid}";
value = makeProvisioningConfiguration vmid; value = makeProvisioningConfiguration vmid;
}) allVmIds }) allVmIds
); );
@ -74,8 +62,8 @@ in
type = providers.local.exec; type = providers.local.exec;
imports = [ inputs.nixops4-nixos.modules.nixops4Resource.nixos ]; imports = [ inputs.nixops4-nixos.modules.nixops4Resource.nixos ];
ssh.opts = ""; ssh.opts = "";
ssh.host = "95.215.187.${vmIdTo03d vmid}"; ssh.host = "95.215.187.${toString vmid}";
ssh.hostPublicKey = readFile ./hostKeys/fedi${vmIdTo03d vmid}/ssh_host_ed25519_key.pub; ssh.hostPublicKey = readFile ./hostKeys/fedi${toString vmid}/ssh_host_ed25519_key.pub;
nixpkgs = inputs.nixpkgs; nixpkgs = inputs.nixpkgs;
nixos.module = { nixos.module = {

View file

@ -8,18 +8,6 @@
let let
inherit (lib) mkOption; inherit (lib) mkOption;
inherit (lib.types) types; inherit (lib.types) types;
vmIdTo03d =
id:
let
sid = toString id;
in
if id >= 0 && id <= 9 then
"00${sid}"
else if id >= 10 && id <= 99 then
"0${sid}"
else
sid;
in in
{ {
@ -30,7 +18,7 @@ in
vmid = mkOption { vmid = mkOption {
type = types.int; type = types.int;
description = '' description = ''
Identifier of the machine. This is a number between 10 and 255. Identifier of the machine. This is a number between 100 and 255.
''; '';
}; };
}; };
@ -43,7 +31,7 @@ in
services.openssh.enable = true; services.openssh.enable = true;
networking = { networking = {
hostName = "fedi${vmIdTo03d config.procolix.vmid}"; hostName = "fedi${toString config.procolix.vmid}";
domain = "procolix.com"; domain = "procolix.com";
interfaces = { interfaces = {
@ -51,7 +39,7 @@ in
ipv4 = { ipv4 = {
addresses = [ addresses = [
{ {
address = "95.215.187.${vmIdTo03d config.procolix.vmid}"; address = "95.215.187.${toString config.procolix.vmid}";
prefixLength = 24; prefixLength = 24;
} }
]; ];
@ -59,7 +47,7 @@ in
ipv6 = { ipv6 = {
addresses = [ addresses = [
{ {
address = "2a00:51c0:13:1305::${vmIdTo03d config.procolix.vmid}"; address = "2a00:51c0:13:1305::${toString config.procolix.vmid}";
prefixLength = 64; prefixLength = 64;
} }
]; ];