Merge pull request #167947 from MatthewCroughan/mc/callLocklessFlake
lib: add callLocklessFlake
This commit is contained in:
commit
a5357d06e4
5 changed files with 48 additions and 0 deletions
|
@ -11,6 +11,9 @@ let
|
|||
callLibs = file: import file { lib = self; };
|
||||
in {
|
||||
|
||||
# interacting with flakes
|
||||
flakes = callLibs ./flakes.nix;
|
||||
|
||||
# often used, or depending on very little
|
||||
trivial = callLibs ./trivial.nix;
|
||||
fixedPoints = callLibs ./fixed-points.nix;
|
||||
|
@ -59,6 +62,7 @@ let
|
|||
# linux kernel configuration
|
||||
kernel = callLibs ./kernel.nix;
|
||||
|
||||
inherit (self.flakes) callLocklessFlake;
|
||||
inherit (builtins) add addErrorContext attrNames concatLists
|
||||
deepSeq elem elemAt filter genericClosure genList getAttr
|
||||
hasAttr head isAttrs isBool isInt isList isString length
|
||||
|
|
22
lib/flakes.nix
Normal file
22
lib/flakes.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
{ lib }:
|
||||
|
||||
rec {
|
||||
|
||||
/* imports a flake.nix without acknowledging its lock file, useful for
|
||||
referencing subflakes from a parent flake. The second argument allows
|
||||
specifying the inputs of this flake.
|
||||
|
||||
Example:
|
||||
callLocklessFlake {
|
||||
path = ./directoryContainingFlake;
|
||||
inputs = { inherit nixpkgs; };
|
||||
}
|
||||
*/
|
||||
callLocklessFlake = { path, inputs ? { } }:
|
||||
let
|
||||
self = { outPath = path; } //
|
||||
((import (path + "/flake.nix")).outputs (inputs // { self = self; }));
|
||||
in
|
||||
self;
|
||||
|
||||
}
|
8
lib/tests/flakes/subflakeTest/flake.nix
Normal file
8
lib/tests/flakes/subflakeTest/flake.nix
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
outputs = { self, subflake, callLocklessFlake }: rec {
|
||||
x = (callLocklessFlake {
|
||||
path = subflake;
|
||||
inputs = {};
|
||||
}).subflakeOutput;
|
||||
};
|
||||
}
|
5
lib/tests/flakes/subflakeTest/subflake/flake.nix
Normal file
5
lib/tests/flakes/subflakeTest/subflake/flake.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
outputs = { self }: {
|
||||
subflakeOutput = 1;
|
||||
};
|
||||
}
|
|
@ -22,6 +22,15 @@ in
|
|||
|
||||
runTests {
|
||||
|
||||
# FLAKES
|
||||
|
||||
testCallLocklessFlake = {
|
||||
expr = callLocklessFlake {
|
||||
path = ./flakes/subflakeTest;
|
||||
inputs = { subflake = ./flakes/subflakeTest/subflake; inherit callLocklessFlake; };
|
||||
};
|
||||
expected = { x = 1; outPath = ./flakes/subflakeTest; };
|
||||
};
|
||||
|
||||
# TRIVIAL
|
||||
|
||||
|
|
Loading…
Reference in a new issue