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

View File

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

View File

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

View File

@ -15,5 +15,5 @@ in
] ]
'' ''
export dream2nixSrc=${dream2nixWithExternals} 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",
)]