aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops
diff options
context:
space:
mode:
authorNick Van den Broeck <nick.van.den.broeck666@gmail.com>2019-05-01 16:24:33 +0200
committerNick Van den Broeck <nick.van.den.broeck666@gmail.com>2019-05-01 16:24:33 +0200
commit43408d3cd6e254c1c69eb9cf9de4de042b986ab6 (patch)
treeef34a13c7a15c1dcfc9cef250847edb485efdaac /src/libexpr/primops
parent00db8d4549b1e87db45395e157dec3f729bdc071 (diff)
flake.lock now uses flakeRef.subdir
Diffstat (limited to 'src/libexpr/primops')
-rw-r--r--src/libexpr/primops/flake.cc23
-rw-r--r--src/libexpr/primops/flake.hh2
2 files changed, 14 insertions, 11 deletions
diff --git a/src/libexpr/primops/flake.cc b/src/libexpr/primops/flake.cc
index e806ef6c7..41b3f6d28 100644
--- a/src/libexpr/primops/flake.cc
+++ b/src/libexpr/primops/flake.cc
@@ -285,7 +285,7 @@ Flake getFlake(EvalState & state, const FlakeRef & flakeRef, bool impureIsAllowe
+ "/" + flake.sourceInfo.rev->to_string(Base16, false));
}
- Path flakeFile = sourceInfo.storePath + resolvedRef.subdir + "/flake.nix";
+ Path flakeFile = sourceInfo.storePath + "/" + resolvedRef.subdir + "/flake.nix";
if (!pathExists(flakeFile))
throw Error("source tree referenced by '%s' does not contain a 'flake.nix' file", resolvedRef);
@@ -367,7 +367,7 @@ ResolvedFlake resolveFlake(EvalState & state, const FlakeRef & topRef,
LockFile lockFile;
if (isTopFlake)
- lockFile = readLockFile(flake.sourceInfo.storePath + "/flake.lock"); // FIXME: symlink attack
+ lockFile = readLockFile(flake.sourceInfo.storePath + "/" + flake.resolvedRef.subdir + "/flake.lock"); // FIXME: symlink attack
ResolvedFlake deps(flake);
@@ -407,16 +407,19 @@ static LockFile makeLockFile(EvalState & evalState, FlakeRef & flakeRef)
return lockFile;
}
-void updateLockFile(EvalState & state, const Path & path)
+void updateLockFile(EvalState & state, const FlakeUri & flakeUri)
{
// FIXME: We are writing the lockfile to the store here! Very bad practice!
- FlakeRef flakeRef = FlakeRef(path);
- auto lockFile = makeLockFile(state, flakeRef);
- writeLockFile(lockFile, path + "/flake.lock");
-
- // Hack: Make sure that flake.lock is visible to Git. Otherwise,
- // exportGit will fail to copy it to the Nix store.
- runProgram("git", true, { "-C", path, "add", "flake.lock" });
+ FlakeRef flakeRef = FlakeRef(flakeUri);
+ if (auto refData = std::get_if<IsPath>(flakeRef)) {
+ auto lockFile = makeLockFile(state, flakeRef);
+ writeLockFile(lockFile, refData->path + "/" + flakeRef.subdir + "/flake.lock");
+
+ // Hack: Make sure that flake.lock is visible to Git. Otherwise,
+ // exportGit will fail to copy it to the Nix store.
+ runProgram("git", true, { "-C", refData->path, "add", flakeRef.subDir + "/flake.lock" });
+ } else
+ throw Error("flakeUri %s can't be updated because it is not a path", flakeUri);
}
void callFlake(EvalState & state, const ResolvedFlake & resFlake, Value & v)
diff --git a/src/libexpr/primops/flake.hh b/src/libexpr/primops/flake.hh
index 8e9af5843..6329c36ec 100644
--- a/src/libexpr/primops/flake.hh
+++ b/src/libexpr/primops/flake.hh
@@ -90,7 +90,7 @@ struct ResolvedFlake
ResolvedFlake resolveFlake(EvalState &, const FlakeRef &, RegistryAccess registryAccess, bool isTopFlake = true);
-void updateLockFile(EvalState &, const Path & path);
+void updateLockFile(EvalState &, const FlakeUri &);
void gitCloneFlake (std::string flakeUri, EvalState &, Registries, Path);
}