Unverified Commit a0bc52cf authored by t4ccer's avatar t4ccer
Browse files

pdsadmin: init at 0.4.74

parent 1a7820b2
Loading
Loading
Loading
Loading
+58 −0
Original line number Diff line number Diff line
{
  stdenvNoCC,
  fetchFromGitHub,
  bash,
  pds,
  makeBinaryWrapper,
  jq,
  curl,
  openssl,
  lib,
}:

stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "pdsadmin";
  inherit (pds) version src;

  patches = [ ./pdsadmin-offline.patch ];

  nativeBuildInputs = [ makeBinaryWrapper ];

  buildInputs = [ bash ];

  strictDeps = true;

  buildPhase = ''
    runHook preBuild

    substituteInPlace pdsadmin.sh \
      --replace-fail NIXPKGS_PDSADMIN_ROOT $out

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    install -Dm755 pdsadmin.sh $out/lib/pds/pdsadmin.sh
    install -Dm755 pdsadmin/*.sh $out/lib/pds
    makeWrapper "$out/lib/pds/pdsadmin.sh" "$out/bin/pdsadmin" \
      --prefix PATH : "${
        lib.makeBinPath [
          jq
          curl
          openssl
        ]
      }"

    runHook postInstall
  '';

  meta = {
    description = "Admin scripts for Bluesky Personal Data Server (PDS)";
    inherit (pds.meta) homepage license;
    maintainers = with lib.maintainers; [ t4ccer ];
    platforms = lib.platforms.unix;
    mainProgram = "pdsadmin";
  };
})
+24 −0
Original line number Diff line number Diff line
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/pds/${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}" "$@"