Merge pull request 'add requireExplicitUpdate option for mobile devices' (#820) from Mic92-target_host into main

This commit is contained in:
clan-bot
2024-02-06 16:59:03 +00:00
4 changed files with 74 additions and 36 deletions

View File

@@ -101,16 +101,6 @@ $ clan config --machine my-machine clan.networking.targetHost root@host_or_ip
_Note: The use of `root@` in the target address implies SSH access as the root user.
Ensure that the root login is secured and only used when necessary._
### Setting the Build Host
If the machine does not have enough resources to run the NixOS evaluation or build itself,
it is also possible to specify a build host instead.
During an update, the cli will ssh into the build host and run `nixos-rebuild` from there.
```shellSession
$ clan config --machine my-machine clan.networking.buildHost root@host_or_ip
```
### Updating Machine Configurations
Execute the following command to update the specified machine:
@@ -124,3 +114,25 @@ You can also update all configured machines simultaneously by omitting the machi
```shellSession
$ clan machines update
```
### Setting a Build Host
If the machine does not have enough resources to run the NixOS evaluation or build itself,
it is also possible to specify a build host instead.
During an update, the cli will ssh into the build host and run `nixos-rebuild` from there.
```shellSession
$ clan config --machine my-machine clan.networking.buildHost root@host_or_ip
```
### Excluding a machine from `clan machine update`
To exclude machines from beeing updated when running `clan machines update` without any machines specified,
one can set the `clan.deployment.requireExplicitUpdate` option to true:
```shellSession
$ clan config --machine my-machine clan.deployment.requireExplicitUpdate true
```
This is useful for machines that are not always online or are not part of the regular update cycle.

View File

@@ -1,6 +1,7 @@
{ config, lib, ... }:
{
options.clan.networking = {
options.clan = {
networking = {
targetHost = lib.mkOption {
description = ''
The target SSH node for deployment.
@@ -33,6 +34,20 @@
default = null;
};
};
deployment = {
requireExplicitUpdate = lib.mkOption {
description = ''
Do not update this machine when running `clan machines update` without any machines specified.
This is useful for machines that are not always online or are not part of the regular update cycle.
'';
type = lib.types.bool;
default = false;
};
};
};
imports = [
(lib.mkRenamedOptionModule [ "clan" "networking" "deploymentAddress" ] [ "clan" "networking" "targetHost" ])
];

View File

@@ -31,6 +31,13 @@
the hostname of the target host to be deployed to
'';
};
deployment.requireExplicitUpdate = lib.mkOption {
type = lib.types.bool;
description = ''
if true, the deployment will not be updated automatically.
'';
default = false;
};
secretsUploadDirectory = lib.mkOption {
type = lib.types.path;
description = ''
@@ -73,6 +80,7 @@
system.clan.deployment.data = {
inherit (config.system.clan) secretsModule secretsData;
inherit (config.clan.networking) targetHost buildHost;
inherit (config.clan.deployment) requireExplicitUpdate;
inherit (config.clanCore) secretsUploadDirectory;
};
system.clan.deployment.file = pkgs.writeText "deployment.json" (builtins.toJSON config.system.clan.deployment.data);

View File

@@ -151,6 +151,9 @@ def get_all_machines(clan_dir: Path) -> HostGroup:
hosts = []
ignored_machines = []
for name, machine_data in machines.items():
if machine_data.get("requireExplicitUpdate", False):
continue
machine = Machine(name=name, flake=clan_dir, deployment_info=machine_data)
try:
hosts.append(machine.build_host)