Files
clan-core/lib
a-kenji 8058a7c158 lib/instrospection: Skip either(oneOf)
For either(oneOf) types, we skip introspection as we cannot
determine which branch of the union was taken without more context
This *should* be safe, as it can currently mostly be triggered through
The `extraModules` setting of inventory modules.

Example:

```
importer.roles.default.extraModules = [
    ../../modules/nixos/common.nix
];
```

Error Message:

```
Traceback (most recent call last):
  File "/nix/store/zaz4r4fic03m4whgz46p5jjszzlkq694-clan-cli/lib/python3.13/site-packages/clan_lib/templates/handler.py", line 91, in machine_template
    yield dst_machine_dir
  File "/nix/store/zaz4r4fic03m4whgz46p5jjszzlkq694-clan-cli/lib/python3.13/site-packages/clan_cli/machines/create.py", line 95, in create_machine
    inventory_store.write(inventory, message=f"machine '{machine_name}'")
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/zaz4r4fic03m4whgz46p5jjszzlkq694-clan-cli/lib/python3.13/site-packages/clan_lib/persist/inventory_store.py", line 269, in write
    write_info = self._write_map()
  File "/nix/store/zaz4r4fic03m4whgz46p5jjszzlkq694-clan-cli/lib/python3.13/site-packages/clan_lib/persist/inventory_store.py", line 214, in _write_map
    current_priority = self._get_inventory_current_priority()
  File "/nix/store/zaz4r4fic03m4whgz46p5jjszzlkq694-clan-cli/lib/python3.13/site-packages/clan_lib/persist/inventory_store.py", line 206, in _get_inventory_current_priority
    return self._flake.select("clanInternals.inventoryClass.introspection")
           ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/zaz4r4fic03m4whgz46p5jjszzlkq694-clan-cli/lib/python3.13/site-packages/clan_lib/flake/flake.py", line 1129, in select
    self.get_from_nix([selector])
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/nix/store/zaz4r4fic03m4whgz46p5jjszzlkq694-clan-cli/lib/python3.13/site-packages/clan_lib/flake/flake.py", line 1054, in get_from_nix
    raise ClanSelectError(
    ...<3 lines>...
    ) from e
clan_lib.flake.flake.ClanSelectError: Error on: $ clan select 'clanInternals.inventoryClass.introspection'
  Reason: Yet Unsupported type: either
Removing left-over machine directory: /tmp/hyperconfig/machines/trooo
Error on: $ clan select 'clanInternals.inventoryClass.introspection'
  Reason: Yet Unsupported type: either

```

Closes: #5387
2025-10-07 22:58:51 +02:00
..
2025-09-16 15:28:12 +02:00
2025-10-05 14:14:12 +02:00
2025-09-01 15:49:53 +02:00
2025-09-17 11:03:08 +02:00
2024-07-09 15:23:26 +02:00
2025-09-15 13:17:09 +02:00
2025-09-16 16:02:10 +02:00

ClanLib

This folder is supposed to contain clan specific nix functions.

Such as:

  • clan function
  • select
  • inventory function
  • json-schema-converter

Structure

Similar to nixpkgs/lib this produces a recursive attribute set in a fixed-point. Functions within lib can depend on each other to create new abstractions.

Conventions

Note: This is not consistently enforced yet. If you start a new feature, or refactoring/touching existing ones, please help us to move towards the below illustrated.

A single feature-set/module may be organized like this:

#     ↓ The final clanLib
{lib, clanLib, ...}:
# ↓ portion to add to clanLib
{
    inventory.resolveTags = tags: inventory.machines; # implementation
    inventory.buildMachines = x: clanLib.inventory.resolveTags x; # implementation
}

Every bigger feature should live in a subfolder with the feature name. It should contain two files:

  • default.nix
  • test.nix
  • Everything else may be adopted as needed.
Example filetree
.
├── default.nix
├── clan
│   ├── default.nix
│   └── test.nix
└── inventory
    ├── services-subfeature
    │   ├── default.nix
    │   └── test.nix
    ├── instances-subfeature # <- We immediately see that this feature is not tested on itself.
    │   └── default.nix
    ├── default.nix
    └── test.nix

Testing

For testing we use nix-unit