diff --git a/pkgs/development/python-modules/fava-portfolio-returns/default.nix b/pkgs/development/python-modules/fava-portfolio-returns/default.nix new file mode 100644 index 000000000000..b539d281c094 --- /dev/null +++ b/pkgs/development/python-modules/fava-portfolio-returns/default.nix @@ -0,0 +1,97 @@ +{ + lib, + buildPythonPackage, + buildNpmPackage, + fetchFromGitHub, + stdenv, + fava, + hatch-vcs, + hatchling, + numpy, + pandas, + protobuf, + pytestCheckHook, + scipy, +}: +let + pname = "fava-portfolio-returns"; + version = "2.3.0"; + src = fetchFromGitHub { + owner = "andreasgerstmayr"; + repo = "fava-portfolio-returns"; + rev = "v${version}"; + hash = "sha256-NM+0gcgSztcgzYj0nCe9DOK90lrzE0TOzH30WvTKsUA="; + }; + + frontend = buildNpmPackage (finalAttrs: { + pname = "${pname}-frontend"; + inherit version; + + src = "${src}/frontend"; + + npmDepsHash = "sha256-MDoZC5IAR9puWMLBhLb5HRoagBPyNiyJ+0879ljCNUo="; + + postPatch = '' + substituteInPlace package.json \ + --replace-fail '"name": "fava-portfolio-returns",' '"name": "fava-portfolio-returns", "version": "${finalAttrs.version}",' + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out + cp ../src/fava_portfolio_returns/FavaPortfolioReturns.js $out/ + + runHook postInstall + ''; + }); +in +buildPythonPackage { + inherit pname version src; + pyproject = true; + + build-system = [ + hatchling + hatch-vcs + ]; + + dependencies = [ + fava + numpy + pandas + protobuf + scipy + ]; + + preInstall = '' + cp ${frontend}/FavaPortfolioReturns.js src/fava_portfolio_returns/ + ''; + + nativeCheckInputs = [ pytestCheckHook ]; + + pythonImportsCheck = [ "fava_portfolio_returns" ]; + + # Stay in the root of the repository, so that relative paths to example files + # loaded by tests stay correct. + # Remove `src` to avoid `PYTHONPATH` issues related to `pytestCheckHook` ([1]) + # [1]: https://github.com/NixOS/nixpkgs/issues/255262 + preCheck = '' + rm -rf src + ''; + + pytestFlags = [ + "${placeholder "out"}" + ]; + + passthru = { + inherit frontend; + }; + + meta = { + description = "Show portfolio returns in Fava"; + homepage = "https://github.com/andreasgerstmayr/fava-portfolio-returns"; + changelog = "https://github.com/andreasgerstmayr/fava-portfolio-returns/blob/main/CHANGELOG.md"; + license = lib.licenses.gpl2Only; + maintainers = with lib.maintainers; [ ambroisie ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 89fff22e1e56..4f7351e54f61 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -5328,6 +5328,8 @@ self: super: with self; { fava-investor = callPackage ../development/python-modules/fava-investor { }; + fava-portfolio-returns = callPackage ../development/python-modules/fava-portfolio-returns { }; + favicon = callPackage ../development/python-modules/favicon { }; fe25519 = callPackage ../development/python-modules/fe25519 { };