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:
parent
783b05e373
commit
abbc9c843a
18 changed files with 199 additions and 130 deletions
54
nix/README
Normal file
54
nix/README
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
Nix configuration directory for the MMGen Wallet suite
|
||||
|
||||
Only BTC and a bare minimum of packages are enabled by default.
|
||||
|
||||
For altcoin and additional package support, copy the file ‘user-packages.nix’ to
|
||||
your MMGen datadir (~/.mmgen) and edit, uncommenting the relevant lines. For an
|
||||
XMR-enabled setup, for example, you’d uncomment the system package ‘monero-cli’
|
||||
and Python packages ‘monero’, ‘pycryptodome’ and ‘pysocks’.
|
||||
|
||||
From the mmgen-wallet repo root, you may build individual system packages in the
|
||||
MMGen Wallet environment as follows (we’ll use the curl package in this example):
|
||||
|
||||
$ nix-build nix --attr curl
|
||||
|
||||
To build all configured packages in one go, run ‘nix-build nix’ without
|
||||
additional arguments.
|
||||
|
||||
The last lines of nix-build’s output are store paths in ‘/nix/store/’, which
|
||||
you may optionally install into your default environment as follows:
|
||||
|
||||
$ nix-env --install <store path>
|
||||
|
||||
Note that use of MMGen Wallet from the default environment is discouraged in
|
||||
favor of the custom shell environment, which we’ll now describe.
|
||||
|
||||
From the mmgen-wallet repo root, execute:
|
||||
|
||||
$ nix-shell nix
|
||||
|
||||
This will build any unbuilt configured packages and drop you to the custom shell
|
||||
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 from your native environment inaccessible within the
|
||||
shell, so you may need to add some additional tools to your environment such as
|
||||
a text editor. For examples, refer to ‘user-packages.nix’
|
||||
|
||||
NixOS:
|
||||
|
||||
To install the MMGen Wallet environment under NixOS, copy the contents of the ‘nix’
|
||||
directory to ‘/etc/nixos/mmgen-project’ and add ‘./mmgen-project/nixos-packages.nix’
|
||||
to your imports list in ‘configuration.nix’. If altcoin support or additional
|
||||
packages are required, edit ‘user-packages.nix’ in ‘/etc/nixos/mmgen-project’ as
|
||||
described above for the copy of that file in the MMGen datadir. Rebuild NixOS.
|
||||
From the mmgen-wallet repo root, execute:
|
||||
|
||||
export PYTHONPATH=$(pwd)
|
||||
export PATH=$(pwd)/cmds:$PATH
|
||||
|
||||
You can now test and use MMGen Wallet in your native shell environment.
|
||||
48
nix/bitcoin-cash-node.nix
Normal file
48
nix/bitcoin-cash-node.nix
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
{ 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
|
||||
'';
|
||||
}
|
||||
1
nix/default.nix
Normal file
1
nix/default.nix
Normal file
|
|
@ -0,0 +1 @@
|
|||
import ./merged-packages.nix { add_pkgs_path = null; }
|
||||
51
nix/go-ethereum.nix
Normal file
51
nix/go-ethereum.nix
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
## 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";
|
||||
};
|
||||
}
|
||||
44
nix/litecoin.nix
Normal file
44
nix/litecoin.nix
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
{ 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
|
||||
'';
|
||||
}
|
||||
30
nix/merged-packages.nix
Normal file
30
nix/merged-packages.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{ add_pkgs_path }:
|
||||
|
||||
let
|
||||
dfl_nixpkgs = import ./nixpkgs-24.05.nix {};
|
||||
dfl_python = pkgs.python312;
|
||||
null_pkgs = {
|
||||
system-packages = {};
|
||||
python-packages = {};
|
||||
};
|
||||
usr_pkgs_path = if builtins.pathExists ~/.mmgen/user-packages.nix then
|
||||
~/.mmgen/user-packages.nix else ./user-packages.nix;
|
||||
usr_pkgs = import usr_pkgs_path { pkgs = dfl_nixpkgs; python = dfl_python; bdir = ./.; };
|
||||
pkgs = if usr_pkgs?pkgs then usr_pkgs.pkgs else dfl_nixpkgs;
|
||||
python = if usr_pkgs?pkgs then usr_pkgs.python else dfl_python;
|
||||
wallet_pkgs = import ./packages.nix { pkgs = pkgs; python = python; };
|
||||
add_pkgs = if add_pkgs_path == null then null_pkgs else
|
||||
(import add_pkgs_path { pkgs = pkgs; python = python; });
|
||||
in
|
||||
|
||||
wallet_pkgs.system-packages //
|
||||
add_pkgs.system-packages //
|
||||
usr_pkgs.system-packages //
|
||||
{
|
||||
pyenv = python.withPackages (ps:
|
||||
builtins.attrValues (
|
||||
wallet_pkgs.python-packages //
|
||||
add_pkgs.python-packages //
|
||||
usr_pkgs.python-packages)
|
||||
);
|
||||
}
|
||||
5
nix/nixos-packages.nix
Normal file
5
nix/nixos-packages.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
environment.systemPackages = builtins.attrValues (import ./default.nix);
|
||||
}
|
||||
7
nix/nixpkgs-24.05.nix
Normal file
7
nix/nixpkgs-24.05.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import (
|
||||
fetchGit {
|
||||
url = "https://github.com/NixOS/nixpkgs.git";
|
||||
rev = "63dacb46bf939521bdc93981b4cbb7ecb58427a0"; # refs/tags/24.05
|
||||
shallow = true;
|
||||
}
|
||||
)
|
||||
50
nix/packages.nix
Normal file
50
nix/packages.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{ pkgs, python }:
|
||||
|
||||
{
|
||||
system-packages = with pkgs; {
|
||||
bitcoind = bitcoind; # Bitcoin Core daemon
|
||||
vanitygen = (callPackage ./vanitygen-plusplus.nix {}); # test suite
|
||||
curl = curl;
|
||||
git = git;
|
||||
gcc = gcc;
|
||||
libtool = libtool;
|
||||
autoconf = autoconf;
|
||||
gmp = gmp;
|
||||
gmp4 = gmp4;
|
||||
openssl = openssl;
|
||||
pcre = pcre;
|
||||
mpfr = mpfr;
|
||||
secp256k1 = secp256k1.overrideAttrs {
|
||||
pname = "secp256k1-v0.6.0";
|
||||
src = fetchGit {
|
||||
url = "https://github.com/bitcoin-core/secp256k1.git";
|
||||
ref = "refs/tags/v0.6.0";
|
||||
};
|
||||
};
|
||||
less = less; # test suite (cmdtest.py regtest)
|
||||
procps = procps; # test suite (pgrep)
|
||||
ruff = ruff;
|
||||
|
||||
## For test suite with --pure:
|
||||
e2fsprogs = e2fsprogs;
|
||||
util-linux = util-linux; # losetup
|
||||
ncurses = ncurses; # infocmp
|
||||
};
|
||||
|
||||
python-packages = with python.pkgs; {
|
||||
pip = pip;
|
||||
setuptools = setuptools;
|
||||
build = build;
|
||||
wheel = wheel;
|
||||
gmpy2 = gmpy2;
|
||||
cryptography = cryptography;
|
||||
pynacl = pynacl;
|
||||
ecdsa = ecdsa;
|
||||
aiohttp = aiohttp;
|
||||
requests = requests;
|
||||
py-scrypt = py-scrypt;
|
||||
semantic-version = semantic-version;
|
||||
pexpect = pexpect; # test suite
|
||||
pycoin = pycoin; # test suite
|
||||
};
|
||||
}
|
||||
38
nix/shell.nix
Normal file
38
nix/shell.nix
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# Nix shell environment for mmgen-wallet
|
||||
|
||||
{ add_pkgs_path ? null }:
|
||||
|
||||
let
|
||||
pkgs = import <nixpkgs> {};
|
||||
in
|
||||
|
||||
pkgs.mkShellNoCC {
|
||||
packages = builtins.attrValues (import ./merged-packages.nix { add_pkgs_path = add_pkgs_path; });
|
||||
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
|
||||
)
|
||||
}
|
||||
|
||||
read _ _ name <<<$(grep ^name setup.cfg)
|
||||
|
||||
[[ "$name" =~ ^mmgen-(wallet|node-tools)$ ]] || {
|
||||
echo "Error: this script must be executed in the mmgen-wallet or mmgen-node-tools repository root"
|
||||
exit 1
|
||||
}
|
||||
|
||||
pwd=$(pwd)
|
||||
export PYTHONPATH=$pwd
|
||||
export PATH=$pwd/cmds:$pwd/.bin-override:$HOME/.local/bin:$PATH
|
||||
|
||||
[ "$UID" == 0 ] || do_sudo_override
|
||||
'';
|
||||
}
|
||||
48
nix/user-packages.nix
Normal file
48
nix/user-packages.nix
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# Nix environment user configuration for the MMGen Project
|
||||
#
|
||||
# In addition to setting new attributes, this file may be used to override the defaults
|
||||
# in nix/packages.nix of the mmgen-wallet repository
|
||||
|
||||
{ pkgs, python, bdir }:
|
||||
|
||||
rec {
|
||||
### Set nixpkgs globally for the MMGen environment.
|
||||
### If you set it, make sure to uncomment the python variable assignment below.
|
||||
# pkgs = import (bdir + /nixpkgs-24.05.nix) {};
|
||||
|
||||
### Set python version globally for the MMGen environment.
|
||||
### Must be set if pkgs is set.
|
||||
# python = pkgs.python312;
|
||||
|
||||
system-packages = with pkgs; {
|
||||
# monero-cli = monero-cli; # Monero daemon
|
||||
# # go-ethereum = go-ethereum; # Geth - latest version for transacting on mainnet
|
||||
# go-ethereum = callPackage (bdir + /go-ethereum.nix) { # Geth - old version for test suite (ethdev)
|
||||
# buildGoModule = buildGo122Module;
|
||||
# tag_version = "v1.13.15";
|
||||
# vendor_hash = "sha256-LWNFuF66KudxrpWBBXjMbrWP5CwEuPE2h3kGfILIII0";
|
||||
# };
|
||||
# litecoin = callPackage (bdir + /litecoin.nix) {}; # Litecoin daemon
|
||||
# bitcoin-cash = callPackage (bdir + /bitcoin-cash-node.nix) {}; # Bitcoin Cash Node daemon
|
||||
# zcash-mini = callPackage (bdir + /zcash-mini.nix) {}; # ZEC (test suite)
|
||||
|
||||
### For development with --pure (add/remove packages for your setup):
|
||||
# neovim-qt = neovim-qt;
|
||||
# rxvt-unicode = rxvt-unicode;
|
||||
# which = which;
|
||||
# ctags = ctags;
|
||||
# xclip = xclip;
|
||||
|
||||
### For test suite with --pure:
|
||||
# openssh = openssh; # XMR tests
|
||||
};
|
||||
|
||||
python-packages = with python.pkgs; {
|
||||
# pycryptodome = pycryptodome; # altcoins
|
||||
# py-ecc = py-ecc; # ETH, ETC
|
||||
# mypy-extensions = mypy-extensions; # ETH, ETC
|
||||
# pysocks = pysocks; # XMR
|
||||
# monero = monero; # XMR (test suite)
|
||||
# eth-keys = eth-keys; # ETH, ETC (test suite)
|
||||
};
|
||||
}
|
||||
15
nix/vanitygen-plusplus.nix
Normal file
15
nix/vanitygen-plusplus.nix
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{ 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
|
||||
'';
|
||||
}
|
||||
29
nix/zcash-mini.nix
Normal file
29
nix/zcash-mini.nix
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{ 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue