docs: add machines update instructions

This commit is contained in:
Johannes Kirschbauer
2025-07-12 15:17:25 +02:00
parent 3d8ddd1be1
commit 055cf3d924

View File

@@ -10,64 +10,23 @@ See the complete [list](../../guides/more-machines.md#automatic-registration) of
## Create a machine ## Create a machine
=== "flake.nix (flake-parts)" === "clan.nix (declarative)"
```{.nix hl_lines=12-15} ```{.nix hl_lines="3-4"}
{ {
inputs.clan-core.url = "https://git.clan.lol/clan/clan-core/archive/main.tar.gz"; inventory.machines = {
inputs.nixpkgs.follows = "clan-core/nixpkgs"; # Define a machine
inputs.flake-parts.follows = "clan-core/flake-parts"; jon = { };
inputs.flake-parts.inputs.nixpkgs-lib.follows = "clan-core/nixpkgs";
outputs =
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ inputs.clan-core.flakeModules.default ];
clan = {
inventory.machines = {
# Define a machine
jon = { };
};
};
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
}; };
}
```
=== "flake.nix (classic)" # Additional NixOS configuration can be added here.
# machines/jon/configuration.nix will be automatically imported.
```{.nix hl_lines=11-14} # See: https://docs.clan.lol/guides/more-machines/#automatic-registration
{ machines = {
inputs.clan-core.url = "https://git.clan.lol/clan/clan-core/archive/main.tar.gz"; # jon = { config, ... }: {
inputs.nixpkgs.follows = "clan-core/nixpkgs"; # environment.systemPackages = [ pkgs.asciinema ];
# };
outputs = };
{ self, clan-core, ... }:
let
clan = clan-core.lib.clan {
inherit self;
inventory.machines = {
# Define a machine
jon = { };
};
};
in
{
inherit (clan.config)
nixosConfigurations
nixosModules
clanInternals
darwinConfigurations
darwinModules
;
};
} }
``` ```
@@ -89,16 +48,18 @@ See the complete [list](../../guides/more-machines.md#automatic-registration) of
The option: `machines.<name>` is used to add extra *nixosConfiguration* to a machine The option: `machines.<name>` is used to add extra *nixosConfiguration* to a machine
```{.nix .annotate title="flake.nix" hl_lines="3-13 18-22"} Add the following to your `clan.nix` file for each machine.
# Sometimes this attribute set is defined in clan.nix This example demonstrates what is needed based on a machine called `jon`:
clan = {
```{.nix .annotate title="clan.nix" hl_lines="3-9 18-22"}
{
inventory.machines = { inventory.machines = {
jon = { jon = {
# Define targetHost here # Define targetHost here
# Required before deployment # Required before deployment
deploy.targetHost = "root@jon"; # (1) deploy.targetHost = "root@jon"; # (1)
# Define tags here # Define tags here (optional)
tags = [ ]; tags = [ ]; # (3)
}; };
sara = { sara = {
deploy.targetHost = "root@sara"; deploy.targetHost = "root@sara";
@@ -119,6 +80,7 @@ clan = {
1. It is required to define a *targetHost* for each machine before deploying. Best practice has been, to use the zerotier ip/hostname or the ip from the from overlay network you decided to use. 1. It is required to define a *targetHost* for each machine before deploying. Best practice has been, to use the zerotier ip/hostname or the ip from the from overlay network you decided to use.
2. Add your *ssh key* here - That will ensure you can always login to your machine via *ssh* in case something goes wrong. 2. Add your *ssh key* here - That will ensure you can always login to your machine via *ssh* in case something goes wrong.
3. Tags can be used to automatically add this machine to services later on. - You dont need to set this now.
### (Optional) Renaming a Machine ### (Optional) Renaming a Machine