mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 12:10:59 +01:00
Merged R9207
This commit is contained in:
parent
13b632ca57
commit
ca3d96222a
29 changed files with 258 additions and 104 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
my $rootsDir = "@localstatedir@/nix/gcroots/channels";
|
my $rootsDir = "@localstatedir@/nix/gcroots";
|
||||||
|
|
||||||
my $stateDir = $ENV{"NIX_STATE_DIR"};
|
my $stateDir = $ENV{"NIX_STATE_DIR"};
|
||||||
$stateDir = "@localstatedir@/nix" unless defined $stateDir;
|
$stateDir = "@localstatedir@/nix" unless defined $stateDir;
|
||||||
|
|
@ -10,8 +10,8 @@ $stateDir = "@localstatedir@/nix" unless defined $stateDir;
|
||||||
|
|
||||||
# Turn on caching in nix-prefetch-url.
|
# Turn on caching in nix-prefetch-url.
|
||||||
my $channelCache = "$stateDir/channel-cache";
|
my $channelCache = "$stateDir/channel-cache";
|
||||||
$ENV{'NIX_DOWNLOAD_CACHE'} = $channelCache;
|
|
||||||
mkdir $channelCache, 0755 unless -e $channelCache;
|
mkdir $channelCache, 0755 unless -e $channelCache;
|
||||||
|
$ENV{'NIX_DOWNLOAD_CACHE'} = $channelCache if -W $channelCache;
|
||||||
|
|
||||||
|
|
||||||
# Figure out the name of the `.nix-channels' file to use.
|
# Figure out the name of the `.nix-channels' file to use.
|
||||||
|
|
@ -76,16 +76,25 @@ sub removeChannel {
|
||||||
sub update {
|
sub update {
|
||||||
readChannels;
|
readChannels;
|
||||||
|
|
||||||
# Remove all the old manifests.
|
# Do we have write permission to the manifests directory? If not,
|
||||||
for my $manifest (glob "$stateDir/manifests/*.nixmanifest") {
|
# then just skip pulling the manifest and just download the Nix
|
||||||
unlink $manifest or die "cannot remove `$manifest': $!";
|
# expressions. If the user is a non-privileged user in a
|
||||||
}
|
# multi-user Nix installation, he at least gets installation from
|
||||||
|
# source.
|
||||||
|
if (-W "$stateDir/manifests") {
|
||||||
|
|
||||||
|
# Remove all the old manifests.
|
||||||
|
for my $manifest (glob "$stateDir/manifests/*.nixmanifest") {
|
||||||
|
unlink $manifest or die "cannot remove `$manifest': $!";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Pull cache manifests.
|
||||||
|
foreach my $url (@channels) {
|
||||||
|
#print "pulling cache manifest from `$url'\n";
|
||||||
|
system("@bindir@/nix-pull", "--skip-wrong-store", "$url/MANIFEST") == 0
|
||||||
|
or die "cannot pull cache manifest from `$url'";
|
||||||
|
}
|
||||||
|
|
||||||
# Pull cache manifests.
|
|
||||||
foreach my $url (@channels) {
|
|
||||||
#print "pulling cache manifest from `$url'\n";
|
|
||||||
system("@bindir@/nix-pull", "--skip-wrong-store", "$url/MANIFEST") == 0
|
|
||||||
or die "cannot pull cache manifest from `$url'";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a Nix expression that fetches and unpacks the channel Nix
|
# Create a Nix expression that fetches and unpacks the channel Nix
|
||||||
|
|
@ -112,7 +121,7 @@ sub update {
|
||||||
my $userName = getpwuid($<);
|
my $userName = getpwuid($<);
|
||||||
die "who ARE you? go away" unless defined $userName;
|
die "who ARE you? go away" unless defined $userName;
|
||||||
|
|
||||||
my $rootFile = "$rootsDir/$userName";
|
my $rootFile = "$rootsDir/per-user/$userName/channels";
|
||||||
|
|
||||||
# Instantiate the Nix expression.
|
# Instantiate the Nix expression.
|
||||||
print "unpacking channel Nix expressions...\n";
|
print "unpacking channel Nix expressions...\n";
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ fi
|
||||||
|
|
||||||
|
|
||||||
doDownload() {
|
doDownload() {
|
||||||
@curl@ $cacheFlags --fail -# --show-error --location --max-redirs 20 --disable-epsv \
|
@curl@ $cacheFlags --fail -# --location --max-redirs 20 --disable-epsv \
|
||||||
--cookie-jar $tmpPath/cookies "$url" -o $tmpFile
|
--cookie-jar $tmpPath/cookies "$url" -o $tmpFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,9 @@ sub downloadFile {
|
||||||
my $url = shift;
|
my $url = shift;
|
||||||
$ENV{"PRINT_PATH"} = 1;
|
$ENV{"PRINT_PATH"} = 1;
|
||||||
$ENV{"QUIET"} = 1;
|
$ENV{"QUIET"} = 1;
|
||||||
my ($dummy, $path) = `@bindir@/nix-prefetch-url '$url'`;
|
my ($dummy, $path) = `$binDir/nix-prefetch-url '$url'`;
|
||||||
|
die "cannot fetch `$url'" if $? != 0;
|
||||||
|
die "nix-prefetch-url did not return a path" unless defined $path;
|
||||||
chomp $path;
|
chomp $path;
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
@ -74,7 +76,7 @@ sub processURL {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (readManifest($manifest, \%narFiles, \%localPaths, \%patches) < 3) {
|
if (readManifest($manifest, \%narFiles, \%localPaths, \%patches) < 3) {
|
||||||
die "manifest `$url' is too old (i.e., for Nix <= 0.7)\n";
|
die "`$url' is not manifest or it is too old (i.e., for Nix <= 0.7)\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($skipWrongStore) {
|
if ($skipWrongStore) {
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,7 @@ print STDERR "uploading manifest...\n";
|
||||||
if ($localCopy) {
|
if ($localCopy) {
|
||||||
copyFile $manifest, $localManifestFile;
|
copyFile $manifest, $localManifestFile;
|
||||||
} else {
|
} else {
|
||||||
system("$curl --show-error --upload-file " .
|
system("$curl --show-error --upload-file " .
|
||||||
"'$manifest' '$manifestPutURL' > /dev/null") == 0 or
|
"'$manifest' '$manifestPutURL' > /dev/null") == 0 or
|
||||||
die "curl failed on $manifest: $?";
|
die "curl failed on $manifest: $?";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -298,6 +298,17 @@ static Expr prim_getEnv(EvalState & state, const ATermVector & args)
|
||||||
return makeStr(getEnv(name));
|
return makeStr(getEnv(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* for debugging purposes. print the first arg on stdout (perhaps stderr should be used?)
|
||||||
|
* and return the second
|
||||||
|
*/
|
||||||
|
static Expr prim_trace(EvalState & state, const ATermVector & args)
|
||||||
|
{
|
||||||
|
//string str = evalStringNoCtx(state, args[0]);
|
||||||
|
|
||||||
|
Expr a = evalExpr(state, args[0]);
|
||||||
|
printf("traced value: %s\n", atPrint(a).c_str());
|
||||||
|
return evalExpr(state, args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
static Expr prim_relativise(EvalState & state, const ATermVector & args)
|
static Expr prim_relativise(EvalState & state, const ATermVector & args)
|
||||||
{
|
{
|
||||||
|
|
@ -892,6 +903,39 @@ static Expr prim_hasAttr(EvalState & state, const ATermVector & args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* takes
|
||||||
|
* param: list of { attr="attr"; value=value }
|
||||||
|
* returns an attribute set
|
||||||
|
* */
|
||||||
|
static Expr prim_listToAttrs(EvalState & state, const ATermVector & args)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
ATermMap res = ATermMap();
|
||||||
|
|
||||||
|
ATermList list;
|
||||||
|
list = evalList(state, args[0]);
|
||||||
|
for (ATermIterator i(list); i; ++i){
|
||||||
|
// *i should now contain a pointer to the list item expression
|
||||||
|
ATermList attrs;
|
||||||
|
Expr evaledExpr = evalExpr(state, *i);
|
||||||
|
if (matchAttrs(evaledExpr, attrs)){
|
||||||
|
Expr e = evalExpr(state, makeSelect(evaledExpr, toATerm("attr")));
|
||||||
|
string attr = evalStringNoCtx(state,e);
|
||||||
|
ATerm value;
|
||||||
|
Expr r = makeSelect(evaledExpr, toATerm("value"));
|
||||||
|
res.set(toATerm(attr), makeAttrRHS(r, makeNoPos()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw EvalError(format("passed list item is a %s (value: %s). Set { attr=\"name\"; value=nix expr; } expected.") % showType(evaledExpr) % showValue(evaledExpr));
|
||||||
|
}
|
||||||
|
} // for
|
||||||
|
return makeAttrs(res);
|
||||||
|
} catch (Error & e) {
|
||||||
|
e.addPrefix(format("while calling listToAttrs "));
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static Expr prim_removeAttrs(EvalState & state, const ATermVector & args)
|
static Expr prim_removeAttrs(EvalState & state, const ATermVector & args)
|
||||||
{
|
{
|
||||||
ATermMap attrs;
|
ATermMap attrs;
|
||||||
|
|
@ -906,6 +950,12 @@ static Expr prim_removeAttrs(EvalState & state, const ATermVector & args)
|
||||||
return makeAttrs(attrs);
|
return makeAttrs(attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Determine whether the argument is a list. */
|
||||||
|
static Expr prim_isAttrs(EvalState & state, const ATermVector & args)
|
||||||
|
{
|
||||||
|
ATermList list;
|
||||||
|
return makeBool(matchAttrs(evalExpr(state, args[0]), list));
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
* Lists
|
* Lists
|
||||||
|
|
@ -1049,6 +1099,7 @@ void EvalState::addPrimOps()
|
||||||
addPrimOp("abort", 1, prim_abort);
|
addPrimOp("abort", 1, prim_abort);
|
||||||
addPrimOp("throw", 1, prim_throw);
|
addPrimOp("throw", 1, prim_throw);
|
||||||
addPrimOp("__getEnv", 1, prim_getEnv);
|
addPrimOp("__getEnv", 1, prim_getEnv);
|
||||||
|
addPrimOp("__trace", 2, prim_trace);
|
||||||
|
|
||||||
addPrimOp("relativise", 2, prim_relativise);
|
addPrimOp("relativise", 2, prim_relativise);
|
||||||
|
|
||||||
|
|
@ -1071,7 +1122,9 @@ void EvalState::addPrimOps()
|
||||||
addPrimOp("__attrNames", 1, prim_attrNames);
|
addPrimOp("__attrNames", 1, prim_attrNames);
|
||||||
addPrimOp("__getAttr", 2, prim_getAttr);
|
addPrimOp("__getAttr", 2, prim_getAttr);
|
||||||
addPrimOp("__hasAttr", 2, prim_hasAttr);
|
addPrimOp("__hasAttr", 2, prim_hasAttr);
|
||||||
|
addPrimOp("__isAttrs", 1, prim_isAttrs);
|
||||||
addPrimOp("removeAttrs", 2, prim_removeAttrs);
|
addPrimOp("removeAttrs", 2, prim_removeAttrs);
|
||||||
|
addPrimOp("__listToAttrs", 1, prim_listToAttrs);
|
||||||
|
|
||||||
// Lists
|
// Lists
|
||||||
addPrimOp("__isList", 1, prim_isList);
|
addPrimOp("__isList", 1, prim_isList);
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,8 @@ void createSymlink(const Path & link, const Path & target, bool careful)
|
||||||
/* Create directories up to `gcRoot'. */
|
/* Create directories up to `gcRoot'. */
|
||||||
createDirs(dirOf(link));
|
createDirs(dirOf(link));
|
||||||
|
|
||||||
|
/* !!! shouldn't removing and creating the symlink be atomic? */
|
||||||
|
|
||||||
/* Remove the old symlink. */
|
/* Remove the old symlink. */
|
||||||
if (pathExists(link)) {
|
if (pathExists(link)) {
|
||||||
if (careful && (!isLink(link) || !isInStore(readLink(link))))
|
if (careful && (!isLink(link) || !isInStore(readLink(link))))
|
||||||
|
|
@ -68,7 +70,7 @@ void createSymlink(const Path & link, const Path & target, bool careful)
|
||||||
unlink(link.c_str());
|
unlink(link.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* And create the new own. */
|
/* And create the new one. */
|
||||||
if (symlink(target.c_str(), link.c_str()) == -1)
|
if (symlink(target.c_str(), link.c_str()) == -1)
|
||||||
throw SysError(format("symlinking `%1%' to `%2%'")
|
throw SysError(format("symlinking `%1%' to `%2%'")
|
||||||
% link % target);
|
% link % target);
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,7 @@ static TableId dbSharedState = 0;
|
||||||
|
|
||||||
static void upgradeStore07();
|
static void upgradeStore07();
|
||||||
static void upgradeStore09();
|
static void upgradeStore09();
|
||||||
|
static void upgradeStore11();
|
||||||
|
|
||||||
|
|
||||||
void checkStoreNotSymlink()
|
void checkStoreNotSymlink()
|
||||||
|
|
@ -245,6 +246,8 @@ LocalStore::LocalStore(bool reserveSpace)
|
||||||
upgradeStore07();
|
upgradeStore07();
|
||||||
if (curSchema == 2)
|
if (curSchema == 2)
|
||||||
upgradeStore09();
|
upgradeStore09();
|
||||||
|
if (curSchema == 3)
|
||||||
|
upgradeStore11();
|
||||||
writeFile(schemaFN, (format("%1%") % nixSchemaVersion).str());
|
writeFile(schemaFN, (format("%1%") % nixSchemaVersion).str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1926,10 +1929,10 @@ static void upgradeStore09()
|
||||||
{
|
{
|
||||||
/* !!! we should disallow concurrent upgrades */
|
/* !!! we should disallow concurrent upgrades */
|
||||||
|
|
||||||
printMsg(lvlError, "upgrading Nix store to new schema (this may take a while)...");
|
|
||||||
|
|
||||||
if (!pathExists(nixDBPath + "/referers")) return;
|
if (!pathExists(nixDBPath + "/referers")) return;
|
||||||
|
|
||||||
|
printMsg(lvlError, "upgrading Nix store to new schema (this may take a while)...");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Transaction txn(nixDB);
|
Transaction txn(nixDB);
|
||||||
|
|
||||||
|
|
@ -1970,4 +1973,29 @@ static void upgradeStore09()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Upgrade from schema 3 (Nix 0.10) to schema 4 (Nix >= 0.11). The
|
||||||
|
only thing to do here is to delete the substitutes table and get
|
||||||
|
rid of invalid but substitutable references/referrers. */
|
||||||
|
static void upgradeStore11()
|
||||||
|
{
|
||||||
|
if (!pathExists(nixDBPath + "/substitutes")) return;
|
||||||
|
|
||||||
|
printMsg(lvlError, "upgrading Nix store to new schema (this may take a while)...");
|
||||||
|
|
||||||
|
Transaction txn(nixDB);
|
||||||
|
TableId dbSubstitutes = nixDB.openTable("substitutes");
|
||||||
|
|
||||||
|
Paths subKeys;
|
||||||
|
nixDB.enumTable(txn, dbSubstitutes, subKeys);
|
||||||
|
for (Paths::iterator i = subKeys.begin(); i != subKeys.end(); ++i) {
|
||||||
|
if (!isValidPathTxn(txn, *i))
|
||||||
|
invalidateStorePath(txn, *i);
|
||||||
|
}
|
||||||
|
|
||||||
|
txn.commit();
|
||||||
|
nixDB.closeTable(dbSubstitutes);
|
||||||
|
nixDB.deleteTable("substitutes");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ class Transaction;
|
||||||
|
|
||||||
|
|
||||||
/* Nix store and database schema version. Version 1 (or 0) was Nix <=
|
/* Nix store and database schema version. Version 1 (or 0) was Nix <=
|
||||||
0.7. Version 2 was Nix 0.8 and 0.9. Version 3 is Nix 0.10 and
|
0.7. Version 2 was Nix 0.8 and 0.9. Version 3 is Nix 0.10.
|
||||||
up. */
|
Version 4 is Nix 0.11. */
|
||||||
const int nixSchemaVersion = 3;
|
const int nixSchemaVersion = 4;
|
||||||
|
|
||||||
|
|
||||||
extern string drvsLogDir;
|
extern string drvsLogDir;
|
||||||
|
|
|
||||||
|
|
@ -161,10 +161,8 @@ void PathLocks::lockPaths(const PathSet & _paths, const string & waitMsg)
|
||||||
|
|
||||||
debug(format("locking path `%1%'") % path);
|
debug(format("locking path `%1%'") % path);
|
||||||
|
|
||||||
if (lockedPaths.find(lockPath) != lockedPaths.end()) {
|
if (lockedPaths.find(lockPath) != lockedPaths.end())
|
||||||
debug(format("already holding lock on `%1%'") % lockPath);
|
throw Error("deadlock: trying to re-acquire self-held lock");
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoCloseFD fd;
|
AutoCloseFD fd;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,27 +10,27 @@ namespace nix {
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
wopQuit, //0
|
wopQuit = 0, //0
|
||||||
wopIsValidPath,
|
wopIsValidPath,
|
||||||
|
wopHasSubstitutes = 3,
|
||||||
wopIsValidStatePath,
|
wopIsValidStatePath,
|
||||||
wopIsValidComponentOrStatePath,
|
wopIsValidComponentOrStatePath,
|
||||||
wopHasSubstitutes,
|
|
||||||
wopQueryPathHash,
|
wopQueryPathHash,
|
||||||
wopQueryStatePathDrv,
|
wopQueryStatePathDrv,
|
||||||
wopQueryStoreReferences,
|
wopQueryStoreReferences,
|
||||||
wopQueryStateReferences,
|
wopQueryStateReferences,
|
||||||
wopQueryStoreReferrers, //10
|
wopQueryStoreReferrers,
|
||||||
wopQueryStateReferrers,
|
wopQueryStateReferrers, //10
|
||||||
wopAddToStore,
|
wopAddToStore,
|
||||||
wopAddTextToStore,
|
wopAddTextToStore,
|
||||||
wopBuildDerivations, //14 TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! HANGS SOMETIMES !!!!!
|
wopBuildDerivations, //13
|
||||||
wopEnsurePath,
|
wopEnsurePath,
|
||||||
wopAddTempRoot,
|
wopAddTempRoot,
|
||||||
wopAddIndirectRoot,
|
wopAddIndirectRoot,
|
||||||
wopSyncWithGC,
|
wopSyncWithGC,
|
||||||
wopFindRoots,
|
wopFindRoots,
|
||||||
wopCollectGarbage, //20
|
wopCollectGarbage,
|
||||||
wopExportPath,
|
wopExportPath, //20
|
||||||
wopImportPath,
|
wopImportPath,
|
||||||
wopQueryDeriver,
|
wopQueryDeriver,
|
||||||
wopQueryDerivers,
|
wopQueryDerivers,
|
||||||
|
|
@ -39,15 +39,15 @@ typedef enum {
|
||||||
wopIsStateComponent,
|
wopIsStateComponent,
|
||||||
wopStorePathRequisites,
|
wopStorePathRequisites,
|
||||||
wopSetStateRevisions,
|
wopSetStateRevisions,
|
||||||
wopQueryStateRevisions, //30
|
wopQueryStateRevisions,
|
||||||
wopQueryAvailableStateRevisions,
|
wopQueryAvailableStateRevisions, //30
|
||||||
wopCommitStatePath,
|
wopCommitStatePath,
|
||||||
wopScanAndUpdateAllReferences,
|
wopScanAndUpdateAllReferences,
|
||||||
wopGetSharedWith,
|
wopGetSharedWith,
|
||||||
wopToNonSharedPathSet,
|
wopToNonSharedPathSet,
|
||||||
wopRevertToRevision,
|
wopRevertToRevision,
|
||||||
wopShareState,
|
wopShareState,
|
||||||
wopUnShareState,
|
wopUnShareState, //37
|
||||||
} WorkerOp;
|
} WorkerOp;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,11 @@ TESTS_ENVIRONMENT = $(SHELL) -e
|
||||||
|
|
||||||
extra1 = $(shell pwd)/test-tmp/shared
|
extra1 = $(shell pwd)/test-tmp/shared
|
||||||
|
|
||||||
simple.sh: simple.nix
|
simple.sh substitutes.sh substitutes2.sh fallback.sh: simple.nix
|
||||||
dependencies.sh gc.sh nix-push.sh nix-pull.in logging.sh nix-build.sh install-package.sh check-refs.sh: dependencies.nix
|
dependencies.sh gc.sh nix-push.sh nix-pull.in logging.sh nix-build.sh install-package.sh check-refs.sh: dependencies.nix
|
||||||
locking.sh: locking.nix
|
locking.sh: locking.nix
|
||||||
parallel.sh: parallel.nix
|
parallel.sh: parallel.nix
|
||||||
build-hook.sh: build-hook.nix
|
build-hook.sh: build-hook.nix
|
||||||
substitutes.sh: substitutes.nix
|
|
||||||
substitutes2.sh: substitutes2.nix
|
|
||||||
fallback.sh: fallback.nix
|
|
||||||
gc-concurrent.sh: gc-concurrent.nix gc-concurrent2.nix
|
gc-concurrent.sh: gc-concurrent.nix gc-concurrent2.nix
|
||||||
user-envs.sh: user-envs.nix
|
user-envs.sh: user-envs.nix
|
||||||
fixed.sh: fixed.nix
|
fixed.sh: fixed.nix
|
||||||
|
|
@ -21,7 +18,8 @@ TESTS = init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \
|
||||||
locking.sh parallel.sh build-hook.sh substitutes.sh substitutes2.sh \
|
locking.sh parallel.sh build-hook.sh substitutes.sh substitutes2.sh \
|
||||||
fallback.sh nix-push.sh gc.sh gc-concurrent.sh verify.sh nix-pull.sh \
|
fallback.sh nix-push.sh gc.sh gc-concurrent.sh verify.sh nix-pull.sh \
|
||||||
referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \
|
referrers.sh user-envs.sh logging.sh nix-build.sh misc.sh fixed.sh \
|
||||||
gc-runtime.sh install-package.sh check-refs.sh filter-source.sh
|
gc-runtime.sh install-package.sh check-refs.sh filter-source.sh \
|
||||||
|
remote-store.sh
|
||||||
|
|
||||||
XFAIL_TESTS =
|
XFAIL_TESTS =
|
||||||
|
|
||||||
|
|
@ -36,11 +34,9 @@ EXTRA_DIST = $(TESTS) \
|
||||||
locking.nix.in locking.builder.sh \
|
locking.nix.in locking.builder.sh \
|
||||||
parallel.nix.in parallel.builder.sh \
|
parallel.nix.in parallel.builder.sh \
|
||||||
build-hook.nix.in build-hook.hook.sh \
|
build-hook.nix.in build-hook.hook.sh \
|
||||||
substitutes.nix.in substituter.sh \
|
substituter.sh substituter2.sh \
|
||||||
substitutes2.nix.in substituter2.sh \
|
|
||||||
gc-concurrent.nix.in gc-concurrent.builder.sh \
|
gc-concurrent.nix.in gc-concurrent.builder.sh \
|
||||||
gc-concurrent2.nix.in gc-concurrent2.builder.sh \
|
gc-concurrent2.nix.in gc-concurrent2.builder.sh \
|
||||||
fallback.nix.in \
|
|
||||||
user-envs.nix.in user-envs.builder.sh \
|
user-envs.nix.in user-envs.builder.sh \
|
||||||
fixed.nix.in fixed.builder1.sh fixed.builder2.sh \
|
fixed.nix.in fixed.builder1.sh fixed.builder2.sh \
|
||||||
gc-runtime.nix.in \
|
gc-runtime.nix.in \
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ set -e
|
||||||
|
|
||||||
export TEST_ROOT=$(pwd)/test-tmp
|
export TEST_ROOT=$(pwd)/test-tmp
|
||||||
export NIX_STORE_DIR
|
export NIX_STORE_DIR
|
||||||
if ! NIX_STORE_DIR=$(readlink -f $TEST_ROOT/store); then
|
if ! NIX_STORE_DIR=$(readlink -f $TEST_ROOT/store 2> /dev/null); then
|
||||||
# Maybe the build directory is symlinked.
|
# Maybe the build directory is symlinked.
|
||||||
export NIX_IGNORE_SYMLINK_STORE=1
|
export NIX_IGNORE_SYMLINK_STORE=1
|
||||||
NIX_STORE_DIR=$TEST_ROOT/store
|
NIX_STORE_DIR=$TEST_ROOT/store
|
||||||
|
|
@ -19,7 +19,9 @@ export NIX_LIBEXEC_DIR=$TEST_ROOT/bin
|
||||||
export NIX_ROOT_FINDER=
|
export NIX_ROOT_FINDER=
|
||||||
export SHARED=$TEST_ROOT/shared
|
export SHARED=$TEST_ROOT/shared
|
||||||
|
|
||||||
export NIX_REMOTE=
|
if test -z "$FORCE_NIX_REMOTE"; then
|
||||||
|
export NIX_REMOTE=
|
||||||
|
fi
|
||||||
|
|
||||||
export REAL_BIN_DIR=@bindir@
|
export REAL_BIN_DIR=@bindir@
|
||||||
export REAL_LIBEXEC_DIR=@libexecdir@
|
export REAL_LIBEXEC_DIR=@libexecdir@
|
||||||
|
|
@ -46,6 +48,7 @@ export nixinstantiate=$TOP/src/nix-instantiate/nix-instantiate
|
||||||
export nixstore=$TOP/src/nix-store/nix-store
|
export nixstore=$TOP/src/nix-store/nix-store
|
||||||
export nixenv=$TOP/src/nix-env/nix-env
|
export nixenv=$TOP/src/nix-env/nix-env
|
||||||
export nixhash=$TOP/src/nix-hash/nix-hash
|
export nixhash=$TOP/src/nix-hash/nix-hash
|
||||||
|
export nixworker=$TOP/src/nix-worker/nix-worker
|
||||||
export nixbuild=$NIX_BIN_DIR/nix-build
|
export nixbuild=$NIX_BIN_DIR/nix-build
|
||||||
|
|
||||||
readLink() {
|
readLink() {
|
||||||
|
|
@ -66,3 +69,7 @@ clearProfiles() {
|
||||||
profiles="$NIX_STATE_DIR"/profiles
|
profiles="$NIX_STATE_DIR"/profiles
|
||||||
rm -f $profiles/*
|
rm -f $profiles/*
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearManifests() {
|
||||||
|
rm -f $NIX_STATE_DIR/manifests/*
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
derivation {
|
|
||||||
name = "fall-back";
|
|
||||||
system = "@system@";
|
|
||||||
builder = "@shell@";
|
|
||||||
args = ["-e" "-x" ./simple.builder.sh];
|
|
||||||
goodPath = "@testPath@";
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +1,19 @@
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
drvPath=$($nixinstantiate fallback.nix)
|
clearStore
|
||||||
|
|
||||||
|
drvPath=$($nixinstantiate simple.nix)
|
||||||
echo "derivation is $drvPath"
|
echo "derivation is $drvPath"
|
||||||
|
|
||||||
outPath=$($nixstore -q --fallback "$drvPath")
|
outPath=$($nixstore -q --fallback "$drvPath")
|
||||||
echo "output path is $outPath"
|
echo "output path is $outPath"
|
||||||
|
|
||||||
# Register a non-existant substitute
|
# Build with a substitute that fails. This should fail.
|
||||||
(echo $outPath && echo "" && echo $TOP/no-such-program && echo 0 && echo 0) | $nixstore --register-substitutes
|
export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh
|
||||||
|
if $nixstore -r "$drvPath"; then echo unexpected fallback; exit 1; fi
|
||||||
|
|
||||||
# Build the derivation
|
# Build with a substitute that fails. This should fall back to a source build.
|
||||||
|
export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh
|
||||||
$nixstore -r --fallback "$drvPath"
|
$nixstore -r --fallback "$drvPath"
|
||||||
|
|
||||||
text=$(cat "$outPath"/hello)
|
text=$(cat "$outPath"/hello)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
echo dummy: $dummy
|
||||||
|
if test -n "$dummy"; then sleep 2; fi
|
||||||
mkdir $out
|
mkdir $out
|
||||||
mkdir $out/bla
|
mkdir $out/bla
|
||||||
echo "Hello World!" > $out/foo
|
echo "Hello World!" > $out/foo
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
rec {
|
rec {
|
||||||
|
|
||||||
f = builder: mode: algo: hash: derivation {
|
f2 = dummy: builder: mode: algo: hash: derivation {
|
||||||
name = "fixed";
|
name = "fixed";
|
||||||
system = "@system@";
|
system = "@system@";
|
||||||
builder = "@shell@";
|
builder = "@shell@";
|
||||||
|
|
@ -9,8 +9,11 @@ rec {
|
||||||
outputHashAlgo = algo;
|
outputHashAlgo = algo;
|
||||||
outputHash = hash;
|
outputHash = hash;
|
||||||
PATH = "@testPath@";
|
PATH = "@testPath@";
|
||||||
|
inherit dummy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
f = f2 "";
|
||||||
|
|
||||||
good = [
|
good = [
|
||||||
(f ./fixed.builder1.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858")
|
(f ./fixed.builder1.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858")
|
||||||
(f ./fixed.builder1.sh "flat" "sha1" "a0b65939670bc2c010f4d5d6a0b3e4e4590fb92b")
|
(f ./fixed.builder1.sh "flat" "sha1" "a0b65939670bc2c010f4d5d6a0b3e4e4590fb92b")
|
||||||
|
|
@ -35,4 +38,11 @@ rec {
|
||||||
(f ./fixed.builder1.sh "flat" "md5" "ddd8be4b179a529afa5f2ffae4b9858")
|
(f ./fixed.builder1.sh "flat" "md5" "ddd8be4b179a529afa5f2ffae4b9858")
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Test for building two derivations in parallel that produce the
|
||||||
|
# same output path because they're fixed-output derivations.
|
||||||
|
parallelSame = [
|
||||||
|
(f2 "foo" ./fixed.builder2.sh "flat" "md5" "3670af73070fa14077ad74e0f5ea4e42")
|
||||||
|
(f2 "bar" ./fixed.builder2.sh "flat" "md5" "3670af73070fa14077ad74e0f5ea4e42")
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,18 +1,33 @@
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
|
clearStore
|
||||||
|
|
||||||
|
echo 'testing good...'
|
||||||
drvs=$($nixinstantiate fixed.nix -A good)
|
drvs=$($nixinstantiate fixed.nix -A good)
|
||||||
echo $drvs
|
echo $drvs
|
||||||
$nixstore -r $drvs
|
$nixstore -r $drvs
|
||||||
|
|
||||||
|
echo 'testing good2...'
|
||||||
drvs=$($nixinstantiate fixed.nix -A good2)
|
drvs=$($nixinstantiate fixed.nix -A good2)
|
||||||
echo $drvs
|
echo $drvs
|
||||||
$nixstore -r $drvs
|
$nixstore -r $drvs
|
||||||
|
|
||||||
|
echo 'testing bad...'
|
||||||
drvs=$($nixinstantiate fixed.nix -A bad)
|
drvs=$($nixinstantiate fixed.nix -A bad)
|
||||||
echo $drvs
|
echo $drvs
|
||||||
if $nixstore -r $drvs; then false; fi
|
if $nixstore -r $drvs; then false; fi
|
||||||
|
|
||||||
|
echo 'testing reallyBad...'
|
||||||
if $nixinstantiate fixed.nix -A reallyBad; then false; fi
|
if $nixinstantiate fixed.nix -A reallyBad; then false; fi
|
||||||
|
|
||||||
# While we're at it, check attribute selection a bit more.
|
# While we're at it, check attribute selection a bit more.
|
||||||
|
echo 'testing attribute selection...'
|
||||||
test $($nixinstantiate fixed.nix -A good.1 | wc -l) = 1
|
test $($nixinstantiate fixed.nix -A good.1 | wc -l) = 1
|
||||||
|
|
||||||
|
# Test parallel builds of derivations that produce the same output.
|
||||||
|
# Only one should run at the same time.
|
||||||
|
echo 'testing parallelSame...'
|
||||||
|
clearStore
|
||||||
|
drvs=$($nixinstantiate fixed.nix -A parallelSame)
|
||||||
|
echo $drvs
|
||||||
|
$nixstore -r $drvs -j2
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ ln -s $storestatedir $NIX_BIN_DIR/
|
||||||
ln -s $nixinstantiate $NIX_BIN_DIR/
|
ln -s $nixinstantiate $NIX_BIN_DIR/
|
||||||
ln -s $nixhash $NIX_BIN_DIR/
|
ln -s $nixhash $NIX_BIN_DIR/
|
||||||
ln -s $nixenv $NIX_BIN_DIR/
|
ln -s $nixenv $NIX_BIN_DIR/
|
||||||
|
ln -s $nixworker $NIX_BIN_DIR/
|
||||||
ln -s $TOP/scripts/nix-prefetch-url $NIX_BIN_DIR/
|
ln -s $TOP/scripts/nix-prefetch-url $NIX_BIN_DIR/
|
||||||
ln -s $TOP/scripts/nix-collect-garbage $NIX_BIN_DIR/
|
ln -s $TOP/scripts/nix-collect-garbage $NIX_BIN_DIR/
|
||||||
ln -s $TOP/scripts/nix-build $NIX_BIN_DIR/
|
ln -s $TOP/scripts/nix-build $NIX_BIN_DIR/
|
||||||
|
|
|
||||||
8
tests/lang/eval-okay-listToAttrs.nix
Normal file
8
tests/lang/eval-okay-listToAttrs.nix
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# this test shows how to use listToAttrs and that evaluation is still lazy (throw isn't called)
|
||||||
|
let
|
||||||
|
asi = attr: value : { inherit attr value; };
|
||||||
|
list = [ ( asi "a" "A" ) ( asi "b" "B" ) ];
|
||||||
|
a = builtins.listToAttrs list;
|
||||||
|
b = builtins.listToAttrs ( list ++ list );
|
||||||
|
r = builtins.listToAttrs [ (asi "result" [ a b ]) ( asi "throw" (throw "this should not be thrown")) ];
|
||||||
|
in r.result
|
||||||
1
tests/lang/eval-okay-listToAttrs.out
Normal file
1
tests/lang/eval-okay-listToAttrs.out
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
List([Attrs([Bind("a",Str("A",[]),NoPos),Bind("b",Str("B",[]),NoPos)]),Attrs([Bind("a",Str("A",[]),NoPos),Bind("b",Str("B",[]),NoPos)])])
|
||||||
|
|
@ -6,6 +6,7 @@ pullCache () {
|
||||||
}
|
}
|
||||||
|
|
||||||
clearStore
|
clearStore
|
||||||
|
clearManifests
|
||||||
pullCache
|
pullCache
|
||||||
|
|
||||||
drvPath=$($nixinstantiate dependencies.nix)
|
drvPath=$($nixinstantiate dependencies.nix)
|
||||||
|
|
@ -17,6 +18,7 @@ $nixstore -r $outPath
|
||||||
cat $outPath/input-2/bar
|
cat $outPath/input-2/bar
|
||||||
|
|
||||||
clearStore
|
clearStore
|
||||||
|
clearManifests
|
||||||
pullCache
|
pullCache
|
||||||
|
|
||||||
echo "building $drvPath using substitutes..."
|
echo "building $drvPath using substitutes..."
|
||||||
|
|
@ -28,4 +30,4 @@ cat $outPath/input-2/bar
|
||||||
test $($nixstore -q --deriver "$outPath") = "$drvPath"
|
test $($nixstore -q --deriver "$outPath") = "$drvPath"
|
||||||
$nixstore -q --deriver $(readLink $outPath/input-2) | grep -q -- "-input-2.drv"
|
$nixstore -q --deriver $(readLink $outPath/input-2) | grep -q -- "-input-2.drv"
|
||||||
|
|
||||||
$nixstore --clear-substitutes
|
clearManifests
|
||||||
|
|
|
||||||
17
tests/remote-store.sh
Normal file
17
tests/remote-store.sh
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
export FORCE_NIX_REMOTE=1
|
||||||
|
|
||||||
|
echo '*** testing slave mode ***'
|
||||||
|
clearStore
|
||||||
|
clearManifests
|
||||||
|
NIX_REMOTE=slave $SHELL ./user-envs.sh
|
||||||
|
|
||||||
|
echo '*** testing daemon mode ***'
|
||||||
|
clearStore
|
||||||
|
clearManifests
|
||||||
|
$nixworker --daemon &
|
||||||
|
pidDaemon=$!
|
||||||
|
NIX_REMOTE=daemon $SHELL ./user-envs.sh
|
||||||
|
kill -9 $pidDaemon
|
||||||
|
wait $pidDaemon || true
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
echo "PATH=$PATH"
|
echo "PATH=$PATH"
|
||||||
|
|
||||||
# Verify that the PATH is empty.
|
# Verify that the PATH is empty.
|
||||||
if mkdir foo; then exit 1; fi
|
if mkdir foo 2> /dev/null; then exit 1; fi
|
||||||
|
|
||||||
# Set a PATH (!!! impure).
|
# Set a PATH (!!! impure).
|
||||||
export PATH=$goodPath
|
export PATH=$goodPath
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,19 @@
|
||||||
#! /bin/sh -ex
|
#! /bin/sh -e
|
||||||
echo $*
|
echo substituter args: $* >&2
|
||||||
|
|
||||||
case $* in
|
|
||||||
*)
|
|
||||||
mkdir $1
|
|
||||||
echo $3 $4 > $1/hello
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
if test $1 = "--query-paths"; then
|
||||||
|
cat $TEST_ROOT/sub-paths
|
||||||
|
elif test $1 = "--query-info"; then
|
||||||
|
shift
|
||||||
|
for i in in $@; do
|
||||||
|
echo $i
|
||||||
|
echo "" # deriver
|
||||||
|
echo 0 # nr of refs
|
||||||
|
done
|
||||||
|
elif test $1 = "--substitute"; then
|
||||||
|
mkdir $2
|
||||||
|
echo "Hallo Wereld" > $2/hello
|
||||||
|
else
|
||||||
|
echo "unknown substituter operation"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,18 @@
|
||||||
#! /bin/sh -ex
|
#! /bin/sh -e
|
||||||
echo $*
|
echo substituter2 args: $* >&2
|
||||||
exit 1
|
|
||||||
|
if test $1 = "--query-paths"; then
|
||||||
|
cat $TEST_ROOT/sub-paths
|
||||||
|
elif test $1 = "--query-info"; then
|
||||||
|
shift
|
||||||
|
for i in in $@; do
|
||||||
|
echo $i
|
||||||
|
echo "" # deriver
|
||||||
|
echo 0 # nr of refs
|
||||||
|
done
|
||||||
|
elif test $1 = "--substitute"; then
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "unknown substituter operation"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
derivation {
|
|
||||||
name = "substitutes";
|
|
||||||
system = "@system@";
|
|
||||||
builder = "@shell@";
|
|
||||||
args = ["-e" "-x" ./simple.builder.sh];
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +1,20 @@
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
|
clearStore
|
||||||
|
|
||||||
# Instantiate.
|
# Instantiate.
|
||||||
drvPath=$($nixinstantiate substitutes.nix)
|
drvPath=$($nixinstantiate simple.nix)
|
||||||
echo "derivation is $drvPath"
|
echo "derivation is $drvPath"
|
||||||
|
|
||||||
# Find the output path.
|
# Find the output path.
|
||||||
outPath=$($nixstore -qvv "$drvPath")
|
outPath=$($nixstore -qvv "$drvPath")
|
||||||
echo "output path is $outPath"
|
echo "output path is $outPath"
|
||||||
|
|
||||||
regSub() {
|
echo $outPath > $TEST_ROOT/sub-paths
|
||||||
(echo $1 && echo "" && echo $2 && echo 3 && echo $outPath && echo Hallo && echo Wereld && echo 0) | $nixstore --register-substitutes
|
|
||||||
}
|
|
||||||
|
|
||||||
# Register a substitute for the output path.
|
|
||||||
regSub $outPath $(pwd)/substituter.sh
|
|
||||||
|
|
||||||
|
export NIX_SUBSTITUTERS=$(pwd)/substituter.sh
|
||||||
|
|
||||||
$nixstore -rvv "$drvPath"
|
$nixstore -rvv "$drvPath"
|
||||||
|
|
||||||
text=$(cat "$outPath"/hello)
|
text=$(cat "$outPath"/hello)
|
||||||
if test "$text" != "Hallo Wereld"; then exit 1; fi
|
if test "$text" != "Hallo Wereld"; then echo "wrong substitute output: $text"; exit 1; fi
|
||||||
|
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
derivation {
|
|
||||||
name = "substitutes-2";
|
|
||||||
system = "@system@";
|
|
||||||
builder = "@shell@";
|
|
||||||
args = ["-e" "-x" ./simple.builder.sh];
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +1,21 @@
|
||||||
source common.sh
|
source common.sh
|
||||||
|
|
||||||
|
clearStore
|
||||||
|
|
||||||
# Instantiate.
|
# Instantiate.
|
||||||
drvPath=$($nixinstantiate substitutes2.nix)
|
drvPath=$($nixinstantiate simple.nix)
|
||||||
echo "derivation is $drvPath"
|
echo "derivation is $drvPath"
|
||||||
|
|
||||||
# Find the output path.
|
# Find the output path.
|
||||||
outPath=$($nixstore -qvvvvv "$drvPath")
|
outPath=$($nixstore -qvvvvv "$drvPath")
|
||||||
echo "output path is $outPath"
|
echo "output path is $outPath"
|
||||||
|
|
||||||
regSub() {
|
echo $outPath > $TEST_ROOT/sub-paths
|
||||||
(echo $1 && echo "" && echo $2 && echo 3 && echo $outPath && echo Hallo && echo Wereld && echo 0) | $nixstore --register-substitutes
|
|
||||||
}
|
|
||||||
|
|
||||||
# Register a substitute for the output path.
|
# First try a substituter that fails, then one that succeeds
|
||||||
regSub $outPath $(pwd)/substituter.sh
|
export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh:$(pwd)/substituter.sh
|
||||||
|
|
||||||
# Register another substitute for the output path. This one takes
|
|
||||||
# precedence over the previous one. It will fail.
|
|
||||||
regSub $outPath $(pwd)/substituter2.sh
|
|
||||||
|
|
||||||
$nixstore -rvv "$drvPath"
|
$nixstore -rvv "$drvPath"
|
||||||
|
|
||||||
text=$(cat "$outPath"/hello)
|
text=$(cat "$outPath"/hello)
|
||||||
if test "$text" != "Hallo Wereld"; then exit 1; fi
|
if test "$text" != "Hallo Wereld"; then echo "wrong substitute output: $text"; exit 1; fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue