aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/flake/flake.cc19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc
index 20d7878e9..d96f2b22e 100644
--- a/src/libexpr/flake/flake.cc
+++ b/src/libexpr/flake/flake.cc
@@ -645,29 +645,28 @@ LockedFlake lockFlake(
auto newLockFileS = fmt("%s\n", newLockFile);
- if (lockFlags.outputLockFilePath)
+ if (lockFlags.outputLockFilePath) {
+ if (lockFlags.commitLockFile)
+ throw Error("'--commit-lock-file' and '--output-lock-file' are incompatible");
writeFile(*lockFlags.outputLockFilePath, newLockFileS);
- else {
+ } else {
auto relPath = (topRef.subdir == "" ? "" : topRef.subdir + "/") + "flake.lock";
- auto outputLockFilePath = sourcePath ? std::optional{*sourcePath + "/" + relPath} : std::nullopt;
+ auto outputLockFilePath = *sourcePath + "/" + relPath;
- bool lockFileExists = pathExists(*outputLockFilePath);
+ bool lockFileExists = pathExists(outputLockFilePath);
if (lockFileExists) {
auto s = chomp(diff);
if (s.empty())
- warn("updating lock file '%s'", *outputLockFilePath);
+ warn("updating lock file '%s'", outputLockFilePath);
else
- warn("updating lock file '%s':\n%s", *outputLockFilePath, s);
+ warn("updating lock file '%s':\n%s", outputLockFilePath, s);
} else
- warn("creating lock file '%s'", *outputLockFilePath);
+ warn("creating lock file '%s'", outputLockFilePath);
std::optional<std::string> commitMessage = std::nullopt;
if (lockFlags.commitLockFile) {
- if (lockFlags.outputLockFilePath) {
- throw Error("--commit-lock-file and --output-lock-file are currently incompatible");
- }
std::string cm;
cm = fetchSettings.commitLockFileSummary.get();