add inject for lib2

This commit is contained in:
DavHau 2022-03-10 17:05:34 +07:00
parent 6341f38026
commit d0cfed18e7
5 changed files with 40 additions and 6 deletions

View File

@ -439,8 +439,7 @@
(dreamOverrides."${dreamLock._generic.subsystem}" or {})
(args.packageOverrides or {});
inject =
utils.dreamLock.decompressDependencyGraph args.inject or {};
inject = args.inject or {};
};
allOutputs = builderOutputs;
@ -587,6 +586,7 @@
# transform a list of resolved projects to buildable outputs
realizeProjects = {
inject ? {},
translatedProjects ? translateProjects {inherit pname settings source;},
# alternative way of calling (for debugging)
pname ? null,
@ -610,7 +610,7 @@
# extends each package with a `.resolve` attribute
outputsForProject = proj: let
outputs = makeOutputsForDreamLock rec {
inherit packageOverrides;
inherit inject packageOverrides;
dreamLock = proj.dreamLock;
sourceOverrides = oldSources: (defaultSourceOverride proj.dreamLock);
};

View File

@ -92,6 +92,7 @@
};
makeFlakeOutputsFunc = {
inject ? {},
pname ? throw "Please pass `pname` to makeFlakeOutputs",
pkgs ? null,
packageOverrides ? {},
@ -168,7 +169,7 @@
};
realizedProjects = dream2nix.realizeProjects {
inherit packageOverrides translatedProjects source;
inherit inject packageOverrides translatedProjects source;
};
allOutputs =

View File

@ -170,7 +170,7 @@
versions)
[
oldDependencyGraph
inject
(decompressDependencyGraph inject)
];
in
lib.recursiveUpdate lock {

View File

@ -15,5 +15,5 @@ in
]
''
export dream2nixSrc=${dream2nixWithExternals}
${python3.pkgs.pytest}/bin/pytest ${self}/tests/unit "$@"
${python3.pkgs.pytest}/bin/pytest ${self}/tests/unit -v "$@"
''

View File

@ -0,0 +1,33 @@
import pytest
import nix_ffi
exampleDreamLock = dict(
_generic = dict(
defaultPackage="example",
packages=dict(
example="1.2.3",
),
subsystem = "nodejs",
_subsystemAttrs = {},
),
dependencies = {},
cyclicDependencies = {},
sources = {},
)
def test_dream_lock_inject():
result = nix_ffi.callNixFunction(
'utils.dreamLock.injectDependencies',
dreamLock=exampleDreamLock,
inject=dict(
example={
"1.2.3": [
[ "injected-package", "1.0.0" ]
]
}
),
)
assert result['dependencies']['example']['1.2.3'] == [dict(
name="injected-package",
version="1.0.0",
)]