2020-04-24 23:36:52 +00:00
|
|
|
{
|
|
|
|
stdenv,
|
|
|
|
lib,
|
|
|
|
fetchurl,
|
|
|
|
readline,
|
|
|
|
enableCurrenciesUpdater ? true,
|
|
|
|
pythonPackages ? null
|
|
|
|
}:
|
|
|
|
|
|
|
|
assert enableCurrenciesUpdater -> pythonPackages != null;
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
let pythonEnv = pythonPackages.python.withPackages(ps: [
|
|
|
|
ps.requests
|
|
|
|
]);
|
|
|
|
in stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "units";
|
2023-03-24 00:07:29 +00:00
|
|
|
version = "2.22";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "mirror://gnu/units/${pname}-${version}.tar.gz";
|
2023-03-24 00:07:29 +00:00
|
|
|
sha256 = "sha256-XRPhIHch/ncm2Qa6HZLcDt2qn8JnWe0i47jRp5MSWEg=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [ readline ]
|
|
|
|
++ lib.optionals enableCurrenciesUpdater [
|
|
|
|
pythonEnv
|
|
|
|
]
|
|
|
|
;
|
2023-04-29 16:46:19 +00:00
|
|
|
prePatch = lib.optionalString enableCurrenciesUpdater ''
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace units_cur \
|
|
|
|
--replace "#!/usr/bin/env python" ${pythonEnv}/bin/python
|
|
|
|
'';
|
|
|
|
postInstall = ''
|
|
|
|
cp units_cur ${placeholder "out"}/bin/
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Unit conversion tool";
|
|
|
|
homepage = "https://www.gnu.org/software/units/";
|
|
|
|
license = [ licenses.gpl3Plus ];
|
|
|
|
platforms = platforms.all;
|
|
|
|
maintainers = [ maintainers.vrthra ];
|
|
|
|
};
|
|
|
|
}
|