feat: modules: refactor to flat structure

This commit is contained in:
DavHau 2022-08-12 20:30:45 +02:00
parent 7d824c1da7
commit 4b33d2f655
12 changed files with 41 additions and 21 deletions

View File

@ -24,15 +24,4 @@
in {
inherit translators mapTranslators;
callTranslator = modules.callModule;
# pupulates a translators special args with defaults
getextraArgsDefaults = extraArgsDef:
l.mapAttrs
(
name: def:
if def.type == "flag"
then false
else def.default or null
)
extraArgsDef;
}

View File

@ -14,7 +14,7 @@ modules:
}: let
lib = config.lib;
t = lib.types;
subsystemsDir = lib.toString ../../../subsystems;
subsystemsDir = lib.toString ../../subsystems;
subsystems = dlib.dirNames subsystemsDir;
/*

View File

@ -0,0 +1,6 @@
{
imports = [
./implementation.nix
./interface.nix
];
}

View File

@ -0,0 +1,20 @@
{config, ...}: let
lib = config.lib;
# pupulates a translators special args with defaults
makeTranslatorDefaultArgs = extraArgsDef:
lib.mapAttrs
(
name: def:
if def.type == "flag"
then false
else def.default or null
)
extraArgsDef;
in {
functions.translators = {
inherit
makeTranslatorDefaultArgs
;
};
}

View File

@ -0,0 +1,8 @@
{config, ...}: let
lib = config.lib;
t = lib.types;
in {
options.functions.translators = {
makeTranslatorDefaultArgs = lib.mkOption {type = t.functionTo t.anything;};
};
}

View File

@ -1,5 +0,0 @@
{
imports = [
./subsystem-loading
];
}

View File

@ -6,7 +6,8 @@
t = lib.types;
in {
imports = [
./functions
./functions.subsystem-loading
./functions.translators
./translators
];
options = {

View File

@ -12,7 +12,7 @@ in {
Translator module definitions
'';
};
translators = lib.mkOption {
translatorInstances = lib.mkOption {
type = t.attrsOf t.anything;
};
translatorsBySubsystem = lib.mkOption {

View File

@ -86,7 +86,7 @@
args:
translateOriginal
(
(dlib.translators.getextraArgsDefaults
(framework.functions.translators.makeTranslatorDefaultArgs
(translatorModule.extraArgs or {}))
// args
// (args.project.subsystemInfo or {})

View File

@ -22,6 +22,7 @@
subsystems,
config,
configFile,
framework,
...
}: let
b = builtins;
@ -197,7 +198,7 @@ in
project = l.removeAttrs args.project ["dreamLock"];
outputFile = project.dreamLockPath;
}
// (dlib.translators.getextraArgsDefaults translator.extraArgs or {})
// (framework.functions.translators.makeTranslatorDefaultArgs translator.extraArgs or {})
// args.project.subsystemInfo or {}
));
script =