From 3a7b48d67de536538d755f6d18af71cc65eafc49 Mon Sep 17 00:00:00 2001 From: klea Date: Thu, 11 Dec 2025 20:42:41 +0000 Subject: pywb: create wrapper --- pkgs/default.nix | 13 +++++++++++-- pkgs/pywb/default.nix | 29 +++++++++++++++++++++++++++++ pkgs/pywikibot-scripts/default.nix.bak | 29 +++++++++++++++++++++++++++++ pkgs/shell/default.nix | 2 ++ 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 pkgs/pywb/default.nix create mode 100644 pkgs/pywikibot-scripts/default.nix.bak diff --git a/pkgs/default.nix b/pkgs/default.nix index aee22c3..c115292 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -5,8 +5,17 @@ lib.makeScope newScope (self: { /*example = self.callPackage ./example { };*/ pywikibot-scripts = self.callPackage ./pywikibot-scripts { }; - pywikibot = self.callPackage ./pywikibot { pywikibot-scripts = self.pywikibot-scripts; }; + pywikibot = self.callPackage ./pywikibot { + pywikibot-scripts = self.pywikibot-scripts; + }; + pywb = self.callPackage ./pywb { + pywikibot = self.pywikibot; + pywikibot-scripts = self.pywikibot-scripts; + }; - shell = self.callPackage ./shell { pywikibot = self.pywikibot; }; + shell = self.callPackage ./shell { + pywb = self.pywb; + pywikibot = self.pywikibot; + }; }) diff --git a/pkgs/pywb/default.nix b/pkgs/pywb/default.nix new file mode 100644 index 0000000..9664cd7 --- /dev/null +++ b/pkgs/pywb/default.nix @@ -0,0 +1,29 @@ +{ lib +, writeShellApplication +, python3 +, pywikibot-scripts +, pywikibot +}: + +writeShellApplication { + name = "pywb"; + text = '' + pwbs="${pywikibot-scripts}/${python3.sitePackages}/scripts" + if [ -z "''${1:-}" ]; then + echo "not specified command to run" >&2 + exit 2 + fi + if [ -f "$pwbs/''${1:-}.py" ]; then + exec "${pywikibot}/bin/pwb" "$pwbs/''${1:-}" "$@" + elif [ -f "$pwbs/''${1:-}" ]; then + exec "${pywikibot}/bin/pwb" "$pwbs/''${1:-}" "$@" + else + if [ "$1" = "__get_path" ]; then + echo "$pwbs" + exit + fi + echo "$1 not found in pywkibot's scripts folder (make sure it doesn't end in .py)" >&2 + exit 1 + fi + ''; +} diff --git a/pkgs/pywikibot-scripts/default.nix.bak b/pkgs/pywikibot-scripts/default.nix.bak new file mode 100644 index 0000000..18e9b28 --- /dev/null +++ b/pkgs/pywikibot-scripts/default.nix.bak @@ -0,0 +1,29 @@ +{ + lib, + fetchgit, + python3, + stdenv, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "pywikibot-scripts"; + version = "f1b4b4d0cfbc199c36fb72570425328daa93b067"; + + src = fetchgit { + url = "https://gerrit.wikimedia.org/r/pywikibot/core"; + rev = finalAttrs.version; + fetchSubmodules = true; + hash = "sha256-L/Yz9yidpTV7WCqHs2L6lFw/CpQyZ1UNd+NpMLJT0Hs="; + }; + + wbsitePackages = "${placeholder "out"}/${python3.sitePackages}"; + wbdistInfo = "${finalAttrs.wbsitePackages}/scripts-${finalAttrs.version}.dist-info"; + installPhase = '' + #mkdir -p ${finalAttrs.wbsitePackages} ${finalAttrs.wbdistInfo} + #cp -r $src/scripts/ ${finalAttrs.wbsitePackages}/ + #printf "Metadata-Version: 2.4\nName: scripts\nVersion: ${finalAttrs.version}\n" >${finalAttrs.wbdistInfo}/METADATA + #printf "Wheel-Version: 1.0\n" >${finalAttrs.wbdistInfo}/WHEEL + #echo "scripts" >${finalAttrs.wbdistInfo}/top_level.txt + #touch ${finalAttrs.wbdistInfo}/RECORD + ''; +}) diff --git a/pkgs/shell/default.nix b/pkgs/shell/default.nix index 85fa3a7..3db055d 100644 --- a/pkgs/shell/default.nix +++ b/pkgs/shell/default.nix @@ -8,6 +8,7 @@ , git , internetarchive , pywikibot +, pywb }: mkShellNoCC { @@ -18,6 +19,7 @@ mkShellNoCC { pywikibot ])) pywikibot + pywb websocat # connect to websocket jq libfaketime # used by my fossil script -- cgit v1.3.1-10-gc9f91