summary refs log tree commit diff
path: root/pkgs/tools
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/tools')
-rw-r--r--pkgs/tools/archivers/gnutar/default.nix7
-rw-r--r--pkgs/tools/archivers/p7zip/default.nix6
-rw-r--r--pkgs/tools/archivers/sharutils/4.6.3.nix13
-rw-r--r--pkgs/tools/compression/gzip/default.nix9
-rw-r--r--pkgs/tools/compression/lzma/default.nix18
-rw-r--r--pkgs/tools/misc/coreutils/default.nix13
-rw-r--r--pkgs/tools/misc/dosfstools/2.11deb.nix33
-rw-r--r--pkgs/tools/misc/findutils/default.nix11
-rw-r--r--pkgs/tools/misc/grub/default.nix1
-rw-r--r--pkgs/tools/misc/man-db/default.nix32
-rw-r--r--pkgs/tools/misc/man-db/share.patch110
-rw-r--r--pkgs/tools/misc/man/default.nix23
-rw-r--r--pkgs/tools/misc/man/share.patch207
-rw-r--r--pkgs/tools/misc/mc/default.nix11
-rw-r--r--pkgs/tools/misc/relfs/cvs.2007.12.01.nix20
-rw-r--r--pkgs/tools/misc/shebangfix/default.nix15
-rw-r--r--pkgs/tools/networking/lsh/default.nix17
-rw-r--r--pkgs/tools/networking/nc6/1.0.nix25
-rw-r--r--pkgs/tools/networking/p2p/ktorrent/default.nix14
-rw-r--r--pkgs/tools/networking/socat/1.6.0.0.nix34
-rw-r--r--pkgs/tools/networking/socat/2.0.0-b1.nix25
-rw-r--r--pkgs/tools/networking/vpnc/builder.sh9
-rw-r--r--pkgs/tools/networking/vpnc/default.nix20
-rw-r--r--pkgs/tools/networking/vpnc/makefile.patch22
-rw-r--r--pkgs/tools/package-management/nix/unstable.nix4
-rw-r--r--pkgs/tools/package-management/snix/default.nix36
-rw-r--r--pkgs/tools/system/cron/default.nix2
-rw-r--r--pkgs/tools/system/which/default.nix6
-rw-r--r--pkgs/tools/text/diffutils/default.nix7
-rw-r--r--pkgs/tools/text/gawk/default.nix6
-rw-r--r--pkgs/tools/text/gnugrep/default.nix7
-rw-r--r--pkgs/tools/text/gnused/default.nix7
-rw-r--r--pkgs/tools/text/replace/default.nix9
-rwxr-xr-xpkgs/tools/typesetting/lout/builder.sh42
-rw-r--r--pkgs/tools/typesetting/lout/default.nix20
35 files changed, 689 insertions, 152 deletions
diff --git a/pkgs/tools/archivers/gnutar/default.nix b/pkgs/tools/archivers/gnutar/default.nix
index 9205612f3bc..7242f32f71c 100644
--- a/pkgs/tools/archivers/gnutar/default.nix
+++ b/pkgs/tools/archivers/gnutar/default.nix
@@ -2,9 +2,16 @@
 
 stdenv.mkDerivation {
   name = "gnutar-1.19";
+  
   src = fetchurl {
     url = mirror://gnu/tar/tar-1.19.tar.bz2;
     sha256 = "1d4wh27wlgryz3ld6gp6fn56knh7dmny93bmgixy07kvlxnx9466";
   };
+  
   patches = [./implausible.patch];
+
+  meta = {
+    homepage = http://www.gnu.org/software/grep/;
+    description = "GNU implementation of the tar archiver";
+  };
 }
diff --git a/pkgs/tools/archivers/p7zip/default.nix b/pkgs/tools/archivers/p7zip/default.nix
index c9d97033500..00bc47878f4 100644
--- a/pkgs/tools/archivers/p7zip/default.nix
+++ b/pkgs/tools/archivers/p7zip/default.nix
@@ -1,11 +1,11 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation {
-  name = "p7zip-4.53";
+  name = "p7zip-4.57";
   
   src = fetchurl {
-    url = mirror://sourceforge/p7zip/p7zip_4.53_src_all.tar.bz2;
-    sha256 = "0pbgvpq852qnzq4isgc13p4nnp416xhy5vmn1rcwm8fk43l5rbqd";
+    url = mirror://sourceforge/p7zip/p7zip_4.57_src_all.tar.bz2;
+    sha256 = "0lsvw1bh6dzpxn8kyl7s79w2drpfxaa1c79khqm56gfmdlw27s80";
   };
   
   preConfigure = "
diff --git a/pkgs/tools/archivers/sharutils/4.6.3.nix b/pkgs/tools/archivers/sharutils/4.6.3.nix
new file mode 100644
index 00000000000..830c2a072b6
--- /dev/null
+++ b/pkgs/tools/archivers/sharutils/4.6.3.nix
@@ -0,0 +1,13 @@
+args: with args;
+stdenv.mkDerivation rec {
+  name = "sharutils-" + version;
+
+  src = fetchurl {
+    url = "mirror://gnu/sharutils/REL-${version}/${name}.tar.bz2";
+    sha256 = "1sirrzas8llcsd8gnh56pns39wa1f803vff1kmy5islfi1p9vqk8";
+  };
+
+  meta = {
+    homepage = http://www.gnu.org/software/sharutils;
+  };
+}
diff --git a/pkgs/tools/compression/gzip/default.nix b/pkgs/tools/compression/gzip/default.nix
index 58d6e8b9707..0a2afd05372 100644
--- a/pkgs/tools/compression/gzip/default.nix
+++ b/pkgs/tools/compression/gzip/default.nix
@@ -2,9 +2,16 @@
 
 stdenv.mkDerivation {
   name = "gzip-1.3.12";
+  
   src = fetchurl {
     url = http://ftp.gnu.org/gnu/gzip/gzip-1.3.12.tar.gz;
     sha256 = "1bw7sm68xjlnlzgcx66hnw80ac1qqyvhw0vw27zilgbzbzh5nmiz";
   };
-	patches = [./gnulib-futimens.patch];
+
+  meta = {
+    homepage = http://www.gzip.org/;
+    description = "The gzip compression program";
+  };
+  
+  patches = [./gnulib-futimens.patch];
 }
diff --git a/pkgs/tools/compression/lzma/default.nix b/pkgs/tools/compression/lzma/default.nix
new file mode 100644
index 00000000000..67ef9c3add1
--- /dev/null
+++ b/pkgs/tools/compression/lzma/default.nix
@@ -0,0 +1,18 @@
+{stdenv, fetchurl}:
+
+stdenv.mkDerivation {
+  name = "lzma-4.32.5";
+  
+  src = fetchurl {
+    url = http://tukaani.org/lzma/lzma-4.32.5.tar.gz;
+    sha256 = "1mqy1biy46gqky6n3gyr2l395hwckh0xyi96waz5p5x8mgp372ch";
+  };
+
+  CFLAGS = "-O3";
+  CXXFLAGS = "-O3";
+
+  meta = {
+    homepage = http://tukaani.org/lzma/;
+    description = "The LZMA compression program";
+  };
+}
diff --git a/pkgs/tools/misc/coreutils/default.nix b/pkgs/tools/misc/coreutils/default.nix
index 770a1dbfbc9..8292c56f0ea 100644
--- a/pkgs/tools/misc/coreutils/default.nix
+++ b/pkgs/tools/misc/coreutils/default.nix
@@ -1,10 +1,15 @@
 {stdenv, fetchurl}:
 
 stdenv.mkDerivation {
-  name = "coreutils-6.9";
+  name = "coreutils-6.10";
+  
   src = fetchurl {
-    url = mirror://gnu/coreutils/coreutils-6.9.tar.bz2;
-    sha256 = "1c4p2kiy4m024qcl1przvphy8vhivf8jvclq6bjm1pjps5d8khl9";
+    url = mirror://gnu/coreutils/coreutils-6.10.tar.gz;
+    sha256 = "0zpbxfl16sq45s53fxw43i9i8lrdcc845714c1j5f84zi13ka08x";
+  };
+
+  meta = {
+    homepage = http://www.gnu.org/software/coreutils/;
+    description = "The basic file, shell and text manipulation utilities of the GNU operating system";
   };
-  patches = [ ./gnulib-futimens.patch ] ;
 }
diff --git a/pkgs/tools/misc/dosfstools/2.11deb.nix b/pkgs/tools/misc/dosfstools/2.11deb.nix
new file mode 100644
index 00000000000..13f327dcff5
--- /dev/null
+++ b/pkgs/tools/misc/dosfstools/2.11deb.nix
@@ -0,0 +1,33 @@
+args : with args; with builderDefs {src="";} null;
+    let patch = 
+        fetchurl {
+          url = http://ftp.de.debian.org/debian/pool/main/d/dosfstools/dosfstools_2.11-2.3.diff.gz;
+          sha256 = "0bzjhpgg4ih6c76ax8byis9vxgkr2c7bbbshqrkfq8j7ar48n5ld";
+        };	
+      localDefs = builderDefs (rec {
+        src = /* put a fetchurl here */
+          fetchurl {
+            url = http://ftp.de.debian.org/debian/pool/main/d/dosfstools/dosfstools_2.11.orig.tar.gz;
+            sha256 = "1154k0y04npblgac81p4pcmglilk1ldrqll4hvbrwgcb7096vb0f";
+          };
+	preBuild = FullDepEntry (''
+	  gunzip < ${patch} | patch -Np1
+	'')["minInit" "doUnpack"];
+
+        buildInputs = [];
+        configureFlags = [];
+	makeFlags = " PREFIX=$out ";
+    }) null; /* null is a terminator for sumArgs */
+    in with localDefs;
+stdenv.mkDerivation rec {
+    name = "dosfstools-"+version;
+    builder = writeScript (name + "-builder")
+        (textClosure localDefs 
+            [preBuild "doMakeInstall" doForceShare doPropagate]);
+    meta = {
+        description = "
+        Dosfstools - utilities for vfat file system.
+";
+	homepage = "http://sixpak.org/dosfstools/dosfstools-2.8vb2.tar.gz";
+    };
+}
diff --git a/pkgs/tools/misc/findutils/default.nix b/pkgs/tools/misc/findutils/default.nix
index 5aa28d0c451..acfbf90d946 100644
--- a/pkgs/tools/misc/findutils/default.nix
+++ b/pkgs/tools/misc/findutils/default.nix
@@ -1,10 +1,10 @@
 {stdenv, fetchurl, coreutils}:
 
 stdenv.mkDerivation {
-  name = "findutils-4.2.31";
+  name = "findutils-4.2.32";
   src = fetchurl {
-    url = mirror://gnu/findutils/findutils-4.2.31.tar.gz;
-    sha256 = "01329mrgg7pc2069hdbcl45jzrzvi94nnv1zf2hcrcx0mj7lplz0";
+    url = mirror://gnu/findutils/findutils-4.2.32.tar.gz;
+    sha256 = "05sj0154kl4mbqg7dcabiaa16snjv2ppfwwhcvl2zyn2yc28igc7";
   };
   buildInputs = [coreutils];
 
@@ -12,4 +12,9 @@ stdenv.mkDerivation {
     # Note: the dietlibc patch is just to get findutils to compile.
     # The locate command probably won't work though.
     ++ stdenv.lib.optional (stdenv ? isDietLibC) ./dietlibc-hack.patch;
+
+  meta = {
+    homepage = http://www.gnu.org/software/findutils/;
+    description = "The basic directory searching utilities of the GNU operating system";
+  };
 }
diff --git a/pkgs/tools/misc/grub/default.nix b/pkgs/tools/misc/grub/default.nix
index 87ba35566c0..9f021a66955 100644
--- a/pkgs/tools/misc/grub/default.nix
+++ b/pkgs/tools/misc/grub/default.nix
@@ -25,6 +25,7 @@ stdenv.mkDerivation {
 
   preConfigure = ''
     unpackFile $gentooPatches
+    rm patch/400_all_grub-0.97-reiser4-20050808-gentoo.patch
     for i in patch/*.patch; do
       echo "applying patch $i"
       patch -p1 < $i || patch -p0 < $i
diff --git a/pkgs/tools/misc/man-db/default.nix b/pkgs/tools/misc/man-db/default.nix
new file mode 100644
index 00000000000..54367e671ea
--- /dev/null
+++ b/pkgs/tools/misc/man-db/default.nix
@@ -0,0 +1,32 @@
+{stdenv, fetchurl, db4, groff}:
+ 
+stdenv.mkDerivation {
+  name = "man-db-2.5.1";
+  
+  src = fetchurl {
+    url = http://download.savannah.nongnu.org/releases/man-db/man-db-2.5.1.tar.gz;
+    sha256 = "178w1fk23ffh8vabj29cn0yyg5ps7bwy1zrrrcsw8aypbh3sfjy3";
+  };
+  
+  buildInputs = [db4 groff];
+  
+  configureFlags = ''
+    --disable-setuid
+    --with-nroff=${groff}/bin/nroff
+    --with-tbl=${groff}/bin/tbl
+    --with-eqn=${groff}/bin/eqn
+    --with-neqn=${groff}/bin/neqn
+  '';
+
+  troff = "${groff}/bin/troff";
+  
+  patches = [
+    # Search in "share/man" relative to each path in $PATH (in addition to "man").
+    ./share.patch
+  ];
+
+  meta = {
+    homepage = http://www.nongnu.org/man-db/;
+    description = "An implementation of the standard Unix documentation system accessed using the man command";
+  };
+}
diff --git a/pkgs/tools/misc/man-db/share.patch b/pkgs/tools/misc/man-db/share.patch
new file mode 100644
index 00000000000..95582a50269
--- /dev/null
+++ b/pkgs/tools/misc/man-db/share.patch
@@ -0,0 +1,110 @@
+diff -rc man-db-2.5.1-orig/src/manp.c man-db-2.5.1/src/manp.c
+*** man-db-2.5.1-orig/src/manp.c	2008-01-07 03:23:11.000000000 +0100
+--- man-db-2.5.1/src/manp.c	2008-02-07 14:20:20.000000000 +0100
+***************
+*** 96,102 ****
+  
+  static void mkcatdirs (const char *mandir, const char *catdir);
+  static inline char *get_manpath_from_path (const char *path);
+! static inline char *has_mandir (const char *p);
+  static inline char *fsstnd (const char *path);
+  static char *def_path (int flag);
+  static void add_dir_to_list (char **lp, const char *dir);
+--- 96,102 ----
+  
+  static void mkcatdirs (const char *mandir, const char *catdir);
+  static inline char *get_manpath_from_path (const char *path);
+! static inline char *has_mandir (const char *p, const char *mandir);
+  static inline char *fsstnd (const char *path);
+  static char *def_path (int flag);
+  static void add_dir_to_list (char **lp, const char *dir);
+***************
+*** 928,934 ****
+  		} else {
+  			debug ("is not in the config file\n");
+  
+! 		 	t = has_mandir (p);
+  		 	if (t) {
+  				debug ("but does have a ../man or man "
+  				       "subdirectory\n");
+--- 928,934 ----
+  		} else {
+  			debug ("is not in the config file\n");
+  
+! 		 	t = has_mandir (p, "man");
+  		 	if (t) {
+  				debug ("but does have a ../man or man "
+  				       "subdirectory\n");
+***************
+*** 938,943 ****
+--- 938,952 ----
+  		 	} else
+  				debug ("and doesn't have ../man or man "
+  				       "subdirectories\n");
++  
++  		 	t = has_mandir (p, "share/man");
++  		 	if (t) {
++                                 debug ("but does have a ../share/man or share/man subdirectory\n");
++  	
++  				add_dir_to_list (tmplist, t);
++  				free (t);
++  		 	} else
++  				debug ("and doesn't have ../share/man or share/man subdirectories\n");
+  		}
+  	}
+  
+***************
+*** 1013,1019 ****
+  
+  /* path does not exist in config file: check to see if path/../man or 
+     path/man exist.  If so return it, if not return NULL. */
+! static inline char *has_mandir (const char *path)
+  {
+  	char *newpath = NULL;
+  
+--- 1022,1028 ----
+  
+  /* path does not exist in config file: check to see if path/../man or 
+     path/man exist.  If so return it, if not return NULL. */
+! static inline char *has_mandir (const char *path, const char *mandir)
+  {
+  	char *newpath = NULL;
+  
+***************
+*** 1023,1031 ****
+  	char *subdir = strrchr (path, '/');
+  	if (subdir) {
+  		const int prefix_len = subdir + 1 - path;
+! 		newpath = xmalloc (prefix_len + sizeof ("man") + 1);
+  		strncpy (newpath, path, prefix_len);
+! 		strcpy (newpath + prefix_len, "man");
+  
+  		if (is_directory (newpath) == 1)
+  			return newpath;
+--- 1032,1040 ----
+  	char *subdir = strrchr (path, '/');
+  	if (subdir) {
+  		const int prefix_len = subdir + 1 - path;
+! 		newpath = xmalloc (prefix_len + strlen (mandir) + 2);
+  		strncpy (newpath, path, prefix_len);
+! 		strcpy (newpath + prefix_len, mandir);
+  
+  		if (is_directory (newpath) == 1)
+  			return newpath;
+***************
+*** 1033,1039 ****
+  			*newpath = '\0';
+  	}
+  
+! 	newpath = appendstr (newpath, path, "/man", NULL);
+  
+  	if (is_directory (newpath) == 1)
+  		return newpath;
+--- 1042,1048 ----
+  			*newpath = '\0';
+  	}
+  
+! 	newpath = appendstr (newpath, path, "/", mandir, NULL);
+  
+  	if (is_directory (newpath) == 1)
+  		return newpath;
diff --git a/pkgs/tools/misc/man/default.nix b/pkgs/tools/misc/man/default.nix
index deb0f83ad8a..490aa4606ab 100644
--- a/pkgs/tools/misc/man/default.nix
+++ b/pkgs/tools/misc/man/default.nix
@@ -1,15 +1,26 @@
-{stdenv, fetchurl, db4, groff}:
+{stdenv, fetchurl, groff, less}:
  
 stdenv.mkDerivation {
-  name = "man-2.4.3";
+  name = "man-1.6f";
+  
   src = fetchurl {
-    url = http://savannah.nongnu.org/download/man-db/man-db-2.4.3.tar.gz;
-    md5 = "30814a47f209f43b152659ba51fc7937";
+    url = http://primates.ximian.com/~flucifredi/man/man-1.6f.tar.gz;
+    sha256 = "0v2z6ywhy8kd2fa3ywkqayhjdivbaqn6qvhx93a1ldw135z8q84z";
   };
-  buildInputs = [db4 groff];
-  configureFlags = "--disable-setuid";
+  
+  buildInputs = [groff less];
+
+  preBuild = ''
+    makeFlagsArray=(bindir=$out/bin sbindir=$out/sbin libdir=$out/lib mandir=$out/share/man)
+  '';
+
   patches = [
     # Search in "share/man" relative to each path in $PATH (in addition to "man").
     ./share.patch
   ];
+
+  meta = {
+    homepage = http://primates.ximian.com/~flucifredi/man/;
+    description = "Tool to read online Unix documentation";
+  };
 }
diff --git a/pkgs/tools/misc/man/share.patch b/pkgs/tools/misc/man/share.patch
index 3367f4ceb61..837786e28eb 100644
--- a/pkgs/tools/misc/man/share.patch
+++ b/pkgs/tools/misc/man/share.patch
@@ -1,113 +1,116 @@
-diff -rc man-db-2.4.3/src/manp.c man-db-2.4.3-new/src/manp.c
-*** man-db-2.4.3/src/manp.c	Mon Nov  8 10:06:03 2004
---- man-db-2.4.3-new/src/manp.c	Tue Jan  9 17:08:31 2007
+diff -rc man-1.6f-orig/src/manpath.c man-1.6f/src/manpath.c
+*** man-1.6f-orig/src/manpath.c	2006-08-03 23:18:33.000000000 +0200
+--- man-1.6f/src/manpath.c	2008-02-07 15:31:43.000000000 +0100
 ***************
-*** 101,107 ****
-  
-  static void mkcatdirs (const char *mandir, const char *catdir);
-  static __inline__ char *get_manpath (char *path);
-! static __inline__ char *has_mandir (const char *p);
-  static __inline__ char *fsstnd (const char *path);
-  static char *def_path (int flag);
-  static void add_dir_to_list (char **lp, const char *dir);
---- 101,107 ----
-  
-  static void mkcatdirs (const char *mandir, const char *catdir);
-  static __inline__ char *get_manpath (char *path);
-! static __inline__ char *has_mandir (const char *p, const char *mandir);
-  static __inline__ char *fsstnd (const char *path);
-  static char *def_path (int flag);
-  static void add_dir_to_list (char **lp, const char *dir);
-***************
-*** 885,891 ****
-  			if (debug)
-  				fputs ("is not in the config file\n", stderr);
-  
-! 		 	t = has_mandir (p);
-  		 	if (t) {
-  				if (debug)
-  					fprintf (stderr, "but does have a ../man or man subdirectory\n");
---- 885,891 ----
-  			if (debug)
-  				fputs ("is not in the config file\n", stderr);
-  
-! 		 	t = has_mandir (p, "man");
-  		 	if (t) {
-  				if (debug)
-  					fprintf (stderr, "but does have a ../man or man subdirectory\n");
-***************
-*** 895,900 ****
---- 895,911 ----
-  		 	} else
-  				if (debug)
-  					fprintf (stderr, "and doesn't have ../man or man subdirectories\n");
-+ 
-+ 		 	t = has_mandir (p, "share/man");
-+ 		 	if (t) {
-+ 				if (debug)
-+ 					fprintf (stderr, "but does have a ../share/man or share/man subdirectory\n");
-+ 	
-+ 				add_dir_to_list (tmplist, t);
-+ 				free (t);
-+ 		 	}
-+ 				if (debug)
-+ 					fprintf (stderr, "and doesn't have ../share/man or share/man subdirectories\n");
-  		}
-  	}
+*** 109,121 ****
+   * or ../man or ../man1 or ../man8 subdirectories. 
+   */
+  static char *
+! find_man_subdir (char *p) {
+       int len;
+       char *t, *sp;
   
-***************
-*** 973,979 ****
+       len = strlen (p);
   
-  /* path does not exist in config file: check to see if path/../man or 
-     path/man exist.  If so return it, if not return NULL. */
-! static __inline__ char *has_mandir (const char *path)
-  {
-  	char *newpath = NULL;
+!      t = my_malloc ((unsigned) len + 20);
   
---- 984,990 ----
+       memcpy (t, p, len);
+       strcpy (t + len, "/man");
+--- 109,121 ----
+   * or ../man or ../man1 or ../man8 subdirectories. 
+   */
+  static char *
+! find_man_subdir (char *p, char * maybe_share) {
+       int len;
+       char *t, *sp;
   
-  /* path does not exist in config file: check to see if path/../man or 
-     path/man exist.  If so return it, if not return NULL. */
-! static __inline__ char *has_mandir (const char *path, const char *mandir)
-  {
-  	char *newpath = NULL;
+       len = strlen (p);
   
+!      t = my_malloc ((unsigned) len + 30);
+  
+       memcpy (t, p, len);
+       strcpy (t + len, "/man");
 ***************
-*** 983,991 ****
-  	char *subdir = strrchr (path, '/');
-  	if (subdir) {
-  		const int prefix_len = subdir + 1 - path;
-! 		newpath = xmalloc (prefix_len + sizeof ("man") + 1);
-  		strncpy (newpath, path, prefix_len);
-! 		strcpy (newpath + prefix_len, "man");
-  
-  		if (is_directory (newpath) == 1)
-  			return newpath;
---- 994,1002 ----
-  	char *subdir = strrchr (path, '/');
-  	if (subdir) {
-  		const int prefix_len = subdir + 1 - path;
-! 		newpath = xmalloc (prefix_len + strlen (mandir) + 2);
-  		strncpy (newpath, path, prefix_len);
-! 		strcpy (newpath + prefix_len, mandir);
-  
-  		if (is_directory (newpath) == 1)
-  			return newpath;
-***************
-*** 993,999 ****
-  			*newpath = '\0';
-  	}
+*** 139,159 ****
+       }
+  
+       /* look for the situation with packagedir/bin and packagedir/man */
+!      strcpy (t + len, "/man");
+  
+       if (is_directory (t) == 1)
+  	  return t;
+  
+       /* look for the situation with pkg/bin and pkg/man1 or pkg/man8 */
+       /* (looking for all man[1-9] would probably be a waste of stats) */
+!      strcpy (t + len, "/man1");
+  
+       if (is_directory (t) == 1) {
+  	  t[len] = 0;
+  	  return t;
+       }
   
-! 	newpath = strappend (newpath, path, "/man", NULL);
+!      strcpy (t + len, "/man8");
   
-  	if (is_directory (newpath) == 1)
-  		return newpath;
---- 1004,1010 ----
-  			*newpath = '\0';
-  	}
+       if (is_directory (t) == 1) {
+  	  t[len] = 0;
+--- 139,159 ----
+       }
   
-! 	newpath = strappend (newpath, path, "/", mandir, NULL);
+       /* look for the situation with packagedir/bin and packagedir/man */
+!      sprintf (t + len, "%s/man", maybe_share);
+  
+       if (is_directory (t) == 1)
+  	  return t;
+  
+       /* look for the situation with pkg/bin and pkg/man1 or pkg/man8 */
+       /* (looking for all man[1-9] would probably be a waste of stats) */
+!      sprintf (t + len, "%s/man1", maybe_share);
+  
+       if (is_directory (t) == 1) {
+  	  t[len] = 0;
+  	  return t;
+       }
+  
+!      sprintf (t + len, "%s/man8", maybe_share);
+  
+       if (is_directory (t) == 1) {
+  	  t[len] = 0;
+***************
+*** 341,347 ****
+          if (debug)
+              gripe (IS_NOT_IN_CONFIG);
+            
+!         t = find_man_subdir (dir);
+          if (t != NULL) {
+              if (debug)
+                  gripe (MAN_NEARBY);
+--- 341,347 ----
+          if (debug)
+              gripe (IS_NOT_IN_CONFIG);
+            
+!         t = find_man_subdir (dir, "");
+          if (t != NULL) {
+              if (debug)
+                  gripe (MAN_NEARBY);
+***************
+*** 352,357 ****
+--- 352,370 ----
+              if (debug)
+                  gripe (NO_MAN_NEARBY);
+          }
++ 
++         t = find_man_subdir (dir, "/share");
++         if (t != NULL) {
++             if (debug)
++                 gripe (MAN_NEARBY);
++               
++             add_to_mandirlist (t, perrs);
++             free (t);
++         } else {
++             if (debug)
++                 gripe (NO_MAN_NEARBY);
++         }
++ 
+      }
+  }
   
-  	if (is_directory (newpath) == 1)
-  		return newpath;
-Only in man-db-2.4.3-new/src: manp.c~
diff --git a/pkgs/tools/misc/mc/default.nix b/pkgs/tools/misc/mc/default.nix
index e5cce46bba8..8f03756a2d3 100644
--- a/pkgs/tools/misc/mc/default.nix
+++ b/pkgs/tools/misc/mc/default.nix
@@ -6,10 +6,15 @@ stdenv.mkDerivation rec {
     url = "http://www.ibiblio.org/pub/Linux/utils/file/managers/mc/${name}.tar.gz";
     sha256 = "0zly25mwdn84s0wqx9mzyqi177mm828716nv1n6a4a5cm8yv0sh8";
   };
-  buildInputs = [pkgconfig glib ncurses libX11];
+  buildInputs = [pkgconfig glib ncurses libX11 shebangfix perl zip];
   configureFlags = "--with-screen=ncurses";
+  makeFlags = "UNZIP=unzip";
+  postInstall = ''
+    find $out -iname "*.pl" | xargs shebangfix;
+  '';
   meta = {
-	  description = "File Manager and User Shell for the GNU Project";
-	  homepage = http://www.ibiblio.org/mc;
+    description = "File Manager and User Shell for the GNU Project";
+    homepage = http://www.ibiblio.org/mc;
   };
 }
+
diff --git a/pkgs/tools/misc/relfs/cvs.2007.12.01.nix b/pkgs/tools/misc/relfs/cvs.2007.12.01.nix
index aa0ee224169..83beb68151f 100644
--- a/pkgs/tools/misc/relfs/cvs.2007.12.01.nix
+++ b/pkgs/tools/misc/relfs/cvs.2007.12.01.nix
@@ -1,7 +1,7 @@
 args : with args;
 	let localDefs = builderDefs {
 	src = /* put a fetchurl here */
-	fetchcvs {
+	if args ? src then args.src else fetchcvs {
 		url = ":pserver:anonymous@relfs.cvs.sourceforge.net:/cvsroot/relfs";
 		module = "relfs";
 		date = "2007-12-01";
@@ -25,16 +25,16 @@ let build = FullDepEntry ("
 	mkdir -p \$out/bin
 	echo '
 		createuser -A -D \$1
-		dropdb relfs_\$1 ;
-		rm -rf /tmp/relfs-\$1-tmp;
-		mkdir /tmp/relfs-\$1-tmp;
-		USER=\$1 relfs -f -s /tmp/relfs-raskin-tmp  &
-		sleep 1 &&
+		dropdb relfs_\$1 ; 
+		rm -rf /tmp/relfs-\$1-tmp;  
+		mkdir /tmp/relfs-\$1-tmp;  
+		USER=\$1 relfs -f -s /tmp/relfs-raskin-tmp  & 
+		sleep 1 && 
 		kill -15 \${!};
-		rm -rf /tmp/relfs-\$1-tmp ;
-		psql -d relfs_\$1 <<< \"ALTER DATABASE relfs_raskin OWNER TO raskin;
-			ALTER TABLE obj OWNER TO \$1;
-			ALTER TABLE obj_mimetype OWNER TO \$1;
+		rm -rf /tmp/relfs-\$1-tmp ; 
+		psql -d relfs_\$1 <<< \"ALTER DATABASE relfs_raskin OWNER TO raskin; 
+			ALTER TABLE obj OWNER TO \$1; 
+			ALTER TABLE obj_mimetype OWNER TO \$1; 
 			ALTER TABLE membership OWNER TO \$1;\"' > \$out/bin/relfs_grant;
 	chmod a+x \$out/bin/relfs_grant;
 ") [minInit doUnpack addInputs];
diff --git a/pkgs/tools/misc/shebangfix/default.nix b/pkgs/tools/misc/shebangfix/default.nix
index f5ed86e99f7..ca4a0004d19 100644
--- a/pkgs/tools/misc/shebangfix/default.nix
+++ b/pkgs/tools/misc/shebangfix/default.nix
@@ -8,13 +8,14 @@ stdenv.mkDerivation {
 
   phases = "buildPhase";
 
-  buildPhase = "
-    ensureDir \$out/bin
-    s=\$out/bin/shebangfix
-    cp \$file \$s
-    chmod +x \$s
-    perl \$s \$s
-  ";
+  buildPhase = ''
+    ensureDir $out/bin
+    s=$out/bin/shebangfix
+    cp $file $s
+    chmod +wx $s
+    ls -l $s
+    perl $s $s
+  '';
 
   meta = { description = "replaces the #!executable with $#!correctpath/executable "; };
 }
diff --git a/pkgs/tools/networking/lsh/default.nix b/pkgs/tools/networking/lsh/default.nix
new file mode 100644
index 00000000000..087aeddf497
--- /dev/null
+++ b/pkgs/tools/networking/lsh/default.nix
@@ -0,0 +1,17 @@
+{stdenv, fetchurl, gperf, guile, gmp, zlib, liboop, gnum4}:
+
+stdenv.mkDerivation {
+  name = "lsh-2.0.4";
+  src = fetchurl {
+    url = http://www.lysator.liu.se/~nisse/archive/lsh-2.0.4.tar.gz;
+    sha256 = "614b9d63e13ad3e162c82b6405d1f67713fc622a8bc11337e72949d613713091";
+  };
+
+  buildInputs = [gperf guile gmp zlib liboop gnum4];
+
+  meta = {
+    description = "GNU lsh, a GPL'd implementation of the SSH protocol.";
+    homepage = http://www.lysator.liu.se/~nisse/lsh/;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/tools/networking/nc6/1.0.nix b/pkgs/tools/networking/nc6/1.0.nix
new file mode 100644
index 00000000000..1a28e3b0cad
--- /dev/null
+++ b/pkgs/tools/networking/nc6/1.0.nix
@@ -0,0 +1,25 @@
+args : with args; with builderDefs {src="";} null;
+let localDefs = builderDefs (rec {
+    src = /* put a fetchurl here */
+    fetchurl {
+      url = ftp://ftp.deepspace6.net/pub/ds6/sources/nc6/nc6-1.0.tar.bz2;
+      sha256 = "01l28zv1yal58ilfnz6albdzqqxzsx3a58vmc14r9gv0bahffdgb";
+    };
+
+    buildInputs = [];
+    configureFlags = [];
+    }) null; /* null is a terminator for sumArgs */
+in with localDefs;
+stdenv.mkDerivation rec {
+  name = "nc6-"+version;
+  builder = writeScript (name + "-builder")
+    (textClosure localDefs 
+     [doConfigure doMakeInstall doForceShare doPropagate]);
+  meta = {
+    description = "
+      nc6 - one more netcat, IPv6 support included.
+    ";
+    homepage = "http://www.deepspace6.net/projects/netcat6.html";
+  };
+}
+
diff --git a/pkgs/tools/networking/p2p/ktorrent/default.nix b/pkgs/tools/networking/p2p/ktorrent/default.nix
index a28189757b3..0c724f2ca5d 100644
--- a/pkgs/tools/networking/p2p/ktorrent/default.nix
+++ b/pkgs/tools/networking/p2p/ktorrent/default.nix
@@ -3,13 +3,21 @@
 }:
 
 stdenv.mkDerivation {
-  name = "ktorrent-2.2.1";
+  name = "ktorrent-2.2.5";
+  
   src = fetchurl {
-    url = http://ktorrent.pwsp.net/downloads/2.2.1/ktorrent-2.2.1.tar.gz;
-    sha256 = "1wv7y8p21fliys55hcbxgxndz6y7ilr3cqyz99y32sm0v6l7qpyd";
+    url = http://ktorrent.org/downloads/2.2.5/ktorrent-2.2.5.tar.bz2;
+    sha256 = "1rkblfpg4ysg4935i3l22ns553h37rn2flm4rgkqzdf67aq0akkx";
   };
+  
   buildInputs = [
     pkgconfig kdelibs kdelibs.qt xlibs.xlibs zlib libpng libjpeg perl gmp
   ];
+  
   configureFlags = "--without-arts";
+
+  meta = {
+    homepage = http://ktorrent.org/;
+    description = "A BitTorrent client for KDE";
+  };
 }
diff --git a/pkgs/tools/networking/socat/1.6.0.0.nix b/pkgs/tools/networking/socat/1.6.0.0.nix
new file mode 100644
index 00000000000..1e176f47720
--- /dev/null
+++ b/pkgs/tools/networking/socat/1.6.0.0.nix
@@ -0,0 +1,34 @@
+args : with args; with builderDefs {src="";} null;
+    let localDefs = builderDefs (rec {
+        src = /* put a fetchurl here */
+        fetchurl {
+            url = http://www.dest-unreach.org/socat/download/socat-1.6.0.0.tar.bz2;
+            sha256 = "1j01iazwfr63q71cfcfzrdz8digqlg3ldhlbb72yl5mn9awr0w0m";
+        };
+        patches = [
+          (fetchurl {
+              url = http://www.dest-unreach.org/socat/contrib/socat-servicenames.patch;
+              sha256 = "1r8zd6mk257n01i34i5syxl2k6fr35nlr7bqs9sfc79irjl62z66";
+          })
+          (fetchurl {
+              url = http://www.dest-unreach.org/socat/contrib/socat-maxfds.patch.gz;
+              sha256 = "0fsn0k0qsrdbjbhj09a6kxfsxb7yhxs4cad26znd9naginsj7pxa";
+          })
+        ];
+        buildInputs = [openssl];
+        configureFlags = [];
+    }) null; /* null is a terminator for sumArgs */
+    in with localDefs;
+stdenv.mkDerivation rec {
+    name = "socat-"+version;
+    builder = writeScript (name + "-builder")
+        (textClosure localDefs 
+            [doPatch doConfigure doMakeInstall doForceShare doPropagate]);
+    meta = {
+        description = "
+        Socat, one more analogue of netcat, but not mimicking it.
+	'netcat++' (extended design, new implementation)
+";
+        homepage = "http://www.dest-unreach.org/socat/";
+    };
+}
diff --git a/pkgs/tools/networking/socat/2.0.0-b1.nix b/pkgs/tools/networking/socat/2.0.0-b1.nix
new file mode 100644
index 00000000000..5fb3fee7879
--- /dev/null
+++ b/pkgs/tools/networking/socat/2.0.0-b1.nix
@@ -0,0 +1,25 @@
+args : with args; with builderDefs {src="";} null;
+    let localDefs = builderDefs (rec {
+        src = /* put a fetchurl here */
+        fetchurl {
+            url = http://www.dest-unreach.org/socat/download/socat-2.0.0-b1.tar.bz2;
+            sha256 = "0ybd5fw22icl10r33k987rskh9gvysm1jph90a1pfdjj57cy44fk";
+        };
+        
+        buildInputs = [openssl];
+        configureFlags = [];
+    }) null; /* null is a terminator for sumArgs */
+    in with localDefs;
+stdenv.mkDerivation rec {
+    name = "socat-"+version;
+    builder = writeScript (name + "-builder")
+        (textClosure localDefs 
+            [doPatch doConfigure doMakeInstall doForceShare doPropagate]);
+    meta = {
+        description = "
+        Socat, one more analogue of netcat, but not mimicking it.
+	'netcat++' (extended design, new implementation)
+";
+        homepage = "http://www.dest-unreach.org/socat/";
+    };
+}
diff --git a/pkgs/tools/networking/vpnc/builder.sh b/pkgs/tools/networking/vpnc/builder.sh
new file mode 100644
index 00000000000..ecfabe2eb5e
--- /dev/null
+++ b/pkgs/tools/networking/vpnc/builder.sh
@@ -0,0 +1,9 @@
+source "$stdenv/setup"
+
+tar zxvf "$src" &&
+cd vpnc-*.*
+
+cat config.c |								\
+sed "s|/etc/vpnc/vpnc-script|$out/etc/vpnc/vpnc-script|g" > ,,tmp &&	\
+mv ,,tmp config.c &&							\
+patchPhase && buildPhase && installPhase && fixupPhase && distPhase
diff --git a/pkgs/tools/networking/vpnc/default.nix b/pkgs/tools/networking/vpnc/default.nix
new file mode 100644
index 00000000000..c11a4721cb7
--- /dev/null
+++ b/pkgs/tools/networking/vpnc/default.nix
@@ -0,0 +1,20 @@
+{stdenv, fetchurl, libgcrypt, perl}:
+
+stdenv.mkDerivation {
+  name = "vpnc-0.5.1";
+  src = fetchurl {
+    url = http://www.unix-ag.uni-kl.de/~massar/vpnc/vpnc-0.5.1.tar.gz;
+    sha256 = "f63660bd020bbe6a39e8eb67ad60c54d719046c6198a6834371d098947f9a2ed";
+  };
+
+  patches = [ ./makefile.patch ];
+
+  buildInputs = [libgcrypt perl];
+  builder = ./builder.sh;
+
+  meta = {
+    description = "VPNC, a virtual private network (VPN) client for Cisco's VPN concentrators";
+    homepage = http://www.unix-ag.uni-kl.de/~massar/vpnc/;
+    license = "GPL";
+  };
+}
diff --git a/pkgs/tools/networking/vpnc/makefile.patch b/pkgs/tools/networking/vpnc/makefile.patch
new file mode 100644
index 00000000000..89a8cd6da95
--- /dev/null
+++ b/pkgs/tools/networking/vpnc/makefile.patch
@@ -0,0 +1,22 @@
+--- vpnc-0.5.1.orig/Makefile	2008-02-10 22:22:43.000000000 +0100
++++ vpnc-0.5.1/Makefile	2008-02-10 22:22:32.000000000 +0100
+@@ -20,8 +20,8 @@
+ # $Id: Makefile 236 2007-09-05 20:40:59Z Joerg Mayer $
+ 
+ DESTDIR=
+-PREFIX=/usr/local
+-ETCDIR=/etc/vpnc
++PREFIX=$(out)
++ETCDIR=$(out)/etc/vpnc
+ BINDIR=$(PREFIX)/bin
+ SBINDIR=$(PREFIX)/sbin
+ MANDIR=$(PREFIX)/share/man
+@@ -71,7 +71,7 @@
+ 	$(CC) -o $@ $^ $(LDFLAGS)
+ 
+ vpnc.8 : vpnc.8.template makeman.pl vpnc
+-	./makeman.pl
++	perl makeman.pl
+ 
+ cisco-decrypt : cisco-decrypt.o config.o supp.o sysdep.o vpnc-debug.o
+ 	$(CC) -o $@ $^ $(LDFLAGS)
diff --git a/pkgs/tools/package-management/nix/unstable.nix b/pkgs/tools/package-management/nix/unstable.nix
index a204b10f1f5..1a507f20a04 100644
--- a/pkgs/tools/package-management/nix/unstable.nix
+++ b/pkgs/tools/package-management/nix/unstable.nix
@@ -3,14 +3,14 @@
 , stateDir ? "/nix/var"
 }:
 
-let version = "0.12pre10389"; in
+let version = "0.12pre10505"; in
 
 stdenv.mkDerivation {
   name = "nix-${version}";
   
   src = fetchurl {
     url = "http://nix.cs.uu.nl/dist/nix/nix-${version}/nix-${version}.tar.bz2";
-    md5 = "5824debe60299ebc9c5aa6532e6a8b67";
+    md5 = "44dd2927ce97f12b3f110a7ad991828e";
   };
 
   buildInputs = [perl curl openssl];
diff --git a/pkgs/tools/package-management/snix/default.nix b/pkgs/tools/package-management/snix/default.nix
new file mode 100644
index 00000000000..caf852de4e2
--- /dev/null
+++ b/pkgs/tools/package-management/snix/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, fetchurl, aterm, db4, perl, curl, bzip2, openssl ? null
+
+, ext3cowtools, e3cfsprogs, rsync
+#, libtool, docbook5, docbook5-xsl, flex, bison
+
+, ext3cow_kernel
+
+, storeDir ? "/nix/store"
+, stateDir ? "/nix/var"
+, nixStoreStateDir ? "/nix/state"
+}:
+
+stdenv.mkDerivation {
+  name = "snix-0.12rev9419";
+  
+  src = fetchurl {
+    url = http://www.denbreejen.net/public/nix/snix-0.12rev9419.tar.gz;
+    sha256 = "fe7c06a8c41f6c9c94898a5fd690ed76da397012ea4c624adac9029b23c88a1c";
+  };
+  
+  buildInputs = [perl curl openssl rsync];
+
+  configureFlags = "
+    --with-store-dir=${storeDir} --localstatedir=${stateDir}
+    --with-aterm=${aterm} --with-bdb=${db4} --with-bzip2=${bzip2}
+    --disable-init-state
+    --with-store-state-dir=${nixStoreStateDir}
+    --with-ext3cow-header=${ext3cow_kernel}/lib/modules/2.*/build/include/linux/ext3cow_fs.h
+    --with-rsync=${rsync}/bin/rsync";
+
+  meta = {
+    description = "The SNix Deployment System (Nix extended to handle state)";
+    homepage = http://nix.cs.uu.nl/;
+    license = "LGPL";
+  };
+}
diff --git a/pkgs/tools/system/cron/default.nix b/pkgs/tools/system/cron/default.nix
index 066f594ea84..4d7dcb93db2 100644
--- a/pkgs/tools/system/cron/default.nix
+++ b/pkgs/tools/system/cron/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
   unpackCmd = "(mkdir cron && cd cron && sh $src)";
 
   preBuild = "
-    substituteInPlace Makefile --replace '-o root' '' --replace 111 755
+    substituteInPlace Makefile --replace ' -o root' ' ' --replace 111 755
     makeFlags=\"DESTROOT=$out\"
   ";
 
diff --git a/pkgs/tools/system/which/default.nix b/pkgs/tools/system/which/default.nix
index 67ddaa94295..b6c35c4fbf1 100644
--- a/pkgs/tools/system/which/default.nix
+++ b/pkgs/tools/system/which/default.nix
@@ -1,5 +1,4 @@
-args: with args;
-stdenv.mkDerivation {
+{stdenv, fetchurl, readline}: stdenv.mkDerivation {
   name = "which-2.19";
   src = fetchurl {
     url = mirror://gnu/which/which-2.19.tar.gz;
@@ -8,3 +7,6 @@ stdenv.mkDerivation {
 
   buildInputs = [readline];
 }
+
+
+
diff --git a/pkgs/tools/text/diffutils/default.nix b/pkgs/tools/text/diffutils/default.nix
index 3c0d5479ec5..44b7715607c 100644
--- a/pkgs/tools/text/diffutils/default.nix
+++ b/pkgs/tools/text/diffutils/default.nix
@@ -2,10 +2,17 @@
 
 stdenv.mkDerivation {
   name = "diffutils-2.8.1";
+  
   src = fetchurl {
     url = mirror://gnu/diffutils/diffutils-2.8.1.tar.gz;
     md5 = "71f9c5ae19b60608f6c7f162da86a428";
   };
+  
   /* If no explicit coreutils is given, use the one from stdenv. */
   buildInputs = [coreutils];
+
+  meta = {
+    homepage = http://www.gnu.org/software/diffutils/diffutils.html;
+    description = "Commands for showing the differences between files (diff, cmp, etc.)";
+  };
 }
diff --git a/pkgs/tools/text/gawk/default.nix b/pkgs/tools/text/gawk/default.nix
index b50b3aa9bd0..10dd08214af 100644
--- a/pkgs/tools/text/gawk/default.nix
+++ b/pkgs/tools/text/gawk/default.nix
@@ -2,8 +2,14 @@
 
 stdenv.mkDerivation {
   name = "gawk-3.1.6";
+  
   src = fetchurl {
     url = mirror://gnu/gawk/gawk-3.1.6.tar.bz2;
     sha256 = "0v6ba4hxfiiy3bny5japd3zmzxlh8vdkmswk96yngd6i1dddsgsi";
   };
+
+  meta = {
+    homepage = http://www.gnu.org/software/gawk/;
+    description = "GNU implementation of the AWK programming language";
+  };
 }
diff --git a/pkgs/tools/text/gnugrep/default.nix b/pkgs/tools/text/gnugrep/default.nix
index 6979e4a1b01..9b36dad6cfe 100644
--- a/pkgs/tools/text/gnugrep/default.nix
+++ b/pkgs/tools/text/gnugrep/default.nix
@@ -2,9 +2,16 @@
 
 stdenv.mkDerivation {
   name = "gnugrep-2.5.3";
+  
   src = fetchurl {
     url = http://nix.cs.uu.nl/dist/tarballs/grep-2.5.3-with-info.tar.bz2;
     sha256 = "0rg9dipksqzbg8v1xalib1n3xkkycc5r1l2gb9cxy1cz3cjip5l8";
   };
+  
   buildInputs = [pcre];
+
+  meta = {
+    homepage = http://www.gnu.org/software/grep/;
+    description = "GNU implementation of the Unix grep command";
+  };
 }
diff --git a/pkgs/tools/text/gnused/default.nix b/pkgs/tools/text/gnused/default.nix
index c70cf022570..2425147688b 100644
--- a/pkgs/tools/text/gnused/default.nix
+++ b/pkgs/tools/text/gnused/default.nix
@@ -2,10 +2,17 @@
 
 stdenv.mkDerivation {
   name = "gnused-4.1.5";
+  
   src = fetchurl {
     url = mirror://gnu/sed/sed-4.1.5.tar.gz;
     md5 = "7a1cbbbb3341287308e140bd4834c3ba";
   };
+  
   # !!! hack: this should go away in gnused > 4.1.5
   patches = [./gettext-fix.patch];
+
+  meta = {
+    homepage = http://www.gnu.org/software/grep/;
+    description = "GNU implementation of the Unix sed command";
+  };
 }
diff --git a/pkgs/tools/text/replace/default.nix b/pkgs/tools/text/replace/default.nix
index 3135204ef03..ca96309e40e 100644
--- a/pkgs/tools/text/replace/default.nix
+++ b/pkgs/tools/text/replace/default.nix
@@ -1,4 +1,5 @@
 {stdenv, fetchurl}:
+
 stdenv.mkDerivation {
   name = "replace-2.24";
 
@@ -7,14 +8,12 @@ stdenv.mkDerivation {
     sha256 = "1c2nkxx83vmlh1v3ib6r2xqh121gdb1rharwsimcb2h0xwc558dm";
   };
 
-  buildInputs = [];
-  makeFlags = " TREE=\$(out) ";
+  makeFlags = "TREE=\$(out)";
 
   postInstall = "mv \$out/bin/replace \$out/bin/replace-literal";
 
   meta = {
-    description = "
-	Replace verbatim strings. Sed is not fit to do it. Replace is.
-";
+    homepage = http://replace.richardlloyd.org.uk/;
+    description = "A tool to replace verbatim strings";
   };
 }
diff --git a/pkgs/tools/typesetting/lout/builder.sh b/pkgs/tools/typesetting/lout/builder.sh
new file mode 100755
index 00000000000..28788fc5227
--- /dev/null
+++ b/pkgs/tools/typesetting/lout/builder.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# Prepare a makefile specifying the appropriate output directories.
+#
+# Written by Ludovic Courtès <ludo@gnu.org>.
+
+source "$stdenv/setup" || exit 1
+
+nixMakefile="nix-makefile"
+
+# Build and install documentation, PS and PDF.
+installDoc ()
+{
+  echo "building and installing documentation..."
+  for doc in design expert slides user
+  do
+    echo "building \`$doc' document..."
+    if [ ! -f "doc/$doc/outfile.ps" ]
+    then
+      ( PATH="$PWD:$PATH" ;				\
+        cd "doc/$doc" && lout -r4 -o outfile.ps all )	\
+      || return 1
+    fi
+    cp "doc/$doc/outfile.ps" "$out/doc/lout/$doc.ps" &&		\
+    ps2pdf "doc/$doc/outfile.ps" "$out/doc/lout/$doc.pdf"
+  done
+
+  return 0
+}
+
+unpackPhase &&									\
+cd lout-*.* &&									\
+cat makefile |									\
+  sed -e "s|^PREFIX[[:blank:]]*=.*\$|PREFIX = $out|g ;				\
+          s|^LOUTLIBDIR[[:blank:]]*=.*$|LOUTLIBDIR = \$(PREFIX)/lib/lout|g ;	\
+	  s|^LOUTDOCDIR[[:blank:]]*=.*$|LOUTDOCDIR = \$(PREFIX)/doc/lout|g ;	\
+	  s|^MANDIR[[:blank:]]*=.*$|MANDIR = \$(PREFIX)/man|g"			\
+  > "$nixMakefile" &&								\
+mkdir -p "$out/bin" && mkdir -p "$out/lib"					\
+mkdir -p "$out/man" && mkdir -p "$out/doc/lout" &&				\
+make -f "$nixMakefile" install installman &&					\
+installDoc
diff --git a/pkgs/tools/typesetting/lout/default.nix b/pkgs/tools/typesetting/lout/default.nix
new file mode 100644
index 00000000000..e36cc9ad303
--- /dev/null
+++ b/pkgs/tools/typesetting/lout/default.nix
@@ -0,0 +1,20 @@
+{stdenv, fetchurl, ghostscript}:
+
+stdenv.mkDerivation {
+  name = "lout-3.36";
+  src = fetchurl {
+    url = ftp://ftp.cs.usyd.edu.au/jeff/lout/lout-3.36.tar.gz;
+    sha256 = "b689cbe12074be8817c90070b162593fc9cc51f2f8868701833ff599b24fd4ad";
+  };
+
+  buildInputs = [ ghostscript ];
+  builder = ./builder.sh;
+
+  meta = {
+    description = ''Lout is a document layout system, similar in functionality
+    		    to TeX/LaTeX, but based on a purely functional programming
+		    language.  It can produce PostScript output.'';
+    homepage = http://www.cs.usyd.edu.au/~jeff/;
+    license = "GPL";
+  };
+}