Skip to content

Commit

Permalink
import callLocklessFlake
Browse files Browse the repository at this point in the history
This function was added to nixpkgs in
NixOS/nixpkgs#167947 by Artturin.
And later reverted because it's for unstable flakes.

So let's add it here, since a lot of projects are already importing
flake-utils.
  • Loading branch information
zimbatm committed May 26, 2022
1 parent 04c1b18 commit 7d5ff83
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 16 additions & 0 deletions call-lockless-flake.nix
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7d5ff83

Please sign in to comment.