forked from lix-project/lix
* Sync with the trunk.
This commit is contained in:
commit
6c31232e14
|
@ -346,9 +346,6 @@ AC_CONFIG_FILES([Makefile
|
||||||
perl/Makefile
|
perl/Makefile
|
||||||
scripts/Makefile
|
scripts/Makefile
|
||||||
corepkgs/Makefile
|
corepkgs/Makefile
|
||||||
corepkgs/nar/Makefile
|
|
||||||
corepkgs/buildenv/Makefile
|
|
||||||
corepkgs/channels/Makefile
|
|
||||||
doc/Makefile
|
doc/Makefile
|
||||||
doc/manual/Makefile
|
doc/manual/Makefile
|
||||||
misc/Makefile
|
misc/Makefile
|
||||||
|
|
|
@ -1 +1,11 @@
|
||||||
SUBDIRS = nar buildenv channels
|
all-local: config.nix
|
||||||
|
|
||||||
|
files = nar.nix buildenv.nix buildenv.pl unpack-channel.nix unpack-channel.sh
|
||||||
|
|
||||||
|
install-exec-local:
|
||||||
|
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
|
||||||
|
$(INSTALL_DATA) config.nix $(files) $(DESTDIR)$(datadir)/nix/corepkgs
|
||||||
|
|
||||||
|
include ../substitute.mk
|
||||||
|
|
||||||
|
EXTRA_DIST = config.nix.in $(files)
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
{system, derivations, manifest}:
|
with import <nix/config.nix>;
|
||||||
|
|
||||||
|
{ system, derivations, manifest }:
|
||||||
|
|
||||||
derivation {
|
derivation {
|
||||||
name = "user-environment";
|
name = "user-environment";
|
||||||
system = system;
|
system = system;
|
||||||
builder = ./builder.pl;
|
builder = perl;
|
||||||
|
args = [ "-w" ./buildenv.pl ];
|
||||||
|
|
||||||
manifest = manifest;
|
manifest = manifest;
|
||||||
|
|
2
corepkgs/buildenv/builder.pl.in → corepkgs/buildenv.pl
Executable file → Normal file
2
corepkgs/buildenv/builder.pl.in → corepkgs/buildenv.pl
Executable file → Normal file
|
@ -1,5 +1,3 @@
|
||||||
#! @perl@ -w
|
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Cwd;
|
use Cwd;
|
||||||
use IO::Handle;
|
use IO::Handle;
|
|
@ -1,11 +0,0 @@
|
||||||
all-local: builder.pl
|
|
||||||
|
|
||||||
install-exec-local:
|
|
||||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
|
|
||||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs/buildenv
|
|
||||||
$(INSTALL_DATA) $(srcdir)/default.nix $(DESTDIR)$(datadir)/nix/corepkgs/buildenv
|
|
||||||
$(INSTALL_PROGRAM) builder.pl $(DESTDIR)$(datadir)/nix/corepkgs/buildenv
|
|
||||||
|
|
||||||
include ../../substitute.mk
|
|
||||||
|
|
||||||
EXTRA_DIST = default.nix builder.pl.in
|
|
|
@ -1,11 +0,0 @@
|
||||||
all-local: unpack.sh
|
|
||||||
|
|
||||||
install-exec-local:
|
|
||||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
|
|
||||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs/channels
|
|
||||||
$(INSTALL_DATA) $(srcdir)/unpack.nix $(DESTDIR)$(datadir)/nix/corepkgs/channels
|
|
||||||
$(INSTALL_PROGRAM) unpack.sh $(DESTDIR)$(datadir)/nix/corepkgs/channels
|
|
||||||
|
|
||||||
include ../../substitute.mk
|
|
||||||
|
|
||||||
EXTRA_DIST = unpack.nix unpack.sh.in
|
|
|
@ -1,7 +0,0 @@
|
||||||
{system, inputs}:
|
|
||||||
|
|
||||||
derivation {
|
|
||||||
name = "channels";
|
|
||||||
builder = ./unpack.sh;
|
|
||||||
inherit system inputs;
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
#! @shell@ -e
|
|
||||||
|
|
||||||
# Cygwin compatibility hack: bunzip2 expects cygwin.dll in $PATH.
|
|
||||||
export PATH=@coreutils@
|
|
||||||
|
|
||||||
@coreutils@/mkdir $out
|
|
||||||
@coreutils@/mkdir $out/tmp
|
|
||||||
cd $out/tmp
|
|
||||||
|
|
||||||
inputs=($inputs)
|
|
||||||
for ((n = 0; n < ${#inputs[*]}; n += 2)); do
|
|
||||||
channelName=${inputs[n]}
|
|
||||||
channelTarball=${inputs[n+1]}
|
|
||||||
|
|
||||||
echo "unpacking channel $channelName"
|
|
||||||
|
|
||||||
@bzip2@ -d < $channelTarball | @tar@ xf -
|
|
||||||
|
|
||||||
if test -e */channel-name; then
|
|
||||||
channelName="$(@coreutils@/cat */channel-name)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
nr=1
|
|
||||||
attrName=$(echo $channelName | @tr@ -- '- ' '__')
|
|
||||||
dirName=$attrName
|
|
||||||
while test -e ../$dirName; do
|
|
||||||
nr=$((nr+1))
|
|
||||||
dirName=$attrName-$nr
|
|
||||||
done
|
|
||||||
|
|
||||||
@coreutils@/mv * ../$dirName # !!! hacky
|
|
||||||
done
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
@coreutils@/rmdir tmp
|
|
13
corepkgs/config.nix.in
Normal file
13
corepkgs/config.nix.in
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
let
|
||||||
|
fromEnv = var: def:
|
||||||
|
let val = builtins.getEnv var; in
|
||||||
|
if val != "" then val else def;
|
||||||
|
in {
|
||||||
|
perl = "@perl@";
|
||||||
|
shell = "@shell@";
|
||||||
|
coreutils = "@coreutils@";
|
||||||
|
bzip2 = fromEnv "NIX_BZIP2" "@bzip2@";
|
||||||
|
tar = "@tar@";
|
||||||
|
tr = "@tr@";
|
||||||
|
nixBinDir = fromEnv "NIX_BIN_DIR" "@bindir@";
|
||||||
|
}
|
30
corepkgs/nar.nix
Normal file
30
corepkgs/nar.nix
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
with import <nix/config.nix>;
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
builder = builtins.toFile "nar.sh"
|
||||||
|
''
|
||||||
|
export PATH=${nixBinDir}:${coreutils}
|
||||||
|
|
||||||
|
echo "packing ‘$storePath’..."
|
||||||
|
mkdir $out
|
||||||
|
dst=$out/tmp.nar.bz2
|
||||||
|
|
||||||
|
set -o pipefail
|
||||||
|
nix-store --dump "$storePath" | ${bzip2} > $dst
|
||||||
|
|
||||||
|
nix-hash --flat --type $hashAlgo --base32 $dst > $out/narbz2-hash
|
||||||
|
|
||||||
|
mv $out/tmp.nar.bz2 $out/$(cat $out/narbz2-hash).nar.bz2
|
||||||
|
'';
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
{ system, storePath, hashAlgo }:
|
||||||
|
|
||||||
|
derivation {
|
||||||
|
name = "nar";
|
||||||
|
builder = shell;
|
||||||
|
args = [ "-e" builder ];
|
||||||
|
inherit system storePath hashAlgo;
|
||||||
|
}
|
|
@ -1,11 +0,0 @@
|
||||||
all-local: nar.sh
|
|
||||||
|
|
||||||
install-exec-local:
|
|
||||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
|
|
||||||
$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs/nar
|
|
||||||
$(INSTALL_DATA) $(srcdir)/nar.nix $(DESTDIR)$(datadir)/nix/corepkgs/nar
|
|
||||||
$(INSTALL_PROGRAM) nar.sh $(DESTDIR)$(datadir)/nix/corepkgs/nar
|
|
||||||
|
|
||||||
include ../../substitute.mk
|
|
||||||
|
|
||||||
EXTRA_DIST = nar.nix nar.sh.in
|
|
|
@ -1,7 +0,0 @@
|
||||||
{ system, storePath, hashAlgo }:
|
|
||||||
|
|
||||||
derivation {
|
|
||||||
name = "nar";
|
|
||||||
builder = ./nar.sh;
|
|
||||||
inherit system storePath hashAlgo;
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
#! @shell@ -e
|
|
||||||
|
|
||||||
echo "packing $storePath into $out..."
|
|
||||||
@coreutils@/mkdir $out
|
|
||||||
dst=$out/tmp.nar.bz2
|
|
||||||
@bindir@/nix-store --dump "$storePath" > tmp
|
|
||||||
|
|
||||||
@bzip2@ < tmp > $dst
|
|
||||||
|
|
||||||
@bindir@/nix-hash --flat --type $hashAlgo --base32 $dst > $out/narbz2-hash
|
|
||||||
|
|
||||||
@coreutils@/mv $out/tmp.nar.bz2 $out/$(@coreutils@/cat $out/narbz2-hash).nar.bz2
|
|
11
corepkgs/unpack-channel.nix
Normal file
11
corepkgs/unpack-channel.nix
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
with import <nix/config.nix>;
|
||||||
|
|
||||||
|
{ system, inputs }:
|
||||||
|
|
||||||
|
derivation {
|
||||||
|
name = "channels";
|
||||||
|
builder = shell;
|
||||||
|
args = [ "-e" ./unpack-channel.sh ];
|
||||||
|
inherit system inputs bzip2 tar tr;
|
||||||
|
PATH = "${nixBinDir}:${coreutils}";
|
||||||
|
}
|
30
corepkgs/unpack-channel.sh
Normal file
30
corepkgs/unpack-channel.sh
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
mkdir $out
|
||||||
|
mkdir $out/tmp
|
||||||
|
cd $out/tmp
|
||||||
|
|
||||||
|
inputs=($inputs)
|
||||||
|
for ((n = 0; n < ${#inputs[*]}; n += 2)); do
|
||||||
|
channelName=${inputs[n]}
|
||||||
|
channelTarball=${inputs[n+1]}
|
||||||
|
|
||||||
|
echo "unpacking channel $channelName"
|
||||||
|
|
||||||
|
$bzip2 -d < $channelTarball | $tar xf -
|
||||||
|
|
||||||
|
if test -e */channel-name; then
|
||||||
|
channelName="$(cat */channel-name)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
nr=1
|
||||||
|
attrName=$(echo $channelName | $tr -- '- ' '__')
|
||||||
|
dirName=$attrName
|
||||||
|
while test -e ../$dirName; do
|
||||||
|
nr=$((nr+1))
|
||||||
|
dirName=$attrName-$nr
|
||||||
|
done
|
||||||
|
|
||||||
|
mv * ../$dirName # !!! hacky
|
||||||
|
done
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
rmdir tmp
|
|
@ -43,10 +43,10 @@ is also available as <function>builtins.derivation</function>.</para>
|
||||||
|
|
||||||
<listitem><para>Return the names of the attributes in the
|
<listitem><para>Return the names of the attributes in the
|
||||||
attribute set <replaceable>attrs</replaceable> in a sorted list.
|
attribute set <replaceable>attrs</replaceable> in a sorted list.
|
||||||
For instance, <literal>builtins.attrNames {y = 1; x =
|
For instance, <literal>builtins.attrNames { y = 1; x = "foo";
|
||||||
"foo";}</literal> evaluates to <literal>["x" "y"]</literal>.
|
}</literal> evaluates to <literal>[ "x" "y" ]</literal>. There is
|
||||||
There is no built-in function <function>attrValues</function>, but
|
no built-in function <function>attrValues</function>, but you can
|
||||||
you can easily define it yourself:
|
easily define it yourself:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
attrValues = attrs: map (name: builtins.getAttr name attrs) (builtins.attrNames attrs);</programlisting>
|
attrValues = attrs: map (name: builtins.getAttr name attrs) (builtins.attrNames attrs);</programlisting>
|
||||||
|
@ -442,10 +442,10 @@ x: x + 456</programlisting>
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
builtins.listToAttrs [
|
builtins.listToAttrs
|
||||||
{name = "foo"; value = 123;}
|
[ { name = "foo"; value = 123; }
|
||||||
{name = "bar"; value = 456;}
|
{ name = "bar"; value = 456; }
|
||||||
]
|
]
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
evaluates to
|
evaluates to
|
||||||
|
@ -466,10 +466,10 @@ builtins.listToAttrs [
|
||||||
example,
|
example,
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
map (x: "foo" + x) ["bar" "bla" "abc"]</programlisting>
|
map (x: "foo" + x) [ "bar" "bla" "abc" ]</programlisting>
|
||||||
|
|
||||||
evaluates to <literal>["foobar" "foobla"
|
evaluates to <literal>[ "foobar" "foobla" "fooabc"
|
||||||
"fooabc"]</literal>.</para></listitem>
|
]</literal>.</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
@ -491,10 +491,10 @@ map (x: "foo" + x) ["bar" "bla" "abc"]</programlisting>
|
||||||
a package name and version. The package name is everything up to
|
a package name and version. The package name is everything up to
|
||||||
but not including the first dash followed by a digit, and the
|
but not including the first dash followed by a digit, and the
|
||||||
version is everything following that dash. The result is returned
|
version is everything following that dash. The result is returned
|
||||||
in an attribute set <literal>{name, version}</literal>. Thus,
|
in an attribute set <literal>{ name, version }</literal>. Thus,
|
||||||
<literal>builtins.parseDrvName "nix-0.12pre12876"</literal>
|
<literal>builtins.parseDrvName "nix-0.12pre12876"</literal>
|
||||||
returns <literal>{name = "nix"; version =
|
returns <literal>{ name = "nix"; version = "0.12pre12876";
|
||||||
"0.12pre12876";}</literal>.</para></listitem>
|
}</literal>.</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
@ -550,9 +550,9 @@ in config.someSetting</programlisting>
|
||||||
exist in <replaceable>attrs</replaceable>. For instance,
|
exist in <replaceable>attrs</replaceable>. For instance,
|
||||||
|
|
||||||
<screen>
|
<screen>
|
||||||
removeAttrs { x = 1; y = 2; z = 3; } ["a" "x" "z"]</screen>
|
removeAttrs { x = 1; y = 2; z = 3; } [ "a" "x" "z" ]</screen>
|
||||||
|
|
||||||
evaluates to <literal>{y = 2;}</literal>.</para></listitem>
|
evaluates to <literal>{ y = 2; }</literal>.</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
@ -632,7 +632,7 @@ removeAttrs { x = 1; y = 2; z = 3; } ["a" "x" "z"]</screen>
|
||||||
linkend='ex-hello-builder' /> into one file:
|
linkend='ex-hello-builder' /> into one file:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{stdenv, fetchurl, perl}:
|
{ stdenv, fetchurl, perl }:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "hello-2.1.1";
|
name = "hello-2.1.1";
|
||||||
|
@ -765,12 +765,12 @@ in foo</programlisting>
|
||||||
using <function>toXML</function></title>
|
using <function>toXML</function></title>
|
||||||
|
|
||||||
<programlisting><![CDATA[
|
<programlisting><![CDATA[
|
||||||
{stdenv, fetchurl, libxslt, jira, uberwiki}:
|
{ stdenv, fetchurl, libxslt, jira, uberwiki }:
|
||||||
|
|
||||||
stdenv.mkDerivation (rec {
|
stdenv.mkDerivation (rec {
|
||||||
name = "web-server";
|
name = "web-server";
|
||||||
|
|
||||||
buildInputs = [libxslt];
|
buildInputs = [ libxslt ];
|
||||||
|
|
||||||
builder = builtins.toFile "builder.sh" "
|
builder = builtins.toFile "builder.sh" "
|
||||||
source $stdenv/setup
|
source $stdenv/setup
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>nix-prefetch-url</refname>
|
<refname>nix-prefetch-url</refname>
|
||||||
<refpurpose>copy a file from a URL into the store and print its MD5 hash</refpurpose>
|
<refpurpose>copy a file from a URL into the store and print its hash</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
|
|
||||||
<refsynopsisdiv>
|
<refsynopsisdiv>
|
||||||
|
|
|
@ -264,8 +264,8 @@
|
||||||
expression evaluator will automatically try to call functions that
|
expression evaluator will automatically try to call functions that
|
||||||
it encounters. It can automatically call functions for which every
|
it encounters. It can automatically call functions for which every
|
||||||
argument has a <link linkend='ss-functions'>default value</link>
|
argument has a <link linkend='ss-functions'>default value</link>
|
||||||
(e.g., <literal>{<replaceable>argName</replaceable> ?
|
(e.g., <literal>{ <replaceable>argName</replaceable> ?
|
||||||
<replaceable>defaultValue</replaceable>}:
|
<replaceable>defaultValue</replaceable> }:
|
||||||
<replaceable>...</replaceable></literal>). With
|
<replaceable>...</replaceable></literal>). With
|
||||||
<option>--arg</option>, you can also call functions that have
|
<option>--arg</option>, you can also call functions that have
|
||||||
arguments without a default value (or override a default value).
|
arguments without a default value (or override a default value).
|
||||||
|
|
|
@ -52,7 +52,7 @@ need to do three things:
|
||||||
<example xml:id='ex-hello-nix'><title>Nix expression for GNU Hello
|
<example xml:id='ex-hello-nix'><title>Nix expression for GNU Hello
|
||||||
(<filename>default.nix</filename>)</title>
|
(<filename>default.nix</filename>)</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{stdenv, fetchurl, perl}: <co xml:id='ex-hello-nix-co-1' />
|
{ stdenv, fetchurl, perl }: <co xml:id='ex-hello-nix-co-1' />
|
||||||
|
|
||||||
stdenv.mkDerivation { <co xml:id='ex-hello-nix-co-2' />
|
stdenv.mkDerivation { <co xml:id='ex-hello-nix-co-2' />
|
||||||
name = "hello-2.1.1"; <co xml:id='ex-hello-nix-co-3' />
|
name = "hello-2.1.1"; <co xml:id='ex-hello-nix-co-3' />
|
||||||
|
@ -92,8 +92,8 @@ the single Nix expression in that directory
|
||||||
function that downloads files. <varname>perl</varname> is the
|
function that downloads files. <varname>perl</varname> is the
|
||||||
Perl interpreter.</para>
|
Perl interpreter.</para>
|
||||||
|
|
||||||
<para>Nix functions generally have the form <literal>{x, y, ...,
|
<para>Nix functions generally have the form <literal>{ x, y, ...,
|
||||||
z}: e</literal> where <varname>x</varname>, <varname>y</varname>,
|
z }: e</literal> where <varname>x</varname>, <varname>y</varname>,
|
||||||
etc. are the names of the expected arguments, and where
|
etc. are the names of the expected arguments, and where
|
||||||
<replaceable>e</replaceable> is the body of the function. So
|
<replaceable>e</replaceable> is the body of the function. So
|
||||||
here, the entire remainder of the file is the body of the
|
here, the entire remainder of the file is the body of the
|
||||||
|
@ -114,10 +114,10 @@ the single Nix expression in that directory
|
||||||
<emphasis>attributes</emphasis>. An attribute set is just a list
|
<emphasis>attributes</emphasis>. An attribute set is just a list
|
||||||
of key/value pairs where each value is an arbitrary Nix
|
of key/value pairs where each value is an arbitrary Nix
|
||||||
expression. They take the general form
|
expression. They take the general form
|
||||||
<literal>{<replaceable>name1</replaceable> =
|
<literal>{ <replaceable>name1</replaceable> =
|
||||||
<replaceable>expr1</replaceable>; <replaceable>...</replaceable>
|
<replaceable>expr1</replaceable>; <replaceable>...</replaceable>
|
||||||
<replaceable>nameN</replaceable> =
|
<replaceable>nameN</replaceable> =
|
||||||
<replaceable>exprN</replaceable>;}</literal>.</para>
|
<replaceable>exprN</replaceable>; }</literal>.</para>
|
||||||
|
|
||||||
</callout>
|
</callout>
|
||||||
|
|
||||||
|
@ -564,7 +564,7 @@ genericBuild <co xml:id='ex-hello-builder2-co-3' /></programlisting>
|
||||||
expression, like this:
|
expression, like this:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
buildInputs = [perl];</programlisting>
|
buildInputs = [ perl ];</programlisting>
|
||||||
|
|
||||||
The <varname>perl</varname> attribute can then be removed, and the
|
The <varname>perl</varname> attribute can then be removed, and the
|
||||||
builder becomes even shorter:
|
builder becomes even shorter:
|
||||||
|
@ -771,14 +771,14 @@ stdenv.mkDerivation {
|
||||||
values between square brackets. For example,
|
values between square brackets. For example,
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
[ 123 ./foo.nix "abc" (f {x=y;}) ]</programlisting>
|
[ 123 ./foo.nix "abc" (f { x = y; }) ]</programlisting>
|
||||||
|
|
||||||
defines a list of four elements, the last being the result of a call
|
defines a list of four elements, the last being the result of a call
|
||||||
to the function <varname>f</varname>. Note that function calls have
|
to the function <varname>f</varname>. Note that function calls have
|
||||||
to be enclosed in parentheses. If they had been omitted, e.g.,
|
to be enclosed in parentheses. If they had been omitted, e.g.,
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
[ 123 ./foo.nix "abc" f {x=y;} ]</programlisting>
|
[ 123 ./foo.nix "abc" f { x = y; } ]</programlisting>
|
||||||
|
|
||||||
the result would be a list of five elements, the fourth one being a
|
the result would be a list of five elements, the fourth one being a
|
||||||
function and the fifth being an attribute set.</para>
|
function and the fifth being an attribute set.</para>
|
||||||
|
@ -891,15 +891,12 @@ propagate attributes). This can be shortened using the
|
||||||
<literal>inherit</literal> keyword. For instance,
|
<literal>inherit</literal> keyword. For instance,
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
let
|
let x = 123; in
|
||||||
x = 123;
|
{ inherit x;
|
||||||
in
|
y = 456;
|
||||||
{
|
}</programlisting>
|
||||||
inherit x;
|
|
||||||
y = 456;
|
|
||||||
}</programlisting>
|
|
||||||
|
|
||||||
evaluates to <literal>{x = 123; y = 456;}</literal>. (Note that this
|
evaluates to <literal>{ x = 123; y = 456; }</literal>. (Note that this
|
||||||
works because <varname>x</varname> is added to the lexical scope by
|
works because <varname>x</varname> is added to the lexical scope by
|
||||||
the <literal>let</literal> construct.) It is also possible to inherit
|
the <literal>let</literal> construct.) It is also possible to inherit
|
||||||
attributes from another attribute set. For instance, in this fragment
|
attributes from another attribute set. For instance, in this fragment
|
||||||
|
@ -960,20 +957,20 @@ in if negate true then concat "foo" "bar" else ""</programlisting>
|
||||||
arguments of a function); e.g.,
|
arguments of a function); e.g.,
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
map (concat "foo") ["bar" "bla" "abc"]</programlisting>
|
map (concat "foo") [ "bar" "bla" "abc" ]</programlisting>
|
||||||
|
|
||||||
evaluates to <literal>["foobar" "foobla"
|
evaluates to <literal>[ "foobar" "foobla"
|
||||||
"fooabc"]</literal>.</para></listitem>
|
"fooabc" ]</literal>.</para></listitem>
|
||||||
|
|
||||||
|
|
||||||
<listitem><para>An <emphasis>attribute set pattern</emphasis> of the
|
<listitem><para>An <emphasis>attribute set pattern</emphasis> of the
|
||||||
form <literal>{name1, name2, …, nameN}</literal>
|
form <literal>{ name1, name2, …, nameN }</literal>
|
||||||
matches an attribute set containing the listed attributes, and binds
|
matches an attribute set containing the listed attributes, and binds
|
||||||
the values of those attributes to variables in the function body.
|
the values of those attributes to variables in the function body.
|
||||||
For example, the function
|
For example, the function
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{x, y, z}: z + y + x</programlisting>
|
{ x, y, z }: z + y + x</programlisting>
|
||||||
|
|
||||||
can only be called with a set containing exactly the attributes
|
can only be called with a set containing exactly the attributes
|
||||||
<varname>x</varname>, <varname>y</varname> and
|
<varname>x</varname>, <varname>y</varname> and
|
||||||
|
@ -982,7 +979,7 @@ map (concat "foo") ["bar" "bla" "abc"]</programlisting>
|
||||||
(<literal>...</literal>):
|
(<literal>...</literal>):
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{x, y, z, ....}: z + y + x</programlisting>
|
{ x, y, z, ... }: z + y + x</programlisting>
|
||||||
|
|
||||||
This works on any set that contains at least the three named
|
This works on any set that contains at least the three named
|
||||||
attributes.</para>
|
attributes.</para>
|
||||||
|
@ -995,7 +992,7 @@ map (concat "foo") ["bar" "bla" "abc"]</programlisting>
|
||||||
<replaceable>e</replaceable> is an arbitrary expression. For example,
|
<replaceable>e</replaceable> is an arbitrary expression. For example,
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{x, y ? "foo", z ? "bar"}: z + y + x</programlisting>
|
{ x, y ? "foo", z ? "bar" }: z + y + x</programlisting>
|
||||||
|
|
||||||
specifies a function that only requires an attribute named
|
specifies a function that only requires an attribute named
|
||||||
<varname>x</varname>, but optionally accepts <varname>y</varname>
|
<varname>x</varname>, but optionally accepts <varname>y</varname>
|
||||||
|
@ -1007,11 +1004,11 @@ map (concat "foo") ["bar" "bla" "abc"]</programlisting>
|
||||||
of the <literal>@</literal>-sign. For example:
|
of the <literal>@</literal>-sign. For example:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
args@{x, y, z, ...}: z + y + x + args.a</programlisting>
|
args@{ x, y, z, ... }: z + y + x + args.a</programlisting>
|
||||||
|
|
||||||
Here <varname>args</varname> is bound to the entire argument, which
|
Here <varname>args</varname> is bound to the entire argument, which
|
||||||
is further matches against the pattern <literal>{x, y, z,
|
is further matches against the pattern <literal>{ x, y, z,
|
||||||
...}</literal>.</para></listitem>
|
... }</literal>.</para></listitem>
|
||||||
|
|
||||||
|
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
@ -1020,8 +1017,8 @@ args@{x, y, z, ...}: z + y + x + args.a</programlisting>
|
||||||
a name, you can bind them to an attribute, e.g.,
|
a name, you can bind them to an attribute, e.g.,
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
let concat = {x, y}: x + y;
|
let concat = { x, y }: x + y;
|
||||||
in concat {x = "foo"; y = "bar";}</programlisting>
|
in concat { x = "foo"; y = "bar"; }</programlisting>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
@ -1142,7 +1139,7 @@ lexical scope of the expression <replaceable>e2</replaceable>. For
|
||||||
instance,
|
instance,
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
let as = {x = "foo"; y = "bar";};
|
let as = { x = "foo"; y = "bar"; };
|
||||||
in with as; x + y</programlisting>
|
in with as; x + y</programlisting>
|
||||||
|
|
||||||
evaluates to <literal>"foobar"</literal> since the
|
evaluates to <literal>"foobar"</literal> since the
|
||||||
|
@ -1480,21 +1477,20 @@ allowedReferences = [];
|
||||||
references graph of their inputs. The attribute is a list of
|
references graph of their inputs. The attribute is a list of
|
||||||
inputs in the Nix store whose references graph the builder needs
|
inputs in the Nix store whose references graph the builder needs
|
||||||
to know. The value of this attribute should be a list of pairs
|
to know. The value of this attribute should be a list of pairs
|
||||||
<literal>[<replaceable>name1</replaceable>
|
<literal>[ <replaceable>name1</replaceable>
|
||||||
<replaceable>path1</replaceable> <replaceable>name2</replaceable>
|
<replaceable>path1</replaceable> <replaceable>name2</replaceable>
|
||||||
<replaceable>path2</replaceable>
|
<replaceable>path2</replaceable> <replaceable>...</replaceable>
|
||||||
<replaceable>...</replaceable>]</literal>. The references graph
|
]</literal>. The references graph of each
|
||||||
of each <replaceable>pathN</replaceable> will be stored in a text
|
<replaceable>pathN</replaceable> will be stored in a text file
|
||||||
file <replaceable>nameN</replaceable> in the temporary build
|
<replaceable>nameN</replaceable> in the temporary build directory.
|
||||||
directory. The text files have the format used by
|
The text files have the format used by <command>nix-store
|
||||||
<command>nix-store --register-validity</command> (with the deriver
|
--register-validity</command> (with the deriver fields left
|
||||||
fields left empty). For example, when the following derivation is
|
empty). For example, when the following derivation is built:
|
||||||
built:
|
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
derivation {
|
derivation {
|
||||||
...
|
...
|
||||||
exportReferencesGraph = ["libfoo-graph" libfoo];
|
exportReferencesGraph = [ "libfoo-graph" libfoo ];
|
||||||
};
|
};
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
|
@ -1571,14 +1567,14 @@ fetchurl {
|
||||||
<varname>fetchurl</varname>:
|
<varname>fetchurl</varname>:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{stdenv, curl}: # The <command>curl</command> program is used for downloading.
|
{ stdenv, curl }: # The <command>curl</command> program is used for downloading.
|
||||||
|
|
||||||
{url, md5}:
|
{ url, md5 }:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = baseNameOf (toString url);
|
name = baseNameOf (toString url);
|
||||||
builder = ./builder.sh;
|
builder = ./builder.sh;
|
||||||
buildInputs = [curl];
|
buildInputs = [ curl ];
|
||||||
|
|
||||||
# This is a fixed-output derivation; the output must be a regular
|
# This is a fixed-output derivation; the output must be a regular
|
||||||
# file with MD5 hash <varname>md5</varname>.
|
# file with MD5 hash <varname>md5</varname>.
|
||||||
|
@ -1650,7 +1646,7 @@ stdenv.mkDerivation {
|
||||||
Nixpkgs has the line
|
Nixpkgs has the line
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
impureEnvVars = ["http_proxy" "https_proxy" <replaceable>...</replaceable>];
|
impureEnvVars = [ "http_proxy" "https_proxy" <replaceable>...</replaceable> ];
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
to make it use the proxy server configuration specified by the
|
to make it use the proxy server configuration specified by the
|
||||||
|
|
|
@ -2,6 +2,7 @@ package Nix::Config;
|
||||||
|
|
||||||
$binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@";
|
$binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@";
|
||||||
$libexecDir = $ENV{"NIX_LIBEXEC_DIR"} || "@libexecdir@";
|
$libexecDir = $ENV{"NIX_LIBEXEC_DIR"} || "@libexecdir@";
|
||||||
|
$stateDir = $ENV{"NIX_STATE_DIR"} || "@localstatedir@/nix";
|
||||||
$manifestDir = $ENV{"NIX_MANIFESTS_DIR"} || "@localstatedir@/nix/manifests";
|
$manifestDir = $ENV{"NIX_MANIFESTS_DIR"} || "@localstatedir@/nix/manifests";
|
||||||
$logDir = $ENV{"NIX_LOG_DIR"} || "@localstatedir@/log/nix";
|
$logDir = $ENV{"NIX_LOG_DIR"} || "@localstatedir@/log/nix";
|
||||||
$confDir = $ENV{"NIX_CONF_DIR"} || "@sysconfdir@/nix";
|
$confDir = $ENV{"NIX_CONF_DIR"} || "@sysconfdir@/nix";
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#! @perl@ -w -I@libexecdir@/nix
|
#! @perl@ -w -I@libexecdir@/nix
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use Nix::Config;
|
||||||
my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@";
|
|
||||||
|
|
||||||
|
|
||||||
my $addDrvLink = 0;
|
my $addDrvLink = 0;
|
||||||
|
@ -156,7 +155,7 @@ foreach my $expr (@exprs) {
|
||||||
# Instantiate.
|
# Instantiate.
|
||||||
my @drvPaths;
|
my @drvPaths;
|
||||||
# !!! would prefer the perl 5.8.0 pipe open feature here.
|
# !!! would prefer the perl 5.8.0 pipe open feature here.
|
||||||
my $pid = open(DRVPATHS, "-|") || exec "$binDir/nix-instantiate", "--add-root", $drvLink, "--indirect", @instArgs, $expr;
|
my $pid = open(DRVPATHS, "-|") || exec "$Nix::Config::binDir/nix-instantiate", "--add-root", $drvLink, "--indirect", @instArgs, $expr;
|
||||||
while (<DRVPATHS>) {chomp; push @drvPaths, $_;}
|
while (<DRVPATHS>) {chomp; push @drvPaths, $_;}
|
||||||
if (!close DRVPATHS) {
|
if (!close DRVPATHS) {
|
||||||
die "nix-instantiate killed by signal " . ($? & 127) . "\n" if ($? & 127);
|
die "nix-instantiate killed by signal " . ($? & 127) . "\n" if ($? & 127);
|
||||||
|
@ -170,7 +169,7 @@ foreach my $expr (@exprs) {
|
||||||
|
|
||||||
# Build.
|
# Build.
|
||||||
my @outPaths;
|
my @outPaths;
|
||||||
$pid = open(OUTPATHS, "-|") || exec "$binDir/nix-store", "--add-root", $outLink, "--indirect", "-r",
|
$pid = open(OUTPATHS, "-|") || exec "$Nix::Config::binDir/nix-store", "--add-root", $outLink, "--indirect", "-r",
|
||||||
@buildArgs, @drvPaths;
|
@buildArgs, @drvPaths;
|
||||||
while (<OUTPATHS>) {chomp; push @outPaths, $_;}
|
while (<OUTPATHS>) {chomp; push @outPaths, $_;}
|
||||||
if (!close OUTPATHS) {
|
if (!close OUTPATHS) {
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
#! @perl@ -w
|
#! @perl@ -w
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use Nix::Config;
|
||||||
|
|
||||||
my $rootsDir = "@localstatedir@/nix/gcroots";
|
my $manifestDir = $Nix::Config::manifestDir;
|
||||||
|
|
||||||
my $stateDir = $ENV{"NIX_STATE_DIR"};
|
|
||||||
$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 = "$Nix::Config::stateDir/channel-cache";
|
||||||
mkdir $channelCache, 0755 unless -e $channelCache;
|
mkdir $channelCache, 0755 unless -e $channelCache;
|
||||||
$ENV{'NIX_DOWNLOAD_CACHE'} = $channelCache if -W $channelCache;
|
$ENV{'NIX_DOWNLOAD_CACHE'} = $channelCache if -W $channelCache;
|
||||||
|
|
||||||
|
@ -79,19 +77,19 @@ sub update {
|
||||||
readChannels;
|
readChannels;
|
||||||
|
|
||||||
# Create the manifests directory if it doesn't exist.
|
# Create the manifests directory if it doesn't exist.
|
||||||
mkdir "$stateDir/manifests", 0755 unless -e "$stateDir/manifests";
|
mkdir $manifestDir, 0755 unless -e $manifestDir;
|
||||||
|
|
||||||
# Do we have write permission to the manifests directory? If not,
|
# Do we have write permission to the manifests directory? If not,
|
||||||
# then just skip pulling the manifest and just download the Nix
|
# then just skip pulling the manifest and just download the Nix
|
||||||
# expressions. If the user is a non-privileged user in a
|
# expressions. If the user is a non-privileged user in a
|
||||||
# multi-user Nix installation, he at least gets installation from
|
# multi-user Nix installation, he at least gets installation from
|
||||||
# source.
|
# source.
|
||||||
if (-W "$stateDir/manifests") {
|
if (-W $manifestDir) {
|
||||||
|
|
||||||
# Pull cache manifests.
|
# Pull cache manifests.
|
||||||
foreach my $url (@channels) {
|
foreach my $url (@channels) {
|
||||||
#print "pulling cache manifest from `$url'\n";
|
#print "pulling cache manifest from `$url'\n";
|
||||||
system("@bindir@/nix-pull", "--skip-wrong-store", "$url/MANIFEST") == 0
|
system("$Nix::Config::binDir/nix-pull", "--skip-wrong-store", "$url/MANIFEST") == 0
|
||||||
or die "cannot pull cache manifest from `$url'";
|
or die "cannot pull cache manifest from `$url'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +108,7 @@ sub update {
|
||||||
print "downloading Nix expressions from `$fullURL'...\n";
|
print "downloading Nix expressions from `$fullURL'...\n";
|
||||||
$ENV{"PRINT_PATH"} = 1;
|
$ENV{"PRINT_PATH"} = 1;
|
||||||
$ENV{"QUIET"} = 1;
|
$ENV{"QUIET"} = 1;
|
||||||
my ($hash, $path) = `@bindir@/nix-prefetch-url '$fullURL'`;
|
my ($hash, $path) = `$Nix::Config::binDir/nix-prefetch-url '$fullURL'`;
|
||||||
die "cannot fetch `$fullURL'" if $? != 0;
|
die "cannot fetch `$fullURL'" if $? != 0;
|
||||||
chomp $path;
|
chomp $path;
|
||||||
$inputs .= '"' . $channelName . '"' . " " . $path . " ";
|
$inputs .= '"' . $channelName . '"' . " " . $path . " ";
|
||||||
|
@ -121,13 +119,13 @@ 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/per-user/$userName/channels";
|
my $rootFile = "$Nix::Config::stateDir/gcroots/per-user/$userName/channels";
|
||||||
|
|
||||||
# Build the Nix expression.
|
# Build the Nix expression.
|
||||||
print "unpacking channel Nix expressions...\n";
|
print "unpacking channel Nix expressions...\n";
|
||||||
my $outPath = `\\
|
my $outPath = `\\
|
||||||
@bindir@/nix-build --out-link '$rootFile' --drv-link '$rootFile'.tmp \\
|
$Nix::Config::binDir/nix-build --out-link '$rootFile' --drv-link '$rootFile'.tmp \\
|
||||||
@datadir@/nix/corepkgs/channels/unpack.nix \\
|
'<nix/unpack-channel.nix>' \\
|
||||||
--argstr system @system@ --arg inputs '$inputs'`
|
--argstr system @system@ --arg inputs '$inputs'`
|
||||||
or die "cannot unpack the channels";
|
or die "cannot unpack the channels";
|
||||||
chomp $outPath;
|
chomp $outPath;
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
#! @perl@ -w
|
#! @perl@ -w
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use Nix::Config;
|
||||||
|
|
||||||
my $profilesDir = "@localstatedir@/nix/profiles";
|
my $profilesDir = "@localstatedir@/nix/profiles";
|
||||||
|
|
||||||
my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@";
|
|
||||||
|
|
||||||
|
|
||||||
# Process the command line arguments.
|
# Process the command line arguments.
|
||||||
my @args = ();
|
my @args = ();
|
||||||
|
@ -36,7 +35,7 @@ sub removeOldGenerations {
|
||||||
$name = $dir . "/" . $name;
|
$name = $dir . "/" . $name;
|
||||||
if (-l $name && (readlink($name) =~ /link/)) {
|
if (-l $name && (readlink($name) =~ /link/)) {
|
||||||
print STDERR "removing old generations of profile $name\n";
|
print STDERR "removing old generations of profile $name\n";
|
||||||
system("$binDir/nix-env", "-p", $name, "--delete-generations", "old");
|
system("$Nix::Config::binDir/nix-env", "-p", $name, "--delete-generations", "old");
|
||||||
}
|
}
|
||||||
elsif (! -l $name && -d $name) {
|
elsif (! -l $name && -d $name) {
|
||||||
removeOldGenerations $name;
|
removeOldGenerations $name;
|
||||||
|
@ -50,4 +49,4 @@ removeOldGenerations $profilesDir if $removeOld;
|
||||||
|
|
||||||
|
|
||||||
# Run the actual garbage collector.
|
# Run the actual garbage collector.
|
||||||
exec "$binDir/nix-store", "--gc", @args;
|
exec "$Nix::Config::binDir/nix-store", "--gc", @args;
|
||||||
|
|
|
@ -8,9 +8,6 @@ use Nix::Manifest;
|
||||||
my $tmpDir = tempdir("nix-pull.XXXXXX", CLEANUP => 1, TMPDIR => 1)
|
my $tmpDir = tempdir("nix-pull.XXXXXX", CLEANUP => 1, TMPDIR => 1)
|
||||||
or die "cannot create a temporary directory";
|
or die "cannot create a temporary directory";
|
||||||
|
|
||||||
my $libexecDir = ($ENV{"NIX_LIBEXEC_DIR"} or "@libexecdir@");
|
|
||||||
my $storeDir = ($ENV{"NIX_STORE_DIR"} or "@storedir@");
|
|
||||||
my $stateDir = ($ENV{"NIX_STATE_DIR"} or "@localstatedir@/nix");
|
|
||||||
my $manifestDir = $Nix::Config::manifestDir;
|
my $manifestDir = $Nix::Config::manifestDir;
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +22,7 @@ if (! -e $manifestDir) {
|
||||||
|
|
||||||
|
|
||||||
# Make sure that the manifests directory is scanned for GC roots.
|
# Make sure that the manifests directory is scanned for GC roots.
|
||||||
my $gcRootsDir = "$stateDir/gcroots";
|
my $gcRootsDir = "$Nix::Config::stateDir/gcroots";
|
||||||
my $manifestDirLink = "$gcRootsDir/manifests";
|
my $manifestDirLink = "$gcRootsDir/manifests";
|
||||||
if (! -l $manifestDirLink) {
|
if (! -l $manifestDirLink) {
|
||||||
symlink($manifestDir, $manifestDirLink) or die "cannot create symlink `$manifestDirLink'";
|
symlink($manifestDir, $manifestDirLink) or die "cannot create symlink `$manifestDirLink'";
|
||||||
|
|
|
@ -18,11 +18,6 @@ my $curl = "$Nix::Config::curl --fail --silent";
|
||||||
my $extraCurlFlags = ${ENV{'CURL_FLAGS'}};
|
my $extraCurlFlags = ${ENV{'CURL_FLAGS'}};
|
||||||
$curl = "$curl $extraCurlFlags" if defined $extraCurlFlags;
|
$curl = "$curl $extraCurlFlags" if defined $extraCurlFlags;
|
||||||
|
|
||||||
my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@";
|
|
||||||
|
|
||||||
my $dataDir = $ENV{"NIX_DATA_DIR"};
|
|
||||||
$dataDir = "@datadir@" unless defined $dataDir;
|
|
||||||
|
|
||||||
|
|
||||||
# Parse the command line.
|
# Parse the command line.
|
||||||
my $localCopy;
|
my $localCopy;
|
||||||
|
@ -82,7 +77,7 @@ foreach my $path (@ARGV) {
|
||||||
# Get all paths referenced by the normalisation of the given
|
# Get all paths referenced by the normalisation of the given
|
||||||
# Nix expression.
|
# Nix expression.
|
||||||
my $pid = open(READ,
|
my $pid = open(READ,
|
||||||
"$binDir/nix-store --query --requisites --force-realise " .
|
"$Nix::Config::binDir/nix-store --query --requisites --force-realise " .
|
||||||
"--include-outputs '$path'|") or die;
|
"--include-outputs '$path'|") or die;
|
||||||
|
|
||||||
while (<READ>) {
|
while (<READ>) {
|
||||||
|
@ -107,7 +102,7 @@ foreach my $storePath (@storePaths) {
|
||||||
|
|
||||||
# Construct a Nix expression that creates a Nix archive.
|
# Construct a Nix expression that creates a Nix archive.
|
||||||
my $nixexpr =
|
my $nixexpr =
|
||||||
"((import $dataDir/nix/corepkgs/nar/nar.nix) " .
|
"(import <nix/nar.nix> " .
|
||||||
"{ storePath = builtins.storePath \"$storePath\"; system = \"@system@\"; hashAlgo = \"$hashAlgo\"; }) ";
|
"{ storePath = builtins.storePath \"$storePath\"; system = \"@system@\"; hashAlgo = \"$hashAlgo\"; }) ";
|
||||||
|
|
||||||
print NIX $nixexpr;
|
print NIX $nixexpr;
|
||||||
|
@ -120,7 +115,7 @@ close NIX;
|
||||||
# Instantiate store derivations from the Nix expression.
|
# Instantiate store derivations from the Nix expression.
|
||||||
my @storeExprs;
|
my @storeExprs;
|
||||||
print STDERR "instantiating store derivations...\n";
|
print STDERR "instantiating store derivations...\n";
|
||||||
my $pid = open(READ, "$binDir/nix-instantiate $nixExpr|")
|
my $pid = open(READ, "$Nix::Config::binDir/nix-instantiate $nixExpr|")
|
||||||
or die "cannot run nix-instantiate";
|
or die "cannot run nix-instantiate";
|
||||||
while (<READ>) {
|
while (<READ>) {
|
||||||
chomp;
|
chomp;
|
||||||
|
@ -142,7 +137,7 @@ while (scalar @tmp > 0) {
|
||||||
my @tmp2 = @tmp[0..$n - 1];
|
my @tmp2 = @tmp[0..$n - 1];
|
||||||
@tmp = @tmp[$n..scalar @tmp - 1];
|
@tmp = @tmp[$n..scalar @tmp - 1];
|
||||||
|
|
||||||
my $pid = open(READ, "$binDir/nix-store --realise @tmp2|")
|
my $pid = open(READ, "$Nix::Config::binDir/nix-store --realise @tmp2|")
|
||||||
or die "cannot run nix-store";
|
or die "cannot run nix-store";
|
||||||
while (<READ>) {
|
while (<READ>) {
|
||||||
chomp;
|
chomp;
|
||||||
|
@ -182,16 +177,16 @@ for (my $n = 0; $n < scalar @storePaths; $n++) {
|
||||||
|
|
||||||
my $narbz2Size = stat($narFile)->size;
|
my $narbz2Size = stat($narFile)->size;
|
||||||
|
|
||||||
my $references = `$binDir/nix-store --query --references '$storePath'`;
|
my $references = `$Nix::Config::binDir/nix-store --query --references '$storePath'`;
|
||||||
die "cannot query references for `$storePath'" if $? != 0;
|
die "cannot query references for `$storePath'" if $? != 0;
|
||||||
$references = join(" ", split(" ", $references));
|
$references = join(" ", split(" ", $references));
|
||||||
|
|
||||||
my $deriver = `$binDir/nix-store --query --deriver '$storePath'`;
|
my $deriver = `$Nix::Config::binDir/nix-store --query --deriver '$storePath'`;
|
||||||
die "cannot query deriver for `$storePath'" if $? != 0;
|
die "cannot query deriver for `$storePath'" if $? != 0;
|
||||||
chomp $deriver;
|
chomp $deriver;
|
||||||
$deriver = "" if $deriver eq "unknown-deriver";
|
$deriver = "" if $deriver eq "unknown-deriver";
|
||||||
|
|
||||||
my $narHash = `$binDir/nix-store --query --hash '$storePath'`;
|
my $narHash = `$Nix::Config::binDir/nix-store --query --hash '$storePath'`;
|
||||||
die "cannot query hash for `$storePath'" if $? != 0;
|
die "cannot query hash for `$storePath'" if $? != 0;
|
||||||
chomp $narHash;
|
chomp $narHash;
|
||||||
|
|
||||||
|
@ -199,13 +194,13 @@ for (my $n = 0; $n < scalar @storePaths; $n++) {
|
||||||
# store of the host), the database doesn't contain the hash. So
|
# store of the host), the database doesn't contain the hash. So
|
||||||
# compute it.
|
# compute it.
|
||||||
if ($narHash =~ /^sha256:0*$/) {
|
if ($narHash =~ /^sha256:0*$/) {
|
||||||
$narHash = `$binDir/nix-hash --type sha256 --base32 '$storePath'`;
|
$narHash = `$Nix::Config::binDir/nix-hash --type sha256 --base32 '$storePath'`;
|
||||||
die "cannot hash `$storePath'" if $? != 0;
|
die "cannot hash `$storePath'" if $? != 0;
|
||||||
chomp $narHash;
|
chomp $narHash;
|
||||||
$narHash = "sha256:$narHash";
|
$narHash = "sha256:$narHash";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $narSize = `$binDir/nix-store --query --size '$storePath'`;
|
my $narSize = `$Nix::Config::binDir/nix-store --query --size '$storePath'`;
|
||||||
die "cannot query size for `$storePath'" if $? != 0;
|
die "cannot query size for `$storePath'" if $? != 0;
|
||||||
chomp $narSize;
|
chomp $narSize;
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
||||||
|
|
||||||
/* Get the environment builder expression. */
|
/* Get the environment builder expression. */
|
||||||
Value envBuilder;
|
Value envBuilder;
|
||||||
state.evalFile(nixDataDir + "/nix/corepkgs/buildenv", envBuilder);
|
state.evalFile(state.findFile("nix/buildenv.nix"), envBuilder);
|
||||||
|
|
||||||
/* Construct a Nix expression that calls the user environment
|
/* Construct a Nix expression that calls the user environment
|
||||||
builder with the manifest as argument. */
|
builder with the manifest as argument. */
|
||||||
|
|
|
@ -8,7 +8,8 @@ TESTS = init.sh hash.sh lang.sh add.sh simple.sh dependencies.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 export.sh export-graph.sh negative-caching.sh \
|
remote-store.sh export.sh export-graph.sh negative-caching.sh \
|
||||||
binary-patching.sh timeout.sh secure-drv-outputs.sh multiple-outputs.sh
|
binary-patching.sh timeout.sh secure-drv-outputs.sh nix-channel.sh \
|
||||||
|
multiple-outputs.sh
|
||||||
|
|
||||||
XFAIL_TESTS =
|
XFAIL_TESTS =
|
||||||
|
|
||||||
|
@ -38,4 +39,3 @@ EXTRA_DIST = $(TESTS) \
|
||||||
multiple-outputs.nix \
|
multiple-outputs.nix \
|
||||||
$(wildcard lang/*.nix) $(wildcard lang/*.exp) $(wildcard lang/*.exp.xml) $(wildcard lang/*.flags) $(wildcard lang/dir*/*.nix) \
|
$(wildcard lang/*.nix) $(wildcard lang/*.exp) $(wildcard lang/*.exp.xml) $(wildcard lang/*.flags) $(wildcard lang/dir*/*.nix) \
|
||||||
common.sh.in
|
common.sh.in
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ if ! NIX_STORE_DIR=$(readlink -f $TEST_ROOT/store 2> /dev/null); then
|
||||||
export NIX_IGNORE_SYMLINK_STORE=1
|
export NIX_IGNORE_SYMLINK_STORE=1
|
||||||
NIX_STORE_DIR=$TEST_ROOT/store
|
NIX_STORE_DIR=$TEST_ROOT/store
|
||||||
fi
|
fi
|
||||||
export NIX_DATA_DIR=$TEST_ROOT/data
|
|
||||||
export NIX_LOCALSTATE_DIR=$TEST_ROOT/var
|
export NIX_LOCALSTATE_DIR=$TEST_ROOT/var
|
||||||
export NIX_LOG_DIR=$TEST_ROOT/var/log/nix
|
export NIX_LOG_DIR=$TEST_ROOT/var/log/nix
|
||||||
export NIX_STATE_DIR=$TEST_ROOT/var/nix
|
export NIX_STATE_DIR=$TEST_ROOT/var/nix
|
||||||
|
@ -19,15 +18,11 @@ export NIX_BIN_DIR=$TEST_ROOT/bin
|
||||||
export NIX_LIBEXEC_DIR=$TEST_ROOT/bin
|
export NIX_LIBEXEC_DIR=$TEST_ROOT/bin
|
||||||
export NIX_MANIFESTS_DIR=$TEST_ROOT/var/nix/manifests
|
export NIX_MANIFESTS_DIR=$TEST_ROOT/var/nix/manifests
|
||||||
export NIX_ROOT_FINDER=
|
export NIX_ROOT_FINDER=
|
||||||
|
export NIX_PATH=nix=$TOP/corepkgs
|
||||||
export SHARED=$TEST_ROOT/shared
|
export SHARED=$TEST_ROOT/shared
|
||||||
|
|
||||||
export PATH=$NIX_BIN_DIR:$TOP/scripts:$PATH
|
export PATH=$NIX_BIN_DIR:$TOP/scripts:$PATH
|
||||||
|
|
||||||
export REAL_BIN_DIR=@bindir@
|
|
||||||
export REAL_LIBEXEC_DIR=@libexecdir@
|
|
||||||
export REAL_LOCALSTATE_DIR=@localstatedir@
|
|
||||||
export REAL_DATA_DIR=@datadir@
|
|
||||||
export REAL_STORE_DIR=@storedir@
|
|
||||||
export NIX_BUILD_HOOK=
|
export NIX_BUILD_HOOK=
|
||||||
export PERL=perl
|
export PERL=perl
|
||||||
export PERL5LIB=$TOP/perl/lib:$PERL5LIB
|
export PERL5LIB=$TOP/perl/lib:$PERL5LIB
|
||||||
|
|
|
@ -13,5 +13,6 @@ rec {
|
||||||
builder = shell;
|
builder = shell;
|
||||||
args = ["-e" args.builder];
|
args = ["-e" args.builder];
|
||||||
PATH = path;
|
PATH = path;
|
||||||
} // removeAttrs args ["builder"]);
|
} // removeAttrs args ["builder" "meta"])
|
||||||
|
// { meta = args.meta or {}; };
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ let {
|
||||||
builder = ./dependencies.builder0.sh + "/FOOBAR/../.";
|
builder = ./dependencies.builder0.sh + "/FOOBAR/../.";
|
||||||
input1 = input1 + "/.";
|
input1 = input1 + "/.";
|
||||||
inherit input2;
|
inherit input2;
|
||||||
|
meta.description = "Random test package";
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ fi
|
||||||
mkdir "$TEST_ROOT"
|
mkdir "$TEST_ROOT"
|
||||||
|
|
||||||
mkdir "$NIX_STORE_DIR"
|
mkdir "$NIX_STORE_DIR"
|
||||||
mkdir "$NIX_DATA_DIR"
|
|
||||||
mkdir "$NIX_LOCALSTATE_DIR"
|
mkdir "$NIX_LOCALSTATE_DIR"
|
||||||
mkdir -p "$NIX_LOG_DIR"/drvs
|
mkdir -p "$NIX_LOG_DIR"/drvs
|
||||||
mkdir "$NIX_STATE_DIR"
|
mkdir "$NIX_STATE_DIR"
|
||||||
|
@ -39,29 +38,6 @@ env-keep-derivations = false
|
||||||
fsync-metadata = false
|
fsync-metadata = false
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
mkdir $NIX_DATA_DIR/nix
|
|
||||||
cp -pr $TOP/corepkgs $NIX_DATA_DIR/nix/
|
|
||||||
# Bah, scripts have the prefix hard-coded. This is really messy stuff
|
|
||||||
# (and likely to fail).
|
|
||||||
for i in \
|
|
||||||
$NIX_DATA_DIR/nix/corepkgs/nar/nar.sh \
|
|
||||||
; do
|
|
||||||
sed < $i > $i.tmp \
|
|
||||||
-e "s^$REAL_BIN_DIR/nix-store^$NIX_BIN_DIR/nix-store^" \
|
|
||||||
-e "s^$REAL_BIN_DIR/nix-hash^$NIX_BIN_DIR/nix-hash^" \
|
|
||||||
-e "s^$REAL_LIBEXEC_DIR^$NIX_LIBEXEC_DIR^" \
|
|
||||||
-e "s^$REAL_LOCALSTATE_DIR^$NIX_LOCALSTATE_DIR^" \
|
|
||||||
-e "s^$REAL_DATA_DIR^$NIX_DATA_DIR^" \
|
|
||||||
-e "s^$REAL_STORE_DIR\([^/]\)^$NIX_STORE_DIR\1^"
|
|
||||||
mv $i.tmp $i
|
|
||||||
chmod +x $i
|
|
||||||
done
|
|
||||||
|
|
||||||
# Another ugly hack.
|
|
||||||
sed "s|^$|PATH='$PATH'|" < $NIX_DATA_DIR/nix/corepkgs/nar/nar.sh > tmp
|
|
||||||
chmod +x tmp
|
|
||||||
mv tmp $NIX_DATA_DIR/nix/corepkgs/nar/nar.sh
|
|
||||||
|
|
||||||
# An uberhack for Mac OS X 10.5: download-using-manifests uses Perl,
|
# An uberhack for Mac OS X 10.5: download-using-manifests uses Perl,
|
||||||
# and Perl links against Darwin's libutil.dylib (in /usr/lib), but
|
# and Perl links against Darwin's libutil.dylib (in /usr/lib), but
|
||||||
# when running "make check", the libtool wrapper script around the Nix
|
# when running "make check", the libtool wrapper script around the Nix
|
||||||
|
|
|
@ -40,7 +40,7 @@ for i in lang/eval-okay-*.nix; do
|
||||||
if test -e lang/$i.flags; then
|
if test -e lang/$i.flags; then
|
||||||
flags=$(cat lang/$i.flags)
|
flags=$(cat lang/$i.flags)
|
||||||
fi
|
fi
|
||||||
if ! NIX_PATH=lang/dir3:lang/dir4 nix-instantiate $flags --eval-only --strict lang/$i.nix > lang/$i.out; then
|
if ! NIX_PATH=lang/dir3:lang/dir4:$NIX_PATH nix-instantiate $flags --eval-only --strict lang/$i.nix > lang/$i.out; then
|
||||||
echo "FAIL: $i should evaluate"
|
echo "FAIL: $i should evaluate"
|
||||||
fail=1
|
fail=1
|
||||||
elif ! diff lang/$i.out lang/$i.exp; then
|
elif ! diff lang/$i.out lang/$i.exp; then
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
assert builtins.pathExists <nix/buildenv>;
|
assert builtins.pathExists <nix/buildenv.nix>;
|
||||||
|
|
||||||
import <a.nix> + import <b.nix> + import <c.nix> + import <dir5/c.nix>
|
import <a.nix> + import <b.nix> + import <c.nix> + import <dir5/c.nix>
|
||||||
|
|
43
tests/nix-channel.sh
Normal file
43
tests/nix-channel.sh
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
clearProfiles
|
||||||
|
clearManifests
|
||||||
|
|
||||||
|
rm -f $TEST_ROOT/.nix-channels
|
||||||
|
|
||||||
|
# Override location of ~/.nix-channels.
|
||||||
|
export HOME=$TEST_ROOT
|
||||||
|
|
||||||
|
# Test add/list/remove.
|
||||||
|
nix-channel --add http://foo/bar
|
||||||
|
nix-channel --list | grep -q http://foo/bar
|
||||||
|
nix-channel --remove http://foo/bar
|
||||||
|
|
||||||
|
[ -e $TEST_ROOT/.nix-channels ]
|
||||||
|
[ "$(cat $TEST_ROOT/.nix-channels)" = '' ]
|
||||||
|
|
||||||
|
# Create a channel.
|
||||||
|
rm -rf $TEST_ROOT/foo
|
||||||
|
mkdir -p $TEST_ROOT/foo
|
||||||
|
nix-push --copy $TEST_ROOT/foo $TEST_ROOT/foo/MANIFEST $(nix-store -r $(nix-instantiate dependencies.nix))
|
||||||
|
rm -rf $TEST_ROOT/nixexprs
|
||||||
|
mkdir -p $TEST_ROOT/nixexprs
|
||||||
|
cp config.nix dependencies.nix dependencies.builder*.sh $TEST_ROOT/nixexprs/
|
||||||
|
ln -s dependencies.nix $TEST_ROOT/nixexprs/default.nix
|
||||||
|
(cd $TEST_ROOT && tar cvf - nixexprs) | bzip2 > $TEST_ROOT/foo/nixexprs.tar.bz2
|
||||||
|
|
||||||
|
# Test the update action.
|
||||||
|
nix-channel --add file://$TEST_ROOT/foo
|
||||||
|
nix-channel --update
|
||||||
|
|
||||||
|
# Do a query.
|
||||||
|
nix-env -qa \* --meta --xml --out-path > $TEST_ROOT/meta.xml
|
||||||
|
if [ "$xmllint" != false ]; then
|
||||||
|
$xmllint --noout $TEST_ROOT/meta.xml || fail "malformed XML"
|
||||||
|
fi
|
||||||
|
grep -q 'meta.*description.*Random test package' $TEST_ROOT/meta.xml
|
||||||
|
grep -q 'item.*attrPath="foo".*name="dependencies"' $TEST_ROOT/meta.xml
|
||||||
|
|
||||||
|
# Do an install.
|
||||||
|
nix-env -i dependencies
|
||||||
|
[ -e $TEST_ROOT/var/nix/profiles/default/foobar ]
|
|
@ -36,7 +36,7 @@ nix-env -p $profiles/test -q '*' | grep -q foo-2.0pre1
|
||||||
test "$($profiles/test/bin/foo)" = "foo-2.0pre1"
|
test "$($profiles/test/bin/foo)" = "foo-2.0pre1"
|
||||||
|
|
||||||
# Upgrade "foo": should install foo-2.0.
|
# Upgrade "foo": should install foo-2.0.
|
||||||
NIX_PATH=nixpkgs=./user-envs.nix nix-env -p $profiles/test -f '<nixpkgs>' -u foo
|
NIX_PATH=nixpkgs=./user-envs.nix:$NIX_PATH nix-env -p $profiles/test -f '<nixpkgs>' -u foo
|
||||||
|
|
||||||
# Query installed: should contain foo-2.0 now.
|
# Query installed: should contain foo-2.0 now.
|
||||||
test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1
|
test "$(nix-env -p $profiles/test -q '*' | wc -l)" -eq 1
|
||||||
|
|
Loading…
Reference in a new issue