forked from lix-project/lix
* Give unpacked channels more sensible names than 0, 1, ... They now
get the basename of the channel URL (e.g., nixpkgs-unstable). The top-level Nix expression of the channel is now an attribute set, the attributes of which are the individual channels (e.g., {nixpkgs_unstable = ...; strategoxt_unstable = ...}). This makes attribute paths ("nix-env -qaA" and "nix-env -iA") more sensible, e.g., "nix-env -iA nixpkgs_unstable.subversion".
This commit is contained in:
parent
a9d15d4f43
commit
93aefd9fc0
|
@ -139,6 +139,7 @@ fi
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
|
|
||||||
NEED_PROG(cat, cat)
|
NEED_PROG(cat, cat)
|
||||||
|
NEED_PROG(tr, tr)
|
||||||
AC_ARG_WITH(coreutils-bin, AC_HELP_STRING([--with-coreutils-bin=PATH],
|
AC_ARG_WITH(coreutils-bin, AC_HELP_STRING([--with-coreutils-bin=PATH],
|
||||||
[path of cat, mkdir, etc.]),
|
[path of cat, mkdir, etc.]),
|
||||||
coreutils=$withval, coreutils=$(dirname $cat))
|
coreutils=$withval, coreutils=$(dirname $cat))
|
||||||
|
|
|
@ -5,18 +5,29 @@
|
||||||
cd $out/tmp
|
cd $out/tmp
|
||||||
|
|
||||||
expr=$out/default.nix
|
expr=$out/default.nix
|
||||||
echo '[' > $expr
|
echo '{' > $expr
|
||||||
|
|
||||||
nr=0
|
inputs=($inputs)
|
||||||
for i in $inputs; do
|
for ((n = 0; n < ${#inputs[*]}; n += 2)); do
|
||||||
echo "unpacking $i"
|
channelName=${inputs[n]}
|
||||||
@bunzip2@ < $i | @tar@ xf -
|
channelTarball=${inputs[n+1]}
|
||||||
@coreutils@/mv * ../$nr # !!! hacky
|
echo "unpacking channel $channelName"
|
||||||
echo "(import ./$nr)" >> $expr
|
@bunzip2@ < $channelTarball | @tar@ xf -
|
||||||
nr=$(($nr + 1))
|
|
||||||
|
nr=1
|
||||||
|
dirName=$channelName
|
||||||
|
while test -e ../$dirName; do
|
||||||
|
nr=$((nr+1))
|
||||||
|
dirName=$channelName-$nr
|
||||||
done
|
done
|
||||||
|
|
||||||
echo ']' >> $expr
|
@coreutils@/mv * ../$dirName # !!! hacky
|
||||||
|
|
||||||
|
attrName=$(echo $dirName | @tr@ -- '- ' '__')
|
||||||
|
echo "$attrName = import ./$dirName {};" >> $expr
|
||||||
|
done
|
||||||
|
|
||||||
|
echo '} // {_combineChannels = true;}' >> $expr
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
@coreutils@/rmdir tmp
|
@coreutils@/rmdir tmp
|
||||||
|
|
|
@ -89,21 +89,22 @@ sub update {
|
||||||
# Create a Nix expression that fetches and unpacks the channel Nix
|
# Create a Nix expression that fetches and unpacks the channel Nix
|
||||||
# expressions.
|
# expressions.
|
||||||
|
|
||||||
my $nixExpr = "[";
|
my $inputs = "[";
|
||||||
foreach my $url (@channels) {
|
foreach my $url (@channels) {
|
||||||
|
$url =~ /\/([^\/]+)\/?$/;
|
||||||
|
my $channelName = $1;
|
||||||
|
$channelName = "unnamed" unless defined $channelName;
|
||||||
|
print "$channelName\n";
|
||||||
|
|
||||||
my $fullURL = "$url/nixexprs.tar.bz2";
|
my $fullURL = "$url/nixexprs.tar.bz2";
|
||||||
print "downloading Nix expressions from `$fullURL'...\n";
|
print "downloading Nix expressions from `$fullURL'...\n";
|
||||||
$ENV{"PRINT_PATH"} = 1;
|
$ENV{"PRINT_PATH"} = 1;
|
||||||
my ($hash, $path) = `@bindir@/nix-prefetch-url '$fullURL' 2> /dev/null`;
|
my ($hash, $path) = `@bindir@/nix-prefetch-url '$fullURL' 2> /dev/null`;
|
||||||
die "cannot fetch `$fullURL'" if $? != 0;
|
die "cannot fetch `$fullURL'" if $? != 0;
|
||||||
chomp $path;
|
chomp $path;
|
||||||
$nixExpr .= $path . " ";
|
$inputs .= '"' . $channelName . '"' . " " . $path . " ";
|
||||||
}
|
}
|
||||||
$nixExpr .= "]";
|
$inputs .= "]";
|
||||||
|
|
||||||
$nixExpr =
|
|
||||||
"(import @datadir@/nix/corepkgs/channels/unpack.nix) " .
|
|
||||||
"{inputs = $nixExpr; system = \"@system@\";}";
|
|
||||||
|
|
||||||
# Figure out a name for the GC root.
|
# Figure out a name for the GC root.
|
||||||
my $userName = getpwuid($<);
|
my $userName = getpwuid($<);
|
||||||
|
@ -113,7 +114,7 @@ sub update {
|
||||||
|
|
||||||
# Instantiate the Nix expression.
|
# Instantiate the Nix expression.
|
||||||
print "unpacking channel Nix expressions...\n";
|
print "unpacking channel Nix expressions...\n";
|
||||||
my $storeExpr = `echo '$nixExpr' | @bindir@/nix-instantiate --add-root '$rootFile'.tmp -`
|
my $storeExpr = `@bindir@/nix-instantiate --add-root '$rootFile'.tmp @datadir@/nix/corepkgs/channels/unpack.nix --argstr system @system@ --arg inputs '$inputs'`
|
||||||
or die "cannot instantiate Nix expression";
|
or die "cannot instantiate Nix expression";
|
||||||
chomp $storeExpr;
|
chomp $storeExpr;
|
||||||
|
|
||||||
|
|
|
@ -171,11 +171,20 @@ static void getDerivations(EvalState & state, Expr e,
|
||||||
ATermMap drvMap(ATgetLength(es));
|
ATermMap drvMap(ATgetLength(es));
|
||||||
queryAllAttrs(e, drvMap);
|
queryAllAttrs(e, drvMap);
|
||||||
|
|
||||||
|
/* !!! undocumented hackery to support
|
||||||
|
corepkgs/channels/unpack.sh. */
|
||||||
|
Expr e2 = drvMap.get(toATerm("_combineChannels"));
|
||||||
|
bool combineChannels = e2 && evalBool(state, e2);
|
||||||
|
|
||||||
for (ATermMap::const_iterator i = drvMap.begin(); i != drvMap.end(); ++i) {
|
for (ATermMap::const_iterator i = drvMap.begin(); i != drvMap.end(); ++i) {
|
||||||
startNest(nest, lvlDebug,
|
startNest(nest, lvlDebug,
|
||||||
format("evaluating attribute `%1%'") % aterm2String(i->key));
|
format("evaluating attribute `%1%'") % aterm2String(i->key));
|
||||||
string pathPrefix2 = addToPath(pathPrefix, aterm2String(i->key));
|
string pathPrefix2 = addToPath(pathPrefix, aterm2String(i->key));
|
||||||
if (getDerivation(state, i->value, pathPrefix2, drvs, doneExprs)) {
|
if (combineChannels) {
|
||||||
|
if (((string) aterm2String(i->key)) != "_combineChannels")
|
||||||
|
getDerivations(state, i->value, pathPrefix2, autoArgs, drvs, doneExprs);
|
||||||
|
}
|
||||||
|
else if (getDerivation(state, i->value, pathPrefix2, drvs, doneExprs)) {
|
||||||
/* If the value of this attribute is itself an
|
/* If the value of this attribute is itself an
|
||||||
attribute set, should we recurse into it? => Only
|
attribute set, should we recurse into it? => Only
|
||||||
if it has a `recurseForDerivations = true'
|
if it has a `recurseForDerivations = true'
|
||||||
|
@ -185,8 +194,8 @@ static void getDerivations(EvalState & state, Expr e,
|
||||||
if (matchAttrs(e, es)) {
|
if (matchAttrs(e, es)) {
|
||||||
ATermMap attrs(ATgetLength(es));
|
ATermMap attrs(ATgetLength(es));
|
||||||
queryAllAttrs(e, attrs, false);
|
queryAllAttrs(e, attrs, false);
|
||||||
Expr e2 = attrs.get(toATerm("recurseForDerivations"));
|
if (((e2 = attrs.get(toATerm("recurseForDerivations")))
|
||||||
if (e2 && evalBool(state, e2))
|
&& evalBool(state, e2)))
|
||||||
getDerivations(state, e, pathPrefix2, autoArgs, drvs, doneExprs);
|
getDerivations(state, e, pathPrefix2, autoArgs, drvs, doneExprs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
-e "s^@perl\@^$(perl)^g" \
|
-e "s^@perl\@^$(perl)^g" \
|
||||||
-e "s^@coreutils\@^$(coreutils)^g" \
|
-e "s^@coreutils\@^$(coreutils)^g" \
|
||||||
-e "s^@tar\@^$(tar)^g" \
|
-e "s^@tar\@^$(tar)^g" \
|
||||||
|
-e "s^@tr\@^$(tr)^g" \
|
||||||
-e "s^@dot\@^$(dot)^g" \
|
-e "s^@dot\@^$(dot)^g" \
|
||||||
-e "s^@xmllint\@^$(xmllint)^g" \
|
-e "s^@xmllint\@^$(xmllint)^g" \
|
||||||
-e "s^@xmlflags\@^$(xmlflags)^g" \
|
-e "s^@xmlflags\@^$(xmlflags)^g" \
|
||||||
|
|
Loading…
Reference in a new issue