diff --git a/pkgs/tools/misc/units/default.nix b/pkgs/tools/misc/units/default.nix index 8f66f566aa7d..8bea94770ba6 100644 --- a/pkgs/tools/misc/units/default.nix +++ b/pkgs/tools/misc/units/default.nix @@ -1,4 +1,13 @@ -{ stdenv, fetchurl, readline }: +{ + stdenv, + lib, + fetchurl, + readline, + enableCurrenciesUpdater ? true, + pythonPackages ? null +}: + +assert enableCurrenciesUpdater -> pythonPackages != null; stdenv.mkDerivation rec { pname = "units"; @@ -9,7 +18,22 @@ stdenv.mkDerivation rec { sha256 = "0mk562g7dnidjgfgvkxxpvlba66fh1ykmfd9ylzvcln1vxmi6qj2"; }; - buildInputs = [ readline ]; + pythonEnv = pythonPackages.python.withPackages(ps: [ + ps.requests + ]); + + buildInputs = [ readline ] + ++ lib.optionals enableCurrenciesUpdater [ + pythonEnv + ] + ; + prePatch = '' + substituteInPlace units_cur \ + --replace "#!/usr/bin/env python" ${pythonEnv}/bin/python + ''; + postInstall = '' + cp units_cur ${placeholder "out"}/bin/ + ''; doCheck = true; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a078c813f7c0..dfabdb9b635a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6936,7 +6936,10 @@ in unbound = callPackage ../tools/networking/unbound { }; - units = callPackage ../tools/misc/units { }; + units = callPackage ../tools/misc/units { + enableCurrenciesUpdater = true; + pythonPackages = python3Packages; + }; unittest-cpp = callPackage ../development/libraries/unittest-cpp { };