mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-20 04:52:15 +03:00
refactor translators: introduce all
This commit is contained in:
parent
5004d7eb5a
commit
0c7e66d79a
@ -33,7 +33,7 @@ let
|
|||||||
translators = import ./translators.nix { inherit dlib lib; };
|
translators = import ./translators.nix { inherit dlib lib; };
|
||||||
discoverers = import ../discoverers { inherit dlib lib; };
|
discoverers = import ../discoverers { inherit dlib lib; };
|
||||||
|
|
||||||
parseUtils = callPackageDream ./parsing.nix {};
|
parseUtils = import ./parsing.nix { inherit lib; };
|
||||||
|
|
||||||
|
|
||||||
# INTERNAL
|
# INTERNAL
|
||||||
|
@ -13,11 +13,28 @@ let
|
|||||||
|
|
||||||
# attrset of: subsystem -> translator-type -> (function subsystem translator-type)
|
# attrset of: subsystem -> translator-type -> (function subsystem translator-type)
|
||||||
mkTranslatorsSet = function:
|
mkTranslatorsSet = function:
|
||||||
l.genAttrs (dlib.dirNames ../translators) (subsystem:
|
l.genAttrs
|
||||||
l.genAttrs
|
(dlib.dirNames ../translators)
|
||||||
(l.filter (dir: builtins.pathExists (../translators + "/${subsystem}/${dir}")) translatorTypes)
|
(subsystem:
|
||||||
(transType: function subsystem transType)
|
let
|
||||||
);
|
availableTypes =
|
||||||
|
l.filter
|
||||||
|
(type: l.pathExists (../translators + "/${subsystem}/${type}"))
|
||||||
|
translatorTypes;
|
||||||
|
|
||||||
|
translatorsForTypes =
|
||||||
|
l.genAttrs
|
||||||
|
availableTypes
|
||||||
|
(transType: function subsystem transType);
|
||||||
|
|
||||||
|
in
|
||||||
|
translatorsForTypes // {
|
||||||
|
all =
|
||||||
|
l.foldl'
|
||||||
|
(a: b: a // b)
|
||||||
|
{}
|
||||||
|
(l.attrValues translatorsForTypes);
|
||||||
|
});
|
||||||
|
|
||||||
# flat list of all translators sorted by priority (pure translators first)
|
# flat list of all translators sorted by priority (pure translators first)
|
||||||
translatorsList =
|
translatorsList =
|
||||||
@ -58,9 +75,22 @@ let
|
|||||||
|
|
||||||
# attrset of: subsystem -> translator-type -> translator
|
# attrset of: subsystem -> translator-type -> translator
|
||||||
translators = mkTranslatorsSet (subsystem: type:
|
translators = mkTranslatorsSet (subsystem: type:
|
||||||
l.genAttrs (dlib.dirNames (../translators + "/${subsystem}/${type}")) (translatorName:
|
let
|
||||||
callTranslator subsystem type translatorName (../translators + "/${subsystem}/${type}/${translatorName}") {}
|
translatorNames =
|
||||||
)
|
dlib.dirNames (../translators + "/${subsystem}/${type}");
|
||||||
|
|
||||||
|
translatorsLoaded =
|
||||||
|
l.genAttrs
|
||||||
|
translatorNames
|
||||||
|
(translatorName:
|
||||||
|
callTranslator
|
||||||
|
subsystem
|
||||||
|
type
|
||||||
|
translatorName
|
||||||
|
(../translators + "/${subsystem}/${type}/${translatorName}")
|
||||||
|
{});
|
||||||
|
in
|
||||||
|
translatorsLoaded
|
||||||
);
|
);
|
||||||
|
|
||||||
mapTranslators = f:
|
mapTranslators = f:
|
||||||
|
Loading…
Reference in New Issue
Block a user