Commit Graph

358 Commits

Author SHA1 Message Date
Valentin Gagarin
ebd5afe8f5 fixup(jsonschema): test attrsOf submodules with valid value 2025-04-16 16:55:50 +02:00
Valentin Gagarin
6a2e81373c lib/jsonschema: render defaults for submodule options
this relaxes the constraint that options of type `submodule` are always
required, and will render benign default values.
2025-04-16 16:55:46 +02:00
Johannes Kirschbauer
9f7e9ca9df feat(jsonschema): add test for attrsof submodule 2025-04-16 14:48:49 +02:00
Valentin Gagarin
e28681c4f2 lib/jsonschema: make attrs required
Before the change, modules of the form

```nix
{ lib, ... }: {
  foo.bar = lib.mkOption {
    # ...
  };
}
```

or

```nix
{ lib, ... }: {
  foo = lib.mkOption {
    type = lib.types.subModule {
      bar = lib.mkOption {
        # ...
      };
    };
  };
}
```

would not render with `foo` as required, which is not faithful to the
module system's semantics.

This change also tests that fields with defaults are not marked required.
Note that submodule options cannot have their defaults rendered to JSON
schema, and are therefore always marked required.

Architecturally this change is rather unfortunate: So far the checks for
defaults happen in the rendering (using `isDefault`) and not in the parsing,
but here we're adding a field to `$exportedModuleInfo`. While strictly
speaking we probably don't want to consider requiredness as module-level
information, it seems more reasonable to me to do it that way since at
the JSON schema level we have lost the distinction between `attrs`,
`attrsOf`, `submodule`.
2025-04-16 13:20:00 +02:00
Johannes Kirschbauer
2796038254 chore(test/makeTestClan): document all options, remove magic specialArgs 2025-04-16 10:33:32 +02:00
Johannes Kirschbauer
7bdb2cabf9 fix: rename folder lib/tests -> lib/test to be consistent with the attribute name 2025-04-16 10:04:31 +02:00
Johannes Kirschbauer
8ae0f5ddcb tests(clan): move test-inventory.nix to clanLib. And name it 'makeTestClan'
Exposing the function via clanLib makes it more accessible to clan modules
This allows each module to define its own test without needing to depend on any fileSystem path assumptions in the clan-core repo
2025-04-15 18:17:40 +02:00
Johannes Kirschbauer
f331295dd5 feat(buildClan): expose {nixosModules,darwinModules} from clanInternals
These are the exact same modules that where used internally to construct the corresponding
'nixosConfiguration', 'darwinConfiguration'
They can be externally used, and would yield the same result
Given that you pass the same 'specialArgs'
2025-04-15 17:25:57 +02:00
Johannes Kirschbauer
9800255a2c refactor(buildClan): simplify pkgs overriding logic 2025-04-15 16:05:57 +02:00
Johannes Kirschbauer
e68ab67112 refactor(buildClan): move modules into 'forName' and import the correct core module depending on class 2025-04-15 15:29:01 +02:00
Johannes Kirschbauer
d264e262bd fixup(buildClan): use clan.inventory instead of refering to the clanInternals dumping ground within the module 2025-04-15 15:10:08 +02:00
Johannes Kirschbauer
af04bf547f fixup(buildClan): split up the inner-module into: {forSystem, forName}
I am preparing this such that we can move the forName modules into the
defaults for the deferred module outputs and the forSystem modules are
added later and only for the 'configsPerSystem' where we actually need
the system modules
2025-04-15 15:02:37 +02:00
Johannes Kirschbauer
14ace40820 refactor: buildClan output; output deferred modules instead of nixosConfig 2025-04-15 14:25:02 +02:00
Michael Hoang
5cc1d823aa build-clan: drop unused machinesFunc 2025-04-15 13:30:28 +02:00
Michael Hoang
95fd1ec7eb build-clan: expose Clan configuration as a module 2025-04-14 16:04:06 +02:00
Johannes Kirschbauer
35379d3b86 Reapply "Merge pull request 'chore(buildClan): move machineClass option into inventory.machines submodule' (#3259) from hsjobeki/clan-core:buildclan-cleanup into main"
This reverts commit 62dfb23e41.
2025-04-09 18:16:35 +02:00
Johannes Kirschbauer
c344d57298 fix(checks/data-mesher): format, dont pass a duplicate data-mesher module 2025-04-09 18:03:04 +02:00
Johannes Kirschbauer
ec2aee3013 fix(eval/inventory): fix some test arguments to buildInventory 2025-04-09 17:38:06 +02:00
Johannes Kirschbauer
05c45371af feat(buildInventory): move instance resolution into buildInventory
Such that buildClan doesn't have to compose the results
buildInventory should be more self contained. But it is NOT meant a
public API! use buildClan argument 'inventory' instead
2025-04-09 17:31:35 +02:00
Johannes Kirschbauer
a6a79e83a0 treewide(clanLib): rename all occurences of {clan-core,self}.lib to 'clanLib' 2025-04-09 11:32:46 +02:00
Johannes Kirschbauer
c357cfa29f chore(lib/buildClan): remove dependencies {nixpkgs,nix-darwin} from the clanLib file 2025-04-08 22:13:46 +02:00
Johannes Kirschbauer
f399aad06e chore(lib/getModuleClass): remove unused library function 2025-04-08 22:09:10 +02:00
hsjobeki
f60da91dea Merge pull request 'docs(authoring): restructure authoring guides' (#3248) from hsjobeki/clan-core:docs-authoring into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3248
2025-04-08 19:58:59 +00:00
hsjobeki
aa75cc4777 Merge pull request 'chore(inventory/services): dont check _class in our logics. Let the error eccour in the final evaluation.' (#3236) from hsjobeki/clan-core:role-settings into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3236
2025-04-08 19:49:46 +00:00
Johannes Kirschbauer
b4f63b8835 docs(authoring): restructure authoring guides
Mainly because we have two module specs now and they will remain
valid for a while. We need to keep the older format documented for a while
2025-04-08 21:32:19 +02:00
Sam Lehman
e0a6ed3d49 devshells: name shells for clarity 2025-04-08 19:31:30 +00:00
Johannes Kirschbauer
9af20ad8b5 chore(inventory/instances): don't eagerly test the service modules _class 2025-04-08 20:30:35 +02:00
Johannes Kirschbauer
f7d5a529aa chore(inventory/services): dont check _class of legacy clanModules.
Let the module system handle the error. Once we shift to deferred
modules, things get more complicated and we cannot check the module
class eagerly
2025-04-08 20:30:33 +02:00
Johannes Kirschbauer
821264fe2e fix(getModulesSchema): forward argument to evalClanModules 2025-04-08 19:53:20 +02:00
Johannes Kirschbauer
ce84c4cddb chore(lib/modulesDocs): move dependency on clan-core and pkgs into function args
This is a good idea, to make lib agnostic from clan-core
The next step could be to rename the clan-core argument name
Or to explizitly pass the actual dependencies, instead of everything in
clan-core
2025-04-08 15:30:49 +02:00
hsjobeki
411440ef35 Merge pull request 'feat(inventory/instances): add extendSettings as argument to perInstance, perMachine' (#3233) from hsjobeki/clan-core:role-settings into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3233
2025-04-08 12:46:44 +00:00
Johannes Kirschbauer
07e6df35a5 feat(inventory/instances): dont set module location to allow underlying error location to bubble up 2025-04-08 14:36:29 +02:00
Mic92
8fad1df70b Merge pull request 'directory-context' (#3234) from directory-context into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3234
2025-04-08 12:09:36 +00:00
Jörg Thalheim
f008da9472 inventory: don't loose string context of directory 2025-04-08 13:50:27 +02:00
Johannes Kirschbauer
4913d2db87 feat(inventory/instances): add extendSettings as argument to perInstance, perMachine 2025-04-08 13:15:06 +02:00
Brian McGee
0c7cf305e2 fix(docs): tighten up validation for meta.name and improved description 2025-04-08 10:44:35 +01:00
Michael Hoang
67745e1b27 tests: add --show-trace to nix-unit tests 2025-04-08 08:53:29 +02:00
Michael Hoang
6de4735c81 build-clan: support constructing darwinConfigurations 2025-04-08 08:53:29 +02:00
Michael Hoang
66e4c41142 lib/jsonschema: fix enum support 2025-04-08 08:53:27 +02:00
hsjobeki
b0d8d1f195 Merge pull request 'chore(lib/select): move into subfolder with a test file' (#3175) from hsjobeki/clan-core:lib-cleanup into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3175
2025-04-04 12:32:32 +00:00
Johannes Kirschbauer
f326c307eb feat(lib/inventory): fix arguments discrepancy on perInstance and perMachine 2025-04-04 14:22:36 +02:00
Johannes Kirschbauer
6d4bbc3e92 chore(lib/select): init simple test 2025-04-04 14:06:05 +02:00
DavHau
2ed69d7ef8 workaround bug in docs rendering if machine.name is not set 2025-04-03 17:29:07 +07:00
DavHau
73d14e078e remove default for clan.core.settings.machine.name and make readOnly
There is not reason that there needs to be a default. Machines are usually defined as an attrset, so there is no reason to have a default.
Also make this readOnly as we never want to override it.
2025-04-03 17:29:07 +07:00
Johannes Kirschbauer
788d9b9670 feat(inventory/instances): prevent modules without explizit class from beeing used 2025-04-02 14:57:21 +02:00
Johannes Kirschbauer
0ec63de3e6 feat(buildClan): add clan.modules as output 2025-04-02 13:38:38 +02:00
Johannes Kirschbauer
2efe1ae241 chore(lib/introspection): add comment about upstream PRs, that allows removing features 2025-04-02 12:38:28 +02:00
Johannes Kirschbauer
69078433cd chore(lib/select): move into subfolder with a test file 2025-04-02 12:37:49 +02:00
Johannes Kirschbauer
2715c398cc fix(inventory/interface): use explizit file dependency, until dependency injection works properly 2025-04-02 11:12:16 +02:00
Johannes Kirschbauer
2ab53b05fe chore(lib/treewide): cleanup directory struture of lib. See lib/readme.md for details 2025-04-02 11:11:21 +02:00