units: fix build with enableCurrenciesUpdater=false; pythonPackages=null;
Units allows to build it without a python dependency by setting { enableCurrenciesUpdater=false; pythonPackages=null; }. Unfortunately this feature is currently broken due to two problems: 1. The `pythonEnv` string is part of the builder environment, so it is not evaluated lazily. This means that `pythonPackages==null` will always cause eval to fail. 2. `pythonEnv` is used unconditionally in an antiquotation in the `prePatch` phase; if it is null this will fail. Let's fix these so we can build a pythonless "units" package. This is helpful when cross-compiling, because right now a lot of python packages (especially python-cryptography) fail to cross-compile.
This commit is contained in:
parent
7bc6fbcd8b
commit
3f11515a26
|
@ -9,7 +9,10 @@
|
|||
|
||||
assert enableCurrenciesUpdater -> pythonPackages != null;
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
let pythonEnv = pythonPackages.python.withPackages(ps: [
|
||||
ps.requests
|
||||
]);
|
||||
in stdenv.mkDerivation rec {
|
||||
pname = "units";
|
||||
version = "2.21";
|
||||
|
||||
|
@ -18,16 +21,12 @@ stdenv.mkDerivation rec {
|
|||
sha256 = "sha256-bD6AqfmAWJ/ZYqWFKiZ0ZCJX2xxf1bJ8TZ5mTzSGy68=";
|
||||
};
|
||||
|
||||
pythonEnv = pythonPackages.python.withPackages(ps: [
|
||||
ps.requests
|
||||
]);
|
||||
|
||||
buildInputs = [ readline ]
|
||||
++ lib.optionals enableCurrenciesUpdater [
|
||||
pythonEnv
|
||||
]
|
||||
;
|
||||
prePatch = ''
|
||||
prePatch = lib.optionalString enableCurrenciesUpdater ''
|
||||
substituteInPlace units_cur \
|
||||
--replace "#!/usr/bin/env python" ${pythonEnv}/bin/python
|
||||
'';
|
||||
|
|
Loading…
Reference in a new issue