summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-05-22 18:36:54 -0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-05-22 18:36:54 -0400
commit6814b1dfa1efee2b801f13ec428c72b7245880ee (patch)
treedd2dca327ca117ec033a7fd96c3877ea9ea59efb
parent591aab7e2166f1c7208cccdda7ce50c3c362f12b (diff)
downloadguix-6814b1dfa1efee2b801f13ec428c72b7245880ee.tar.gz
Generate binary tarballs for installing Nix
For several platforms we don't currently have "native" Nix packages
(e.g. Mac OS X and FreeBSD).  This provides the next best thing: a
tarball containing the closure of Nix, plus a simple script
"nix-finish-install" that initialises the Nix database, registers the
paths in the closure as valid, and runs "nix-env -i /path/to/nix" to
initialise the user profile.

The tarball must be unpacked in the root directory.  It creates
/nix/store/... and /usr/bin/nix-finish-install.  Typical installation
is as follows:

  $ cd /
  $ tar xvf /path/to/nix-1.1pre1234_abcdef-x86_64-linux.tar.bz2
  $ nix-finish-install
  (if necessary add ~/.nix-profile/etc/profile.d/nix.sh to the shell
  login scripts)

After this, /usr/bin/nix-finish-install can be deleted, if desired.

The downside to the binary tarball is that it's pretty big (~55 MiB
for x86_64-linux).
-rw-r--r--release.nix35
-rw-r--r--scripts/install-nix-from-closure.sh34
2 files changed, 68 insertions, 1 deletions
diff --git a/release.nix b/release.nix
index 8281853fe9..ae3b4ec554 100644
--- a/release.nix
+++ b/release.nix
@@ -63,7 +63,7 @@ let
 
 
     build =
-      { system ? "i686-linux" }:
+      { system ? "x86_64-linux" }:
 
       with import nixpkgs { inherit system; };
 
@@ -80,9 +80,42 @@ let
           --enable-gc
         '';
 
+        enableParallelBuilding = true;
+
         doInstallCheck = true;
       };
 
+    binaryTarball =
+      { system ? "x86_64-linux" }:
+
+      with import nixpkgs { inherit system; };
+
+      let
+        toplevel = build { inherit system; };
+        version = toplevel.src.version;
+      in
+
+      runCommand "nix-binary-tarball-${version}"
+        { exportReferencesGraph = [ "closure" toplevel ];
+          buildInputs = [ perl ];
+          meta.description = "Distribution-independent Nix bootstrap binaries for ${system}";
+        }
+        ''
+          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
+          chmod +x $TMPDIR/install
+          fn=$out/nix-${version}-${system}.tar.bz2
+          mkdir -p $out/nix-support
+          echo "file binary-dist $fn" >> $out/nix-support/hydra-build-products
+          tar cvfj $fn \
+            --owner=root --group=root --absolute-names \
+            --transform "s,$TMPDIR/install,/usr/bin/nix-finish-install," \
+            --transform "s,$TMPDIR/reginfo,/nix/store/reginfo," \
+            $TMPDIR/install $TMPDIR/reginfo $storePaths
+        '';
+
 
     coverage =
       with import nixpkgs { system = "x86_64-linux"; };
diff --git a/scripts/install-nix-from-closure.sh b/scripts/install-nix-from-closure.sh
new file mode 100644
index 0000000000..41e596e5ff
--- /dev/null
+++ b/scripts/install-nix-from-closure.sh
@@ -0,0 +1,34 @@
+#! /bin/sh -e
+
+nix=@nix@
+regInfo=@regInfo@
+
+if ! $nix/bin/nix-store --load-db < $regInfo; then
+    echo "$0: unable to register valid paths"
+    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"
+    exit 1
+fi
+
+# Add nix.sh to the shell's profile.d directory.
+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
+variables are set, please add the line
+
+  source $p
+
+to your shell profile (e.g. ~/.profile).
+EOF
+fi
\ No newline at end of file