forked from lix-project/lix
flake.lock now uses flakeRef.subdir
This commit is contained in:
parent
00db8d4549
commit
43408d3cd6
2 changed files with 13 additions and 10 deletions
|
@ -285,7 +285,7 @@ Flake getFlake(EvalState & state, const FlakeRef & flakeRef, bool impureIsAllowe
|
||||||
+ "/" + flake.sourceInfo.rev->to_string(Base16, false));
|
+ "/" + 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))
|
if (!pathExists(flakeFile))
|
||||||
throw Error("source tree referenced by '%s' does not contain a 'flake.nix' file", resolvedRef);
|
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;
|
LockFile lockFile;
|
||||||
|
|
||||||
if (isTopFlake)
|
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);
|
ResolvedFlake deps(flake);
|
||||||
|
|
||||||
|
@ -407,16 +407,19 @@ static LockFile makeLockFile(EvalState & evalState, FlakeRef & flakeRef)
|
||||||
return lockFile;
|
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!
|
// FIXME: We are writing the lockfile to the store here! Very bad practice!
|
||||||
FlakeRef flakeRef = FlakeRef(path);
|
FlakeRef flakeRef = FlakeRef(flakeUri);
|
||||||
auto lockFile = makeLockFile(state, flakeRef);
|
if (auto refData = std::get_if<IsPath>(flakeRef)) {
|
||||||
writeLockFile(lockFile, path + "/flake.lock");
|
auto lockFile = makeLockFile(state, flakeRef);
|
||||||
|
writeLockFile(lockFile, refData->path + "/" + flakeRef.subdir + "/flake.lock");
|
||||||
|
|
||||||
// Hack: Make sure that flake.lock is visible to Git. Otherwise,
|
// Hack: Make sure that flake.lock is visible to Git. Otherwise,
|
||||||
// exportGit will fail to copy it to the Nix store.
|
// exportGit will fail to copy it to the Nix store.
|
||||||
runProgram("git", true, { "-C", path, "add", "flake.lock" });
|
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)
|
void callFlake(EvalState & state, const ResolvedFlake & resFlake, Value & v)
|
||||||
|
|
|
@ -90,7 +90,7 @@ struct ResolvedFlake
|
||||||
|
|
||||||
ResolvedFlake resolveFlake(EvalState &, const FlakeRef &, RegistryAccess registryAccess, bool isTopFlake = true);
|
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);
|
void gitCloneFlake (std::string flakeUri, EvalState &, Registries, Path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue