diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2008, Maximilian Bolingbroke
+All rights reserved.
+
+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
+      conditions 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 name of Maximilian Bolingbroke nor the names of other 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 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/Network/HostName.hs b/Network/HostName.hs
new file mode 100644
--- /dev/null
+++ b/Network/HostName.hs
@@ -0,0 +1,48 @@
+module Network.HostName (
+    HostName, getHostName
+  ) where
+
+import Foreign.C.Error
+import Foreign.C.String
+import Foreign.C.Types
+import Foreign.Marshal.Array
+
+#ifdef WINDOWS
+
+import Foreign.Marshal.Utils
+import Foreign.Ptr
+import Foreign.Storable
+
+import System.Win32.Types
+
+foreign import stdcall unsafe "windows.h GetComputerNameExW" getComputerNameEx :: COMPUTER_NAME_FORMAT -> LPTSTR -> LPDWORD -> IO BOOL
+
+type COMPUTER_NAME_FORMAT = CInt
+
+computerNamePhysicalDnsHostname :: COMPUTER_NAME_FORMAT
+computerNamePhysicalDnsHostname = 5
+
+getHostName :: IO HostName
+getHostName = with 0 $ \p_charcount -> do
+    -- On the first run, determine the character count and ignore any error we get
+    _ <- getComputerNameEx computerNamePhysicalDnsHostname nullPtr p_charcount
+    charcount <- peek p_charcount
+    
+    -- The second time around, use the correct character count to retrieve the data
+    withTString (replicate (fromIntegral charcount) ' ') $ \name -> do
+        failIfFalse_ "GetComputerNameExW" $ getComputerNameEx computerNamePhysicalDnsHostname name p_charcount
+        peekTString name
+
+#else
+
+foreign import ccall unsafe "gethostname" gethostname :: CString -> CSize -> IO CInt
+
+getHostName :: IO HostName
+getHostName = allocaArray0 size $ \cstr -> do
+        throwErrnoIfMinus1_ "getHostName" $ gethostname cstr (fromIntegral size)
+        peekCString cstr
+    where size = 256
+
+#endif
+
+type HostName = String
diff --git a/Setup.lhs b/Setup.lhs
new file mode 100644
--- /dev/null
+++ b/Setup.lhs
@@ -0,0 +1,4 @@
+#! /usr/bin/env runhaskell
+
+> import Distribution.Simple
+> main = defaultMain
diff --git a/hostname.cabal b/hostname.cabal
new file mode 100644
--- /dev/null
+++ b/hostname.cabal
@@ -0,0 +1,22 @@
+Name:               hostname
+Version:            1.0
+Cabal-Version:      >= 1.2
+Category:           Network
+Synopsis:           A very simple package providing a cross-platform means of determining the hostname
+License:            BSD3
+License-File:       LICENSE
+Author:             Max Bolingbroke <batterseapower@hotmail.com>
+Maintainer:         Max Bolingbroke <batterseapower@hotmail.com>
+Build-Type:         Simple
+
+Library
+        Exposed-Modules: Network.HostName
+                         
+        Build-Depends:   base >= 3 && < 5
+                         
+        Extensions:      CPP, ForeignFunctionInterface
+        
+        if os(windows)
+                         Build-Depends:   Win32 >= 2.0
+                         Cpp-Options:     -DWINDOWS
+                         Extra-Libraries: "kernel32"
