From bec7df1d6b5b3ea342fc28292ceaf83dc7498054 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 3 Jan 2025 16:42:11 +0300 Subject: [PATCH] support Nix and NixOS Quick Start for BTC: $ git clone https://github.com/mmgen/mmgen-wallet $ git clone https://github.com/mmgen/mmgen-node-tools $ cd mmgen-node-tools $ test/init.sh $ nix-shell --pure nix Enable altcoins and additional packages: # From the mmgen-node-tools repository root: $ mkdir -p ~/.mmgen $ cp ../mmgen-wallet/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.node-tools ../mmgen-wallet/nix/README --- mmgen_node_tools/data/version | 2 +- nix/README.node-tools | 11 ++++++++ nix/default.nix | 6 +++++ nix/node-tools-packages.nix | 12 +++++++++ nix/shell.nix | 1 + nix/yahooquery-noversioning.patch | 45 +++++++++++++++++++++++++++++++ nix/yahooquery.nix | 44 ++++++++++++++++++++++++++++++ setup.cfg | 2 +- 8 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 nix/README.node-tools create mode 100644 nix/default.nix create mode 100644 nix/node-tools-packages.nix create mode 100644 nix/shell.nix create mode 100644 nix/yahooquery-noversioning.patch create mode 100644 nix/yahooquery.nix diff --git a/mmgen_node_tools/data/version b/mmgen_node_tools/data/version index f19fa82..cf8acd2 100644 --- a/mmgen_node_tools/data/version +++ b/mmgen_node_tools/data/version @@ -1 +1 @@ -3.5.dev3 +3.5.dev4 diff --git a/nix/README.node-tools b/nix/README.node-tools new file mode 100644 index 0000000..9308181 --- /dev/null +++ b/nix/README.node-tools @@ -0,0 +1,11 @@ +Nix configuration directory for the MMGen Node Tools suite + +Usage is as described in ‘nix/README’ in the mmgen-wallet repository, with the +following differences: + + a) all commands are executed from the repository root of mmgen-node-tools + instead of mmgen-wallet + + b) for NixOS, complete the steps as described up until the rebuild step. + Copy the contents of this directory to ‘/etc/nixos/mmgen-project’ (this + will overwrite ‘default.nix’), and continue with the rebuild step. diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..7b4b214 --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,6 @@ +import ( + if builtins.pathExists ./merged-packages.nix then + ./merged-packages.nix + else + ../../mmgen-wallet/nix/merged-packages.nix + ) { add_pkgs_path = ./node-tools-packages.nix; } diff --git a/nix/node-tools-packages.nix b/nix/node-tools-packages.nix new file mode 100644 index 0000000..19792c7 --- /dev/null +++ b/nix/node-tools-packages.nix @@ -0,0 +1,12 @@ +{ pkgs, python }: + +{ + system-packages = with pkgs; { + cacert = cacert; # ticker (curl) + }; + + python-packages = with python.pkgs; { + yahooquery = (pkgs.callPackage ./yahooquery.nix {}); # ticker + pyyaml = pyyaml; # ticker + }; +} diff --git a/nix/shell.nix b/nix/shell.nix new file mode 100644 index 0000000..01991d2 --- /dev/null +++ b/nix/shell.nix @@ -0,0 +1 @@ +import ../../mmgen-wallet/nix/shell.nix { add_pkgs_path = ./node-tools-packages.nix; } diff --git a/nix/yahooquery-noversioning.patch b/nix/yahooquery-noversioning.patch new file mode 100644 index 0000000..4bd3297 --- /dev/null +++ b/nix/yahooquery-noversioning.patch @@ -0,0 +1,45 @@ +diff --git a/pyproject.toml b/pyproject.toml +index 9d3fb29..399c215 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -10,24 +10,24 @@ readme = "README.md" + + [tool.poetry.dependencies] + python = ">=3.8.1,<4.0" +-requests = "^2.31.0" +-pandas = "^2.0.3" +-requests-futures = "^1.0.1" +-tqdm = "^4.65.0" +-lxml = "^4.9.3" +-selenium = {version = "^4.10.0", optional = true} +-beautifulsoup4 = "^4.12.2" ++requests = ">=2.31.0" ++pandas = ">=2.0.3" ++requests-futures = ">=1.0.1" ++tqdm = ">=4.65.0" ++lxml = ">=4.9.3" ++selenium = {version = ">=4.10.0", optional = true} ++beautifulsoup4 = ">=4.12.2" + + [tool.poetry.dev-dependencies] +-pytest = "^7.4.0" +-isort = "^5.0.0" +-flake8 = "^6.0.0" +-mypy = "^1.4.1" +-pytest-cov = "^4.1.0" +-black = "^23.7.0" +-pre-commit = "^3.3.3" +-ipython = "^8.0.0" +-mkdocs-material = "^9.1.18" ++pytest = ">=7.4.0" ++isort = ">=5.0.0" ++flake8 = ">=6.0.0" ++mypy = ">=1.4.1" ++pytest-cov = ">=4.1.0" ++black = ">=23.7.0" ++pre-commit = ">=3.3.3" ++ipython = ">=8.0.0" ++mkdocs-material = ">=9.1.18" + + [build-system] + requires = ["poetry-core>=1.0.0"] diff --git a/nix/yahooquery.nix b/nix/yahooquery.nix new file mode 100644 index 0000000..8b1535d --- /dev/null +++ b/nix/yahooquery.nix @@ -0,0 +1,44 @@ +{ + lib, + pkgs, + fetchFromGitHub, +}: + +with pkgs.python312.pkgs; + +buildPythonPackage rec { + pname = "yahooquery"; + version = "2.3.7"; + pyproject = true; + + disabled = pythonOlder "3.8.1"; + + src = fetchFromGitHub { + owner = "dpguthrie"; + repo = "yahooquery"; + rev = "refs/tags/v${version}"; + hash = "sha256-Iyuni1SoTB6f7nNFhN5A8Gnv9kV78frjpqvvW8qd+/M="; + }; + + patches = [ ./yahooquery-noversioning.patch ]; + + build-system = [ poetry-core ]; + + dependencies = [ + requests # ^2.31.0 + pandas # ^2.0.3 + requests-futures # ^1.0.1 + tqdm # ^4.65.0 + lxml # ^4.9.3 + selenium # {version = ^4.10.0, optional = true} + beautifulsoup4 # ^4.12.2 + ]; + + doCheck = false; # skip tests + + meta = with lib; { + description = "Python wrapper for an unofficial Yahoo Finance API"; + homepage = "https://yahooquery.dpguthrie.com"; + license = licenses.mit; + }; +} diff --git a/setup.cfg b/setup.cfg index edbad57..f63dd91 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,7 +38,7 @@ python_requires = >=3.9 include_package_data = True install_requires = - mmgen-wallet>=15.1.dev6 + mmgen-wallet>=15.1.dev9 pyyaml yahooquery