2024-10-28 09:51:44 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2024-11-09 14:02:26 +00:00
|
|
|
with lib;
|
|
|
|
{
|
2024-10-28 09:51:44 +00:00
|
|
|
options.networking = {
|
|
|
|
rootHostName = mkOption {
|
|
|
|
description = "Hostname of the running host";
|
2024-10-28 10:43:52 +00:00
|
|
|
type = types.str;
|
2024-10-28 09:51:44 +00:00
|
|
|
default = "";
|
|
|
|
example = "rainbow-resort";
|
|
|
|
};
|
|
|
|
nodeID = mkOption {
|
|
|
|
description = "Unique node ID";
|
2024-10-28 10:43:52 +00:00
|
|
|
type = types.str;
|
2024-10-28 09:51:44 +00:00
|
|
|
readOnly = true;
|
|
|
|
};
|
|
|
|
fullHostName = mkOption {
|
|
|
|
description = "Full combined host name";
|
2024-10-28 10:43:52 +00:00
|
|
|
type = types.str;
|
2024-10-28 09:51:44 +00:00
|
|
|
readOnly = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
networking = rec {
|
|
|
|
fullHostName =
|
2024-11-09 14:02:26 +00:00
|
|
|
if config.networking.rootHostName == "" then
|
|
|
|
config.networking.hostName
|
|
|
|
else
|
|
|
|
"${config.networking.rootHostName}-${config.networking.hostName}";
|
2024-10-28 09:51:44 +00:00
|
|
|
nodeID = lib.substring 0 8 (builtins.hashString "sha256" fullHostName);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|