Our Personal Data Server from scratch!
tranquil.farm
oauth
atproto
pds
rust
postgresql
objectstorage
fun
1{
2 lib,
3 stdenvNoCC,
4
5 fetchDenoDeps,
6 fetchFromGitHub,
7
8 buildGoModule,
9
10 deno,
11 esbuild,
12}: let
13 toml = (lib.importTOML ./Cargo.toml).workspace.package;
14 deno-deps = fetchDenoDeps {
15 pname = "tranquil-frontend-deno-deps";
16 denoLock = ./frontend/deno.lock;
17 hash = "sha256-UB+E00TjWX0fTUZ7XwcwRJ/OUOSSJpz6Ss04U5i8dGI=";
18 };
19 # the esbuild in upstream nixpkgs is too old.
20 esbuild' = esbuild.override {
21 buildGoModule = args: buildGoModule (
22 args // (
23 let
24 version = "0.27.2";
25 in {
26 inherit version;
27 src = fetchFromGitHub {
28 owner = "evanw";
29 repo = "esbuild";
30 tag = "v${version}";
31 hash = "sha256-JbJB3F1NQlmA5d0rdsLm4RVD24OPdV4QXpxW8VWbESA";
32 };
33 vendorHash = "sha256-+BfxCyg0KkDQpHt/wycy/8CTG6YBA/VJvJFhhzUnSiQ";
34 }
35 )
36 );
37 };
38in stdenvNoCC.mkDerivation {
39 pname = "tranquil-frontend";
40 inherit (toml) version;
41
42 src = ./frontend;
43
44 nativeBuildInputs = [
45 deno
46 ];
47 # tell vite (through the esbuild api) where the nix provided esbuild binary is
48 env.ESBUILD_BINARY_PATH = lib.getExe esbuild';
49
50 buildPhase = ''
51 # copy the deps to the required location
52 cp -r --no-preserve=mode ${deno-deps.denoDeps}/.deno ./
53 cp -r --no-preserve=mode ${deno-deps.denoDeps}/vendor ./
54
55 pwd
56 ls /build/frontend/vendor
57
58 # Now you can run the project using deps
59 # you need to activate [deno's vendor feature](https://docs.deno.com/runtime/fundamentals/modules/#vendoring-remote-modules)
60 # you need to use the `$DENO_DIR` env var, to point deno to the correct local cache
61 DENO_DIR=./.deno deno run --frozen --cached-only build
62 '';
63 installPhase = ''
64 cp -r ./dist $out
65 '';
66}