# SPDX-FileCopyrightText: 2022-2023 Gregor Kleen <gregor@kleen.consulting>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

{ frontendSource, ... }: final: prev: {
  uniworxWellKnown = prev.stdenv.mkDerivation {
    name = "uniworx-well-known";
    src = frontendSource;

    phases = ["unpackPhase" "buildPhase" "installPhase" "fixupPhase"];

    buildPhase = ''
      ln -s ${final.uniworxNodeDependencies}/lib/node_modules ./node_modules
      export PATH="${final.uniworxNodeDependencies}/bin:${prev.exiftool}/bin:$PATH"
      webpack --progress
    '';

    installPhase = ''
      mkdir -p $out
      cp -r --reflink=auto well-known $out/.nix-well-known
    '';

    outputHashMode = "recursive";
    outputHash = "sha256-18MfdmJX3q826Q4p2F3SnwS2fCjLN0LUpIV/jqUPH4I==";
  };
}
