summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/build-support/build-fhs-chrootenv/default.nix84
-rw-r--r--pkgs/build-support/build-fhs-chrootenv/destroy.sh.in21
-rw-r--r--pkgs/build-support/build-fhs-chrootenv/init.sh.in48
-rw-r--r--pkgs/build-support/build-fhs-chrootenv/load.sh.in6
-rw-r--r--pkgs/build-support/build-fhs-chrootenv/mount.sh.in23
-rw-r--r--pkgs/build-support/build-fhs-chrootenv/umount.sh.in6
-rw-r--r--pkgs/games/steam/chrootenv.nix12
-rw-r--r--pkgs/games/steam/default.nix27
-rw-r--r--pkgs/top-level/all-packages.nix10
9 files changed, 236 insertions, 1 deletions
diff --git a/pkgs/build-support/build-fhs-chrootenv/default.nix b/pkgs/build-support/build-fhs-chrootenv/default.nix
new file mode 100644
index 00000000000..8756c4835b2
--- /dev/null
+++ b/pkgs/build-support/build-fhs-chrootenv/default.nix
@@ -0,0 +1,84 @@
+{stdenv, glibc, glibcLocales, gcc, coreutils, diffutils, findutils, gnused, gnugrep, gnutar, gzip, bzip2, 
+bashInteractive, xz, shadow, gawk, less, buildEnv}:
+{name, pkgs ? [], profile ? ""}:
+
+let
+  basePkgs = [ glibc glibcLocales gcc coreutils diffutils findutils gnused gnugrep gnutar gzip bzip2 
+bashInteractive xz shadow gawk less ];
+
+  # Compose a global profile for the chroot environment
+  profilePkg = stdenv.mkDerivation {
+    name = "${name}-chrootenv-profile";
+    buildCommand = ''
+      mkdir -p $out/etc
+      cat >> $out/etc/profile << "EOF"
+      export PS1='${name}-chrootenv:\u@\h:\w\$ '
+      ${profile}
+      EOF
+    '';
+  };
+
+  paths = basePkgs ++ [ profilePkg ] ++ pkgs;
+
+  # Composes a /usr like directory structure
+  staticUsrProfile = buildEnv {
+    name = "system-profile";
+    inherit paths;
+  };
+  
+  # References to shell scripts that set up or tear down the environment
+  initSh = ./init.sh.in;
+  mountSh = ./mount.sh.in;
+  loadSh = ./load.sh.in;
+  umountSh = ./umount.sh.in;
+  destroySh = ./destroy.sh.in;                                                                                       
+in                                                                                                                   
+stdenv.mkDerivation {                                                                                                
+  name = "${name}-chrootenv";                                                                                        
+  buildCommand = ''                                                                                                  
+    mkdir -p $out/sw                                                                                                 
+    cd $out/sw                                                                                                       
+                                                                                                                     
+    for i in ${staticUsrProfile}/{etc,bin,lib{,32,64},sbin,var}                                                      
+    do                                                                                                               
+        if [ -x "$i" ]
+        then
+            ln -s "$i"
+        fi
+    done
+    
+    ln -s ${staticUsrProfile} usr
+    
+    cd ..
+    
+    mkdir -p bin
+    cd bin
+    
+    sed -e "s|@chrootEnv@|$out|g" \
+        -e "s|@name@|${name}|g" \
+        -e "s|@shell@|${stdenv.shell}|g" \
+        ${initSh} > init-${name}-chrootenv
+    chmod +x init-${name}-chrootenv
+    
+    sed -e "s|@shell@|${stdenv.shell}|g" \
+        -e "s|@name@|${name}|g" \
+        ${mountSh} > mount-${name}-chrootenv
+    chmod +x mount-${name}-chrootenv
+    
+    sed -e "s|@shell@|${stdenv.shell}|g" \
+        -e "s|@name@|${name}|g" \
+        ${loadSh} > load-${name}-chrootenv
+    chmod +x load-${name}-chrootenv
+    
+    sed -e "s|@shell@|${stdenv.shell}|g" \
+        -e "s|@name@|${name}|g" \
+        ${umountSh} > umount-${name}-chrootenv
+    chmod +x umount-${name}-chrootenv
+    
+    sed -e "s|@chrootEnv@|$out|g" \
+        -e "s|@shell@|${stdenv.shell}|g" \
+        -e "s|@name@|${name}|g" \
+        ${destroySh} > destroy-${name}-chrootenv
+    chmod +x destroy-${name}-chrootenv
+  '';
+}
diff --git a/pkgs/build-support/build-fhs-chrootenv/destroy.sh.in b/pkgs/build-support/build-fhs-chrootenv/destroy.sh.in
new file mode 100644
index 00000000000..30b51cb5068
--- /dev/null
+++ b/pkgs/build-support/build-fhs-chrootenv/destroy.sh.in
@@ -0,0 +1,21 @@
+#! @shell@ -e
+
+chrootenvDest=/run/chrootenv/@name@
+
+# Remove bind mount points
+rmdir $chrootenvDest/{dev,nix/store,nix,proc,sys,host-etc,home,var,run}
+
+# Remove symlinks to the software that should be part of the chroot system profile
+for i in @chrootEnv@/sw/*
+do
+    if [ "$i" != "@chrootEnv@/sw/etc" ] && [ "$i" != "@chrootEnv@/sw/var" ]
+    then
+        rm $chrootenvDest/$(basename $i)
+    fi
+done
+
+# Remove the remaining folders
+rm -Rf $chrootenvDest/{etc,root,tmp}
+
+# Remove the chroot environment folder
+rmdir $chrootenvDest
diff --git a/pkgs/build-support/build-fhs-chrootenv/init.sh.in b/pkgs/build-support/build-fhs-chrootenv/init.sh.in
new file mode 100644
index 00000000000..2dfa95219c8
--- /dev/null
+++ b/pkgs/build-support/build-fhs-chrootenv/init.sh.in
@@ -0,0 +1,48 @@
+#! @shell@ -e
+
+chrootenvDest=/run/chrootenv/@name@
+
+# Create some mount points for stuff that must be bind mounted
+mkdir -p $chrootenvDest/{nix/store,dev,proc,sys,host-etc,home,var,run}
+
+# Symlink the software that should be part of the chroot system profile
+for i in @chrootEnv@/sw/*
+do
+    if [ "$i" != "@chrootEnv@/sw/etc" ] && [ "$i" != "@chrootEnv@/sw/var" ]
+    then
+        ln -s "$i" "$chrootenvDest"
+    fi
+done
+
+# Symlink the contents of the chroot software's /etc
+
+mkdir $chrootenvDest/etc
+
+for i in @chrootEnv@/sw/etc/*
+do
+    ln -s "$i" $chrootenvDest/etc
+done
+
+# Symlink some NSS stuff
+ln -s ../host-etc/passwd $chrootenvDest/etc/passwd
+ln -s ../host-etc/group $chrootenvDest/etc/group
+ln -s ../host-etc/shadow $chrootenvDest/etc/shadow
+ln -s ../host-etc/hosts $chrootenvDest/etc/hosts
+ln -s ../host-etc/resolv.conf $chrootenvDest/etc/resolv.conf
+ln -s ../host-etc/nsswitch.conf $chrootenvDest/etc/nsswitch.conf
+
+# Symlink PAM stuff
+rm $chrootenvDest/etc/pam.d
+ln -s ../host-etc/static/pam.d $chrootenvDest/etc/pam.d
+
+# Symlink Font stuff
+mkdir $chrootenvDest/etc/fonts
+ln -s ../../host-etc/static/fonts/fonts.conf $chrootenvDest/etc/fonts
+mkdir $chrootenvDest/etc/fonts/conf.d
+ln -s ../../../host-etc/static/fonts/conf.d/00-nixos.conf $chrootenvDest/etc/fonts/conf.d
+
+# Create root folder
+mkdir $chrootenvDest/root
+
+# Create tmp folder
+mkdir -m1777 $chrootenvDest/tmp
diff --git a/pkgs/build-support/build-fhs-chrootenv/load.sh.in b/pkgs/build-support/build-fhs-chrootenv/load.sh.in
new file mode 100644
index 00000000000..8d3f464186b
--- /dev/null
+++ b/pkgs/build-support/build-fhs-chrootenv/load.sh.in
@@ -0,0 +1,6 @@
+#! @shell@ -e
+
+chrootenvDest=/run/chrootenv/@name@
+
+# Enter the LFS chroot environment
+chroot $chrootenvDest /usr/bin/env -i PS1="$PS1" TERM="$TERM" DISPLAY="$DISPLAY" HOME="/root" PATH="/bin:/sbin" /bin/bash --login
diff --git a/pkgs/build-support/build-fhs-chrootenv/mount.sh.in b/pkgs/build-support/build-fhs-chrootenv/mount.sh.in
new file mode 100644
index 00000000000..68459cca256
--- /dev/null
+++ b/pkgs/build-support/build-fhs-chrootenv/mount.sh.in
@@ -0,0 +1,23 @@
+#! @shell@ -e
+
+chrootenvDest=/run/chrootenv/@name@
+
+# Bind mount the Nix store
+mount --bind /nix/store $chrootenvDest/nix/store
+
+# Bind mount some kernel related stuff
+mount --bind /dev $chrootenvDest/dev
+mount --bind /dev/pts $chrootenvDest/dev/pts
+mount --bind /dev/shm $chrootenvDest/dev/shm
+mount --bind /proc $chrootenvDest/proc
+mount --bind /sys $chrootenvDest/sys
+
+# Bind mount home directories
+mount --bind /home $chrootenvDest/home
+
+# Bind mount state directories
+mount --bind /var $chrootenvDest/var
+mount --bind /run $chrootenvDest/run
+
+# Bind mount the host system's /etc
+mount --bind /etc $chrootenvDest/host-etc
diff --git a/pkgs/build-support/build-fhs-chrootenv/umount.sh.in b/pkgs/build-support/build-fhs-chrootenv/umount.sh.in
new file mode 100644
index 00000000000..29d631fbd90
--- /dev/null
+++ b/pkgs/build-support/build-fhs-chrootenv/umount.sh.in
@@ -0,0 +1,6 @@
+#! @shell@ -e
+
+chrootenvDest=/run/chrootenv/@name@
+
+# Unmount all bind mounts
+umount $chrootenvDest/{dev/pts,dev/shm,dev,nix/store,proc,sys,host-etc,home,var,run}
diff --git a/pkgs/games/steam/chrootenv.nix b/pkgs/games/steam/chrootenv.nix
new file mode 100644
index 00000000000..2173d12666e
--- /dev/null
+++ b/pkgs/games/steam/chrootenv.nix
@@ -0,0 +1,12 @@
+{ buildFHSChrootEnv, steam
+, xterm, libX11, zenity, python, mesa, xdg_utils, dbus_tools, alsaLib
+}:
+
+buildFHSChrootEnv {
+  name = "steam";
+  pkgs = [ steam xterm libX11 zenity python mesa xdg_utils dbus_tools alsaLib ];
+  profile = ''
+    export LD_LIBRARY_PATH=/run/opengl-driver/lib:/run/opengl-driver-32/lib:/lib
+    export FONTCONFIG_FILE=/etc/fonts/fonts.conf
+  '';
+}
diff --git a/pkgs/games/steam/default.nix b/pkgs/games/steam/default.nix
index 1e8c0db9045..80be4ec8595 100644
--- a/pkgs/games/steam/default.nix
+++ b/pkgs/games/steam/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, dpkg, makeWrapper, xz, libX11, gcc, glibc
+/*{ stdenv, fetchurl, dpkg, makeWrapper, xz, libX11, gcc, glibc
 , libselinux, libXrandr, pango, freetype, fontconfig, glib, gtk
 , gdk_pixbuf, cairo, libXi, alsaLib, libXrender, nss, nspr, zlib
 , dbus, libpng12, libXfixes, cups, libgcrypt, openal, pulseaudio
@@ -97,3 +97,28 @@ stdenv.mkDerivation rec {
     license = "unfree";
   };
 }
+*/
+
+{stdenv, fetchurl, dpkg}:
+
+stdenv.mkDerivation {
+  name = "steam-1.0.0.42";
+  src = fetchurl {
+    url = http://repo.steampowered.com/steam/archive/precise/steam-launcher_1.0.0.42_all.deb;
+    sha256 = "1jyvk0h1z78sdpvl4hs1kdvr6z2kwamf09vjgjx1f6j04kgqrfbw";
+  };
+  buildInputs = [ dpkg ];
+  unpackPhase = "true";
+  installPhase = ''
+    mkdir -p $out
+    dpkg -x $src $out
+    cp -av $out/usr/* $out
+    rm -Rf $out/usr
+  '';
+  
+  meta = {
+    description = "A digital distribution platform";
+    homepage = http://store.steampowered.com/;
+    license = "unfree";
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 8ad6167c5bc..1a2ddeeeda2 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -266,6 +266,12 @@ let
   buildEnv = import ../build-support/buildenv {
     inherit (pkgs) runCommand perl;
   };
+  
+  buildFHSChrootEnv = import ../build-support/build-fhs-chrootenv {
+    inherit stdenv glibc glibcLocales gcc coreutils diffutils findutils;
+    inherit gnused gnugrep gnutar gzip bzip2 bashInteractive xz shadow gawk;
+    inherit less buildEnv;
+  };
 
   dotnetenv = import ../build-support/dotnetenv {
     inherit stdenv;
@@ -9120,6 +9126,10 @@ let
   stardust = callPackage ../games/stardust {};
 
   steam = callPackage_i686 ../games/steam {};
+  
+  steamChrootEnv = callPackage_i686 ../games/steam/chrootenv.nix {
+    zenity = gnome2.zenity;
+  };
 
   stuntrally = callPackage ../games/stuntrally { };