Nix support improvements

Quick Start for BTC:

    $ git clone https://github.com/mmgen/mmgen-wallet
    $ cd mmgen-wallet
    $ nix-shell --pure nix

Enable altcoins and additional packages:

    $ mkdir -p ~/.mmgen
    $ cp nix/user-packages.nix ~/.mmgen
    # ... edit ~/.mmgen/user-packages.nix as required ...
    $ nix-shell --pure nix

For NixOS installation and other information, see:

    nix/README
This commit is contained in:
The MMGen Project 2025-01-03 14:23:20 +00:00
commit abbc9c843a
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
18 changed files with 199 additions and 130 deletions

View file

@ -1,48 +0,0 @@
{ pkgs }:
pkgs.stdenv.mkDerivation rec {
pname = "bitcoin-cash-node";
version = "v28.0.0";
src = fetchGit {
url = "https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node";
ref = "refs/tags/${version}";
};
nativeBuildInputs = [
pkgs.cmake
pkgs.ninja
pkgs.help2man
pkgs.python3
];
buildInputs = [
pkgs.boost
pkgs.libevent
pkgs.db
pkgs.gmp
pkgs.openssl
pkgs.miniupnpc
pkgs.libnatpmp
pkgs.zeromq
pkgs.zlib
];
cmakeFlags = [
"-GNinja"
"-DBUILD_BITCOIN_QT=OFF"
"-DVERBOSE_CONFIGURE=ON"
];
doCheck = false;
postConfigure = ''
chmod ug+x config/run_native_cmake.sh
chmod ug+x src/secp256k1/build_native_gen_context.sh
sed -e 's@/usr/bin/env python3@${pkgs.python3}/bin/python3@' -i ../cmake/utils/gen-ninja-deps.py
sed -e 's@/usr/bin/env bash@${pkgs.bash}/bin/bash@' -i doc/man/gen-doc-man-footer.sh
sed -e 's@/usr/bin/env bash@${pkgs.bash}/bin/bash@' -i doc/man/gen-doc-man.sh
'';
postInstall= ''
rm -f $out/bin/*
install -v --mode=755 src/bitcoind $out/bin/bitcoind-bchn
install -v --mode=755 src/bitcoin-cli $out/bin/bitcoin-cli-bchn
rm -f $out/share/man/man1/bitcoin-{tx,seeder}*
mv $out/share/man/man1/bitcoind.1 $out/share/man/man1/bitcoind-bchn.1
mv $out/share/man/man1/bitcoin-cli.1 $out/share/man/man1/bitcoin-cli-bchn.1
'';
}

View file

@ -1,51 +0,0 @@
## adapted from go-ethereum.nix in nixpkgs repository
{
pkgs,
lib,
stdenv,
buildGoModule,
# nixosTests,
tag_version,
vendor_hash,
}:
buildGoModule {
pname = "go-ethereum";
version = tag_version;
src = fetchGit {
url = "https://github.com/ethereum/go-ethereum.git";
ref = "refs/tags/${tag_version}";
};
proxyVendor = false;
vendorHash = vendor_hash;
doCheck = false;
subPackages = [ "cmd/geth" ];
## Following upstream: https://github.com/ethereum/go-ethereum/blob/v1.11.6/build/ci.go#L218
tags = [ "urfave_cli_no_docs" ];
## Fix for usb-related segmentation faults on darwin
propagatedBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
pkgs.libobjc
pkgs.IOKit
];
# passthru.tests = { inherit (nixosTests) geth; };
meta = with lib; {
homepage = "https://geth.ethereum.org/";
description = "Official golang implementation of the Ethereum protocol";
license = with licenses; [
lgpl3Plus
gpl3Plus
];
maintainers = with maintainers; [ RaghavSood ];
mainProgram = "geth";
};
}

View file

@ -1,44 +0,0 @@
{ pkgs }:
pkgs.stdenv.mkDerivation rec {
pname = "litecoin";
version = "v0.21.4";
src = fetchGit {
url = "https://github.com/litecoin-project/litecoin.git";
ref = "refs/tags/${version}";
};
nativeBuildInputs = [
pkgs.autoconf
pkgs.automake
pkgs.libtool
pkgs.pkg-config
# pkgs.hexdump # for tests
];
buildInputs = [
pkgs.boost
pkgs.libevent
pkgs.fmt
pkgs.db4
pkgs.openssl
pkgs.sqlite
];
preConfigure = [
"./autogen.sh"
];
configureFlags = [
"--without-gui"
"--with-sqlite"
"--disable-bench"
"--disable-tests"
"--with-boost-libdir=${pkgs.boost.out}/lib"
];
buildFlags = [
"src/litecoind"
"src/litecoin-cli"
];
enableParallelBuilding = true;
installPhase = ''
mkdir -p $out/bin
install -D --mode=755 src/litecoind src/litecoin-cli $out/bin
'';
}

View file

@ -1,5 +0,0 @@
{ config, lib, pkgs, ... }:
{
environment.systemPackages = builtins.attrValues (import ./packages.nix);
}

View file

@ -1,7 +0,0 @@
import (
fetchGit {
url = "https://github.com/NixOS/nixpkgs.git";
rev = "63dacb46bf939521bdc93981b4cbb7ecb58427a0"; # refs/tags/24.05
shallow = true;
}
)

View file

@ -1,118 +0,0 @@
# mmgen-wallet-nix: Nix packages directory for mmgen-wallet
#
# Copy the ‘mmgen-wallet-nix’ directory and its files to a location outside the
# mmgen-wallet repo and edit the file ‘packages.nix’, which contains all the
# system and Python packages MMGen Wallet depends on. By default, altcoin
# packages are commented out. To enable the coins you need, uncomment the
# relevant lines. For an XMR-enabled setup, for example, you’ll need the
# system package ‘monero-cli’ and Python packages ‘monero’, ‘pycryptodome’
# and ‘pysocks’.
#
# Individual system packages are built as follows:
#
# $ nix-build /path/to/mmgen-wallet-nix/packages.nix --attr <package name>
#
# The last line of nix-build’s output is a store path in ‘/nix/store/’, which
# you may optionally install into your default environment as follows:
#
# $ nix-env --install <store path>
#
# To build all configured packages in one go, run nix-build without ‘--attr’ and
# package name.
#
# The file ‘shell.nix’ contains a shell environment specially created for use
# with MMGen Wallet. From the mmgen-wallet repo root, execute:
#
# $ nix-shell /path/to/mmgen-wallet-nix/shell.nix
#
# This will build any unbuilt configured packages and drop you to the custom
# environment. At this point you may run the test suite:
#
# [nix-shell:... $] test/test-release -FA
#
# or proceed to use MMGen Wallet as with any conventional installation.
#
# For greater isolation, you can invoke nix-shell with the ‘--pure’ option. This
# will make executables in your native environment inaccessible within the
# shell, so you may need to install some additional tools, such as a text
# editor. See the related comments below.
#
# NixOS:
#
# To install mmgen-wallet under NixOS, copy the ‘mmgen-wallet-nix’ directory
# to ‘/etc/nixos’, edit ‘packages.nix’ to suit and add
# ‘mmgen-wallet-nix/nixos-packages.nix’ to your imports list in
# ‘configuration.nix’. From the mmgen-wallet repo root, execute:
#
# export PYTHONPATH=$(pwd)
# export PATH=$(pwd)/cmds:$PATH
#
# You can now use MMGen Wallet in your native shell environment.
let
pkgs = import ./nixpkgs-24.05.nix {};
pythonEnv = pkgs.python312.withPackages (ps: with ps; [
pip
setuptools
build
wheel
gmpy2
cryptography
pynacl
ecdsa
aiohttp
requests
py-scrypt
semantic-version
# pycryptodome # altcoins
# py-ecc # ETH, ETC
# mypy-extensions # ETH, ETC
# pysocks # XMR
pexpect # test suite
pycoin # test suite
# monero # XMR (test suite)
# eth-keys # ETH, ETC (test suite)
]);
in
{
pymods = pythonEnv;
bitcoind = pkgs.bitcoind; # Bitcoin Core daemon
# monero-cli = pkgs.monero-cli; # Monero daemon
# go-ethereum = pkgs.go-ethereum; # Geth - latest version for mainnet transacting
# go-ethereum = (pkgs.callPackage ./go-ethereum.nix { # Geth - old version for test suite (ethdev)
# buildGoModule = pkgs.buildGo122Module;
# tag_version = "v1.13.15";
# vendor_hash = "sha256-LWNFuF66KudxrpWBBXjMbrWP5CwEuPE2h3kGfILIII0";
# });
# litecoin = (pkgs.callPackage ./litecoin.nix {}); # Litecoin daemon
# bitcoin-cash = (pkgs.callPackage ./bitcoin-cash-node.nix {}); # Bitcoin Cash Node daemon
# zcash-mini = (pkgs.callPackage ./zcash-mini.nix {}); # ZEC (test suite)
vanitygen = (pkgs.callPackage ./vanitygen-plusplus.nix {}); # test suite
curl = pkgs.curl;
git = pkgs.git;
gcc = pkgs.gcc;
libtool = pkgs.libtool;
autoconf = pkgs.autoconf;
gmp = pkgs.gmp;
gmp4 = pkgs.gmp4;
openssl = pkgs.openssl;
pcre = pkgs.pcre;
mpfr = pkgs.mpfr;
secp256k1 = pkgs.secp256k1;
less = pkgs.less; # test suite (cmdtest.py regtest)
procps = pkgs.procps; # test suite (pgrep)
ruff = pkgs.ruff;
## For development with --pure (add/remove packages for your setup):
neovim-qt = pkgs.neovim-qt;
rxvt-unicode = pkgs.rxvt-unicode;
which = pkgs.which;
ctags = pkgs.ctags;
## For test suite with --pure:
openssh = pkgs.openssh; # XMR tests
e2fsprogs = pkgs.e2fsprogs;
util-linux = pkgs.util-linux; # losetup
ncurses = pkgs.ncurses; # infocmp
}

View file

@ -1,34 +0,0 @@
# Nix shell environment for mmgen-wallet
let
pkgs = import <nixpkgs> {};
in
pkgs.mkShellNoCC {
packages = builtins.attrValues (import ./packages.nix);
shellHook = ''
do_sudo_override() {
(
rm -rf .bin-override
mkdir .bin-override
cd .bin-override
if [ -x /bin/sudo ]; then
ln -s /bin/sudo
elif [ -x /run/wrappers/bin/sudo ]; then
ln -s /run/wrappers/bin/sudo
fi
)
}
[ "$(python3 ./setup.py --name 2>/dev/null)" == "mmgen-wallet" ] || {
echo "Error: this script must be executed in the mmgen-wallet repository root"
exit 1
}
pwd=$(pwd)
export PYTHONPATH=$pwd
export PATH=$pwd/cmds:$pwd/.bin-override:$PATH
[ "$UID" == 0 ] || do_sudo_override
'';
}

View file

@ -1,15 +0,0 @@
{ pkgs }:
pkgs.stdenv.mkDerivation {
pname = "vanitygen-plusplus";
version = "e7858035";
src = fetchGit {
url = "https://github.com/10gic/vanitygen-plusplus";
rev = "e7858035d092f9b9d6468e2b812475faaf7c69c6";
};
buildInputs = [ pkgs.openssl pkgs.pcre ];
installPhase = ''
mkdir -p $out/bin
install -sv --mode=755 vanitygen keyconv $out/bin
'';
}

View file

@ -1,29 +0,0 @@
{ pkgs }:
pkgs.stdenvNoCC.mkDerivation {
pname = "zcash-mini";
version = "a2b35042";
src = fetchGit {
url = "https://github.com/FiloSottile/zcash-mini";
rev = "a2b35042ad3a3bc22b925ecfc45e768a376bd29a";
};
buildInputs = [ pkgs.go pkgs.binutils ];
patchPhase = ''
sed -e "s@github.com/FiloSottile/@@" -i main.go
sed -e "s@github.com/FiloSottile/@@" -i zcash/address.go
sed -e "s@github.com/btcsuite@zcash-mini@" -i zcash/address.go
sed -e "s@golang.org/x@zcash-mini@" -i zcash/address.go
mv vendor/github.com/btcsuite/btcutil .
mv vendor/golang.org/x/crypto .
'';
dontConfigure = true;
dontBuild = true;
installPhase = ''
export HOME=$TMPDIR
go mod init zcash-mini
go build -mod=mod
mkdir --parents $out/bin
install --strip --mode=755 zcash-mini $out/bin
'';
dontFixup = true;
}