Commit 31da557c authored by Robert Schütz's avatar Robert Schütz
Browse files

immich: update geodata

Also include the geonames license CC-BY-4.0 in meta.
parent fbcc3353
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -50,9 +50,15 @@ let

  # The geodata website is not versioned, so we use the internet archive
  geodata =
    let
      inherit (sources.components.geonames) timestamp;
      date =
        "${lib.substring 0 4 timestamp}-${lib.substring 4 2 timestamp}-${lib.substring 6 2 timestamp}T"
        + "${lib.substring 8 2 timestamp}:${lib.substring 10 2 timestamp}:${lib.substring 12 2 timestamp}Z";
    in
    runCommand "immich-geodata"
      {
        outputHash = "sha256-imqSfzXaEMNo9T9tZr80sr/89n19kiFc8qwidFzRUaY=";
        outputHash = sources.components.geonames.hash;
        outputHashMode = "recursive";
        nativeBuildInputs = [
          cacert
@@ -64,15 +70,15 @@ let
      }
      ''
        mkdir $out
        url="https://web.archive.org/web/20240724153050/http://download.geonames.org/export/dump"
        url="https://web.archive.org/web/${timestamp}/http://download.geonames.org/export/dump"
        curl -Lo ./cities500.zip "$url/cities500.zip"
        curl -Lo $out/admin1CodesASCII.txt "$url/admin1CodesASCII.txt"
        curl -Lo $out/admin2Codes.txt "$url/admin2Codes.txt"
        curl -Lo $out/ne_10m_admin_0_countries.geojson \
          https://raw.githubusercontent.com/nvkelso/natural-earth-vector/ca96624a56bd078437bca8184e78163e5039ad19/geojson/ne_10m_admin_0_countries.geojson
          https://github.com/nvkelso/natural-earth-vector/raw/ca96624a56bd078437bca8184e78163e5039ad19/geojson/ne_10m_admin_0_countries.geojson

        unzip ./cities500.zip -d $out/
        echo "2024-07-24T15:30:50Z" > $out/geodata-date.txt
        echo "${date}" > $out/geodata-date.txt
      '';

  src = fetchFromGitHub {
@@ -241,7 +247,10 @@ buildNpmPackage' {
  meta = {
    description = "Self-hosted photo and video backup solution";
    homepage = "https://immich.app/";
    license = lib.licenses.agpl3Only;
    license = with lib.licenses; [
      agpl3Only
      cc-by-40 # geonames
    ];
    maintainers = with lib.maintainers; [
      dotlambda
      jvanbruegge
+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,10 @@
    "open-api/typescript-sdk": {
      "npmDepsHash": "sha256-GtqS59I+By1u6WcR+lDj2HKXVwh7jw5/N6MRdUctlaM=",
      "version": "1.122.3"
    },
    "geonames": {
      "timestamp": "20241215052013",
      "hash": "sha256-Gv85Y5KAkeqNU8iMMKwepI5o14Z0s5aQbLJVxhtjY14="
    }
  }
}
+20 −2
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq prefetch-npm-deps nix-prefetch-github coreutils
#!nix-shell -i bash -p curl jq prefetch-npm-deps nix-prefetch-github coreutils ripgrep

set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
@@ -39,6 +39,24 @@ for npm_component in cli server web "open-api/typescript-sdk"; do
      '.components += {($npm_component): {npmDepsHash: $hash, version: $version}}' \
      "$sources_tmp")" > "$sources_tmp"
done

rm "$lock"

url="http://download.geonames.org/export/dump"
curl -s "http://web.archive.org/save/$url/cities500.zip"
curl -s "http://web.archive.org/save/$url/admin1CodesASCII.txt"
curl -s "http://web.archive.org/save/$url/admin1Codes.txt"
timestamp=$(curl -s \
    "http://archive.org/wayback/available?url=$url/cities500.zip" \
    | jq -r ".archived_snapshots.closest.timestamp")
echo "$(jq --arg timestamp "$timestamp" --arg hash "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" \
    '.components += {geonames: {timestamp: $timestamp, hash: $hash}}' \
    "$sources_tmp")" > "$sources_tmp"

cp "$sources_tmp" sources.json
set +o pipefail
output="$(nix-build ../../../.. -A immich.geodata 2>&1 || true)"
set -o pipefail
hash=$(echo "$output" | rg 'got:\s+(sha256-.*)$' -or '$1')
echo "$(jq --arg hash "$hash" '.components.geonames.hash = $hash' "$sources_tmp")" > "$sources_tmp"

mv "$sources_tmp" sources.json