mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-17 06:06:13 +03:00
Merge pull request #177977 from thefloweringash/call-packages-with-function-args
lib/customization: propagate function arguments in callPackagesWith
This commit is contained in:
commit
961ddd92a1
@ -221,9 +221,10 @@ rec {
|
|||||||
let
|
let
|
||||||
f = if isFunction fn then fn else import fn;
|
f = if isFunction fn then fn else import fn;
|
||||||
auto = intersectAttrs (functionArgs f) autoArgs;
|
auto = intersectAttrs (functionArgs f) autoArgs;
|
||||||
|
mirrorArgs = mirrorFunctionArgs f;
|
||||||
origArgs = auto // args;
|
origArgs = auto // args;
|
||||||
pkgs = f origArgs;
|
pkgs = f origArgs;
|
||||||
mkAttrOverridable = name: _: makeOverridable (newArgs: (f newArgs).${name}) origArgs;
|
mkAttrOverridable = name: _: makeOverridable (mirrorArgs (newArgs: (f newArgs).${name})) origArgs;
|
||||||
in
|
in
|
||||||
if isDerivation pkgs then throw
|
if isDerivation pkgs then throw
|
||||||
("function `callPackages` was called on a *single* derivation "
|
("function `callPackages` was called on a *single* derivation "
|
||||||
|
@ -55,6 +55,24 @@ runTests {
|
|||||||
expected = { a = false; b = false; c = true; };
|
expected = { a = false; b = false; c = true; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
testCallPackageWithOverridePreservesArguments =
|
||||||
|
let
|
||||||
|
f = { a ? 0, b }: {};
|
||||||
|
f' = callPackageWith { a = 1; b = 2; } f {};
|
||||||
|
in {
|
||||||
|
expr = functionArgs f'.override;
|
||||||
|
expected = functionArgs f;
|
||||||
|
};
|
||||||
|
|
||||||
|
testCallPackagesWithOverridePreservesArguments =
|
||||||
|
let
|
||||||
|
f = { a ? 0, b }: { nested = {}; };
|
||||||
|
f' = callPackagesWith { a = 1; b = 2; } f {};
|
||||||
|
in {
|
||||||
|
expr = functionArgs f'.nested.override;
|
||||||
|
expected = functionArgs f;
|
||||||
|
};
|
||||||
|
|
||||||
# TRIVIAL
|
# TRIVIAL
|
||||||
|
|
||||||
testId = {
|
testId = {
|
||||||
|
Loading…
Reference in New Issue
Block a user