mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-27 16:33:05 +03:00
add functions.discoverers.discoverProjects2
This commit is contained in:
parent
3d6f13ef9d
commit
e7bd51d83e
@ -2,6 +2,68 @@
|
||||
l = config.lib // builtins;
|
||||
dlib = config.dlib;
|
||||
|
||||
/*
|
||||
Stripped down discoverProjects without settings merging and dreamLockPath
|
||||
represented as an attrset:
|
||||
{
|
||||
${project-name} = {
|
||||
relPath = ...;
|
||||
subsystem = ...;
|
||||
subsystemInfo = {
|
||||
...
|
||||
};
|
||||
translator = "some-translator";
|
||||
|
||||
# all compatible translators
|
||||
translators = [
|
||||
"some-translator"
|
||||
"some-alternative-translator"
|
||||
];
|
||||
}
|
||||
}
|
||||
*/
|
||||
discoverProjects2 = {
|
||||
source ? throw "Pass either `source` or `tree` to discoverProjects",
|
||||
tree ? dlib.prepareSourceTree {inherit source;},
|
||||
}: let
|
||||
discoveredProjects =
|
||||
l.flatten
|
||||
(
|
||||
l.map
|
||||
(discoverer: discoverer.discover {inherit tree;})
|
||||
(l.attrValues config.discoverers)
|
||||
);
|
||||
|
||||
discoveredProjectsSorted = let
|
||||
sorted =
|
||||
l.sort
|
||||
(p1: p2: l.hasPrefix p1.relPath or "" p2.relPath or "")
|
||||
discoveredProjects;
|
||||
in
|
||||
sorted;
|
||||
|
||||
allProjects = discoveredProjectsSorted;
|
||||
|
||||
projectsExtended =
|
||||
l.forEach allProjects
|
||||
(proj:
|
||||
proj
|
||||
// {
|
||||
relPath = proj.relPath or "";
|
||||
translator = proj.translator or (l.head proj.translators);
|
||||
});
|
||||
in
|
||||
l.listToAttrs (
|
||||
l.map
|
||||
(proj: l.nameValuePair proj.name proj)
|
||||
projectsExtended
|
||||
);
|
||||
|
||||
/*
|
||||
legacy function doing some custom merging on `settings`.
|
||||
We should remove that function once there is no more usage within the
|
||||
frameworks code.
|
||||
*/
|
||||
discoverProjects = {
|
||||
source ? throw "Pass either `source` or `tree` to discoverProjects",
|
||||
tree ? dlib.prepareSourceTree {inherit source;},
|
||||
@ -69,6 +131,7 @@ in {
|
||||
functions.discoverers = {
|
||||
inherit
|
||||
discoverProjects
|
||||
discoverProjects2
|
||||
getDreamLockPath
|
||||
applyProjectSettings
|
||||
;
|
||||
|
@ -3,6 +3,9 @@
|
||||
t = l.types;
|
||||
in {
|
||||
options.functions.discoverers = {
|
||||
discoverProjects2 = l.mkOption {
|
||||
type = t.uniq (t.functionTo (t.listOf t.attrs));
|
||||
};
|
||||
discoverProjects = l.mkOption {
|
||||
type = t.uniq (t.functionTo (t.listOf t.attrs));
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user