Skip to content

importer 🔹

Convenient, structured module imports for hosts.

Categories

Utility

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:

inventory.services = {
  importer.base = {
    roles.default.tags = [ "all" ];
    roles.default.extraModules = [ "modules/base.nix" ];
  };
  importer.zone1 = {
    roles.default.tags = [ "zone1" ];
    roles.default.extraModules = [ "modules/zone1.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.

Usage via Inventory

Roles

This module can be used via predefined roles

- `default`

Every role has its own configuration options. Which are each listed below.

For more information, see the inventory guide.

Example

For example the admin module adds the following options globally to all machines where it is used.

clan.admin.allowedkeys

This means there are two equivalent ways to set the allowedkeys option. Either via a nixos module or via the inventory interface. But it is recommended to keep together imports and config to preserve locality of the module configuration.

clan-core.lib.buildClan {
    inventory.services = {
        admin.me = {
            roles.default.machines = [ "jon" ];
            config.allowedkeys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD..." ];
        };
    };
};
clan-core.lib.buildClan {
    machines = {
        jon = {
            clan.admin.allowedkeys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD..." ];
            imports = [ clanModules.admin ];
        };
    };
};

Options of default role

The importer default doesnt offer / require any options to be set.

Usage via Nix

This module cannot be imported directly in your nixos configuration.