nixpkgs/pkgs/by-name/sa/sabnzbd/package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

118 lines
2.2 KiB
Nix
Raw Permalink Normal View History

2024-07-12 12:57:10 +00:00
{
lib,
stdenv,
coreutils,
fetchFromGitHub,
fetchPypi,
2024-07-12 12:57:10 +00:00
python3,
par2cmdline-turbo,
unzip,
unrar,
p7zip,
util-linux,
makeWrapper,
nixosTests,
2020-08-22 02:20:28 +00:00
}:
2016-09-26 18:52:21 +00:00
let
2024-08-26 18:48:07 +00:00
sabctoolsVersion = "8.2.5";
sabctoolsHash = "sha256-ZEC813/JpGPEFL+nXKFAXFfUrrhECCIqONe27LwS00g=";
2024-07-12 12:57:10 +00:00
pythonEnv = python3.withPackages (
ps: with ps; [
apprise
babelfish
cffi
chardet
cheetah3
cheroot
cherrypy
configobj
cryptography
feedparser
guessit
jaraco-classes
jaraco-collections
jaraco-context
jaraco-functools
jaraco-text
more-itertools
notify2
orjson
portend
puremagic
pycparser
pysocks
python-dateutil
pytz
rebulk
# sabnzbd requires a specific version of sabctools
(sabctools.overridePythonAttrs (old: {
version = sabctoolsVersion;
src = fetchPypi {
pname = "sabctools";
version = sabctoolsVersion;
hash = sabctoolsHash;
};
}))
2024-07-12 12:57:10 +00:00
sabyenc3
sgmllib3k
six
tempora
zc-lockfile
]
);
path = lib.makeBinPath [
coreutils
par2cmdline-turbo
unrar
unzip
p7zip
util-linux
];
in
stdenv.mkDerivation rec {
2025-04-09 10:09:28 +00:00
version = "4.5.0";
2017-02-14 13:14:27 +00:00
pname = "sabnzbd";
2017-02-14 13:14:27 +00:00
src = fetchFromGitHub {
treewide: substitute pname for strings Inspired by https://github.com/NixOS/nixpkgs/pull/387725#issuecomment-2704943777, script is based on https://github.com/NixOS/nixpkgs/pull/336172 using what i learned in https://github.com/NixOS/nixpkgs/pull/386865, part of https://github.com/NixOS/nixpkgs/issues/346453 Should be zero rebuilds. All candidates were made using: ```shell export NIXPKGS_ALLOW_UNFREE=1 export NIXPKGS_ALLOW_INSECURE=1 export NIXPKGS_ALLOW_BROKEN=1 git-wait restore . test -s packages.json || ( set -x; time nix-env --extra-experimental-features no-url-literals --option system x86_64-linux -f ./. -qaP --json --meta --drv-path --out-path --show-trace --no-allow-import-from-derivation --arg config '{ allowAliases = false; }' > packages.json ) list_attrpath_fname_col() { jq <packages.json 'to_entries[] | select(.value.meta.position==null|not) | "\(.key)\t\(.value.meta.position)"' -r | sed -e "s#\t$(realpath .)/#\t#" | sed -e 's#:\([0-9]*\)$#\t\1#' | grep . | grep -iv haskell | grep -iv /top-level/ | grep -iv chicken | grep pkgs/by-name/ | grep -iv build | grep -E '/(package|default)\.nix' } FLOCKDIR="$(mktemp -d)" N_WORKERS=4 while read attrpath fname col; do grep -qE 'repo *= *("\$\{pname\}"|pname);' "$fname" || continue echo | ( # mutex on fname flock --nonblock 200 || { >&2 echo "failed to aquire lock for $fname" exit 1 } echo "$attrpath" data="$(nix eval --impure --expr 'with import ./. {}; { inherit ('"$attrpath"') pname drvPath passthru meta; drvPath2='"$attrpath"'.src.drvPath; }' --json)" || exit test -n "$data" || exit pname="$(jq <<<"$data" .pname -r)" test -n "$pname" || exit (set -x sd -F '${pname}' "$pname" "$fname" sd -F ' = pname;' " = \"$pname\";" "$fname" ) data2="$(nix eval --impure --expr 'with import ./. {}; { inherit ('"$attrpath"') pname drvPath passthru meta; drvPath2='"$attrpath"'.src.drvPath; }' --json)" if [[ "$data" = "$data2" ]]; then (set -x; git-wait add "$fname") else (set -x; git-wait restore "$fname") exit fi (set -x sd -F ' rec {' ' {' "$fname" ) data3="$(nix eval --impure --expr 'with import ./. {}; { inherit ('"$attrpath"') pname drvPath passthru meta; drvPath2='"$attrpath"'.src.drvPath; }' --json 2>/dev/nul)" if [[ "$data" = "$data3" ]]; then (set -x; git-wait add "$fname") else (set -x; git-wait restore "$fname") fi ) 200>"$FLOCKDIR"/"$(sha256sum - <<<"$fname" | cut -d' ' -f1)".lock & while [[ $(jobs -p | wc -l) -ge $N_WORKERS ]]; do wait -n < <(jobs -p) || true done done < <(list_attrpath_fname_col) wait git restore . time nix-env --extra-experimental-features no-url-literals --option system x86_64-linux -f ./. -qaP --json --meta --drv-path --out-path --show-trace --no-allow-import-from-derivation --arg config '{ allowAliases = false; }' > packages2.json ``` `diff packages{,2}.json` is empty, indicating that no package nor src derivation has changed. I checked and cherry-picked the changes using `GIT_DIFF_OPTS='-u15' git -c interactive.singleKey=true add --patch`
2025-03-07 00:06:27 +00:00
owner = "sabnzbd";
repo = "sabnzbd";
rev = version;
2025-04-09 10:09:28 +00:00
hash = "sha256-X/ovfhP6QZOmYEfX2YchGWjkLBYZXNFuefXQyzKIW5s=";
};
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ pythonEnv ];
2016-09-26 18:52:21 +00:00
installPhase = ''
2021-06-21 12:57:43 +00:00
runHook preInstall
2016-09-26 18:52:21 +00:00
mkdir -p $out
cp -R * $out/
mkdir $out/bin
echo "${pythonEnv}/bin/python $out/SABnzbd.py \$*" > $out/bin/sabnzbd
chmod +x $out/bin/sabnzbd
wrapProgram $out/bin/sabnzbd --set PATH ${path}
2021-06-21 12:57:43 +00:00
runHook postInstall
2016-09-26 18:52:21 +00:00
'';
passthru = {
tests.smoke-test = nixosTests.sabnzbd;
updateScript = ./update.sh;
2021-09-21 11:38:22 +00:00
};
meta = with lib; {
description = "Usenet NZB downloader, par2 repairer and auto extracting server";
homepage = "https://sabnzbd.org";
license = licenses.gpl2Plus;
platforms = platforms.linux;
2024-07-12 12:57:10 +00:00
maintainers = with lib.maintainers; [
jojosch
adamcstephens
];
2023-11-23 21:09:35 +00:00
mainProgram = "sabnzbd";
};
}