clan services: use service modules from clan-core by default
Users will use clan-core services first before making their own. Therefore this is a better default. Also it allow us to simplify rendering of our docs
This commit is contained in:
@@ -205,9 +205,6 @@ in
|
|||||||
nixpkgs
|
nixpkgs
|
||||||
nix-darwin
|
nix-darwin
|
||||||
;
|
;
|
||||||
# By default clan.directory defaults to self, but we don't
|
|
||||||
# have a sensible default for self here
|
|
||||||
self = throw "set clan.directory in the test";
|
|
||||||
};
|
};
|
||||||
modules = [
|
modules = [
|
||||||
clan-core.modules.clan.default
|
clan-core.modules.clan.default
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ lib.fix (
|
|||||||
# ------------------------------------
|
# ------------------------------------
|
||||||
# ClanLib functions
|
# ClanLib functions
|
||||||
evalClan = clanLib.callLib ./modules/inventory/eval-clan-modules { };
|
evalClan = clanLib.callLib ./modules/inventory/eval-clan-modules { };
|
||||||
inventory = clanLib.callLib ./modules/inventory { };
|
inventory = clanLib.callLib ./modules/inventory { clan-core = self; };
|
||||||
modules = clanLib.callLib ./modules/inventory/frontmatter { };
|
modules = clanLib.callLib ./modules/inventory/frontmatter { };
|
||||||
test = clanLib.callLib ./test { };
|
test = clanLib.callLib ./test { };
|
||||||
# Custom types
|
# Custom types
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ in
|
|||||||
imports = [
|
imports = [
|
||||||
../inventoryClass/builder/default.nix
|
../inventoryClass/builder/default.nix
|
||||||
(lib.modules.importApply ../inventoryClass/service-list-from-inputs.nix {
|
(lib.modules.importApply ../inventoryClass/service-list-from-inputs.nix {
|
||||||
inherit localModuleSet flakeInputs clanLib;
|
inherit flakeInputs clanLib localModuleSet;
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
inherit inventory directory;
|
inherit inventory directory;
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
{ lib, clanLib }:
|
{
|
||||||
|
lib,
|
||||||
|
clanLib,
|
||||||
|
clan-core,
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
services = clanLib.callLib ./distributed-service/inventory-adapter.nix { };
|
services = clanLib.callLib ./distributed-service/inventory-adapter.nix {
|
||||||
|
inherit clan-core;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit (services) mapInstances;
|
inherit (services) mapInstances;
|
||||||
|
|||||||
@@ -12,10 +12,11 @@
|
|||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
clanLib,
|
clanLib,
|
||||||
|
clan-core,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
resolveModule = import ./resolveModule.nix { inherit lib; };
|
resolveModule = import ./resolveModule.nix { inherit lib clan-core; };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
mapInstances =
|
mapInstances =
|
||||||
|
|||||||
@@ -1,19 +1,12 @@
|
|||||||
{ lib }:
|
{ lib, clan-core }:
|
||||||
{
|
{
|
||||||
moduleSpec,
|
moduleSpec,
|
||||||
flakeInputs,
|
flakeInputs,
|
||||||
localModuleSet,
|
localModuleSet,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
resolvedModuleSet =
|
inputName = if moduleSpec.input == null then "<clan>" else moduleSpec.input;
|
||||||
# If the module.name is self then take the modules defined in the flake
|
inputError = throw ''
|
||||||
# Otherwise its an external input which provides the modules via 'clan.modules' attribute
|
|
||||||
if moduleSpec.input == null then
|
|
||||||
localModuleSet
|
|
||||||
else
|
|
||||||
let
|
|
||||||
input =
|
|
||||||
flakeInputs.${moduleSpec.input} or (throw ''
|
|
||||||
Flake doesn't provide input with name '${moduleSpec.input}'
|
Flake doesn't provide input with name '${moduleSpec.input}'
|
||||||
|
|
||||||
Choose one of the following inputs:
|
Choose one of the following inputs:
|
||||||
@@ -29,15 +22,24 @@ let
|
|||||||
...
|
...
|
||||||
- module.input = "${moduleSpec.input}"
|
- module.input = "${moduleSpec.input}"
|
||||||
|
|
||||||
'');
|
'';
|
||||||
clanAttrs =
|
resolvedModuleSet =
|
||||||
input.clan
|
# If the module.name is self then take the modules defined in the flake
|
||||||
or (throw "It seems the flake input ${moduleSpec.input} doesn't export any clan resources");
|
# Otherwise its an external input which provides the modules via 'clan.modules' attribute
|
||||||
|
let
|
||||||
|
input =
|
||||||
|
if moduleSpec.input == null then
|
||||||
|
clan-core
|
||||||
|
else if moduleSpec.input == "self" then
|
||||||
|
{ clan.modules = localModuleSet; }
|
||||||
|
else
|
||||||
|
flakeInputs.${moduleSpec.input} or inputError;
|
||||||
in
|
in
|
||||||
clanAttrs.modules;
|
input.clan.modules
|
||||||
|
or (throw "flake input ${moduleSpec.input} doesn't export any clan services via the `clan.modules` output attribute");
|
||||||
|
|
||||||
resolvedModule =
|
resolvedModule =
|
||||||
resolvedModuleSet.${moduleSpec.name}
|
resolvedModuleSet.${moduleSpec.name}
|
||||||
or (throw "flake doesn't provide clan-module with name ${moduleSpec.name}");
|
or (throw "flake input '${inputName}' doesn't provide clan-module with name ${moduleSpec.name}");
|
||||||
in
|
in
|
||||||
resolvedModule
|
resolvedModule
|
||||||
|
|||||||
Reference in New Issue
Block a user