forked from lix-project/lix
* Allow read-only access to the store (e.g., non-root users on NixOS
can do operations like "nix-store -qR <path>" even without the Nix daemon).
This commit is contained in:
parent
8bc591a6f0
commit
989176c56e
|
@ -8,7 +8,6 @@ use File::Temp qw(tempdir);
|
||||||
my $manifestDir = "@localstatedir@/nix/manifests";
|
my $manifestDir = "@localstatedir@/nix/manifests";
|
||||||
my $logFile = "@localstatedir@/log/nix/downloads";
|
my $logFile = "@localstatedir@/log/nix/downloads";
|
||||||
|
|
||||||
open LOGFILE, ">>$logFile" or die "cannot open log file $logFile";
|
|
||||||
|
|
||||||
# Create a temporary directory.
|
# Create a temporary directory.
|
||||||
my $tmpDir = tempdir("nix-download.XXXXXX", CLEANUP => 1, TMPDIR => 1)
|
my $tmpDir = tempdir("nix-download.XXXXXX", CLEANUP => 1, TMPDIR => 1)
|
||||||
|
@ -76,6 +75,8 @@ die unless scalar @ARGV == 2;
|
||||||
my $targetPath = $ARGV[1];
|
my $targetPath = $ARGV[1];
|
||||||
|
|
||||||
|
|
||||||
|
open LOGFILE, ">>$logFile" or die "cannot open log file $logFile";
|
||||||
|
|
||||||
my $date = strftime ("%F %H:%M:%S UTC", gmtime (time));
|
my $date = strftime ("%F %H:%M:%S UTC", gmtime (time));
|
||||||
print LOGFILE "$$ get $targetPath $date\n";
|
print LOGFILE "$$ get $targetPath $date\n";
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
@ -48,8 +49,14 @@ LocalStore::LocalStore()
|
||||||
|
|
||||||
checkStoreNotSymlink();
|
checkStoreNotSymlink();
|
||||||
|
|
||||||
Path globalLockPath = nixDBPath + "/big-lock";
|
try {
|
||||||
globalLock = openLockFile(globalLockPath.c_str(), true);
|
Path globalLockPath = nixDBPath + "/big-lock";
|
||||||
|
globalLock = openLockFile(globalLockPath.c_str(), true);
|
||||||
|
} catch (SysError & e) {
|
||||||
|
if (e.errNo != EACCES) throw;
|
||||||
|
readOnlyMode = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!lockFile(globalLock, ltRead, false)) {
|
if (!lockFile(globalLock, ltRead, false)) {
|
||||||
printMsg(lvlError, "waiting for the big Nix store lock...");
|
printMsg(lvlError, "waiting for the big Nix store lock...");
|
||||||
|
@ -59,9 +66,6 @@ LocalStore::LocalStore()
|
||||||
createDirs(nixDBPath + "/info");
|
createDirs(nixDBPath + "/info");
|
||||||
createDirs(nixDBPath + "/referrer");
|
createDirs(nixDBPath + "/referrer");
|
||||||
|
|
||||||
//printMsg(lvlTalkative, "cannot access Nix database; continuing anyway");
|
|
||||||
//readOnlyMode = true;
|
|
||||||
|
|
||||||
int curSchema = getSchema();
|
int curSchema = getSchema();
|
||||||
if (curSchema > nixSchemaVersion)
|
if (curSchema > nixSchemaVersion)
|
||||||
throw Error(format("current Nix store schema is version %1%, but I only support %2%")
|
throw Error(format("current Nix store schema is version %1%, but I only support %2%")
|
||||||
|
|
Loading…
Reference in a new issue