From 3d1b0b91ef08a691f8ece6824453de410784b8da Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Sat, 23 Jan 2021 16:09:29 +0100 Subject: [PATCH] getnative: init at 3.0.0 --- default.nix | 8 ++++++- tools/getnative/default.nix | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 tools/getnative/default.nix diff --git a/default.nix b/default.nix index b6b1962..e883f37 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,8 @@ -self: super: { +self: super: +let + callPythonPackage = super.vapoursynth.python3.pkgs.callPackage; +in +{ vapoursynthPlugins = super.recurseIntoAttrs { adaptivegrain = super.callPackage ./plugins/adaptivegrain { }; addgrain = super.callPackage ./plugins/addgrain { }; @@ -39,4 +43,6 @@ self: super: { wwxd = super.callPackage ./plugins/wwxd { }; znedi3 = super.callPackage ./plugins/znedi3 { }; }; + + getnative = callPythonPackage ./tools/getnative { }; } diff --git a/tools/getnative/default.nix b/tools/getnative/default.nix new file mode 100644 index 0000000..248ae37 --- /dev/null +++ b/tools/getnative/default.nix @@ -0,0 +1,44 @@ +{ lib, vapoursynth, vapoursynthPlugins, buildPythonApplication, fetchFromGitHub, matplotlib, imagemagick }: +let + vapoursynth-with-plugins = vapoursynth.withPlugins (with vapoursynthPlugins; [ + ffms2 + descale + ]); +in +buildPythonApplication rec { + pname = "getnative"; + version = "3.0.0"; + + src = fetchFromGitHub { + owner = "Infiziert90"; + repo = pname; + rev = version; + sha256 = "0jvvwyxlgarff2r5v2nvqmy2bw17anz4cid95gwbl3br4a2pmhzn"; + }; + + # vapoursynth is not recognised during installation + postPatch = '' + substituteInPlace requirements.txt \ + --replace "VapourSynth>=45" "" + ''; + + propagatedBuildInputs = [ + matplotlib + vapoursynth-with-plugins + ]; + + checkInputs = [ imagemagick ]; + checkPhase = '' + convert -size 1280x720 canvas: +noise Random test.png + $out/bin/getnative --min-height 699 --max-height 700 test.png + $out/bin/getnative --min-height 699 --max-height 700 -u ffms2.Source test.png + ''; + + meta = with lib; { + description = "A cli tool to find the native resolution(s) of upscaled material (mostly anime)"; + homepage = "https://github.com/Infiziert90/getnative"; + license = licenses.mit; + maintainers = with maintainers; [ sbruder ]; + platforms = platforms.all; + }; +}