feat(clanLib): init evalServiceSchema
This commit is contained in:
@@ -84,7 +84,10 @@ in
|
|||||||
schema =
|
schema =
|
||||||
(self.clanLib.inventory.evalClanService {
|
(self.clanLib.inventory.evalClanService {
|
||||||
modules = [ m ];
|
modules = [ m ];
|
||||||
prefix = [ "checks" system ];
|
prefix = [
|
||||||
|
"checks"
|
||||||
|
system
|
||||||
|
];
|
||||||
}).config.result.api.schema;
|
}).config.result.api.schema;
|
||||||
in
|
in
|
||||||
schema
|
schema
|
||||||
|
|||||||
@@ -206,19 +206,7 @@ in
|
|||||||
inherit inventoryClass;
|
inherit inventoryClass;
|
||||||
|
|
||||||
# Endpoint that can be called to get a service schema
|
# Endpoint that can be called to get a service schema
|
||||||
evalServiceSchema =
|
evalServiceSchema = clan-core.clanLib.evalServiceSchema config.self;
|
||||||
{moduleSpec}:
|
|
||||||
let
|
|
||||||
resolvedModule = clan-core.clanLib.inventory.resolveModule {
|
|
||||||
inherit moduleSpec;
|
|
||||||
flakeInputs = config.self.inputs;
|
|
||||||
localModuleSet = config.inventory.modules;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
(clan-core.clanLib.inventory.evalClanService {
|
|
||||||
modules = [ resolvedModule ];
|
|
||||||
prefix = [ ];
|
|
||||||
}).config.result.api.schema;
|
|
||||||
|
|
||||||
# TODO: unify this interface
|
# TODO: unify this interface
|
||||||
# We should have only clan.modules. (consistent with clan.templates)
|
# We should have only clan.modules. (consistent with clan.templates)
|
||||||
|
|||||||
@@ -15,10 +15,27 @@ lib.fix (clanLib: {
|
|||||||
*/
|
*/
|
||||||
callLib = file: args: import file ({ inherit lib clanLib; } // args);
|
callLib = file: args: import file ({ inherit lib clanLib; } // args);
|
||||||
|
|
||||||
|
# ------------------------------------
|
||||||
buildClan = clanLib.buildClanModule.buildClanWith {
|
buildClan = clanLib.buildClanModule.buildClanWith {
|
||||||
clan-core = self;
|
clan-core = self;
|
||||||
inherit nixpkgs nix-darwin;
|
inherit nixpkgs nix-darwin;
|
||||||
};
|
};
|
||||||
|
evalServiceSchema =
|
||||||
|
self:
|
||||||
|
{
|
||||||
|
moduleSpec,
|
||||||
|
flakeInputs ? self.inputs,
|
||||||
|
localModuleSet ? self.clan.modules,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
resolvedModule = clanLib.inventory.resolveModule {
|
||||||
|
inherit moduleSpec flakeInputs localModuleSet;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
(clanLib.inventory.evalClanService {
|
||||||
|
modules = [ resolvedModule ];
|
||||||
|
prefix = [ ];
|
||||||
|
}).config.result.api.schema;
|
||||||
# ------------------------------------
|
# ------------------------------------
|
||||||
# ClanLib functions
|
# ClanLib functions
|
||||||
evalClan = clanLib.callLib ./inventory/eval-clan-modules { };
|
evalClan = clanLib.callLib ./inventory/eval-clan-modules { };
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ let
|
|||||||
|
|
||||||
'');
|
'');
|
||||||
clanAttrs =
|
clanAttrs =
|
||||||
input.clan or (throw "It seems the flake input ${moduleSpec.input} doesn't export any clan resources");
|
input.clan
|
||||||
|
or (throw "It seems the flake input ${moduleSpec.input} doesn't export any clan resources");
|
||||||
in
|
in
|
||||||
clanAttrs.modules;
|
clanAttrs.modules;
|
||||||
|
|
||||||
|
|||||||
@@ -716,18 +716,18 @@ class Flake:
|
|||||||
if not fallback_nixpkgs_hash.startswith("sha256-"):
|
if not fallback_nixpkgs_hash.startswith("sha256-"):
|
||||||
fallback_nixpkgs = Flake(str(nixpkgs_source()))
|
fallback_nixpkgs = Flake(str(nixpkgs_source()))
|
||||||
fallback_nixpkgs.invalidate_cache()
|
fallback_nixpkgs.invalidate_cache()
|
||||||
assert (
|
assert fallback_nixpkgs.hash is not None, (
|
||||||
fallback_nixpkgs.hash is not None
|
"this should be impossible as invalidate_cache() should always set `hash`"
|
||||||
), "this should be impossible as invalidate_cache() should always set `hash`"
|
)
|
||||||
fallback_nixpkgs_hash = fallback_nixpkgs.hash
|
fallback_nixpkgs_hash = fallback_nixpkgs.hash
|
||||||
|
|
||||||
select_hash = "@select_hash@"
|
select_hash = "@select_hash@"
|
||||||
if not select_hash.startswith("sha256-"):
|
if not select_hash.startswith("sha256-"):
|
||||||
select_flake = Flake(str(select_source()))
|
select_flake = Flake(str(select_source()))
|
||||||
select_flake.invalidate_cache()
|
select_flake.invalidate_cache()
|
||||||
assert (
|
assert select_flake.hash is not None, (
|
||||||
select_flake.hash is not None
|
"this should be impossible as invalidate_cache() should always set `hash`"
|
||||||
), "this should be impossible as invalidate_cache() should always set `hash`"
|
)
|
||||||
select_hash = select_flake.hash
|
select_hash = select_flake.hash
|
||||||
|
|
||||||
nix_code = f"""
|
nix_code = f"""
|
||||||
|
|||||||
Reference in New Issue
Block a user