Commit a5c02729 authored by Ivan Mincik's avatar Ivan Mincik
Browse files

nominatim-ui: revert back to mkDerivation

Revert from using mkYarnPackage back to mkDerivation due to following
issues:

* couln't make it working with finalAttrs
* required local copy of package.json or did IFD
parent 30b6164d
Loading
Loading
Loading
Loading
+0 −48
Original line number Diff line number Diff line
{
    "name": "nominatim-ui",
    "description": "Debug web interface for Nominatim geocoder",
    "version": "3.7.1",
    "license": "GPL-2.0",
    "scripts": {
        "build": "rollup -c",
        "dev": "rollup -c -w",
        "lint": "eslint --quiet *.js src/ test/",
        "lint:fix": "eslint --fix *.js src/ test/",
        "test": "rollup -c && mocha --recursive test/",
        "start": "static-server dist"
    },
    "devDependencies": {
        "@eslint/eslintrc": "^3.1.0",
        "@eslint/js": "^9.12.0",
        "@rollup/plugin-commonjs": "^28.0",
        "@rollup/plugin-node-resolve": "^16.0",
        "eslint": "^9.0",
        "eslint-config-prettier": "^10.1.2",
        "eslint-plugin-import": "^2.22.1",
        "eslint-plugin-mocha": "^11.0",
        "eslint-plugin-prettier": "^5.2.6",
        "eslint-plugin-security": "^3.0.1",
        "eslint-plugin-svelte": "^3.5.0",
        "fs-extra": "^11.0.0",
        "globals": "^16.0.0",
        "http": "^0.0.1-security",
        "http-proxy": "^1.18.1",
        "mocha": "^11.0",
        "puppeteer": "^24.0",
        "rollup": "^4.22.4",
        "rollup-plugin-css-only": "^4.3.0",
        "rollup-plugin-livereload": "^2.0.0",
        "rollup-plugin-svelte": "^7.0.0",
        "rollup-plugin-terser": "^7.0.0",
        "static-server": "^2.2.1",
        "svelte": "^5.0.0"
    },
    "dependencies": {
        "bootstrap": "^5.0.0",
        "escape-html": "^1.0.3",
        "leaflet": "1.9.4",
        "leaflet-minimap": "^3.6.1",
        "timeago.js": "^4.0.2"
    },
    "type": "module"
}
+33 −16
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitHub,
  fetchYarnDeps,
  mkYarnPackage,
  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,
}:

# Notes for the upgrade:
# * Download the tarball of the new version to use.
# * Replace new `package.json` here.
# * Update `version`+`hash` and rebuild.

let
  configFile =
    if customConfig != null then
@@ -26,23 +26,42 @@ let
        Nominatim_Config.Nominatim_API_Endpoint='https://127.0.0.1/';
      '';
in
mkYarnPackage rec {

stdenv.mkDerivation (finalAttrs: {
  pname = "nominatim-ui";
  version = "3.7.1";

  src = fetchFromGitHub {
    owner = "osm-search";
    repo = "nominatim-ui";
    tag = "v${version}";
    tag = "v${finalAttrs.version}";
    hash = "sha256-TliTWDKdIp7Z0uYw5P65i06NQAUNwNymUsSYrihVZFE=";
  };

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

  packageJSON = ./package.json;
  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
@@ -53,19 +72,17 @@ mkYarnPackage rec {
  '';

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

  installPhase = ''
    runHook preInstall

    cp --archive deps/nominatim-ui/dist $out
    cp --archive dist $out

    runHook postInstall
  '';

  doDist = false;

  meta = {
    description = "Debugging user interface for Nominatim geocoder";
    homepage = "https://github.com/osm-search/nominatim-ui";
@@ -74,6 +91,6 @@ mkYarnPackage rec {
      geospatial
      ngi
    ];
    changelog = "https://github.com/osm-search/nominatim-ui/releases/tag/v${version}";
    changelog = "https://github.com/osm-search/nominatim-ui/releases/tag/v${finalAttrs.version}";
  };
}
})