mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 16:26:18 +02:00
Add flags to disallow dirty Git trees and to turn off warnings
This commit is contained in:
parent
99e8e58f2d
commit
68e0f23edc
4 changed files with 21 additions and 6 deletions
|
@ -377,10 +377,16 @@ struct EvalSettings : Config
|
||||||
"Prefixes of URIs that builtin functions such as fetchurl and fetchGit are allowed to fetch."};
|
"Prefixes of URIs that builtin functions such as fetchurl and fetchGit are allowed to fetch."};
|
||||||
|
|
||||||
Setting<bool> traceFunctionCalls{this, false, "trace-function-calls",
|
Setting<bool> traceFunctionCalls{this, false, "trace-function-calls",
|
||||||
"Emit log messages for each function entry and exit at the 'vomit' log level (-vvvv)"};
|
"Emit log messages for each function entry and exit at the 'vomit' log level (-vvvv)."};
|
||||||
|
|
||||||
Setting<std::string> flakeRegistry{this, "https://raw.githubusercontent.com/NixOS/flake-registry/master/flake-registry.json", "flake-registry",
|
Setting<std::string> flakeRegistry{this, "https://raw.githubusercontent.com/NixOS/flake-registry/master/flake-registry.json", "flake-registry",
|
||||||
"Path or URI of the global flake registry."};
|
"Path or URI of the global flake registry."};
|
||||||
|
|
||||||
|
Setting<bool> allowDirty{this, true, "allow-dirty",
|
||||||
|
"Whether to allow dirty Git/Mercurial trees."};
|
||||||
|
|
||||||
|
Setting<bool> warnDirty{this, true, "warn-dirty",
|
||||||
|
"Whether to warn about dirty Git/Mercurial trees."};
|
||||||
};
|
};
|
||||||
|
|
||||||
extern EvalSettings evalSettings;
|
extern EvalSettings evalSettings;
|
||||||
|
|
|
@ -480,9 +480,10 @@ ResolvedFlake resolveFlake(EvalState & state, const FlakeRef & topRef, HandleLoc
|
||||||
if (!(lockFile == oldLockFile)) {
|
if (!(lockFile == oldLockFile)) {
|
||||||
if (allowedToWrite(handleLockFile)) {
|
if (allowedToWrite(handleLockFile)) {
|
||||||
if (auto refData = std::get_if<FlakeRef::IsPath>(&topRef.data)) {
|
if (auto refData = std::get_if<FlakeRef::IsPath>(&topRef.data)) {
|
||||||
if (lockFile.isDirty())
|
if (lockFile.isDirty()) {
|
||||||
|
if (evalSettings.warnDirty)
|
||||||
warn("will not write lock file of flake '%s' because it has a dirty input", topRef);
|
warn("will not write lock file of flake '%s' because it has a dirty input", topRef);
|
||||||
else {
|
} else {
|
||||||
lockFile.write(refData->path + (topRef.subdir == "" ? "" : "/" + topRef.subdir) + "/flake.lock");
|
lockFile.write(refData->path + (topRef.subdir == "" ? "" : "/" + topRef.subdir) + "/flake.lock");
|
||||||
|
|
||||||
// Hack: Make sure that flake.lock is visible to Git, so it ends up in the Nix store.
|
// Hack: Make sure that flake.lock is visible to Git, so it ends up in the Nix store.
|
||||||
|
|
|
@ -47,6 +47,10 @@ GitInfo exportGit(ref<Store> store, std::string uri,
|
||||||
/* This is an unclean working tree. So copy all tracked
|
/* This is an unclean working tree. So copy all tracked
|
||||||
files. */
|
files. */
|
||||||
|
|
||||||
|
if (!evalSettings.allowDirty)
|
||||||
|
throw Error("Git tree '%s' is dirty", uri);
|
||||||
|
|
||||||
|
if (evalSettings.warnDirty)
|
||||||
warn("Git tree '%s' is dirty", uri);
|
warn("Git tree '%s' is dirty", uri);
|
||||||
|
|
||||||
GitInfo gitInfo;
|
GitInfo gitInfo;
|
||||||
|
|
|
@ -36,7 +36,11 @@ HgInfo exportMercurial(ref<Store> store, const std::string & uri,
|
||||||
/* This is an unclean working tree. So copy all tracked
|
/* This is an unclean working tree. So copy all tracked
|
||||||
files. */
|
files. */
|
||||||
|
|
||||||
printTalkative("copying unclean Mercurial working tree '%s'", uri);
|
if (!evalSettings.allowDirty)
|
||||||
|
throw Error("Mercurial tree '%s' is unclean", uri);
|
||||||
|
|
||||||
|
if (evalSettings.warnDirty)
|
||||||
|
warn("Mercurial tree '%s' is unclean", uri);
|
||||||
|
|
||||||
HgInfo hgInfo;
|
HgInfo hgInfo;
|
||||||
hgInfo.rev = "0000000000000000000000000000000000000000";
|
hgInfo.rev = "0000000000000000000000000000000000000000";
|
||||||
|
|
Loading…
Reference in a new issue