diff options
Diffstat (limited to 'nix/readTree/default.nix')
-rw-r--r-- | nix/readTree/default.nix | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/nix/readTree/default.nix b/nix/readTree/default.nix index 0c323bbdc8eb..ce4c7f032a10 100644 --- a/nix/readTree/default.nix +++ b/nix/readTree/default.nix @@ -16,6 +16,11 @@ let readDir substring; + assertMsg = pred: msg: + if pred + then true + else builtins.trace msg false; + argsWithPath = args: parts: let meta.locatedAt = parts; in meta // (if isAttrs args then args else args meta); @@ -38,7 +43,14 @@ let # The marker is added to every set that was imported directly by # readTree. importWithMark = args: path: parts: - let imported = import path (argsWithPath args parts); + let + importedFile = import path; + pathType = builtins.typeOf importedFile; + imported = + assert assertMsg + (pathType == "lambda") + "readTree: trying to import ${toString path}, but it’s a ${pathType}, you need to make it a function like { depot, pkgs, ... }"; + importedFile (argsWithPath args parts); in if (isAttrs imported) then imported // (marker parts) else imported; |