From 35dab762956548a98d7c8a09c27a0ff18285e4ef Mon Sep 17 00:00:00 2001 From: dish Date: Sat, 9 Nov 2024 13:36:27 -0500 Subject: [PATCH] archivebox: modernize --- pkgs/by-name/ar/archivebox/package.nix | 65 +++++++++++++++----------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/pkgs/by-name/ar/archivebox/package.nix b/pkgs/by-name/ar/archivebox/package.nix index 69f58336d323b..65e211c55c909 100644 --- a/pkgs/by-name/ar/archivebox/package.nix +++ b/pkgs/by-name/ar/archivebox/package.nix @@ -11,6 +11,8 @@ readability-extractor, chromium, yt-dlp, + versionCheckHook, + nix-update-script, }: let @@ -66,15 +68,17 @@ python.pkgs.buildPythonApplication rec { fetchSubmodules = true; }; - nativeBuildInputs = with python.pkgs; [ + build-system = with python.pkgs; [ pdm-backend ]; - propagatedBuildInputs = + dependencies = with python.pkgs; [ # Core Libraries django + # Tests do not pass in the Nix build environment, so disable them. + # It still works properly (django-ninja.overridePythonAttrs { doCheck = false; }) django-extensions mypy-extensions @@ -117,11 +121,9 @@ python.pkgs.buildPythonApplication rec { pocket sonic-client yt-dlp - # Plugin dependencies ] - ++ python.pkgs.python-benedict.optional-dependencies.io - ++ python.pkgs.python-benedict.optional-dependencies.parse; + ++ lib.flatten (lib.attrValues python.pkgs.python-benedict.optional-dependencies); optional-dependencies = { ldap = with python.pkgs; [ @@ -137,36 +139,43 @@ python.pkgs.buildPythonApplication rec { ]; }; - makeWrapperArgs = - [ - "--set USE_NODE True" # used through dependencies, not needed explicitly - "--set READABILITY_BINARY ${lib.meta.getExe readability-extractor}" - "--set MERCURY_BINARY ${lib.meta.getExe postlight-parser}" - "--set CURL_BINARY ${lib.meta.getExe curl}" - "--set RIPGREP_BINARY ${lib.meta.getExe ripgrep}" - "--set WGET_BINARY ${lib.meta.getExe wget}" - "--set GIT_BINARY ${lib.meta.getExe git}" - "--set YOUTUBEDL_BINARY ${lib.meta.getExe yt-dlp}" - ] - ++ ( + nativeInstallCheckInputs = [ + versionCheckHook + ]; + + pythonImportsCheck = [ "archivebox" ]; + + makeWrapperArgs = [ + "--set USE_NODE True" # used through dependencies, not needed explicitly + "--set READABILITY_BINARY ${lib.getExe readability-extractor}" + "--set MERCURY_BINARY ${lib.getExe postlight-parser}" + "--set CURL_BINARY ${lib.getExe curl}" + "--set RIPGREP_BINARY ${lib.getExe ripgrep}" + "--set WGET_BINARY ${lib.getExe wget}" + "--set GIT_BINARY ${lib.getExe git}" + "--set YOUTUBEDL_BINARY ${lib.getExe yt-dlp}" + ( if (lib.meta.availableOn stdenv.hostPlatform chromium) then - [ - "--set CHROME_BINARY ${chromium}/bin/chromium-browser" - ] + "--set CHROME_BINARY ${lib.getExe chromium}" else - [ - "--set-default USE_CHROME False" - ] - ); + "--set-default USE_CHROME False" + ) + ]; + + passthru = { + updateScript = nix-update-script { }; + }; - meta = with lib; { + meta = { description = "Open source self-hosted web archiving"; homepage = "https://archivebox.io"; - license = licenses.mit; - maintainers = with maintainers; [ + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ siraben viraptor + pyrox0 ]; - platforms = platforms.unix; + platforms = lib.platforms.unix; + mainProgram = "archivebox"; }; }