From 8cabcfbf136559c5eca73a350d107cf0167a62d7 Mon Sep 17 00:00:00 2001 From: t4ccer Date: Thu, 7 Nov 2024 21:35:39 -0700 Subject: [PATCH] pdsadmin: init at 0.4.67 --- pkgs/by-name/pd/pdsadmin/package.nix | 45 +++++++++++++++++++ .../pd/pdsadmin/pdsadmin-offline.patch | 24 ++++++++++ 2 files changed, 69 insertions(+) create mode 100644 pkgs/by-name/pd/pdsadmin/package.nix create mode 100644 pkgs/by-name/pd/pdsadmin/pdsadmin-offline.patch diff --git a/pkgs/by-name/pd/pdsadmin/package.nix b/pkgs/by-name/pd/pdsadmin/package.nix new file mode 100644 index 0000000000000..fe7d3dbe0f6c3 --- /dev/null +++ b/pkgs/by-name/pd/pdsadmin/package.nix @@ -0,0 +1,45 @@ +{ + stdenvNoCC, + fetchFromGitHub, + lib, + bash, + pds, +}: + +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "pdsadmin"; + inherit (pds) version src; + + patches = [ ./pdsadmin-offline.patch ]; + + nativeBuildInputs = [ bash ]; + + buildPhase = '' + patchShebangs . pdsadmin + substituteInPlace pdsadmin.sh \ + --replace-fail NIXPKGS_PDSADMIN_ROOT $out + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/{bin,lib} + + install -Dm755 pdsadmin.sh $out/bin/pdsadmin + install -Dm755 pdsadmin/*.sh $out/lib + + runHook postInstall + ''; + + meta = { + description = "Admin scripts for Bluesky Personal Data Server (PDS)"; + homepage = "https://github.com/bluesky-social/pds"; + license = with lib.licenses; [ + mit + asl20 + ]; + maintainers = with lib.maintainers; [ t4ccer ]; + platforms = lib.platforms.unix; + mainProgram = "pdsadmin"; + }; +}) diff --git a/pkgs/by-name/pd/pdsadmin/pdsadmin-offline.patch b/pkgs/by-name/pd/pdsadmin/pdsadmin-offline.patch new file mode 100644 index 0000000000000..40cbc970e27d3 --- /dev/null +++ b/pkgs/by-name/pd/pdsadmin/pdsadmin-offline.patch @@ -0,0 +1,24 @@ +diff --git a/pdsadmin.sh b/pdsadmin.sh +index 913d2b4..b09c20c 100644 +--- a/pdsadmin.sh ++++ b/pdsadmin.sh +@@ -15,16 +15,11 @@ if [[ "${EUID}" -ne 0 ]]; then + exit 1 + fi + +-# Download the script, if it exists. +-SCRIPT_URL="${PDSADMIN_BASE_URL}/${COMMAND}.sh" +-SCRIPT_FILE="$(mktemp /tmp/pdsadmin.${COMMAND}.XXXXXX)" ++SCRIPT_FILE="NIXPKGS_PDSADMIN_ROOT/lib/${COMMAND}.sh" + +-if ! curl --fail --silent --show-error --location --output "${SCRIPT_FILE}" "${SCRIPT_URL}"; then ++if ! [ -f "${SCRIPT_FILE}" ]; then + echo "ERROR: ${COMMAND} not found" + exit 2 + fi + +-chmod +x "${SCRIPT_FILE}" +-if "${SCRIPT_FILE}" "$@"; then +- rm --force "${SCRIPT_FILE}" +-fi ++"${SCRIPT_FILE}" "$@"