nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 makeBinaryWrapper,
4 removeReferencesTo,
5 srcOnly,
6 python3,
7 pnpm_9,
8 fetchPnpmDeps,
9 pnpmConfigHook,
10 fetchFromGitHub,
11 nodejs_22,
12 vips,
13 pkg-config,
14 nixosTests,
15 lib,
16 nix-update-script,
17 cctools,
18}:
19
20let
21 # build failure against better-sqlite3, so we use nodejs_22; upstream
22 # bluesky-pds uses 20
23 nodejs = nodejs_22;
24 nodeSources = srcOnly nodejs;
25 pythonEnv = python3.withPackages (p: [ p.setuptools ]);
26in
27
28stdenv.mkDerivation (finalAttrs: {
29 pname = "pds";
30 version = "0.4.204";
31
32 src = fetchFromGitHub {
33 owner = "bluesky-social";
34 repo = "pds";
35 tag = "v${finalAttrs.version}";
36 hash = "sha256-jYCMwHKKFIsfOgGYiKVrWtIT7atPA8NsetvfjDW05yE=";
37 };
38
39 sourceRoot = "${finalAttrs.src.name}/service";
40
41 nativeBuildInputs = [
42 makeBinaryWrapper
43 nodejs
44 pythonEnv
45 pkg-config
46 pnpmConfigHook
47 pnpm_9
48 removeReferencesTo
49 ]
50 ++ lib.optionals stdenv.hostPlatform.isDarwin [
51 cctools.libtool
52 ];
53
54 # Required for `sharp` NPM dependency
55 buildInputs = [ vips ];
56
57 pnpmDeps = fetchPnpmDeps {
58 inherit (finalAttrs)
59 pname
60 version
61 src
62 sourceRoot
63 ;
64 pnpm = pnpm_9;
65 fetcherVersion = 2;
66 hash = "sha256-G6xZfbfz+jud1N6lxwp5FA5baAkFwmofejsPt/Gaze8=";
67 };
68
69 buildPhase = ''
70 runHook preBuild
71
72 pushd ./node_modules/.pnpm/better-sqlite3@*/node_modules/better-sqlite3
73 npm run build-release --offline --nodedir="${nodeSources}"
74 find build -type f -exec remove-references-to -t "${nodeSources}" {} \;
75 popd
76
77 makeWrapper "${lib.getExe nodejs}" "$out/bin/pds" \
78 --add-flags --enable-source-maps \
79 --add-flags "$out/lib/pds/index.js" \
80 --set-default NODE_ENV production
81
82 runHook postBuild
83 '';
84
85 installPhase = ''
86 runHook preInstall
87
88 mkdir -p $out/{bin,lib/pds}
89 mv node_modules $out/lib/pds
90 mv index.js $out/lib/pds
91
92 runHook postInstall
93 '';
94
95 passthru = {
96 tests = lib.optionalAttrs stdenv.hostPlatform.isLinux { inherit (nixosTests) bluesky-pds; };
97 updateScript = nix-update-script { };
98 };
99
100 meta = {
101 description = "Bluesky Personal Data Server (PDS)";
102 homepage = "https://github.com/bluesky-social/pds";
103 license = with lib.licenses; [
104 mit
105 asl20
106 ];
107 maintainers = with lib.maintainers; [
108 t4ccer
109 isabelroses
110 ];
111 platforms = lib.platforms.unix;
112 mainProgram = "pds";
113 };
114})