diff --git a/Distribution/VcsRevision.hs b/Distribution/VcsRevision.hs
new file mode 100644
--- /dev/null
+++ b/Distribution/VcsRevision.hs
@@ -0,0 +1,16 @@
+-- | Example usage in a program that wants to access its own git version:
+-- 
+-- > {-# LANGUAGE TemplateHaskell #-}
+-- > import Distribution.VcsRevision.Git
+-- > import Language.Haskell.TH.Syntax
+-- >
+-- > showMyGitVersion :: String
+-- > showMyGitVersion = $(do
+-- >   v <- qRunIO getRevision
+-- >   lift $ case v of
+-- >     Nothing           -> "<none>"
+-- >     Just (hash,True)  -> hash ++ " (with local modifications)"
+-- >     Just (hash,False) -> hash)
+--   
+module Distribution.VcsRevision () where
+
diff --git a/Distribution/VcsRevision/Git.hs b/Distribution/VcsRevision/Git.hs
new file mode 100644
--- /dev/null
+++ b/Distribution/VcsRevision/Git.hs
@@ -0,0 +1,14 @@
+module Distribution.VcsRevision.Git ( getRevision ) where
+
+import System.Process
+import System.Exit
+
+-- | Nothing if we're not in a git repo, Just (hash,modified) if we're in a repo.
+getRevision :: IO (Maybe (String, Bool))
+getRevision = do
+    (exit,commit,_) <- readProcessWithExitCode "git" ["log", "--format=%h", "-n", "1"] ""
+    case exit of
+        ExitSuccess -> do
+          (exit',_,_) <- readProcessWithExitCode "git" ["diff", "--quiet"] ""
+          return $ Just (init commit, exit' /= ExitSuccess)
+        _ -> return Nothing
diff --git a/Distribution/VcsRevision/Mercurial.hs b/Distribution/VcsRevision/Mercurial.hs
new file mode 100644
--- /dev/null
+++ b/Distribution/VcsRevision/Mercurial.hs
@@ -0,0 +1,13 @@
+module Distribution.VcsRevision.Mercurial ( getRevision ) where
+
+import System.Process
+import System.Exit
+
+-- | Nothing if we're not in a mercurial repo, Just (hash,modified) if we're in a repo.
+getRevision :: IO (Maybe (String, Bool))
+getRevision = do
+    (exit,out,_) <- readProcessWithExitCode "hg" ["identify", "-i"] ""
+    case (exit,init out,last (init out)) of
+        (ExitSuccess,hash,'+') -> return $ Just (init hash, True)
+        (ExitSuccess,hash,_)   -> return $ Just (hash, False)
+        (ExitFailure _,_,_)    -> return Nothing
diff --git a/Distribution/VcsRevision/Svn.hs b/Distribution/VcsRevision/Svn.hs
new file mode 100644
--- /dev/null
+++ b/Distribution/VcsRevision/Svn.hs
@@ -0,0 +1,17 @@
+module Distribution.VcsRevision.Svn ( getRevision ) where
+
+import System.Process
+import System.Exit
+import Data.List
+
+-- | Nothing if we're not in a svn repo, Just (revision,modified) if we're in a repo.
+getRevision :: IO (Maybe (String, Bool))
+getRevision = do
+    (exit,info,_) <- readProcessWithExitCode "svn" ["info"] ""
+    case exit of
+        ExitSuccess -> do
+          let prefix = "Last Changed Rev: "
+          let rev = drop (length prefix) $ head $ filter (prefix `isPrefixOf`) (lines info)
+          (_,out,_) <- readProcessWithExitCode "svn" ["st", "-q"] ""
+          return $ Just (rev, out /= "")
+        _ -> return Nothing
diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,23 @@
+Copyright (c) 2009, Eugene Kirpichov
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+   this list of conditions and the following disclaimer.
+2. 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.
+
+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 OWNER 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/vcs-revision.cabal b/vcs-revision.cabal
new file mode 100644
--- /dev/null
+++ b/vcs-revision.cabal
@@ -0,0 +1,37 @@
+Name: vcs-revision
+Category: System, Data, Parsing
+Version: 0.0.1
+Cabal-version: >= 1.2
+Build-type: Simple
+Copyright: Eugene Kirpichov
+Maintainer: ekirpichov@gmail.com    
+Author: Eugene Kirpichov
+License: BSD3
+License-File: LICENSE
+Synopsis: 
+  Facilities for accessing the version control revision of the current directory.
+Description:
+  Facilities for accessing the version control revision of the current directory.
+  Useful e.g. to make your program output its revision using Template Haskell.
+Cabal-Version: >= 1.6
+
+Source-repository head
+  type: git
+  location: git://github.com/jkff/vcs-revision
+
+Flag split-base
+
+Library
+  if flag(split-base)
+    Build-depends: base >= 3.0 && < 5.0
+  else
+    Build-depends: base < 3.0
+  Build-Depends: process
+  Exposed-modules: 
+    Distribution.VcsRevision
+    Distribution.VcsRevision.Git
+    Distribution.VcsRevision.Mercurial
+    Distribution.VcsRevision.Svn
+--    Distribution.VcsRevision.Cvs
+--    Distribution.VcsRevision.Darcs
+
