diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,36 @@
+Copyright (c) 2009, Andy Gimblett, Andy Price
+All rights reserved.
+
+Developed by:
+
+    Andy Gimblett <haskell@gimbo.org.uk>
+    Andy Price <andy@andrewprice.me.uk>
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditi ons and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+
+    * Neither the names of Andy Price, Andy Gimblett, nor the names of
+      its contributors may be used to endorse or promote products
+      derived from this software without specific prior written
+      permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/docidx.cabal b/docidx.cabal
new file mode 100644
--- /dev/null
+++ b/docidx.cabal
@@ -0,0 +1,45 @@
+name:                   docidx
+version:                1.0.0
+license:                BSD3
+license-file:           LICENSE
+category:               Documentation
+copyright:              Andy Gimblett <haskell@gimbo.org.uk>, Andy Price <andy@andrewprice.me.uk>
+author:                 Andy Gimblett <haskell@gimbo.org.uk>, Andy Price <andy@andrewprice.me.uk>
+maintainer:             Andy Gimblett <haskell@gimbo.org.uk>
+synopsis:               Generate an HTML index of installed Haskell packages and their documentation.
+cabal-Version:          >=1.6
+homepage:               http://github.com/gimbo/docidx.hs
+bug-reports:            http://github.com/gimbo/docidx.hs/issues
+build-type:             Simple
+description:
+
+    docidx is a small tool which creates an HTML index of your
+    installed Haskell packages, with links to each package's Haddock
+    docs locally and on Hackage.  While "cabal install" now creates
+    and maintains an index by module, sometimes it's nice to have this
+    other view (and the quick links to Hackage).
+
+    docidx queries your global and user package databases (via
+    ghc-pkg, via the Cabal package), to build an index of all
+    installed packages - including version numbers where more than one
+    version is present, package synopses, links to the local Haddock
+    docs, and a link to the package on Hackage.
+
+    Packages are grouped by first letter, and there's an A-Z index at
+    the top of the page, which can be easily extended via a config
+    file to include extra links you think are handy - e.g. to the
+    per-module index, to local ghc documentation, to the Haskell
+    report, etc. - whatever you want).
+
+executable docidx
+  hs-source-dirs:       src
+  main-is:              docidx.hs
+  build-depends:        base >= 4 && < 5, Cabal >= 1.8, containers >= 0.3,
+                        directory >= 1.0, filepath >= 1.1, html >= 1.0,
+                        MissingH >= 1.1, mtl >= 2, old-locale, tagsoup >= 0.11,
+                        time >= 1.1
+  ghc-options:          -fwarn-tabs -Wall
+
+source-repository head
+  type:     git
+  location: http://github.com/gimbo/docidx.hs
diff --git a/src/docidx.hs b/src/docidx.hs
new file mode 100644
--- /dev/null
+++ b/src/docidx.hs
@@ -0,0 +1,30 @@
+#!/usr/bin/env runhaskell
+
+{-
+
+A tidy rewrite of an ugly Haskell port of a "horribly hacked together"
+Python script to generate an HTML index page for Haddock-generated
+Haskell package docs. It also works quite nicely as a general index
+for other docs. Note that the docs directory is hard-coded, below: see
+the comments there.
+
+Forked from: <http://github.com/andyprice/docidx.hs> which was ported
+from the python at: <http://gimbo.org.uk/blog/2009/09/23/>
+
+-}
+
+import Data.Time
+import System.Environment
+
+import Distribution.DocIdx.Config
+import Distribution.DocIdx.Html
+import Distribution.GhcPkgList
+
+main :: IO ()
+main = do
+  pkgs <- installedPackages
+  now <- getCurrentTime
+  config <- getConfig
+  let page = htmlPage config pkgs now
+  args <- getArgs
+  if not (null args) then writeFile (head args) page else putStrLn page
