fix(clanLib): propagate clanLib into module apply
This commit is contained in:
@@ -3,12 +3,13 @@
|
||||
## Add any logic to ./module.nix
|
||||
{
|
||||
lib,
|
||||
clanLib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
flakePartsModule = {
|
||||
imports = [
|
||||
./interface.nix
|
||||
(lib.modules.importApply ./interface.nix { inherit clanLib; })
|
||||
./module.nix
|
||||
];
|
||||
};
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
{ pkgs, lib }:
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
clanLib,
|
||||
}:
|
||||
let
|
||||
eval = lib.evalModules {
|
||||
class = "nixos";
|
||||
modules = [
|
||||
./interface.nix
|
||||
(lib.modules.importApply ./interface.nix { inherit clanLib; })
|
||||
];
|
||||
};
|
||||
evalDocs = pkgs.nixosOptionsDoc {
|
||||
|
||||
@@ -19,6 +19,7 @@ in
|
||||
let
|
||||
jsonDocs = import ./eval-docs.nix {
|
||||
inherit pkgs lib;
|
||||
inherit (self) clanLib;
|
||||
};
|
||||
in
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ module:
|
||||
;
|
||||
};
|
||||
modules = [
|
||||
./interface.nix
|
||||
(lib.modules.importApply ./interface.nix { inherit (clan-core) clanLib; })
|
||||
module
|
||||
{
|
||||
inherit specialArgs;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{ clanLib }:
|
||||
{
|
||||
lib,
|
||||
self,
|
||||
@@ -94,7 +95,11 @@ in
|
||||
};
|
||||
|
||||
inventory = lib.mkOption {
|
||||
type = types.submodule { imports = [ ../inventory/build-inventory/interface.nix ]; };
|
||||
type = types.submodule {
|
||||
imports = [
|
||||
(lib.modules.importApply ../inventory/build-inventory/interface.nix { inherit clanLib; })
|
||||
];
|
||||
};
|
||||
description = ''
|
||||
The `Inventory` submodule.
|
||||
|
||||
|
||||
@@ -403,7 +403,7 @@ in
|
||||
};
|
||||
settings = lib.mkOption {
|
||||
default = { };
|
||||
type = types.uniqueDeferredSerializableModule;
|
||||
type = clanLib.types.uniqueDeferredSerializableModule;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ in
|
||||
{
|
||||
inherit (services) evalClanService mapInstances resolveModule;
|
||||
inherit (import ./build-inventory { inherit lib clanLib; }) buildInventory;
|
||||
interface = ./build-inventory/interface.nix;
|
||||
interface = lib.modules.importApply ./build-inventory/interface.nix { inherit clanLib; };
|
||||
# Returns the list of machine names
|
||||
# { ... } -> [ string ]
|
||||
resolveTags =
|
||||
|
||||
@@ -17,7 +17,9 @@ let
|
||||
|
||||
frontMatterSchema = jsonLib.parseOptions self.clanLib.modules.frontmatterOptions { };
|
||||
|
||||
inventorySchema = jsonLib.parseModule (import ../build-inventory/interface.nix);
|
||||
inventorySchema = jsonLib.parseModule (
|
||||
import ../build-inventory/interface.nix { inherit (self) clanLib; }
|
||||
);
|
||||
|
||||
renderSchema = pkgs.writers.writePython3Bin "render-schema" {
|
||||
flakeIgnore = [
|
||||
|
||||
@@ -4,7 +4,12 @@
|
||||
self:
|
||||
|
||||
let
|
||||
checkDef = loc: def: if def.value ? imports then throw "uniqueDeferredSerializableModule doesn't allow nested imports" else def;
|
||||
checkDef =
|
||||
_loc: def:
|
||||
if def.value ? imports then
|
||||
throw "uniqueDeferredSerializableModule doesn't allow nested imports"
|
||||
else
|
||||
def;
|
||||
in
|
||||
# Essentially the "raw" type, but with a custom name and check
|
||||
lib.mkOptionType {
|
||||
@@ -18,8 +23,9 @@
|
||||
merge = loc: defs: {
|
||||
imports = map (
|
||||
def:
|
||||
lib.seq (checkDef loc def)
|
||||
lib.setDefaultModuleLocation "${def.file}, via option ${lib.showOption loc}" def.value
|
||||
lib.seq (checkDef loc def) lib.setDefaultModuleLocation
|
||||
"${def.file}, via option ${lib.showOption loc}"
|
||||
def.value
|
||||
) defs;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -43,7 +43,7 @@ in
|
||||
let
|
||||
eval = evalSettingsModule {
|
||||
foo = {
|
||||
imports = [];
|
||||
imports = [ ];
|
||||
};
|
||||
};
|
||||
in
|
||||
@@ -53,15 +53,17 @@ in
|
||||
expectedError = {
|
||||
type = "ThrownError";
|
||||
message = "*nested imports";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
test_no_function_modules =
|
||||
let
|
||||
eval = evalSettingsModule {
|
||||
foo = {...}: {
|
||||
foo =
|
||||
{ ... }:
|
||||
{
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user