diff options
-rw-r--r-- | doc/manual/installation.xml | 29 | ||||
-rw-r--r-- | doc/manual/nix-shell.xml | 18 | ||||
-rw-r--r-- | doc/manual/writing-nix-expressions.xml | 13 | ||||
-rw-r--r-- | release.nix | 14 | ||||
-rw-r--r-- | scripts/install-nix-from-closure.sh | 119 | ||||
-rwxr-xr-x | scripts/nix-build.in | 3 |
6 files changed, 146 insertions, 50 deletions
diff --git a/doc/manual/installation.xml b/doc/manual/installation.xml index a136d3b1129e..4c433a6bf769 100644 --- a/doc/manual/installation.xml +++ b/doc/manual/installation.xml @@ -69,27 +69,26 @@ $ dpkg -i nix_1.0-1_amd64.deb</screen> <para>For other platforms, including Mac OS X (Darwin), FreeBSD and other Linux distributions, you can download a binary tarball. It -contains Nix and all its dependencies. You should unpack it in the -root directory, then run <command>nix-finish-install</command>: +contains Nix and all its dependencies. You should unpack it somewhere +(e.g. in <filename>/tmp</filename>), and then run the script named +<command>install</command> inside the binary tarball: <screen> -$ cd / -$ tar xfj nix-1.1-x86_64-darwin.tar.bz2 -$ nix-finish-install +alice$ cd /tmp +alice$ tar xfj nix-1.1-x86_64-darwin.tar.bz2 +alice$ cd nix-1.1-x86_64-darwin +alice$ ./install </screen> -After this you can delete -<filename>/usr/bin/nix-finish-install</filename>.</para> - -<para>If you plan to use Nix from a single non-root user account, it’s -probably convenient to change the ownership of the entire Nix store -and database to that user account. In that case, install as follows: +You should run this under your usual user account, +<emphasis>not</emphasis> as root. The script will invoke +<command>sudo</command> to create <filename>/nix</filename> if it +doesn’t already exist. If you don’t have <command>sudo</command>, you +should manually create <command>/nix</command> first as root: <screen> -alice$ cd / -alice$ sudo tar xfj nix-1.1-x86_64-darwin.tar.bz2 -alice$ sudo chown -R alice /nix -alice$ nix-finish-install +$ mkdir /nix +$ chown alice /nix </screen> </para> diff --git a/doc/manual/nix-shell.xml b/doc/manual/nix-shell.xml index 866b3413b967..e57c726f5394 100644 --- a/doc/manual/nix-shell.xml +++ b/doc/manual/nix-shell.xml @@ -31,20 +31,26 @@ <arg><option>--command</option> <replaceable>cmd</replaceable></arg> <arg><option>--exclude</option> <replaceable>regexp</replaceable></arg> <arg><option>--pure</option></arg> - <arg choice='plain' rep='repeat'><replaceable>paths</replaceable></arg> + <arg><replaceable>path</replaceable></arg> </cmdsynopsis> </refsynopsisdiv> <refsection><title>Description</title> -<para>The command <command>nix-shell</command> will build -the dependencies of the specified derivation, but not the derivation +<para>The command <command>nix-shell</command> will build the +dependencies of the specified derivation, but not the derivation itself. It will then start an interactive shell in which all -environment variables defined by the derivation have been set to their -corresponding values, and the script <literal>$stdenv/setup</literal> -has been sourced. This is useful for reproducing the environment of a +environment variables defined by the derivation +<replaceable>path</replaceable> have been set to their corresponding +values, and the script <literal>$stdenv/setup</literal> has been +sourced. This is useful for reproducing the environment of a derivation for development.</para> +<para>If <replaceable>path</replaceable> is not given, +<command>nix-shell</command> defaults to +<filename>shell.nix</filename> if it exists, and +<filename>default.nix</filename> otherwise.</para> + </refsection> diff --git a/doc/manual/writing-nix-expressions.xml b/doc/manual/writing-nix-expressions.xml index 3e6cd7379015..c5b355ea0469 100644 --- a/doc/manual/writing-nix-expressions.xml +++ b/doc/manual/writing-nix-expressions.xml @@ -1740,12 +1740,15 @@ impureEnvVars = [ "http_proxy" "https_proxy" <replaceable>...</replaceable> ]; <varlistentry><term><varname>preferLocalBuild</varname></term> <listitem><para>If this attribute is set to - <literal>true</literal> and <link + <literal>true</literal>, it has two effects. First, the + derivation will always be built, not substituted, even if a + substitute is available. Second, if <link linkend="chap-distributed-builds">distributed building is - enabled</link>, then, if possible, perform this build locally - instead of forwarding it to a remote machine. This is appropriate - for trivial builders where the cost of doing a remote build would - exceed the cost of building locally.</para></listitem> + enabled</link>, then, if possible, the derivaton will be built + locally instead of forwarded to a remote machine. This is + appropriate for trivial builders where the cost of doing a + download or remote build would exceed the cost of building + locally.</para></listitem> </varlistentry> diff --git a/release.nix b/release.nix index e3758f5b2c6c..0547aeeeaf2c 100644 --- a/release.nix +++ b/release.nix @@ -124,15 +124,19 @@ let storePaths=$(perl ${pathsFromGraph} ./closure) printRegistration=1 perl ${pathsFromGraph} ./closure > $TMPDIR/reginfo substitute ${./scripts/install-nix-from-closure.sh} $TMPDIR/install \ - --subst-var-by nix ${toplevel} --subst-var-by regInfo /nix/store/reginfo + --subst-var-by nix ${toplevel} chmod +x $TMPDIR/install - fn=$out/nix-${version}-${system}.tar.bz2 + dir=nix-${version}-${system} + fn=$out/$dir.tar.bz2 mkdir -p $out/nix-support echo "file binary-dist $fn" >> $out/nix-support/hydra-build-products tar cvfj $fn \ - --owner=0 --group=0 --absolute-names \ - --transform "s,$TMPDIR/install,/usr/bin/nix-finish-install," \ - --transform "s,$TMPDIR/reginfo,/nix/store/reginfo," \ + --owner=0 --group=0 --mode=u+rw,uga+r \ + --absolute-names \ + --hard-dereference \ + --transform "s,$TMPDIR/install,$dir/install," \ + --transform "s,$TMPDIR/reginfo,$dir/.reginfo," \ + --transform "s,$NIX_STORE,$dir/store,S" \ $TMPDIR/install $TMPDIR/reginfo $storePaths ''); diff --git a/scripts/install-nix-from-closure.sh b/scripts/install-nix-from-closure.sh index 41e596e5fffd..124819b3e08c 100644 --- a/scripts/install-nix-from-closure.sh +++ b/scripts/install-nix-from-closure.sh @@ -1,34 +1,117 @@ -#! /bin/sh -e +#! /usr/bin/env bash -nix=@nix@ -regInfo=@regInfo@ +set -e -if ! $nix/bin/nix-store --load-db < $regInfo; then - echo "$0: unable to register valid paths" +dest="/nix" +self="$(dirname "$0")" +nix="@nix@" + +if ! [ -e $self/.reginfo ]; then + echo "$0: incomplete installer (.reginfo is missing)" >&2 exit 1 fi -. @nix@/etc/profile.d/nix.sh +if [ -z "$USER" ]; then + echo "$0: \$USER is not set" >&2 + exit 1 +fi + +if [ "$(id -u)" -eq 0 ]; then + echo "warning: installing Nix as root is not recommended" >&2 + exit 1 +fi + +echo "performing a single-user installation of Nix..." >&2 + +if ! [ -e $dest ]; then + cmd="mkdir -m 0755 $dest && chown $USER $dest" + echo "directory $dest does not exist; creating it by running \`$cmd' using sudo" >&2 + if ! sudo sh -c "$cmd"; then + echo "$0: please manually run \`$cmd' as root to create $dest" >&2 + exit 1 + fi +fi -if ! $nix/bin/nix-env -i @nix@; then - echo "$0: unable to install Nix into your default profile" +if ! [ -w $dest ]; then + echo "$0: directory $dest exists, but is not writable by you; please run \`chown -R $USER $dest' as root" >&2 exit 1 fi -# Add nix.sh to the shell's profile.d directory. +mkdir -p $dest/store + +echo -n "copying Nix to $dest/store..." >&2 + +for i in $(cd $self/store && echo *); do + echo -n "." >&2 + i_tmp="$dest/store/$i.$$" + if [ -e "$i_tmp" ]; then + rm -rf "$i_tmp" + fi + if ! [ -e "$dest/store/$i" ]; then + cp -rp "$self/store/$i" "$i_tmp" + mv "$i_tmp" "$dest/store/$i" + fi +done +echo "" >&2 + +echo "initialising Nix database..." >&2 +if ! $nix/bin/nix-store --init; then + echo "$0: failed to initialize the Nix database" >&2 + exit 1 +fi + +if ! $nix/bin/nix-store --load-db < $self/.reginfo; then + echo "$0: unable to register valid paths" >&2 + exit 1 +fi + +. $nix/etc/profile.d/nix.sh + +if ! $nix/bin/nix-env -i $nix; then + echo "$0: unable to install Nix into your default profile" >&2 + exit 1 +fi + +# Subscribe the user to the Nixpkgs channel and fetch it. +if ! $nix/bin/nix-channel --list | grep -q "^nixpkgs "; then + $nix/bin/nix-channel --add http://nixos.org/channels/nixpkgs-unstable +fi +$nix/bin/nix-channel --update nixpkgs + +# Make the shell source nix.sh during login. p=$NIX_LINK/etc/profile.d/nix.sh -if [ -w /etc/profile.d ]; then - ln -s $p /etc/profile.d/ -elif [ -w /usr/local/etc/profile.d ]; then - ln -s $p /usr/local/etc/profile.d/ -else - cat <<EOF -Installation finished. To ensure that the necessary environment +added= +for i in .bash_profile .bash_login .profile; do + fn="$HOME/$i" + if [ -e "$fn" ]; then + if ! grep -q "$p" "$fn"; then + echo "modifying $fn..." >&2 + echo "if [ -e $p ]; then . $p; fi # added by Nix installer" >> $fn + fi + added=1 + break + fi +done + +if [ -z "$added" ]; then + cat >&2 <<EOF + +Installation finished! To ensure that the necessary environment variables are set, please add the line - source $p + . $p to your shell profile (e.g. ~/.profile). EOF -fi \ No newline at end of file +else + cat >&2 <<EOF + +Installation finished! To ensure that the necessary environment +variables are set, either log in again, or type + + . $p + +in your shell. +EOF +fi diff --git a/scripts/nix-build.in b/scripts/nix-build.in index 168730bbc92d..fff71021fbf8 100755 --- a/scripts/nix-build.in +++ b/scripts/nix-build.in @@ -149,7 +149,8 @@ for (my $n = 0; $n < scalar @ARGV; $n++) { } } -@exprs = ("./default.nix") if scalar @exprs == 0; +@exprs = ("shell.nix") if scalar @exprs == 0 && $runEnv && -e "shell.nix"; +@exprs = ("default.nix") if scalar @exprs == 0; $ENV{'IN_NIX_SHELL'} = 1 if $runEnv; |