From 72124a0aa98c272629342388c457050e2d44c978 Mon Sep 17 00:00:00 2001
From: Russell O'Connor <roconnor@theorem.ca>
Date: Sun, 27 Mar 2011 06:44:34 +0000
Subject: [PATCH] Bitcoin.

svn path=/nixpkgs/trunk/; revision=26544
---
 pkgs/applications/misc/bitcoin/default.nix    | 50 +++++++++++++++++++
 pkgs/development/libraries/db4/db4-4.7.nix    | 18 +++++++
 pkgs/development/libraries/db4/db4-4.8.nix    | 18 +++++++
 .../development/libraries/wxGTK-2.9/2.9.0.nix | 46 +++++++++++++++++
 pkgs/top-level/all-packages.nix               | 14 ++++++
 5 files changed, 146 insertions(+)
 create mode 100644 pkgs/applications/misc/bitcoin/default.nix
 create mode 100644 pkgs/development/libraries/db4/db4-4.7.nix
 create mode 100644 pkgs/development/libraries/db4/db4-4.8.nix
 create mode 100644 pkgs/development/libraries/wxGTK-2.9/2.9.0.nix

diff --git a/pkgs/applications/misc/bitcoin/default.nix b/pkgs/applications/misc/bitcoin/default.nix
new file mode 100644
index 000000000000..d66ccf7cb584
--- /dev/null
+++ b/pkgs/applications/misc/bitcoin/default.nix
@@ -0,0 +1,50 @@
+{ fetchurl, stdenv, openssl, db4, boost, zlib, glib, libSM, gtk, wxGTK }:
+
+stdenv.mkDerivation rec {
+  version = "0.3.20.2";
+  name = "bitcoin-${version}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/project/bitcoin/Bitcoin/bitcoin-0.3.20/bitcoin-0.3.20.2-linux.tar.gz";
+    sha256 = "1maq75myqkyngfi9ngaw6kv6nfia5wsjj2zjhns75k3wxhmvgpw5";
+  };
+
+  buildInputs = [ openssl db4 boost zlib glib libSM gtk wxGTK ];
+
+  preConfigure = ''
+    cd src
+    mkdir obj
+    mkdir obj/nogui
+    substituteInPlace makefile.unix \
+      --replace "-Wl,-Bstatic" "" \
+      --replace "-Wl,-Bdynamic" "" \
+      --replace "-mt \\" " \\" \
+      --replace "-l wx_gtk2ud-2.9" "-l wx_gtk2u_core-2.9 -l wx_gtk2u_html-2.9 -l wx_gtk2u_adv-2.9" \
+      --replace "DEBUGFLAGS=-g -D__WXDEBUG__" "DEBUGFLAGS=" \
+      --replace "/usr/local/include/wx-2.9" "${wxGTK}/include/wx-2.9" \
+      --replace "/usr/local/lib/wx/include/gtk2-unicode-debug-static-2.9" "${wxGTK}/lib/wx/include/gtk2-unicode-release-2.9"
+  '';
+
+  makefile = "makefile.unix";
+
+  buildFlags = "bitcoin bitcoind";
+
+  installPhase = ''
+    ensureDir $out/bin
+    cp bitcoin $out/bin
+    cp bitcoind $out/bin
+  '';
+
+  meta = { 
+      description = "Bitcoin is a peer-to-peer currency";
+      longDescription=''
+Bitcoin is a free open source peer-to-peer electronic cash system that is
+completely decentralized, without the need for a central server or trusted
+parties.  Users hold the crypto keys to their own money and transact directly
+with each other, with the help of a P2P network to check for double-spending.
+      '';
+      homepage = "http://www.bitcoin.org/";
+      maintainers = [ stdenv.lib.maintainers.roconnor ];
+      license = "MIT";
+  };
+}
diff --git a/pkgs/development/libraries/db4/db4-4.7.nix b/pkgs/development/libraries/db4/db4-4.7.nix
new file mode 100644
index 000000000000..9fb0d6587c0f
--- /dev/null
+++ b/pkgs/development/libraries/db4/db4-4.7.nix
@@ -0,0 +1,18 @@
+{stdenv, fetchurl, cxxSupport ? true, compat185 ? true}:
+
+stdenv.mkDerivation {
+  name = "db4-4.7.25";
+  
+  builder = ./builder.sh;
+  
+  src = fetchurl {
+    url = http://download-east.oracle.com/berkeley-db/db-4.7.25.tar.gz;
+    sha256 = "0gi667v9cw22c03hddd6xd6374l0pczsd56b7pba25c9sdnxjkzi";
+  };
+  
+  configureFlags = [
+    (if cxxSupport then "--enable-cxx" else "--disable-cxx")
+    (if compat185 then "--enable-compat185" else "--disable-compat185")
+  ];
+  
+}
diff --git a/pkgs/development/libraries/db4/db4-4.8.nix b/pkgs/development/libraries/db4/db4-4.8.nix
new file mode 100644
index 000000000000..5b99f068769a
--- /dev/null
+++ b/pkgs/development/libraries/db4/db4-4.8.nix
@@ -0,0 +1,18 @@
+{stdenv, fetchurl, cxxSupport ? true, compat185 ? true}:
+
+stdenv.mkDerivation {
+  name = "db4-4.8.26";
+  
+  builder = ./builder.sh;
+  
+  src = fetchurl {
+    url = http://download-east.oracle.com/berkeley-db/db-4.8.26.tar.gz;
+    sha256 = "0hcxh0kb6m0wk3apjhs57p7b171zzn63rg4l3nkcavygg5gx2mgp";
+  };
+  
+  configureFlags = [
+    (if cxxSupport then "--enable-cxx" else "--disable-cxx")
+    (if compat185 then "--enable-compat185" else "--disable-compat185")
+  ];
+  
+}
diff --git a/pkgs/development/libraries/wxGTK-2.9/2.9.0.nix b/pkgs/development/libraries/wxGTK-2.9/2.9.0.nix
new file mode 100644
index 000000000000..433f7fe2187d
--- /dev/null
+++ b/pkgs/development/libraries/wxGTK-2.9/2.9.0.nix
@@ -0,0 +1,46 @@
+{ stdenv, fetchurl, pkgconfig, gtk, libXinerama, libSM, libXxf86vm, xf86vidmodeproto
+, mesa, compat24 ? false, compat26 ? true, unicode ? true,
+}:
+
+assert pkgconfig != null && gtk != null;
+assert gtk.libtiff != null;
+assert gtk.libjpeg != null;
+assert gtk.libpng != null;
+assert gtk.libpng.zlib != null;
+
+stdenv.mkDerivation {
+  name = "wxwidgets-2.9.0";
+
+  src = fetchurl {
+    url = mirror://sourceforge/wxwindows/wxWidgets-2.9.0.tar.bz2;
+    sha256 = "10n75mpypd9411b29gxmi0g2s7dgbfwkgiyhxwkjsyrmyvfc3xcc";
+  };
+
+  buildInputs = [
+    pkgconfig gtk gtk.libtiff gtk.libjpeg gtk.libpng gtk.libpng.zlib
+    libXinerama libSM libXxf86vm xf86vidmodeproto mesa
+  ];
+
+  configureFlags = [
+    "--enable-gtk2"
+    (if compat24 then "--enable-compat24" else "--disable-compat24")
+    (if compat26 then "--enable-compat26" else "--disable-compat26")
+    "--disable-precomp-headers"
+    (if unicode then "--enable-unicode" else "")
+    "--with-opengl"
+  ];
+
+  SEARCH_LIB = "${mesa}/lib";
+
+  preConfigure = "
+    substituteInPlace configure --replace 'SEARCH_INCLUDE=' 'DUMMY_SEARCH_INCLUDE='
+    substituteInPlace configure --replace 'SEARCH_LIB=' 'DUMMY_SEARCH_LIB='
+    substituteInPlace configure --replace /usr /no-such-path
+  ";
+
+  postInstall = "
+    (cd $out/include && ln -s wx-*/* .)
+  ";
+
+  passthru = {inherit gtk compat24 compat26 unicode;};
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 61343e0e2578..8024e8c12dea 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -2873,6 +2873,10 @@ let
 
   db45 = callPackage ../development/libraries/db4/db4-4.5.nix { };
 
+  db47 = callPackage ../development/libraries/db4/db4-4.7.nix { };
+
+  db48 = callPackage ../development/libraries/db4/db4-4.8.nix { };
+
   dbus = callPackage ../development/libraries/dbus {
     useX11 = true;
   };
@@ -4194,6 +4198,10 @@ let
     inherit (gtkLibs) gtk;
   };
 
+  wxGTK290 = callPackage ../development/libraries/wxGTK-2.9/2.9.0.nix {
+    inherit (gtkLibs) gtk;
+  };
+
   wtk = callPackage ../development/libraries/wtk { };
 
   x264 = callPackage ../development/libraries/x264 { };
@@ -5698,6 +5706,12 @@ let
     qt = qt4;
   } ;
 
+  bitcoin = callPackage ../applications/misc/bitcoin { 
+    wxGTK = wxGTK290;
+    db4 = db47;
+    inherit (xlibs) libSM;
+  };
+
   bitlbee = callPackage ../applications/networking/instant-messengers/bitlbee { };
 
   # commented out because it's using the new configuration style proposal which is unstable