Unverified Commit 6c75b684 authored by Valentin Gagarin's avatar Valentin Gagarin Committed by GitHub
Browse files

nominatim-ui: rewrite packaging to add missing files and add custom config support (#421464)

parents 5dbc8a39 a5c02729
Loading
Loading
Loading
Loading
+60 −0
Original line number Diff line number Diff line
@@ -2,8 +2,31 @@
  lib,
  stdenv,
  fetchFromGitHub,
  fetchYarnDeps,
  writableTmpDirAsHomeHook,
  writeText,

  fixup-yarn-lock,
  nodejs,
  yarn,

  # Custom application configuration placed to theme/config.theme.js file
  # For the list of available configuration options see
  # https://github.com/osm-search/nominatim-ui/blob/master/dist/config.defaults.js
  customConfig ? null,
}:

let
  configFile =
    if customConfig != null then
      writeText "config.theme.js" customConfig
    else
      writeText "config.theme.js" ''
        // Default configuration
        Nominatim_Config.Nominatim_API_Endpoint='https://127.0.0.1/';
      '';
in

stdenv.mkDerivation (finalAttrs: {
  pname = "nominatim-ui";
  version = "3.7.1";
@@ -15,6 +38,43 @@ stdenv.mkDerivation (finalAttrs: {
    hash = "sha256-TliTWDKdIp7Z0uYw5P65i06NQAUNwNymUsSYrihVZFE=";
  };

  offlineCache = fetchYarnDeps {
    yarnLock = "${finalAttrs.src}/yarn.lock";
    hash = "sha256-IqwsXEd9RSJhkA4BONTJT4xYMTyG9+zddIpD47v6AFc=";
  };

  nativeBuildInputs = [
    writableTmpDirAsHomeHook

    fixup-yarn-lock
    nodejs
    yarn
  ];

  configurePhase = ''
    runHook preConfigure

    yarn config --offline set yarn-offline-mirror $offlineCache
    fixup-yarn-lock yarn.lock

    yarn install --offline --frozen-lockfile --frozen-engines --ignore-scripts
    patchShebangs node_modules

    runHook postConfigure
  '';

  buildPhase = ''
    runHook preBuild

    yarn --offline build

    runHook postBuild
  '';

  preInstall = ''
    ln --symbolic ${configFile} dist/theme/config.theme.js
  '';

  installPhase = ''
    runHook preInstall