Unverified Commit 61605153 authored by Nick Cao's avatar Nick Cao Committed by GitHub
Browse files

video2x: init at 6.4.0 (#385636)

parents beb9682f 7c12d2cf
Loading
Loading
Loading
Loading
+94 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  cmake,
  fetchFromGitHub,
  pkg-config,
  versionCheckHook,
  nix-update-script,
  boost,
  ffmpeg,
  glslang,
  llvmPackages,
  ncnn,
  spdlog,
  vulkan-headers,
  vulkan-loader,
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "video2x";
  version = "6.4.0";

  src = fetchFromGitHub {
    owner = "k4yt3x";
    repo = "video2x";
    tag = finalAttrs.version;
    hash = "sha256-DSsfGAkPOtqqj0FA1N33O+OYmv+CMUsrvmh5SrnF7eA=";
    fetchSubmodules = false;
    leaveDotGit = true;
    postFetch = ''
      pushd $out
      git reset --hard HEAD

      # Fetch the dependencies that nixpkgs cannot provide (non-recursive)
      git submodule update --init third_party/librealesrgan_ncnn_vulkan
      git submodule update --init third_party/librealcugan_ncnn_vulkan
      git submodule update --init third_party/librife_ncnn_vulkan

      # Cleanup
      rm -rf .git

      popd
    '';
  };

  postPatch = ''
    substituteInPlace src/fsutils.cpp \
      --replace-fail '/usr/share/video2x' '${placeholder "out"}/share/video2x'
  '';

  strictDeps = true;

  nativeBuildInputs = [
    cmake
    pkg-config
    glslang
  ];

  buildInputs =
    [
      boost
      ffmpeg
      ncnn
      spdlog
      vulkan-headers
      vulkan-loader
    ]
    ++ lib.optionals stdenv.cc.isClang [
      llvmPackages.openmp
    ];

  cmakeFlags = [
    # Don't build the libvideo2x shared library, we only need the CLI tool
    (lib.cmakeBool "BUILD_SHARED_LIBS" false)
  ];

  nativeInstallCheckInputs = [ versionCheckHook ];

  versionCheckProgramArg = [ "--version" ];
  doInstallCheck = true;

  passthru = {
    updateScript = nix-update-script { };
  };

  meta = {
    description = "AI-powered video upscaling tool";
    changelog = "https://github.com/k4yt3x/video2x/releases/tag/${finalAttrs.version}/CHANGELOG.md";
    homepage = "https://github.com/k4yt3x/video2x";
    license = lib.licenses.agpl3Plus;
    platforms = [ "x86_64-linux" ];
    mainProgram = "video2x";
    maintainers = [ lib.maintainers.matteopacini ];
  };
})