From fc74939824cc92da3a39a6eb37ae2b7df89f55c3 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Fri, 13 Oct 2023 23:02:24 +0200 Subject: [PATCH] mkFlake: Prefer unsafeGetAttrPos over self.outPath for error message This would not be advisable for anything other than error messages, because Nix does not commit to any semantics for that function. --- lib.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib.nix b/lib.nix index 33f20e4..f338367 100644 --- a/lib.nix +++ b/lib.nix @@ -121,14 +121,17 @@ let mkFlake = args: module: let - loc = + inputsPos = builtins.unsafeGetAttrPos "inputs" args; + moduleLocation = args.moduleLocation or ( - if args?inputs.self.outPath + if inputsPos != null + then inputsPos.file + else if args?inputs.self.outPath then args.inputs.self.outPath + "/flake.nix" else "" ); - mod = lib.setDefaultModuleLocation loc module; - eval = flake-parts-lib.evalFlakeModule args mod; + mod = lib.setDefaultModuleLocation moduleLocation module; + eval = flake-parts-lib.evalFlakeModule (args // { inherit moduleLocation; }) mod; in eval.config.flake;