Skip to content

Commit d95f6a1

Browse files
committed
immich: use our own esbuild
This fixes aarch64 builds, as the upstream lockfile does not include binaries for aarch64. Closes #404089 Signed-off-by: Sefa Eyeoglu <[email protected]>
1 parent 6ea347c commit d95f6a1

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

pkgs/by-name/im/immich/package.nix

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,70 @@
3131
perl,
3232
pixman,
3333
vips,
34+
buildPackages,
3435
sourcesJSON ? ./sources.json,
3536
}:
3637
let
3738
buildNpmPackage' = buildNpmPackage.override { inherit nodejs; };
3839
sources = lib.importJSON sourcesJSON;
3940
inherit (sources) version;
4041

42+
esbuild_0_23 = buildPackages.esbuild.override {
43+
buildGoModule =
44+
args:
45+
buildPackages.buildGoModule (
46+
args
47+
// rec {
48+
version = "0.23.0";
49+
src = fetchFromGitHub {
50+
owner = "evanw";
51+
repo = "esbuild";
52+
tag = "v${version}";
53+
hash = "sha256-AH4Y5ELPicAdJZY5CBf2byOxTzOyQFRh4XoqRUQiAQw=";
54+
};
55+
vendorHash = "sha256-+BfxCyg0KkDQpHt/wycy/8CTG6YBA/VJvJFhhzUnSiQ=";
56+
}
57+
);
58+
};
59+
60+
esbuild_0_25 = buildPackages.esbuild.override {
61+
buildGoModule =
62+
args:
63+
buildPackages.buildGoModule (
64+
args
65+
// rec {
66+
version = "0.25.2";
67+
src = fetchFromGitHub {
68+
owner = "evanw";
69+
repo = "esbuild";
70+
tag = "v${version}";
71+
hash = "sha256-aDxheDMeQYqCT9XO3In6RbmzmXVchn+bjgf3nL3VE4I=";
72+
};
73+
vendorHash = "sha256-+BfxCyg0KkDQpHt/wycy/8CTG6YBA/VJvJFhhzUnSiQ=";
74+
}
75+
);
76+
};
77+
78+
# Immich server does not actually need esbuild, but react-email and vite do.
79+
# As esbuild doesn't support passing multiple binaries, we use a custom
80+
# "shim", that picks the right version depending on the working directory.
81+
# The correct version can be looked up in package-lock.json
82+
# TODO: There are numerous other env vars this *could* be based on.
83+
esbuildShim = buildPackages.writeShellScriptBin "esbuild" ''
84+
echo "nixpkgs: esbuild shim for '$PWD'" >&2
85+
case "$PWD" in
86+
"/build/server/node_modules/esbuild")
87+
exec ${lib.getExe esbuild_0_23} "$@"
88+
;;
89+
"/build/server/node_modules/vite/node_modules/esbuild")
90+
exec ${lib.getExe esbuild_0_25} "$@"
91+
exit 0
92+
;;
93+
esac
94+
echo "nixpkgs: Couldn't resolve esbuild version for '$PWD'" >&2
95+
exit 1
96+
'';
97+
4198
buildLock = {
4299
sources =
43100
builtins.map
@@ -206,6 +263,7 @@ buildNpmPackage' {
206263
makeCacheWritable = true;
207264

208265
env.SHARP_FORCE_GLOBAL_LIBVIPS = 1;
266+
env.ESBUILD_BINARY_PATH = lib.getExe esbuildShim;
209267

210268
preBuild = ''
211269
# If exiftool-vendored.pl isn't found, exiftool is searched for on the PATH

0 commit comments

Comments
 (0)