Building Python package triggers network errors

It seems that ledger-autosync is broken in nixpkgs-unstable and I would like to fix it:

$ nix-build -A python3Packages.ledger-autosync
Finished executing setuptoolsBuildPhase
Executing pipInstallPhase
/build/source/dist /build/source
Processing ./ledger_autosync-1.0.2-py3-none-any.whl
Collecting ofxparse@
... several network-related errors ...
builder for '/nix/store/41jw86sg0lrfr1ggi6axq9bsbn1bbrys-ledger-autosync-1.0.2-0b674c5.drv' failed with exit code 1
error: build of '/nix/store/41jw86sg0lrfr1ggi6axq9bsbn1bbrys-ledger-autosync-1.0.2-0b674c5.drv' failed

Nevertheless, the ledger-autosync’s Nix definition references a dependency to ofxparse:

{ lib, python3Packages, fetchFromGitHub, ledger, hledger, useLedger ? true, useHledger ? true }:

python3Packages.buildPythonApplication rec {
  pname = "ledger-autosync";
  version = "1.0.2-0b674c5";

  # no tests included in PyPI tarball
  src = fetchFromGitHub {
    owner = "egh";
    repo = "ledger-autosync";
    rev = "0b674c57c833f75b1a36d8caf78e1567c8e2180c";
    sha256 = "0q404gr85caib5hg83cnmgx4684l72w9slxyxrwsiwhlf7gm443q";

  propagatedBuildInputs = with python3Packages; [
  ] ++ lib.optional useLedger ledger
    ++ lib.optional useHledger hledger;

  # Checks require ledger as a python package,
  # ledger does not support python3 while ledger-autosync requires it.
  checkInputs = with python3Packages; [ ledger hledger nose mock ];
  checkPhase = ''
    nosetests -a generic -a ledger -a hledger

  meta = with lib; {... };

ofxparse builds fine.

Why is building ledger-autosync requiring the network for a package in the build inputs?

I haven’t dealt with one of these firsthand, but I think this happens when the underlying package (probably in has added its own dependency checking/fetching.

It may be the case that there is an env you can set to help it find the nix-supplied dependency without other modifications, or you might need to patch it?

1 Like

I think I found the reason. The project’s specifies an URL for the dependency:

    "ofxparse @"

To fix the problem I updated ofxparse in nixpkgs to a more recent version and patched ofxparse:

diff --git a/ b/
index eda6db5..ed6b90b 100644
--- a/
+++ b/
@@ -38,7 +38,7 @@ setup(
-        "ofxparse @"
+        'ofxparse'
1 Like