From 212d91a7dd61f23de853258d3c30849498f7e076 Mon Sep 17 00:00:00 2001 From: Jaka Hudoklin Date: Thu, 17 Apr 2014 14:43:05 +0200 Subject: [PATCH] bitcoin: add support for altcoins --- pkgs/applications/misc/bitcoin/altcoins.nix | 100 ++++++++++++++++++ pkgs/applications/misc/bitcoin/default.nix | 18 ++-- .../misc/bitcoin/namecoin_dynamic.patch | 11 ++ pkgs/top-level/all-packages.nix | 7 +- 4 files changed, 128 insertions(+), 8 deletions(-) create mode 100644 pkgs/applications/misc/bitcoin/altcoins.nix create mode 100644 pkgs/applications/misc/bitcoin/namecoin_dynamic.patch diff --git a/pkgs/applications/misc/bitcoin/altcoins.nix b/pkgs/applications/misc/bitcoin/altcoins.nix new file mode 100644 index 00000000000..2b99bad58da --- /dev/null +++ b/pkgs/applications/misc/bitcoin/altcoins.nix @@ -0,0 +1,100 @@ +{ fetchurl, stdenv, pkgconfig +, openssl, db48, boost, zlib, miniupnpc, qt4, qrencode, glib, protobuf, utillinux }: + +with stdenv.lib; + +let + buildAltcoin = makeOverridable ({walletName, gui ? true, ...}@a: + stdenv.mkDerivation ({ + name = "${walletName}${toString (optional (!gui) "d")}-${a.version}"; + buildInputs = [ openssl db48 boost zlib miniupnpc ] + ++ optionals gui [ qt4 qrencode ] ++ a.extraBuildInputs or []; + + configurePhase = optional gui "qmake"; + + preBuild = optional (!gui) "cd src"; + makefile = optional (!gui) "makefile.unix"; + + installPhase = if gui then '' + install -D "${walletName}-qt" "$out/bin/${walletName}-qt" + '' else '' + install -D "${walletName}d" "$out/bin/${walletName}d" + ''; + + passthru.walletName = walletName; + + meta = { + platforms = platforms.unix; + license = license.mit; + maintainers = [ maintainers.offline ]; + }; + } // a) + ); + +in rec { + inherit buildAltcoin; + + litecoin = buildAltcoin rec { + walletName = "litecoin"; + version = "0.8.5.3-rc3"; + + src = fetchurl { + url = "https://github.com/litecoin-project/litecoin/archive/v${version}.tar.gz"; + sha256 = "1z4a7bm3z9kd7n0s38kln31z8shsd32d5d5v3br5p0jlnr5g3lk7"; + }; + + meta = { + description = "Litecoin is a lite version of Bitcoin using scrypt as a proof-of-work algorithm."; + longDescription= '' + Litecoin is a peer-to-peer Internet currency that enables instant payments + to anyone in the world. It is based on the Bitcoin protocol but differs + from Bitcoin in that it can be efficiently mined with consumer-grade hardware. + Litecoin provides faster transaction confirmations (2.5 minutes on average) + and uses a memory-hard, scrypt-based mining proof-of-work algorithm to target + the regular computers and GPUs most people already have. + The Litecoin network is scheduled to produce 84 million currency units. + ''; + homepage = https://litecoin.org/; + }; + }; + litecoind = litecoin.override { gui = false; }; + + namecoin = buildAltcoin rec { + walletName = "namecoin"; + version = "0.3.51.00"; + gui = false; + + src = fetchurl { + url = "https://github.com/namecoin/namecoin/archive/nc${version}.tar.gz"; + sha256 = "0r6zjzichfjzhvpdy501gwy9h3zvlla3kbgb38z1pzaa0ld9siyx"; + }; + + patches = [ ./namecoin_dynamic.patch ]; + + extraBuildInputs = [ glib ]; + + meta = { + description = "Namecoin is a decentralized key/value registration and transfer system based on Bitcoin technology."; + homepage = http://namecoin.info; + }; + }; + + dogecoin = buildAltcoin rec { + walletName = "dogecoin"; + version = "1.4"; + + src = fetchurl { + url = "https://github.com/dogecoin/dogecoin/archive/1.4.tar.gz"; + sha256 = "4af983f182976c98f0e32d525083979c9509b28b7d6faa0b90c5bd40b71009cc"; + }; + + meta = { + description = "Wow, such coin, much shiba, very rich"; + longDescription = "wow"; + homepage = http://www.dogecoin.com/; + maintainers = [ maintainers.offline maintainers.edwtjo ]; + }; + }; + dogecoind = dogecoin.override { gui = false; }; + +} diff --git a/pkgs/applications/misc/bitcoin/default.nix b/pkgs/applications/misc/bitcoin/default.nix index d7c1fbc487b..2b68c58b12d 100644 --- a/pkgs/applications/misc/bitcoin/default.nix +++ b/pkgs/applications/misc/bitcoin/default.nix @@ -1,19 +1,21 @@ { fetchurl, stdenv, openssl, db48, boost, zlib, miniupnpc, qt4, utillinux -, pkgconfig, protobuf, qrencode }: +, pkgconfig, protobuf, qrencode, gui ? true }: + +with stdenv.lib; stdenv.mkDerivation rec { version = "0.9.2.1"; - name = "bitcoin-${version}"; + name = "bitcoin${toString (optional (!gui) "d")}-${version}"; src = fetchurl { - url = "https://bitcoin.org/bin/${version}/${name}-linux.tar.gz"; + url = "https://bitcoin.org/bin/${version}/bitcoin-${version}-linux.tar.gz"; sha256 = "0060f7d38b98113ab912d4c184000291d7f026eaf77ca5830deec15059678f54"; }; # hexdump from utillinux is required for tests buildInputs = [ - openssl db48 boost zlib miniupnpc qt4 utillinux pkgconfig protobuf qrencode - ]; + openssl db48 boost zlib miniupnpc utillinux pkgconfig protobuf + ] ++ optionals gui [ qt4 qrencode ]; unpackPhase = '' mkdir tmp-extract && (cd tmp-extract && tar xf $src) @@ -34,6 +36,8 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; + passthru.walletName = "bitcoin"; + meta = { description = "Peer-to-peer electronic cash system"; longDescription= '' @@ -43,7 +47,7 @@ stdenv.mkDerivation rec { 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 = stdenv.lib.licenses.mit; + maintainers = [ maintainers.roconnor ]; + license = licenses.mit; }; } diff --git a/pkgs/applications/misc/bitcoin/namecoin_dynamic.patch b/pkgs/applications/misc/bitcoin/namecoin_dynamic.patch new file mode 100644 index 00000000000..ef4184ede73 --- /dev/null +++ b/pkgs/applications/misc/bitcoin/namecoin_dynamic.patch @@ -0,0 +1,11 @@ +diff -u -r a/src/makefile.unix b/src/makefile.unix +--- a/src/makefile.unix 2014-01-22 22:07:59.801601964 -0800 ++++ b/src/makefile.unix 2014-01-22 22:08:07.980332839 -0800 +@@ -12,7 +12,6 @@ + + # for boost 1.37, add -mt to the boost libraries + LIBS= \ +- -Wl,-Bstatic \ + -l boost_system \ + -l boost_filesystem \ + -l boost_program_options \ diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a5fa04d8936..8ff0a9d043f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8275,7 +8275,12 @@ let bibletime = callPackage ../applications/misc/bibletime { }; - bitcoin = callPackage ../applications/misc/bitcoin { }; + bitcoin = callPackage ../applications/misc/bitcoin {}; + bitcoind = callPackage ../applications/misc/bitcoin { gui = false; }; + + altcoins = recurseIntoAttrs ( + callPackage ../applications/misc/bitcoin/altcoins.nix {} + ); bitlbee = callPackage ../applications/networking/instant-messengers/bitlbee { gnutls = gnutls;