aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libfetchers/git.cc9
-rwxr-xr-xsrc/nix-build/nix-build.cc2
2 files changed, 9 insertions, 2 deletions
diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc
index bc1930138..d89763ccd 100644
--- a/src/libfetchers/git.cc
+++ b/src/libfetchers/git.cc
@@ -4,6 +4,7 @@
#include "tarfile.hh"
#include "store-api.hh"
#include "url-parts.hh"
+#include "pathlocks.hh"
#include <sys/time.h>
#include <sys/wait.h>
@@ -317,11 +318,17 @@ struct GitInputScheme : InputScheme
Path cacheDir = getCacheDir() + "/nix/gitv3/" + hashString(htSHA256, actualUrl).to_string(Base32, false);
repoDir = cacheDir;
+ Path cacheDirLock = cacheDir + ".lock";
+ createDirs(dirOf(cacheDir));
+ AutoCloseFD lock = openLockFile(cacheDirLock, true);
+ lockFile(lock.get(), ltWrite, true);
+
if (!pathExists(cacheDir)) {
- createDirs(dirOf(cacheDir));
runProgram("git", true, { "init", "--bare", repoDir });
}
+ deleteLockFile(cacheDirLock, lock.get());
+
Path localRefFile =
input.getRef()->compare(0, 5, "refs/") == 0
? cacheDir + "/" + *input.getRef()
diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc
index 848b108dd..9e3538394 100755
--- a/src/nix-build/nix-build.cc
+++ b/src/nix-build/nix-build.cc
@@ -269,7 +269,7 @@ static void main_nix_build(int argc, char * * argv)
if (packages) {
std::ostringstream joined;
- joined << "with import <nixpkgs> { }; (pkgs.runCommandCC or pkgs.runCommand) \"shell\" { buildInputs = [ ";
+ joined << "{...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) \"shell\" { buildInputs = [ ";
for (const auto & i : left)
joined << '(' << i << ") ";
joined << "]; } \"\"";