mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-13 11:03:37 +03:00
feat: modules: refactor to flat structure
This commit is contained in:
parent
7d824c1da7
commit
4b33d2f655
@ -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;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ modules:
|
||||
}: let
|
||||
lib = config.lib;
|
||||
t = lib.types;
|
||||
subsystemsDir = lib.toString ../../../subsystems;
|
||||
subsystemsDir = lib.toString ../../subsystems;
|
||||
subsystems = dlib.dirNames subsystemsDir;
|
||||
|
||||
/*
|
6
src/modules/functions.translators/default.nix
Normal file
6
src/modules/functions.translators/default.nix
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
imports = [
|
||||
./implementation.nix
|
||||
./interface.nix
|
||||
];
|
||||
}
|
20
src/modules/functions.translators/implementation.nix
Normal file
20
src/modules/functions.translators/implementation.nix
Normal 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
|
||||
;
|
||||
};
|
||||
}
|
8
src/modules/functions.translators/interface.nix
Normal file
8
src/modules/functions.translators/interface.nix
Normal 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;};
|
||||
};
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./subsystem-loading
|
||||
];
|
||||
}
|
@ -6,7 +6,8 @@
|
||||
t = lib.types;
|
||||
in {
|
||||
imports = [
|
||||
./functions
|
||||
./functions.subsystem-loading
|
||||
./functions.translators
|
||||
./translators
|
||||
];
|
||||
options = {
|
||||
|
@ -12,7 +12,7 @@ in {
|
||||
Translator module definitions
|
||||
'';
|
||||
};
|
||||
translators = lib.mkOption {
|
||||
translatorInstances = lib.mkOption {
|
||||
type = t.attrsOf t.anything;
|
||||
};
|
||||
translatorsBySubsystem = lib.mkOption {
|
||||
|
@ -86,7 +86,7 @@
|
||||
args:
|
||||
translateOriginal
|
||||
(
|
||||
(dlib.translators.getextraArgsDefaults
|
||||
(framework.functions.translators.makeTranslatorDefaultArgs
|
||||
(translatorModule.extraArgs or {}))
|
||||
// args
|
||||
// (args.project.subsystemInfo or {})
|
||||
|
@ -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 =
|
||||
|
Loading…
Reference in New Issue
Block a user