Commit 3576f973 authored by Audrey Dutcher's avatar Audrey Dutcher Committed by Robert Schütz
Browse files

immich: fix npmDeps build failure

It seems like c++filt and readelf are not always in PATH. npmDeps fails to
build because of that.
We add `|| true` to be resilient to this and move to prePatch because
npmConfigHook is a postPatch hook.
parent e1f0c8be
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -120,6 +120,16 @@ let
    sourceRoot = "${src.name}/web";
    inherit (sources.components.web) npmDepsHash;

    # prePatch is needed because npmConfigHook is a postPatch
    prePatch = ''
      # some part of the build wants to use un-prefixed binaries. let them.
      mkdir -p $TMP/bin
      ln -s "$(type -p ${stdenv.cc.targetPrefix}pkg-config)" $TMP/bin/pkg-config || true
      ln -s "$(type -p ${stdenv.cc.targetPrefix}c++filt)" $TMP/bin/c++filt || true
      ln -s "$(type -p ${stdenv.cc.targetPrefix}readelf)" $TMP/bin/readelf || true
      export PATH="$TMP/bin:$PATH"
    '';

    preBuild = ''
      rm node_modules/@immich/sdk
      ln -s ${openapi} node_modules/@immich/sdk
@@ -161,7 +171,8 @@ buildNpmPackage' {
  src = "${src}/server";
  inherit (sources.components.server) npmDepsHash;

  postPatch = ''
  # prePatch is needed because npmConfigHook is a postPatch
  prePatch = ''
    # pg_dumpall fails without database root access
    # see https://github.com/immich-app/immich/issues/13971
    substituteInPlace src/services/backup.service.ts \
@@ -169,9 +180,9 @@ buildNpmPackage' {

    # some part of the build wants to use un-prefixed binaries. let them.
    mkdir -p $TMP/bin
    ln -s "$(type -p ${stdenv.cc.targetPrefix}pkg-config)" $TMP/bin/pkg-config
    ln -s "$(type -p ${stdenv.cc.targetPrefix}c++filt)" $TMP/bin/c++filt
    ln -s "$(type -p ${stdenv.cc.targetPrefix}readelf)" $TMP/bin/readelf
    ln -s "$(type -p ${stdenv.cc.targetPrefix}pkg-config)" $TMP/bin/pkg-config || true
    ln -s "$(type -p ${stdenv.cc.targetPrefix}c++filt)" $TMP/bin/c++filt || true
    ln -s "$(type -p ${stdenv.cc.targetPrefix}readelf)" $TMP/bin/readelf || true
    export PATH="$TMP/bin:$PATH"
  '';