From c71d063a2fce96001c7ef99b301dfbd0c29ebde1 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 20 Aug 2020 15:49:28 -0500 Subject: [PATCH] Allow calling flakes without a flake.lock If no inputs but "self" are specified, Nix will not generate a flake.lock at all. In this case, Flakes are mostly just used to provide a more pure Nix experience, while sources are locked through some other means (niv, ob thunk, manually, etc.). Supporting this is a little weird, but it ends up working for my repo (https://github.com/matthewbauer/nixiosk). --- default.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/default.nix b/default.nix index 63020e9..2ca2c5d 100644 --- a/default.nix +++ b/default.nix @@ -54,6 +54,12 @@ let assert flake.edition == 201909; outputs; + callLocklessFlake = flakeSrc: + let + flake = import (flakeSrc + "/flake.nix"); + outputs = flakeSrc // (flake.outputs ({ self = outputs; })); + in outputs; + rootSrc = let dir = builtins.readDir src; gitDir = builtins.readDir (src + "/.git"); @@ -144,7 +150,9 @@ let lockFile.nodes; result = - if lockFile.version == 4 + if !(builtins.pathExists lockFilePath) + then callLocklessFlake rootSrc + else if lockFile.version == 4 then callFlake4 rootSrc (lockFile.inputs) else if lockFile.version >= 5 && lockFile.version <= 7 then allNodes.${lockFile.root}