Merge pull request 'Migrate Importer module' (#3854) from migrate-importer into main

Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3854
Reviewed-by: Luis Hebendanz <consulting@qube.email>
This commit is contained in:
pinpox
2025-06-05 16:29:37 +00:00
4 changed files with 43 additions and 1 deletions

View File

@@ -47,7 +47,7 @@ nixosLib.runTest (
server.succeed("systemctl status mycelium")
# Check that mycelium is listening on its default port
server.succeed("${pkgs.iproute2}/bin/ss -tulpn | grep -q 'mycelium'")
server.wait_until_succeeds("${pkgs.iproute2}/bin/ss -tulpn | grep -q 'mycelium'", 10)
'';
}
)

View File

@@ -0,0 +1,26 @@
The importer module allows users to configure importing modules in a flexible and structured way.
It exposes the `extraModules` functionality of the inventory, without any added configuration.
## Usage:
```nix
inventory.instances = {
zone1 = {
module.name = "@clan/importer";
roles.default.tags = [ "zone1" ];
roles.default.extraModules = [ "modules/zone1.nix" ];
};
base = {
module.name = "@clan/importer";
roles.default.tags = [ "all" ];
roles.default.extraModules = [ "modules/base.nix" ];
};
};
```
This will import the module `modules/base.nix` to all machines that have the `all` tag,
which by default is every machine managed by the clan.
And also import for all machines tagged with `zone1` the module at `modules/zone1.nix`.

View File

@@ -0,0 +1,10 @@
{ ... }:
{
_class = "clan.service";
manifest.name = "clan-core/importer";
manifest.description = "Convenient, structured module imports for hosts.";
manifest.categories = [ "Utility" ];
manifest.readme = builtins.readFile ./README.md;
roles.default = { };
}

View File

@@ -0,0 +1,6 @@
{ lib, ... }:
{
clan.modules = {
importer = lib.modules.importApply ./default.nix { };
};
}