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;
|
||||
|
||||
my $rootsDir = "@localstatedir@/nix/gcroots/channels";
|
||||
my $rootsDir = "@localstatedir@/nix/gcroots";
|
||||
|
||||
my $stateDir = $ENV{"NIX_STATE_DIR"};
|
||||
$stateDir = "@localstatedir@/nix" unless defined $stateDir;
|
||||
|
|
@ -10,8 +10,8 @@ $stateDir = "@localstatedir@/nix" unless defined $stateDir;
|
|||
|
||||
# Turn on caching in nix-prefetch-url.
|
||||
my $channelCache = "$stateDir/channel-cache";
|
||||
$ENV{'NIX_DOWNLOAD_CACHE'} = $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.
|
||||
|
|
@ -76,16 +76,25 @@ sub removeChannel {
|
|||
sub update {
|
||||
readChannels;
|
||||
|
||||
# Remove all the old manifests.
|
||||
for my $manifest (glob "$stateDir/manifests/*.nixmanifest") {
|
||||
unlink $manifest or die "cannot remove `$manifest': $!";
|
||||
}
|
||||
# Do we have write permission to the manifests directory? If not,
|
||||
# then just skip pulling the manifest and just download the Nix
|
||||
# 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
|
||||
|
|
@ -112,7 +121,7 @@ sub update {
|
|||
my $userName = getpwuid($<);
|
||||
die "who ARE you? go away" unless defined $userName;
|
||||
|
||||
my $rootFile = "$rootsDir/$userName";
|
||||
my $rootFile = "$rootsDir/per-user/$userName/channels";
|
||||
|
||||
# Instantiate the Nix expression.
|
||||
print "unpacking channel Nix expressions...\n";
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ fi
|
|||
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,9 @@ sub downloadFile {
|
|||
my $url = shift;
|
||||
$ENV{"PRINT_PATH"} = 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;
|
||||
return $path;
|
||||
}
|
||||
|
|
@ -74,7 +76,7 @@ sub processURL {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ print STDERR "uploading manifest...\n";
|
|||
if ($localCopy) {
|
||||
copyFile $manifest, $localManifestFile;
|
||||
} else {
|
||||
system("$curl --show-error --upload-file " .
|
||||
system("$curl --show-error --upload-file " .
|
||||
"'$manifest' '$manifestPutURL' > /dev/null") == 0 or
|
||||
die "curl failed on $manifest: $?";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -298,6 +298,17 @@ static Expr prim_getEnv(EvalState & state, const ATermVector & args)
|
|||
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)
|
||||
{
|
||||
|
|
@ -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)
|
||||
{
|
||||
ATermMap attrs;
|
||||
|
|
@ -906,6 +950,12 @@ static Expr prim_removeAttrs(EvalState & state, const ATermVector & args)
|
|||
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
|
||||
|
|
@ -1049,6 +1099,7 @@ void EvalState::addPrimOps()
|
|||
addPrimOp("abort", 1, prim_abort);
|
||||
addPrimOp("throw", 1, prim_throw);
|
||||
addPrimOp("__getEnv", 1, prim_getEnv);
|
||||
addPrimOp("__trace", 2, prim_trace);
|
||||
|
||||
addPrimOp("relativise", 2, prim_relativise);
|
||||
|
||||
|
|
@ -1071,7 +1122,9 @@ void EvalState::addPrimOps()
|
|||
addPrimOp("__attrNames", 1, prim_attrNames);
|
||||
addPrimOp("__getAttr", 2, prim_getAttr);
|
||||
addPrimOp("__hasAttr", 2, prim_hasAttr);
|
||||
addPrimOp("__isAttrs", 1, prim_isAttrs);
|
||||
addPrimOp("removeAttrs", 2, prim_removeAttrs);
|
||||
addPrimOp("__listToAttrs", 1, prim_listToAttrs);
|
||||
|
||||
// Lists
|
||||
addPrimOp("__isList", 1, prim_isList);
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ void createSymlink(const Path & link, const Path & target, bool careful)
|
|||
/* Create directories up to `gcRoot'. */
|
||||
createDirs(dirOf(link));
|
||||
|
||||
/* !!! shouldn't removing and creating the symlink be atomic? */
|
||||
|
||||
/* Remove the old symlink. */
|
||||
if (pathExists(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());
|
||||
}
|
||||
|
||||
/* And create the new own. */
|
||||
/* And create the new one. */
|
||||
if (symlink(target.c_str(), link.c_str()) == -1)
|
||||
throw SysError(format("symlinking `%1%' to `%2%'")
|
||||
% link % target);
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ static TableId dbSharedState = 0;
|
|||
|
||||
static void upgradeStore07();
|
||||
static void upgradeStore09();
|
||||
static void upgradeStore11();
|
||||
|
||||
|
||||
void checkStoreNotSymlink()
|
||||
|
|
@ -245,6 +246,8 @@ LocalStore::LocalStore(bool reserveSpace)
|
|||
upgradeStore07();
|
||||
if (curSchema == 2)
|
||||
upgradeStore09();
|
||||
if (curSchema == 3)
|
||||
upgradeStore11();
|
||||
writeFile(schemaFN, (format("%1%") % nixSchemaVersion).str());
|
||||
}
|
||||
}
|
||||
|
|
@ -1926,10 +1929,10 @@ static void upgradeStore09()
|
|||
{
|
||||
/* !!! we should disallow concurrent upgrades */
|
||||
|
||||
printMsg(lvlError, "upgrading Nix store to new schema (this may take a while)...");
|
||||
|
||||
if (!pathExists(nixDBPath + "/referers")) return;
|
||||
|
||||
printMsg(lvlError, "upgrading Nix store to new schema (this may take a while)...");
|
||||
|
||||
/*
|
||||
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 <=
|
||||
0.7. Version 2 was Nix 0.8 and 0.9. Version 3 is Nix 0.10 and
|
||||
up. */
|
||||
const int nixSchemaVersion = 3;
|
||||
0.7. Version 2 was Nix 0.8 and 0.9. Version 3 is Nix 0.10.
|
||||
Version 4 is Nix 0.11. */
|
||||
const int nixSchemaVersion = 4;
|
||||
|
||||
|
||||
extern string drvsLogDir;
|
||||
|
|
|
|||
|
|
@ -161,10 +161,8 @@ void PathLocks::lockPaths(const PathSet & _paths, const string & waitMsg)
|
|||
|
||||
debug(format("locking path `%1%'") % path);
|
||||
|
||||
if (lockedPaths.find(lockPath) != lockedPaths.end()) {
|
||||
debug(format("already holding lock on `%1%'") % lockPath);
|
||||
continue;
|
||||
}
|
||||
if (lockedPaths.find(lockPath) != lockedPaths.end())
|
||||
throw Error("deadlock: trying to re-acquire self-held lock");
|
||||
|
||||
AutoCloseFD fd;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,27 +10,27 @@ namespace nix {
|
|||
|
||||
|
||||
typedef enum {
|
||||
wopQuit, //0
|
||||
wopIsValidPath,
|
||||
wopQuit = 0, //0
|
||||
wopIsValidPath,
|
||||
wopHasSubstitutes = 3,
|
||||
wopIsValidStatePath,
|
||||
wopIsValidComponentOrStatePath,
|
||||
wopHasSubstitutes,
|
||||
wopQueryPathHash,
|
||||
wopQueryStatePathDrv,
|
||||
wopQueryStoreReferences,
|
||||
wopQueryStateReferences,
|
||||
wopQueryStoreReferrers, //10
|
||||
wopQueryStateReferrers,
|
||||
wopQueryStoreReferrers,
|
||||
wopQueryStateReferrers, //10
|
||||
wopAddToStore,
|
||||
wopAddTextToStore,
|
||||
wopBuildDerivations, //14 TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! HANGS SOMETIMES !!!!!
|
||||
wopBuildDerivations, //13
|
||||
wopEnsurePath,
|
||||
wopAddTempRoot,
|
||||
wopAddIndirectRoot,
|
||||
wopSyncWithGC,
|
||||
wopFindRoots,
|
||||
wopCollectGarbage, //20
|
||||
wopExportPath,
|
||||
wopCollectGarbage,
|
||||
wopExportPath, //20
|
||||
wopImportPath,
|
||||
wopQueryDeriver,
|
||||
wopQueryDerivers,
|
||||
|
|
@ -39,15 +39,15 @@ typedef enum {
|
|||
wopIsStateComponent,
|
||||
wopStorePathRequisites,
|
||||
wopSetStateRevisions,
|
||||
wopQueryStateRevisions, //30
|
||||
wopQueryAvailableStateRevisions,
|
||||
wopQueryStateRevisions,
|
||||
wopQueryAvailableStateRevisions, //30
|
||||
wopCommitStatePath,
|
||||
wopScanAndUpdateAllReferences,
|
||||
wopGetSharedWith,
|
||||
wopToNonSharedPathSet,
|
||||
wopRevertToRevision,
|
||||
wopShareState,
|
||||
wopUnShareState,
|
||||
wopUnShareState, //37
|
||||
} WorkerOp;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,14 +2,11 @@ TESTS_ENVIRONMENT = $(SHELL) -e
|
|||
|
||||
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
|
||||
locking.sh: locking.nix
|
||||
parallel.sh: parallel.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
|
||||
user-envs.sh: user-envs.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 \
|
||||
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 \
|
||||
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 =
|
||||
|
||||
|
|
@ -36,11 +34,9 @@ EXTRA_DIST = $(TESTS) \
|
|||
locking.nix.in locking.builder.sh \
|
||||
parallel.nix.in parallel.builder.sh \
|
||||
build-hook.nix.in build-hook.hook.sh \
|
||||
substitutes.nix.in substituter.sh \
|
||||
substitutes2.nix.in substituter2.sh \
|
||||
substituter.sh substituter2.sh \
|
||||
gc-concurrent.nix.in gc-concurrent.builder.sh \
|
||||
gc-concurrent2.nix.in gc-concurrent2.builder.sh \
|
||||
fallback.nix.in \
|
||||
user-envs.nix.in user-envs.builder.sh \
|
||||
fixed.nix.in fixed.builder1.sh fixed.builder2.sh \
|
||||
gc-runtime.nix.in \
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ set -e
|
|||
|
||||
export TEST_ROOT=$(pwd)/test-tmp
|
||||
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.
|
||||
export NIX_IGNORE_SYMLINK_STORE=1
|
||||
NIX_STORE_DIR=$TEST_ROOT/store
|
||||
|
|
@ -19,7 +19,9 @@ export NIX_LIBEXEC_DIR=$TEST_ROOT/bin
|
|||
export NIX_ROOT_FINDER=
|
||||
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_LIBEXEC_DIR=@libexecdir@
|
||||
|
|
@ -46,6 +48,7 @@ export nixinstantiate=$TOP/src/nix-instantiate/nix-instantiate
|
|||
export nixstore=$TOP/src/nix-store/nix-store
|
||||
export nixenv=$TOP/src/nix-env/nix-env
|
||||
export nixhash=$TOP/src/nix-hash/nix-hash
|
||||
export nixworker=$TOP/src/nix-worker/nix-worker
|
||||
export nixbuild=$NIX_BIN_DIR/nix-build
|
||||
|
||||
readLink() {
|
||||
|
|
@ -66,3 +69,7 @@ clearProfiles() {
|
|||
profiles="$NIX_STATE_DIR"/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
|
||||
|
||||
drvPath=$($nixinstantiate fallback.nix)
|
||||
clearStore
|
||||
|
||||
drvPath=$($nixinstantiate simple.nix)
|
||||
echo "derivation is $drvPath"
|
||||
|
||||
outPath=$($nixstore -q --fallback "$drvPath")
|
||||
echo "output path is $outPath"
|
||||
|
||||
# Register a non-existant substitute
|
||||
(echo $outPath && echo "" && echo $TOP/no-such-program && echo 0 && echo 0) | $nixstore --register-substitutes
|
||||
# Build with a substitute that fails. This should fail.
|
||||
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"
|
||||
|
||||
text=$(cat "$outPath"/hello)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
echo dummy: $dummy
|
||||
if test -n "$dummy"; then sleep 2; fi
|
||||
mkdir $out
|
||||
mkdir $out/bla
|
||||
echo "Hello World!" > $out/foo
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
rec {
|
||||
|
||||
f = builder: mode: algo: hash: derivation {
|
||||
f2 = dummy: builder: mode: algo: hash: derivation {
|
||||
name = "fixed";
|
||||
system = "@system@";
|
||||
builder = "@shell@";
|
||||
|
|
@ -9,8 +9,11 @@ rec {
|
|||
outputHashAlgo = algo;
|
||||
outputHash = hash;
|
||||
PATH = "@testPath@";
|
||||
inherit dummy;
|
||||
};
|
||||
|
||||
f = f2 "";
|
||||
|
||||
good = [
|
||||
(f ./fixed.builder1.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858")
|
||||
(f ./fixed.builder1.sh "flat" "sha1" "a0b65939670bc2c010f4d5d6a0b3e4e4590fb92b")
|
||||
|
|
@ -35,4 +38,11 @@ rec {
|
|||
(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
|
||||
|
||||
clearStore
|
||||
|
||||
echo 'testing good...'
|
||||
drvs=$($nixinstantiate fixed.nix -A good)
|
||||
echo $drvs
|
||||
$nixstore -r $drvs
|
||||
|
||||
echo 'testing good2...'
|
||||
drvs=$($nixinstantiate fixed.nix -A good2)
|
||||
echo $drvs
|
||||
$nixstore -r $drvs
|
||||
|
||||
echo 'testing bad...'
|
||||
drvs=$($nixinstantiate fixed.nix -A bad)
|
||||
echo $drvs
|
||||
if $nixstore -r $drvs; then false; fi
|
||||
|
||||
echo 'testing reallyBad...'
|
||||
if $nixinstantiate fixed.nix -A reallyBad; then false; fi
|
||||
|
||||
# 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 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 $nixhash $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-collect-garbage $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
|
||||
clearManifests
|
||||
pullCache
|
||||
|
||||
drvPath=$($nixinstantiate dependencies.nix)
|
||||
|
|
@ -17,6 +18,7 @@ $nixstore -r $outPath
|
|||
cat $outPath/input-2/bar
|
||||
|
||||
clearStore
|
||||
clearManifests
|
||||
pullCache
|
||||
|
||||
echo "building $drvPath using substitutes..."
|
||||
|
|
@ -28,4 +30,4 @@ cat $outPath/input-2/bar
|
|||
test $($nixstore -q --deriver "$outPath") = "$drvPath"
|
||||
$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"
|
||||
|
||||
# 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).
|
||||
export PATH=$goodPath
|
||||
|
|
|
|||
|
|
@ -1,10 +1,19 @@
|
|||
#! /bin/sh -ex
|
||||
echo $*
|
||||
|
||||
case $* in
|
||||
*)
|
||||
mkdir $1
|
||||
echo $3 $4 > $1/hello
|
||||
;;
|
||||
esac
|
||||
#! /bin/sh -e
|
||||
echo substituter args: $* >&2
|
||||
|
||||
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
|
||||
echo $*
|
||||
exit 1
|
||||
#! /bin/sh -e
|
||||
echo substituter2 args: $* >&2
|
||||
|
||||
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
|
||||
|
||||
clearStore
|
||||
|
||||
# Instantiate.
|
||||
drvPath=$($nixinstantiate substitutes.nix)
|
||||
drvPath=$($nixinstantiate simple.nix)
|
||||
echo "derivation is $drvPath"
|
||||
|
||||
# Find the output path.
|
||||
outPath=$($nixstore -qvv "$drvPath")
|
||||
echo "output path is $outPath"
|
||||
|
||||
regSub() {
|
||||
(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
|
||||
echo $outPath > $TEST_ROOT/sub-paths
|
||||
|
||||
export NIX_SUBSTITUTERS=$(pwd)/substituter.sh
|
||||
|
||||
$nixstore -rvv "$drvPath"
|
||||
|
||||
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
|
||||
|
||||
clearStore
|
||||
|
||||
# Instantiate.
|
||||
drvPath=$($nixinstantiate substitutes2.nix)
|
||||
drvPath=$($nixinstantiate simple.nix)
|
||||
echo "derivation is $drvPath"
|
||||
|
||||
# Find the output path.
|
||||
outPath=$($nixstore -qvvvvv "$drvPath")
|
||||
echo "output path is $outPath"
|
||||
|
||||
regSub() {
|
||||
(echo $1 && echo "" && echo $2 && echo 3 && echo $outPath && echo Hallo && echo Wereld && echo 0) | $nixstore --register-substitutes
|
||||
}
|
||||
echo $outPath > $TEST_ROOT/sub-paths
|
||||
|
||||
# Register a substitute for the output path.
|
||||
regSub $outPath $(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
|
||||
# First try a substituter that fails, then one that succeeds
|
||||
export NIX_SUBSTITUTERS=$(pwd)/substituter2.sh:$(pwd)/substituter.sh
|
||||
|
||||
$nixstore -rvv "$drvPath"
|
||||
|
||||
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