mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-20 13:01:44 +03:00
add settings
argument to lib2.makeFlakeOutputs
This commit is contained in:
parent
29741906b2
commit
2b6bcb7b75
@ -489,15 +489,18 @@ let
|
||||
|
||||
resolveProjectsFromSource =
|
||||
{
|
||||
discoveredProjects ? dlib.discoverers.discoverProjects { inherit tree; },
|
||||
discoveredProjects ? dlib.discoverers.discoverProjects
|
||||
{inherit settings tree;},
|
||||
source ?
|
||||
throw "Pass either `source` or `tree` to resolveProjectsFromSource",
|
||||
tree ? dlib.prepareSourceTree { inherit source; },
|
||||
pname,
|
||||
settings ? [],
|
||||
}@args:
|
||||
|
||||
let
|
||||
|
||||
# This influences error messages only
|
||||
flakeMode = ! builtins ? currentSystem;
|
||||
|
||||
getTranslator = subsystem: translatorName:
|
||||
@ -548,7 +551,7 @@ let
|
||||
impure = isImpure project translator;
|
||||
key = getProjectKey project;
|
||||
resolved = isResolved self;
|
||||
translator = l.head project.translators;
|
||||
translator = project.translator or (l.head project.translators);
|
||||
}; in self))
|
||||
discoveredProjects;
|
||||
|
||||
@ -610,8 +613,7 @@ let
|
||||
if flakeMode then
|
||||
b.trace ''
|
||||
${"\n"}
|
||||
The dream-lock.json for some projects doesn't exist or is outdated.
|
||||
...Falling back to on-the-fly evaluation (possibly slow).
|
||||
Evaluating project data on the fly...
|
||||
To speed up future evalutations run once:
|
||||
nix run .#resolve
|
||||
''
|
||||
@ -619,8 +621,7 @@ let
|
||||
else
|
||||
b.trace ''
|
||||
${"\n"}
|
||||
The dream-lock.json for some projects doesn't exist or is outdated.
|
||||
...Falling back to on-the-fly evaluation (possibly slow).
|
||||
Evaluating project data on the fly...
|
||||
''
|
||||
dreamLocks
|
||||
else
|
||||
@ -629,11 +630,13 @@ let
|
||||
# transform a list of resolved projects to buildable outputs
|
||||
realizeProjects =
|
||||
{
|
||||
dreamLocks ? resolveProjectsFromSource { inherit pname source; },
|
||||
dreamLocks ? resolveProjectsFromSource { inherit pname settings source; },
|
||||
|
||||
# alternative way of calling (for debugging)
|
||||
pname ? null,
|
||||
source ? null,
|
||||
|
||||
settings ? [],
|
||||
}:
|
||||
let
|
||||
|
||||
|
@ -17,11 +17,40 @@ let
|
||||
{
|
||||
source ? throw "Pass either `source` or `tree` to discoverProjects",
|
||||
tree ? dlib.prepareSourceTree { inherit source; },
|
||||
}:
|
||||
l.flatten
|
||||
(l.map
|
||||
(discoverer: discoverer.discover { inherit tree; })
|
||||
allDiscoverers);
|
||||
settings ? [],
|
||||
}: let
|
||||
discovered =
|
||||
l.flatten
|
||||
(l.map
|
||||
(discoverer: discoverer.discover { inherit tree; })
|
||||
allDiscoverers);
|
||||
in
|
||||
applyProjectSettings discovered settings;
|
||||
|
||||
applyProjectSettings = projects: settingsList:
|
||||
let
|
||||
settingsListForProject = project:
|
||||
l.filter
|
||||
(settings:
|
||||
if ! settings ? filter then true
|
||||
else settings.filter project)
|
||||
settingsList;
|
||||
|
||||
applySettings = project: settings:
|
||||
l.recursiveUpdate project settings;
|
||||
|
||||
applyAllSettings = project:
|
||||
l.foldl'
|
||||
(proj: settings: applySettings proj settings)
|
||||
project
|
||||
(settingsListForProject project);
|
||||
|
||||
settingsApplied =
|
||||
l.forEach projects
|
||||
(proj: applyAllSettings proj);
|
||||
|
||||
in settingsApplied;
|
||||
|
||||
|
||||
discoverers = l.genAttrs subsystems (subsystem:
|
||||
(import (./. + "/${subsystem}") { inherit dlib lib subsystem; })
|
||||
@ -30,6 +59,7 @@ in
|
||||
|
||||
{
|
||||
inherit
|
||||
applyProjectSettings
|
||||
discoverProjects
|
||||
discoverers
|
||||
;
|
||||
|
@ -108,6 +108,7 @@ let
|
||||
{
|
||||
pname ? throw "Please pass `pname` to makeFlakeOutputs",
|
||||
pkgs ? null,
|
||||
settings ? [],
|
||||
source,
|
||||
systems ? [],
|
||||
translator ? null,
|
||||
@ -122,6 +123,7 @@ let
|
||||
forAllSystems = f: b.mapAttrs f allPkgs;
|
||||
dream2nixFor = forAllSystems (dream2nixForSystem config);
|
||||
discoveredProjects = dlib.discoverers.discoverProjects {
|
||||
inherit settings;
|
||||
tree = dlib.prepareSourceTree { inherit source; };
|
||||
};
|
||||
|
||||
@ -132,7 +134,7 @@ let
|
||||
dream2nix = dream2nixFor."${system}";
|
||||
|
||||
dreamLocks = dream2nix.resolveProjectsFromSource {
|
||||
inherit pname source;
|
||||
inherit pname settings source;
|
||||
};
|
||||
in
|
||||
dream2nix.realizeProjects {
|
||||
|
Loading…
Reference in New Issue
Block a user