diff --git a/pkgs/pds/default.nix b/pkgs/pds/default.nix index 1e96588..81a2825 100644 --- a/pkgs/pds/default.nix +++ b/pkgs/pds/default.nix @@ -1,10 +1,16 @@ { + stdenv, + makeBinaryWrapper, + removeReferencesTo, + srcOnly, + python3, + pnpm, fetchFromGitHub, nodejs, - buildNpmPackage, vips, pkg-config, writeShellApplication, + bash, xxd, openssl, nixosTests, @@ -27,38 +33,59 @@ let 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; + customPython3 = python3.withPackages (p: [ p.setuptools ]); in -# NOTE: Package comes with `pnpm-lock.yaml` but we cannot use `pnpm.fetchDeps` here because it -# does not work with `sharp` NPM dependency that needs `vips` and `pkg-config` -# Regenerate `package-lock.json` with `npm i --package-lock-only` -# Next release should have bumped `sharp` with pre-built binaries -buildNpmPackage rec { +stdenv.mkDerivation (finalAttrs: { pname = "pds"; - version = "0.4.67"; + version = "0.4.74"; src = fetchFromGitHub { owner = "bluesky-social"; repo = "pds"; - rev = "v${version}"; - hash = "sha256-dEB5u++Zx+F4TH5q44AF/tuwAhLEyYT+U5/18viT4sw="; + rev = "v${finalAttrs.version}"; + hash = "sha256-kNHsQ6funmo8bnkFBNWHQ0Fmd5nf/uh+x9buaRJMZnM="; }; - sourceRoot = "${src.name}/service"; + sourceRoot = "${finalAttrs.src.name}/service"; npmDepsHash = "sha256-uQKhODaVHLj+JEq6LYiJ/zXuu7kDCLmpxOs/VCc0GqQ="; - postPatch = '' - cp ${./package-lock.json} package-lock.json - ''; + nativeBuildInputs = [ + makeBinaryWrapper + nodejs + customPython3 + pkg-config + pnpm.configHook + ]; # Required for `sharp` NPM dependency - nativeBuildInputs = [ pkg-config ]; buildInputs = [ vips ]; + pnpmDeps = pnpm.fetchDeps { + inherit (finalAttrs) + pname + version + src + sourceRoot + ; + hash = "sha256-oU4dwlBdsMmgAUv1ICaOqaqucmg/TjKOZxjnxpm0qL8="; + }; + buildPhase = '' runHook preBuild + for f in $(find -path '*/node_modules/better-sqlite3' -type d); do + (cd "$f" && ( + npm run build-release --offline --nodedir=${nodeSources} + find build -type f -exec \ + ${lib.getExe removeReferencesTo} \ + -t "${nodeSources}" {} \; + )) + done + makeWrapper "${lib.getExe nodejs}" "$out/bin/pds" \ --add-flags --enable-source-maps \ --add-flags "$out/lib/pds/index.js" \ @@ -95,4 +122,4 @@ buildNpmPackage rec { platforms = lib.platforms.unix; mainProgram = "pds"; }; -} +}) diff --git a/pkgs/pdsadmin/default.nix b/pkgs/pdsadmin/default.nix index c444952..bccb445 100644 --- a/pkgs/pdsadmin/default.nix +++ b/pkgs/pdsadmin/default.nix @@ -15,13 +15,15 @@ stdenvNoCC.mkDerivation (finalAttrs: { patches = [ ./pdsadmin-offline.patch ]; + nativeBuildInputs = [ + makeBinaryWrapper + ]; + buildInputs = [ bash ]; - nativeBuildInputs = [ - makeBinaryWrapper - ]; + strictDeps = true; buildPhase = '' runHook preBuild