1
0
forked from clan/clan-core

Revert "clan.core: rename clan.{deployment,networking} -> clan.core.{deployment,networking}"

This reverts commit afbd4a984d.

The old configuration cannot be updated like this:

eve] error:
[eve]        … while calling the 'head' builtin
[eve]          at /nix/store/5b0hl2dnvr1sawqlkwmsnaiyqz00d34h-source/lib/attrsets.nix:1575:11:
[eve]          1574|         || pred here (elemAt values 1) (head values) then
[eve]          1575|           head values
[eve]              |           ^
[eve]          1576|         else
[eve]
[eve]        … while evaluating the attribute 'value'
[eve]          at /nix/store/5b0hl2dnvr1sawqlkwmsnaiyqz00d34h-source/lib/modules.nix:809:9:
[eve]           808|     in warnDeprecation opt //
[eve]           809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
[eve]              |         ^
[eve]           810|         inherit (res.defsFinal') highestPrio;
[eve]
[eve]        … while evaluating the option `system.build.toplevel':
[eve]
[eve]        … while evaluating definitions from `/nix/store/5b0hl2dnvr1sawqlkwmsnaiyqz00d34h-source/nixos/modules/system/activation/top-level.nix':
[eve]
[eve]        … while evaluating the option `assertions':
[eve]
[eve]        … while evaluating definitions from `/nix/store/5b0hl2dnvr1sawqlkwmsnaiyqz00d34h-source/nixos/modules/system/boot/systemd.nix':
[eve]
[eve]        … while evaluating the option `systemd.services':
[eve]
[eve]        … while evaluating definitions from `/nix/store/kpzcdgndym0qm1w490mjvk9c2qmz03h5-source/nixosModules/clanCore/zerotier':
[eve]
[eve]        … while evaluating the option `clan.core.networking.zerotier.networkId':
[eve]
[eve]        (stack trace truncated; use '--show-trace' to show the full, detailed trace)
[eve]
[eve]        error: A definition for option `clan.core.networking.zerotier.networkId' is not of type `null or string'. Definition values:
[eve]        - In `/nix/store/kpzcdgndym0qm1w490mjvk9c2qmz03h5-source/nixosModules/clanCore/networking.nix':
[eve]            {
[eve]              _type = "override";
[eve]              content = "267efd4a15b69623";
[eve]              priorit
This commit is contained in:
Jörg Thalheim 2024-07-05 11:16:05 +02:00
parent 4c6c5b86ad
commit 9778444706
21 changed files with 37 additions and 63 deletions

View File

@ -27,7 +27,7 @@
self.clanModules.localbackup self.clanModules.localbackup
self.clanModules.sshd self.clanModules.sshd
]; ];
clan.core.networking.targetHost = "machine"; clan.networking.targetHost = "machine";
networking.hostName = "machine"; networking.hostName = "machine";
services.openssh.settings.UseDns = false; services.openssh.settings.UseDns = false;

View File

@ -1,7 +1,7 @@
{ self, lib, ... }: { self, lib, ... }:
{ {
clan.machines.test_install_machine = { clan.machines.test_install_machine = {
clan.core.networking.targetHost = "test_install_machine"; clan.networking.targetHost = "test_install_machine";
fileSystems."/".device = lib.mkDefault "/dev/vdb"; fileSystems."/".device = lib.mkDefault "/dev/vdb";
boot.loader.grub.device = lib.mkDefault "/dev/vdb"; boot.loader.grub.device = lib.mkDefault "/dev/vdb";

View File

@ -98,7 +98,7 @@
settings = { settings = {
options = { options = {
urAccepted = -1; urAccepted = -1;
allowedNetworks = [ config.clan.core.networking.zerotier.subnet ]; allowedNetworks = [ config.clan.networking.zerotier.subnet ];
}; };
devices = devices =
{ } { }

View File

@ -57,7 +57,7 @@ in
) filteredMachines ) filteredMachines
); );
in in
lib.mkIf (config.clan.core.networking.zerotier.controller.enable) { lib.mkIf (config.clan.networking.zerotier.controller.enable) {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "zerotierone.service" ]; after = [ "zerotierone.service" ];
path = [ config.clan.core.clanPkgs.zerotierone ]; path = [ config.clan.core.clanPkgs.zerotierone ];
@ -69,5 +69,5 @@ in
''; '';
}; };
config.clan.core.networking.zerotier.networkId = lib.mkDefault networkId; config.clan.networking.zerotier.networkId = lib.mkDefault networkId;
} }

View File

@ -94,8 +94,6 @@ nav:
- reference/clan-core/facts.md - reference/clan-core/facts.md
- reference/clan-core/sops.md - reference/clan-core/sops.md
- reference/clan-core/state.md - reference/clan-core/state.md
- reference/clan-core/deployment.md
- reference/clan-core/networking.md
- Contributing: contributing/contributing.md - Contributing: contributing/contributing.md
docs_dir: site docs_dir: site

View File

@ -89,7 +89,7 @@ Adding or configuring a new machine requires two simple steps:
# Change this to the correct ip-address or hostname # Change this to the correct ip-address or hostname
# The hostname is the machine name by default # The hostname is the machine name by default
clan.core.networking.targetHost = pkgs.lib.mkDefault "root@jon" clan.networking.targetHost = pkgs.lib.mkDefault "root@jon"
# Change this to the ID-LINK of the desired disk shown by 'lsblk' # Change this to the ID-LINK of the desired disk shown by 'lsblk'
disko.devices.disk.main = { disko.devices.disk.main = {
@ -122,7 +122,7 @@ Adding or configuring a new machine requires two simple steps:
# Change this to the correct ip-address or hostname # Change this to the correct ip-address or hostname
# The hostname is the machine name by default # The hostname is the machine name by default
clan.core.networking.targetHost = pkgs.lib.mkDefault "root@jon" clan.networking.targetHost = pkgs.lib.mkDefault "root@jon"
# Change this to the ID-LINK of the desired disk shown by 'lsblk' # Change this to the ID-LINK of the desired disk shown by 'lsblk'
disko.devices.disk.main = { disko.devices.disk.main = {

View File

@ -160,7 +160,7 @@ buildClan {
# Set this for clan commands use ssh i.e. `clan machines update` # Set this for clan commands use ssh i.e. `clan machines update`
# If you change the hostname, you need to update this line to root@<new-hostname> # If you change the hostname, you need to update this line to root@<new-hostname>
# This only works however if you have avahi running on your admin machine else use IP # This only works however if you have avahi running on your admin machine else use IP
clan.core.networking.targetHost = pkgs.lib.mkDefault "root@jon"; clan.networking.targetHost = pkgs.lib.mkDefault "root@jon";
}; };
}; };
}; };
@ -197,7 +197,7 @@ buildClan {
# ... # ...
machines = { machines = {
"jon" = { "jon" = {
clan.core.networking.buildHost = "root@<host_or_ip>"; clan.networking.buildHost = "root@<host_or_ip>";
}; };
}; };
}; };

View File

@ -75,7 +75,7 @@ Below is a guide on how to structure this in your flake.nix:
nixpkgs.hostPlatform = "x86_64-linux"; nixpkgs.hostPlatform = "x86_64-linux";
# Set this for clan commands use ssh i.e. `clan machines update` # Set this for clan commands use ssh i.e. `clan machines update`
clan.core.networking.targetHost = pkgs.lib.mkDefault "root@jon"; clan.networking.targetHost = pkgs.lib.mkDefault "root@jon";
# remote> lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT # remote> lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT
disko.devices.disk.main = { disko.devices.disk.main = {
@ -83,7 +83,7 @@ Below is a guide on how to structure this in your flake.nix:
}; };
# There needs to be exactly one controller per clan # There needs to be exactly one controller per clan
clan.core.networking.zerotier.controller.enable = true; clan.networking.zerotier.controller.enable = true;
}; };
}; };

View File

@ -29,7 +29,7 @@ peers. Once addresses are allocated, the controller's continuous operation is no
2. **Add Configuration**: Input the following configuration to the NixOS 2. **Add Configuration**: Input the following configuration to the NixOS
configuration of the controller machine: configuration of the controller machine:
```nix ```nix
clan.core.networking.zerotier.controller = { clan.networking.zerotier.controller = {
enable = true; enable = true;
public = true; public = true;
}; };
@ -48,7 +48,7 @@ To introduce a new machine to the VPN, adhere to the following steps:
configuration, substituting `<CONTROLLER>` with the controller machine name: configuration, substituting `<CONTROLLER>` with the controller machine name:
```nix ```nix
{ config, ... }: { { config, ... }: {
clan.core.networking.zerotier.networkId = builtins.readFile (config.clan.core.clanDir + "/machines/<CONTROLLER>/facts/zerotier-network-id"); clan.networking.zerotier.networkId = builtins.readFile (config.clan.core.clanDir + "/machines/<CONTROLLER>/facts/zerotier-network-id");
} }
``` ```
1. **Update the New Machine**: Execute: 1. **Update the New Machine**: Execute:

View File

@ -1,6 +1,6 @@
{ config, lib, ... }: { config, lib, ... }:
{ {
options.clan.core = { options.clan = {
networking = { networking = {
targetHost = lib.mkOption { targetHost = lib.mkOption {
description = '' description = ''
@ -53,34 +53,10 @@
[ [
"clan" "clan"
"networking" "networking"
]
[
"clan"
"core"
"networking"
]
)
(lib.mkRenamedOptionModule
[
"clan"
"deployment"
]
[
"clan"
"core"
"deployment"
]
)
(lib.mkRenamedOptionModule
[
"clan"
"core"
"networking"
"deploymentAddress" "deploymentAddress"
] ]
[ [
"clan" "clan"
"core"
"networking" "networking"
"targetHost" "targetHost"
] ]

View File

@ -73,7 +73,7 @@
services services
; ;
}; };
inherit (config.clan.core.networking) targetHost buildHost; inherit (config.clan.networking) targetHost buildHost;
inherit (config.clan.deployment) requireExplicitUpdate; inherit (config.clan.deployment) requireExplicitUpdate;
}; };
system.clan.deployment.file = pkgs.writeText "deployment.json" ( system.clan.deployment.file = pkgs.writeText "deployment.json" (

View File

@ -5,7 +5,7 @@
... ...
}: }:
let let
cfg = config.clan.core.networking.zerotier; cfg = config.clan.networking.zerotier;
facts = config.clan.core.facts.services.zerotier.public or { }; facts = config.clan.core.facts.services.zerotier.public or { };
genMoonScript = pkgs.runCommand "genmoon" { nativeBuildInputs = [ pkgs.python3 ]; } '' genMoonScript = pkgs.runCommand "genmoon" { nativeBuildInputs = [ pkgs.python3 ]; } ''
install -Dm755 ${./genmoon.py} $out/bin/genmoon install -Dm755 ${./genmoon.py} $out/bin/genmoon
@ -13,7 +13,7 @@ let
''; '';
in in
{ {
options.clan.core.networking.zerotier = { options.clan.networking.zerotier = {
networkId = lib.mkOption { networkId = lib.mkOption {
type = lib.types.nullOr lib.types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
@ -231,8 +231,8 @@ in
}; };
}) })
(lib.mkIf (cfg.controller.enable && (facts.zerotier-network-id.value or null) != null) { (lib.mkIf (cfg.controller.enable && (facts.zerotier-network-id.value or null) != null) {
clan.core.networking.zerotier.networkId = facts.zerotier-network-id.value; clan.networking.zerotier.networkId = facts.zerotier-network-id.value;
clan.core.networking.zerotier.settings = { clan.networking.zerotier.settings = {
authTokens = [ null ]; authTokens = [ null ];
authorizationEndpoint = ""; authorizationEndpoint = "";
capabilities = [ ]; capabilities = [ ];

View File

@ -51,7 +51,7 @@ def show_machine_deployment_target(
[ [
f"{clan_dir}#clanInternals.machines.{system}.{machine_name}", f"{clan_dir}#clanInternals.machines.{system}.{machine_name}",
"--apply", "--apply",
"machine: { inherit (machine.config.clan.core.networking) targetHost; }", "machine: { inherit (machine.config.clan.networking) targetHost; }",
"--json", "--json",
] ]
) )

View File

@ -53,7 +53,7 @@ class Machine:
"deploymentAddress" "deploymentAddress"
) )
if val is None: if val is None:
msg = f"the 'clan.core.networking.targetHost' nixos option is not set for machine '{self.name}'" msg = f"the 'clan.networking.targetHost' nixos option is not set for machine '{self.name}'"
raise ClanError(msg) raise ClanError(msg)
return val return val

View File

@ -161,7 +161,7 @@ def update(args: argparse.Namespace) -> None:
if not machines and ignored_machines != []: if not machines and ignored_machines != []:
print( print(
"WARNING: No machines to update. The following defined machines were ignored because they do not have `clan.core.networking.targetHost` nixos option set:", "WARNING: No machines to update. The following defined machines were ignored because they do not have `clan.networking.targetHost` nixos option set:",
file=sys.stderr, file=sys.stderr,
) )
for machine in ignored_machines: for machine in ignored_machines:

View File

@ -1,12 +1,12 @@
{ lib, ... }: { lib, ... }:
{ {
clan.core.networking.targetHost = "__CLAN_TARGET_ADDRESS__"; clan.networking.targetHost = "__CLAN_TARGET_ADDRESS__";
system.stateVersion = lib.version; system.stateVersion = lib.version;
sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__"; sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__";
clan.core.secretsUploadDirectory = "__CLAN_SOPS_KEY_DIR__"; clan.core.secretsUploadDirectory = "__CLAN_SOPS_KEY_DIR__";
clan.virtualisation.graphics = false; clan.virtualisation.graphics = false;
clan.core.networking.zerotier.controller.enable = true; clan.networking.zerotier.controller.enable = true;
networking.useDHCP = false; networking.useDHCP = false;
systemd.services.shutdown-after-boot = { systemd.services.shutdown-after-boot = {

View File

@ -1,12 +1,12 @@
{ lib, ... }: { lib, ... }:
{ {
clan.core.networking.targetHost = "__CLAN_TARGET_ADDRESS__"; clan.networking.targetHost = "__CLAN_TARGET_ADDRESS__";
system.stateVersion = lib.version; system.stateVersion = lib.version;
sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__"; sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__";
clan.core.secretsUploadDirectory = "__CLAN_SOPS_KEY_DIR__"; clan.core.secretsUploadDirectory = "__CLAN_SOPS_KEY_DIR__";
clan.virtualisation.graphics = false; clan.virtualisation.graphics = false;
clan.core.networking.zerotier.controller.enable = true; clan.networking.zerotier.controller.enable = true;
networking.useDHCP = false; networking.useDHCP = false;
systemd.services.shutdown-after-boot = { systemd.services.shutdown-after-boot = {

View File

@ -1,6 +1,6 @@
{ lib, ... }: { lib, ... }:
{ {
clan.core.networking.targetHost = "__CLAN_TARGET_ADDRESS__"; clan.networking.targetHost = "__CLAN_TARGET_ADDRESS__";
system.stateVersion = lib.version; system.stateVersion = lib.version;
clan.virtualisation.graphics = false; clan.virtualisation.graphics = false;

View File

@ -15,14 +15,14 @@
vm1 = vm1 =
{ lib, ... }: { lib, ... }:
{ {
clan.core.networking.targetHost = "__CLAN_TARGET_ADDRESS__"; clan.networking.targetHost = "__CLAN_TARGET_ADDRESS__";
system.stateVersion = lib.version; system.stateVersion = lib.version;
sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__"; sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__";
clan.core.secretsUploadDirectory = "__CLAN_SOPS_KEY_DIR__"; clan.core.secretsUploadDirectory = "__CLAN_SOPS_KEY_DIR__";
clan.core.sops.defaultGroups = [ "admins" ]; clan.core.sops.defaultGroups = [ "admins" ];
clan.virtualisation.graphics = false; clan.virtualisation.graphics = false;
clan.core.networking.zerotier.controller.enable = true; clan.networking.zerotier.controller.enable = true;
networking.useDHCP = false; networking.useDHCP = false;
systemd.services.shutdown-after-boot = { systemd.services.shutdown-after-boot = {
@ -45,11 +45,11 @@
]; ];
clan.user-password.user = "alice"; clan.user-password.user = "alice";
clan.user-password.prompt = false; clan.user-password.prompt = false;
clan.core.networking.targetHost = "__CLAN_TARGET_ADDRESS__"; clan.networking.targetHost = "__CLAN_TARGET_ADDRESS__";
system.stateVersion = lib.version; system.stateVersion = lib.version;
sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__"; sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__";
clan.core.secretsUploadDirectory = "__CLAN_SOPS_KEY_DIR__"; clan.core.secretsUploadDirectory = "__CLAN_SOPS_KEY_DIR__";
clan.core.networking.zerotier.networkId = "82b44b162ec6c013"; clan.networking.zerotier.networkId = "82b44b162ec6c013";
}; };
}; };
}; };

View File

@ -23,12 +23,12 @@
clan.user-password.user = "alice"; clan.user-password.user = "alice";
clan.user-password.prompt = false; clan.user-password.prompt = false;
clan.core.networking.targetHost = "__CLAN_TARGET_ADDRESS__"; clan.networking.targetHost = "__CLAN_TARGET_ADDRESS__";
system.stateVersion = lib.version; system.stateVersion = lib.version;
clan.core.secretStore = "password-store"; clan.core.secretStore = "password-store";
clan.core.secretsUploadDirectory = lib.mkForce "__CLAN_SOPS_KEY_DIR__/secrets"; clan.core.secretsUploadDirectory = lib.mkForce "__CLAN_SOPS_KEY_DIR__/secrets";
clan.core.networking.zerotier.controller.enable = true; clan.networking.zerotier.controller.enable = true;
systemd.services.shutdown-after-boot = { systemd.services.shutdown-after-boot = {
enable = true; enable = true;

View File

@ -42,7 +42,7 @@
# Set this for clan commands use ssh i.e. `clan machines update` # Set this for clan commands use ssh i.e. `clan machines update`
# If you change the hostname, you need to update this line to root@<new-hostname> # If you change the hostname, you need to update this line to root@<new-hostname>
# This only works however if you have avahi running on your admin machine else use IP # This only works however if you have avahi running on your admin machine else use IP
clan.core.networking.targetHost = pkgs.lib.mkDefault "root@jon"; clan.networking.targetHost = pkgs.lib.mkDefault "root@jon";
# ssh root@flash-installer.local lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT # ssh root@flash-installer.local lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT
disko.devices.disk.main = { disko.devices.disk.main = {
@ -58,7 +58,7 @@
# Zerotier needs one controller to accept new nodes. Once accepted # Zerotier needs one controller to accept new nodes. Once accepted
# the controller can be offline and routing still works. # the controller can be offline and routing still works.
clan.core.networking.zerotier.controller.enable = true; clan.networking.zerotier.controller.enable = true;
}; };
# "sara" will be the hostname of the machine # "sara" will be the hostname of the machine
sara = { sara = {
@ -72,7 +72,7 @@
# Set this for clan commands use ssh i.e. `clan machines update` # Set this for clan commands use ssh i.e. `clan machines update`
# If you change the hostname, you need to update this line to root@<new-hostname> # If you change the hostname, you need to update this line to root@<new-hostname>
# This only works however if you have avahi running on your admin machine else use IP # This only works however if you have avahi running on your admin machine else use IP
clan.core.networking.targetHost = pkgs.lib.mkDefault "root@sara"; clan.networking.targetHost = pkgs.lib.mkDefault "root@sara";
# ssh root@flash-installer.local lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT # ssh root@flash-installer.local lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT
disko.devices.disk.main = { disko.devices.disk.main = {
@ -91,7 +91,7 @@
This will allow sara to share the VPN overlay network with jon This will allow sara to share the VPN overlay network with jon
The networkId is generated by the first deployment of jon The networkId is generated by the first deployment of jon
*/ */
# clan.core.networking.zerotier.networkId = builtins.readFile ../jon/facts/zerotier-network-id; # clan.networking.zerotier.networkId = builtins.readFile ../jon/facts/zerotier-network-id;
}; };
}; };
}; };