Inventory
This provides an overview of the available attributes of the inventory
model.
It can be set via the inventory
attribute of the buildClan
function, or via the clan.inventory
attribute of flake-parts.
machines
Attribute: inventory.machines
Machines in the inventory.
Each machine declared here can be referencd via its attributeName
by the inventory.service
s roles
.
Type: attribute set of (submodule)
Default:
machines.description
Attribute: inventory.machines.<name>.description
Optional freeform description
Type: null or string
Default:
machines.icon
Attribute: inventory.machines.<name>.icon
Under construction, will be used for the UI
Type: null or string
Default:
machines.name
Attribute: inventory.machines.<name>.name
Name of the machine or service
Type: string
Default:
machines.tags
Attribute: inventory.machines.<name>.tags
List of tags for the machine.
The machine can be referenced by its tags in inventory.services
Example
Note
Tags can be used to determine the membership of the machine in the services. Without changing the service configuration, the machine can be added to a service by adding the correct tags to the machine.
Type: list of string
Default:
machines.deploy.targetHost
Attribute: inventory.machines.<name>.deploy.targetHost
Configuration for the deployment of the machine
Type: null or string
Default:
meta
Attribute: inventory.meta
This option has no description.
Type: submodule
meta.description
Attribute: inventory.meta.description
Optional freeform description
Type: null or string
Default:
meta.icon
Attribute: inventory.meta.icon
Under construction, will be used for the UI
Type: null or string
Default:
meta.name
Attribute: inventory.meta.name
Name of the clan.
Needs to be (globally) unique, as this determines the folder name where the flake gets downloaded to.
Type: string
modules
Attribute: inventory.modules
A mapping of module names to their path.
Each module can be referenced by its attributeName
in the inventory.services
attribute set.
Important
Each module MUST fullfill the following requirements to be usable with the inventory:
- The module MUST have a
README.md
file with adescription
. - The module MUST have at least
features = [ "inventory" ]
in the frontmatter section. - The module MUST have a subfolder
roles
with at least one{roleName}.nix
file.
For further information see: Module Authoring Guide.
Example
Type: attribute set of path
Default:
services
Attribute: inventory.services
Services of the inventory.
- The first
<name>
is the moduleName. It must be a valid clanModule name. - The second
<name>
is an arbitrary instance name.
Example
Note
Services MUST be added to machines via roles
exclusively.
See roles.<rolename>.machines
or roles.<rolename>.tags
for more information.
Type: attribute set of attribute set of (submodule)
Default:
services.config
Attribute: inventory.services.<name>.<name>.config
Configuration of the specific clanModule.
Note
Configuration is passed to the nixos configuration scoped to the module.
Example
For services.borgbackup
the config is the passed to the machine with the prefix of clan.borgbackup
.
This means all config values are mapped to the borgbackup
clanModule exclusively (config.clan.borgbackup
).
Note
The module author is responsible for supporting multiple instance configurations in different roles. See each clanModule's documentation for more information.
Type: attribute set of anything
Default:
services.enabled
Attribute: inventory.services.<name>.<name>.enabled
Enable or disable the complete service.
If the service is disabled, it will not be added to any machine.
Note
This flag is primarily used to temporarily disable a service. I.e. A 'backup service' without any 'server' might be incomplete and would cause failure if enabled.
Type: boolean
Default:
services.extraModules
Attribute: inventory.services.<name>.<name>.extraModules
List of additionally imported .nix
expressions.
Supported types:
- Strings: Interpreted relative to the 'directory' passed to buildClan.
- Paths: should be relative to the current file.
- Any: Nix expression must be serializable to JSON.
Note
The import only happens if the machine is part of the service or role.
Other types are passed through to the nixos configuration.
Example
To import the special.nix
file
Type: list of (string or anything)
Default:
services.machines
Attribute: inventory.services.<name>.<name>.machines
Attribute set of machines specific config for the service.
Will be merged with other service configs, such as the role config and the global config.
For machine specific overrides use mkForce
or other higher priority methods.
Example
Type: attribute set of (submodule)
Default:
services.roles
Attribute: inventory.services.<name>.<name>.roles
This option has no description.
Type: attribute set of (submodule)
Default:
services.meta.description
Attribute: inventory.services.<name>.<name>.meta.description
Optional freeform description
Type: null or string
Default:
services.meta.icon
Attribute: inventory.services.<name>.<name>.meta.icon
Under construction, will be used for the UI
Type: null or string
Default:
services.meta.name
Attribute: inventory.services.<name>.<name>.meta.name
Name of the machine or service
Type: string
Default:
services.machines.config
Attribute: inventory.services.<name>.<name>.machines.<name>.config
Additional configuration of the specific machine.
See how service.<name>.<name>.config
works in general for further information.
Type: attribute set of anything
Default:
services.machines.extraModules
Attribute: inventory.services.<name>.<name>.machines.<name>.extraModules
List of additionally imported .nix
expressions.
Supported types:
- Strings: Interpreted relative to the 'directory' passed to buildClan.
- Paths: should be relative to the current file.
- Any: Nix expression must be serializable to JSON.
Note
The import only happens if the machine is part of the service or role.
Other types are passed through to the nixos configuration.
Example
To import the special.nix
file
Type: list of (string or anything)
Default:
services.roles.config
Attribute: inventory.services.<name>.<name>.roles.<name>.config
Additional configuration of the specific role.
See how service.<name>.<name>.config
works in general for further information.
Type: attribute set of anything
Default:
services.roles.extraModules
Attribute: inventory.services.<name>.<name>.roles.<name>.extraModules
List of additionally imported .nix
expressions.
Supported types:
- Strings: Interpreted relative to the 'directory' passed to buildClan.
- Paths: should be relative to the current file.
- Any: Nix expression must be serializable to JSON.
Note
The import only happens if the machine is part of the service or role.
Other types are passed through to the nixos configuration.
Example
To import the special.nix
file
Type: list of (string or anything)
Default:
services.roles.machines
Attribute: inventory.services.<name>.<name>.roles.<name>.machines
List of machines which are part of the role.
The machines are referenced by their attributeName
in the inventory.machines
attribute set.
Memberships are decaled here to determine which machines are part of the service.
Alternatively, tags
can be used to determine the membership, more dynamically.
Type: list of string
Default:
services.roles.tags
Attribute: inventory.services.<name>.<name>.roles.<name>.tags
List of tags which are used to determine the membership of the role.
The tags are matched against the inventory.machines.<machineName>.tags
attribute set.
If a machine has at least one tag of the role, it is part of the role.
Type: list of string
Default:
tags
Attribute: inventory.tags
Tags of the inventory are used to group machines together.
It is recommended to use machine.tags
to define the tags of the machines.
This can be used to define custom tags that are either statically set or dynamically computed.
Static Tags
Static Tag Example
The tag foo
will always be added to machineA
and machineB
.
Dynamic Tags
It is possible to compute tags based on the machines properties or based on other tags.
Danger
This is a powerfull feature and should be used with caution.
It is possible to cause infinite recursion by computing tags based on the machines properties or based on other tags.
Dynamic Tag Example
allButFoo is a computed tag. It will be added to all machines except 'foo'
all
is a predefined tag. See the docs of tags.all
.
Warning
Do NOT compute tags
from machine.tags
this will cause infinite recursion.
Type: lazy attribute set of list of string
Default:
tags.all
Attribute: inventory.tags.all
Type: list of string
Default: