bazarr: update expr

* Add runtime program dependencies to buildInputs, instead of setting
  that up as part of the install phase. This allows hacking on bazarr
  straight from `nix-shell -A bazarr`.
* Add missing preInstall/postInstall hooks.
* Quote shell variables.
* Simplify install path: $out/share/${pname}-${version} -> $out/share/${pname}.
  (There's no point in having the version there, and without proper deep
  overrides it can also create some problems.)
This commit is contained in:
Bjørn Forsman 2022-11-04 13:27:35 +01:00
parent 4488784f49
commit 667e5581d1

View file

@ -1,5 +1,11 @@
{ stdenv, lib, fetchurl, makeWrapper, unzip, python3, unrar, ffmpeg, nixosTests }:
let
runtimeProgDeps = [
ffmpeg
unrar
];
in
stdenv.mkDerivation rec {
pname = "bazarr";
version = "1.1.2";
@ -13,16 +19,26 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ unzip makeWrapper ];
buildInputs = [
(python3.withPackages (ps: [ ps.lxml ps.numpy ps.gevent ps.gevent-websocket ]))
] ++ runtimeProgDeps;
installPhase = ''
mkdir -p $out/{bin,share/${pname}-${version}}
cp -r * $out/share/${pname}-${version}
makeWrapper "${
(python3.withPackages
(ps: [ ps.lxml ps.numpy ps.gevent ps.gevent-websocket ])).interpreter
}" \
$out/bin/bazarr \
--add-flags "$out/share/${pname}-${version}/bazarr.py" \
--suffix PATH : ${lib.makeBinPath [ unrar ffmpeg ]}
runHook preInstall
mkdir -p "$out"/{bin,share/${pname}}
cp -r * "$out/share/${pname}"
# Add missing shebang and execute perms so that patchShebangs can do its
# thing.
sed -i "1i #!/usr/bin/env python3" "$out/share/${pname}/bazarr.py"
chmod +x "$out/share/${pname}/bazarr.py"
makeWrapper "$out/share/${pname}/bazarr.py" \
"$out/bin/bazarr" \
--suffix PATH : ${lib.makeBinPath runtimeProgDeps}
runHook postInstall
'';
passthru.tests = {