From 0f9255e01c2351cc7d116c072cb317785dd33b33 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 4 Oct 2023 15:37:54 +0200 Subject: [PATCH] Force root sources like "./." into the Nix store --- default.nix | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 1519ff1..bd63229 100644 --- a/default.nix +++ b/default.nix @@ -104,7 +104,20 @@ let then let res = builtins.fetchGit src; in if res.rev == "0000000000000000000000000000000000000000" then removeAttrs res ["rev" "shortRev"] else res - else { outPath = src; }; + else { + outPath = + # Massage `src` into a store path. + if builtins.isPath src + then + if dirOf (toString src) == builtins.storeDir + then + # If it's already a store path, don't copy it again. + builtins.storePath src + else + "${src}" + else + src; + }; # NB git worktrees have a file for .git, so we don't check the type of .git isGit = builtins.pathExists (src + "/.git"); isShallow = builtins.pathExists (src + "/.git/shallow"); @@ -149,7 +162,7 @@ let subdir = if key == lockFile.root then "" else node.locked.dir or ""; - outPath = (builtins.storePath sourceInfo) + ((if subdir == "" then "" else "/") + subdir); + outPath = sourceInfo + ((if subdir == "" then "" else "/") + subdir); flake = import (outPath + "/flake.nix");