Remove BlueSky PDS because it was added to nixpkgs
This commit is contained in:
parent
38f3a278f4
commit
0b5c640c27
5 changed files with 0 additions and 5918 deletions
|
@ -1,223 +0,0 @@
|
||||||
{
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
cfg = config.services.pds;
|
|
||||||
|
|
||||||
inherit (lib)
|
|
||||||
getExe
|
|
||||||
mkEnableOption
|
|
||||||
mkIf
|
|
||||||
mkOption
|
|
||||||
mkPackageOption
|
|
||||||
escapeShellArgs
|
|
||||||
concatMapStringsSep
|
|
||||||
types
|
|
||||||
literalExpression
|
|
||||||
;
|
|
||||||
|
|
||||||
pdsadminWrapper =
|
|
||||||
let
|
|
||||||
cfgSystemd = config.systemd.services.pds.serviceConfig;
|
|
||||||
in
|
|
||||||
pkgs.writeShellScriptBin "pdsadmin" ''
|
|
||||||
DUMMY_PDS_ENV_FILE="$(mktemp)"
|
|
||||||
trap 'rm -f "$DUMMY_PDS_ENV_FILE"' EXIT
|
|
||||||
env "PDS_ENV_FILE=$DUMMY_PDS_ENV_FILE" \
|
|
||||||
${escapeShellArgs cfgSystemd.Environment} \
|
|
||||||
${concatMapStringsSep " " (envFile: "$(cat ${envFile})") cfgSystemd.EnvironmentFile} \
|
|
||||||
${getExe pkgs.pdsadmin} "$@"
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
# All defaults are from https://github.com/bluesky-social/pds/blob/8b9fc24cec5f30066b0d0b86d2b0ba3d66c2b532/installer.sh
|
|
||||||
{
|
|
||||||
options.services.pds = {
|
|
||||||
enable = mkEnableOption "pds";
|
|
||||||
|
|
||||||
package = mkPackageOption pkgs "pds" { };
|
|
||||||
|
|
||||||
settings = mkOption {
|
|
||||||
type = types.submodule {
|
|
||||||
freeformType = types.attrsOf (types.nullOr types.str);
|
|
||||||
options = {
|
|
||||||
PDS_PORT = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "3000";
|
|
||||||
description = "Port to listen on";
|
|
||||||
};
|
|
||||||
|
|
||||||
PDS_HOSTNAME = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
example = "pds.example.com";
|
|
||||||
description = "Instance hostname (base domain name)";
|
|
||||||
};
|
|
||||||
|
|
||||||
PDS_BLOB_UPLOAD_LIMIT = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "52428800";
|
|
||||||
description = "Size limit of uploaded blobs";
|
|
||||||
};
|
|
||||||
|
|
||||||
PDS_DID_PLC_URL = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "https://plc.directory";
|
|
||||||
description = "URL of DID PLC directory";
|
|
||||||
};
|
|
||||||
|
|
||||||
PDS_BSKY_APP_VIEW_URL = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "https://api.bsky.app";
|
|
||||||
description = "URL of bsky frontend";
|
|
||||||
};
|
|
||||||
|
|
||||||
PDS_BSKY_APP_VIEW_DID = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "did:web:api.bsky.app";
|
|
||||||
description = "DID of bsky frontend";
|
|
||||||
};
|
|
||||||
|
|
||||||
PDS_REPORT_SERVICE_URL = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "https://mod.bsky.app";
|
|
||||||
description = "URL of mod service";
|
|
||||||
};
|
|
||||||
|
|
||||||
PDS_REPORT_SERVICE_DID = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "did:plc:ar7c4by46qjdydhdevvrndac";
|
|
||||||
description = "DID of mod service";
|
|
||||||
};
|
|
||||||
|
|
||||||
PDS_CRAWLERS = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "https://bsky.network";
|
|
||||||
description = "URL of crawlers";
|
|
||||||
};
|
|
||||||
|
|
||||||
PDS_DATA_DIRECTORY = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "/var/lib/pds";
|
|
||||||
description = "Directory to store state";
|
|
||||||
};
|
|
||||||
|
|
||||||
PDS_BLOBSTORE_DISK_LOCATION = mkOption {
|
|
||||||
type = types.nullOr types.str;
|
|
||||||
default = "/var/lib/pds/blocks";
|
|
||||||
description = "Store blobs at this location, set to null to use e.g. S3";
|
|
||||||
};
|
|
||||||
|
|
||||||
LOG_ENABLED = mkOption {
|
|
||||||
type = types.nullOr types.str;
|
|
||||||
default = "true";
|
|
||||||
description = "Enable logging";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
description = ''
|
|
||||||
Environment variables to set for the service. Secrets should be
|
|
||||||
specified using {option}`environmentFile`.
|
|
||||||
|
|
||||||
Refer to <https://github.com/bluesky-social/atproto/blob/92cd7a84ad207278c241afce8c8491e73b0a24e0/packages/pds/src/config/env.ts> for available environment variables.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
environmentFiles = mkOption {
|
|
||||||
type = types.listOf types.path;
|
|
||||||
default = [ ];
|
|
||||||
description = ''
|
|
||||||
File to load environment variables from. Loaded variables override
|
|
||||||
values set in {option}`environment`.
|
|
||||||
|
|
||||||
Use it to set values of `PDS_JWT_SECRET`, `PDS_ADMIN_PASSWORD`,
|
|
||||||
and `PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX` secrets.
|
|
||||||
You can generate initial values with
|
|
||||||
```
|
|
||||||
nix-build -A pds.passthru.generateSecrets
|
|
||||||
./result/bin/generate-pds-secrets > secrets.env
|
|
||||||
```
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
pdsadmin = {
|
|
||||||
enable = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = cfg.enable;
|
|
||||||
defaultText = literalExpression "services.pds.enable";
|
|
||||||
description = "Add pdsadmin script to PATH";
|
|
||||||
};
|
|
||||||
|
|
||||||
useServiceEnvironment = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = true;
|
|
||||||
description = "Inherit environment variables of pds systemd unit";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
|
||||||
environment = mkIf cfg.pdsadmin.enable {
|
|
||||||
systemPackages = [
|
|
||||||
(if cfg.pdsadmin.useServiceEnvironment then pdsadminWrapper else pkgs.pdsadmin)
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.services.pds = {
|
|
||||||
description = "pds";
|
|
||||||
wants = [ "network-online.target" ];
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
|
|
||||||
serviceConfig = {
|
|
||||||
ExecStart = getExe cfg.package;
|
|
||||||
Environment = lib.mapAttrsToList (k: v: "${k}=${v}") (
|
|
||||||
lib.filterAttrs (_: v: v != null) cfg.settings
|
|
||||||
);
|
|
||||||
|
|
||||||
EnvironmentFile = cfg.environmentFiles;
|
|
||||||
User = "pds";
|
|
||||||
Group = "pds";
|
|
||||||
StateDirectory = "pds";
|
|
||||||
StateDirectoryMode = "0755";
|
|
||||||
Restart = "always";
|
|
||||||
|
|
||||||
# Hardening
|
|
||||||
DynamicUser = true;
|
|
||||||
RemoveIPC = true;
|
|
||||||
CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];
|
|
||||||
NoNewPrivileges = true;
|
|
||||||
PrivateDevices = true;
|
|
||||||
ProtectClock = true;
|
|
||||||
ProtectKernelLogs = true;
|
|
||||||
ProtectControlGroups = true;
|
|
||||||
ProtectKernelModules = true;
|
|
||||||
PrivateMounts = true;
|
|
||||||
SystemCallArchitectures = [ "native" ];
|
|
||||||
MemoryDenyWriteExecute = false; # V8 JIT
|
|
||||||
RestrictNamespaces = true;
|
|
||||||
RestrictSUIDSGID = true;
|
|
||||||
ProtectHostname = true;
|
|
||||||
LockPersonality = true;
|
|
||||||
ProtectKernelTunables = true;
|
|
||||||
RestrictAddressFamilies = [
|
|
||||||
"AF_UNIX"
|
|
||||||
"AF_INET"
|
|
||||||
"AF_INET6"
|
|
||||||
];
|
|
||||||
RestrictRealtime = true;
|
|
||||||
DeviceAllow = [ "" ];
|
|
||||||
ProtectSystem = "strict";
|
|
||||||
ProtectProc = "invisible";
|
|
||||||
ProcSubset = "pid";
|
|
||||||
ProtectHome = true;
|
|
||||||
PrivateUsers = true;
|
|
||||||
PrivateTmp = true;
|
|
||||||
UMask = "0077";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
meta.maintainers = with lib.maintainers; [ t4ccer ];
|
|
||||||
}
|
|
|
@ -1,119 +0,0 @@
|
||||||
{
|
|
||||||
stdenv,
|
|
||||||
makeBinaryWrapper,
|
|
||||||
removeReferencesTo,
|
|
||||||
srcOnly,
|
|
||||||
python3,
|
|
||||||
pnpm_9,
|
|
||||||
fetchFromGitHub,
|
|
||||||
nodejs,
|
|
||||||
vips,
|
|
||||||
pkg-config,
|
|
||||||
writeShellApplication,
|
|
||||||
bash,
|
|
||||||
xxd,
|
|
||||||
openssl,
|
|
||||||
nixosTests,
|
|
||||||
lib,
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
generateSecrets = writeShellApplication {
|
|
||||||
name = "generate-pds-secrets";
|
|
||||||
|
|
||||||
runtimeInputs = [
|
|
||||||
xxd
|
|
||||||
openssl
|
|
||||||
];
|
|
||||||
|
|
||||||
# Commands from https://github.com/bluesky-social/pds/blob/8b9fc24cec5f30066b0d0b86d2b0ba3d66c2b532/installer.sh
|
|
||||||
text = ''
|
|
||||||
echo "PDS_JWT_SECRET=$(openssl rand --hex 16)"
|
|
||||||
echo "PDS_ADMIN_PASSWORD=$(openssl rand --hex 16)"
|
|
||||||
echo "PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX=$(openssl ecparam --name secp256k1 --genkey --noout --outform DER | tail --bytes=+8 | head --bytes=32 | xxd --plain --cols 32)"
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
nodeSources = srcOnly nodejs;
|
|
||||||
pythonEnv = python3.withPackages (p: [ p.setuptools ]);
|
|
||||||
in
|
|
||||||
|
|
||||||
stdenv.mkDerivation (finalAttrs: {
|
|
||||||
pname = "pds";
|
|
||||||
version = "0.4.74";
|
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
|
||||||
owner = "bluesky-social";
|
|
||||||
repo = "pds";
|
|
||||||
rev = "v${finalAttrs.version}";
|
|
||||||
hash = "sha256-kNHsQ6funmo8bnkFBNWHQ0Fmd5nf/uh+x9buaRJMZnM=";
|
|
||||||
};
|
|
||||||
|
|
||||||
sourceRoot = "${finalAttrs.src.name}/service";
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
makeBinaryWrapper
|
|
||||||
nodejs
|
|
||||||
pythonEnv
|
|
||||||
pkg-config
|
|
||||||
pnpm_9.configHook
|
|
||||||
];
|
|
||||||
|
|
||||||
# Required for `sharp` NPM dependency
|
|
||||||
buildInputs = [ vips ];
|
|
||||||
|
|
||||||
pnpmDeps = pnpm_9.fetchDeps {
|
|
||||||
inherit (finalAttrs)
|
|
||||||
pname
|
|
||||||
version
|
|
||||||
src
|
|
||||||
sourceRoot
|
|
||||||
;
|
|
||||||
hash = "sha256-oU4dwlBdsMmgAUv1ICaOqaqucmg/TjKOZxjnxpm0qL8=";
|
|
||||||
};
|
|
||||||
|
|
||||||
buildPhase = ''
|
|
||||||
runHook preBuild
|
|
||||||
|
|
||||||
pushd ./node_modules/.pnpm/better-sqlite3@*/node_modules/better-sqlite3
|
|
||||||
npm run build-release --offline --nodedir="${nodeSources}"
|
|
||||||
find build -type f -exec remove-references-to -t "${nodeSources}" {} \;
|
|
||||||
popd
|
|
||||||
|
|
||||||
makeWrapper "${lib.getExe nodejs}" "$out/bin/pds" \
|
|
||||||
--add-flags --enable-source-maps \
|
|
||||||
--add-flags "$out/lib/pds/index.js" \
|
|
||||||
--set-default NODE_ENV production
|
|
||||||
|
|
||||||
runHook postBuild
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
|
|
||||||
mkdir -p $out/{bin,lib/pds}
|
|
||||||
mv node_modules $out/lib/pds
|
|
||||||
mv index.js $out/lib/pds
|
|
||||||
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
inherit generateSecrets;
|
|
||||||
tests = {
|
|
||||||
inherit (nixosTests) pds;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
description = "Bluesky Personal Data Server (PDS)";
|
|
||||||
homepage = "https://bsky.social";
|
|
||||||
license = with lib.licenses; [
|
|
||||||
mit
|
|
||||||
asl20
|
|
||||||
];
|
|
||||||
maintainers = with lib.maintainers; [ t4ccer ];
|
|
||||||
platforms = lib.platforms.unix;
|
|
||||||
mainProgram = "pds";
|
|
||||||
};
|
|
||||||
})
|
|
5490
pkgs/pds/package-lock.json
generated
5490
pkgs/pds/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,62 +0,0 @@
|
||||||
{
|
|
||||||
stdenvNoCC,
|
|
||||||
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
|
|
||||||
|
|
||||||
mkdir -p $out/lib/pds
|
|
||||||
install -Dm755 pdsadmin.sh $out/lib/pds/
|
|
||||||
install -Dm755 pdsadmin/*.sh $out/lib/pds/
|
|
||||||
makeBinaryWrapper "$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";
|
|
||||||
};
|
|
||||||
})
|
|
|
@ -1,24 +0,0 @@
|
||||||
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}" "$@"
|
|
Loading…
Add table
Reference in a new issue