diff --git a/README.md b/README.md index a1b43f6..81e6df9 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,20 @@ Input: }: null ``` +### `callLocklessFlake -> { path, inputs ? { } } -> attrs` + +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; }; +} +``` + #### Example Here is how it looks like in practice: diff --git a/call-lockless-flake.nix b/call-lockless-flake.nix new file mode 100644 index 0000000..93a76ea --- /dev/null +++ b/call-lockless-flake.nix @@ -0,0 +1,16 @@ +/* + 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; }; + } +*/ +{ path, inputs ? { } }: +let + self = { outPath = path; } // + ((import (path + "/flake.nix")).outputs (inputs // { self = self; })); +in +self diff --git a/default.nix b/default.nix index 8c2c729..9735284 100644 --- a/default.nix +++ b/default.nix @@ -192,6 +192,8 @@ let # } filterPackages = import ./filterPackages.nix { inherit allSystems; }; + callLocklessFlake = import ./call-lockless-flake.nix; + # Returns the structure used by `nix app` mkApp = { drv