about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lib/default.nix2
-rw-r--r--lib/trivial.nix16
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/default.nix b/lib/default.nix
index 1f06283790a8b..7d20acc679482 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -64,7 +64,7 @@ let
       hasAttr head isAttrs isBool isInt isList isString length
       lessThan listToAttrs pathExists readFile replaceStrings seq
       stringLength sub substring tail trace;
-    inherit (self.trivial) id const pipe concat or and bitAnd bitOr bitXor
+    inherit (self.trivial) id callLocklessFlake const pipe concat or and bitAnd bitOr bitXor
       bitNot boolToString mergeAttrs flip mapNullable inNixShell isFloat min max
       importJSON importTOML warn warnIf warnIfNot throwIf throwIfNot checkListOfEnum
       info showWarnings nixpkgsVersion version isInOldestRelease
diff --git a/lib/trivial.nix b/lib/trivial.nix
index 18616a189c269..0b9b6bd910f0e 100644
--- a/lib/trivial.nix
+++ b/lib/trivial.nix
@@ -13,6 +13,22 @@ rec {
     # The value to return
     x: x;
 
+  /* 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;
+
   /* The constant function
 
      Ignores the second argument. If called with only one argument,