Installing Nominatim on nixOS Latest

Nominatim is a powerful open-source geocoding tool that allows you to convert addresses into geographic coordinates, and vice versa. Here’s a step-by-step guide on how to install it on nixOS Latest.

Prerequisites

Before we begin, you will need:

Steps

  1. Update your system:
sudo nix-channel --update
sudo nixos-rebuild switch
  1. Install the required dependencies:
sudo nix-env -i postgresql postgis osm2pgsql constantinople git cmake gcc postgresqlLibraries autoconf automake libtool make bzip2 libxml2 libxml2-utils libxslt libgcrypt with-gmp with-pcre with-zlib
  1. Clone the Nominatim source code:
git clone https://github.com/openstreetmap/Nominatim.git
cd Nominatim
  1. Configure the build options:
mkdir build && cd build
cmake .. -DENABLE_HTTP:BOOL=OFF -DENABLE_UNACCENT:BOOL=ON
  1. Build and install Nominatim:
make
sudo make install
  1. Configure PostgreSQL:
sudo -u postgres createuser --createdb nominatim
sudo -u postgres psql
ALTER USER nominatim WITH PASSWORD 'yourpassword';
\q
  1. Import the OpenStreetMap data:
sudo su nominatim
cd Nominatim
./utils/setup.php --osm-file <path to your .osm.pbf file> --all --threads <number of threads>
  1. Configure Nginx:
sudo cp /usr/local/src/Nominatim/build/tpl/nginx.conf /etc/nginx/sites-available/nominatim
sudo ln -s /etc/nginx/sites-available/nominatim /etc/nginx/sites-enabled/nominatim
  1. Restart Nginx and PostgreSQL:
sudo systemctl reload nginx
sudo systemctl restart postgresql

Congratulations! You have successfully installed Nominatim on nixOS Latest. You can now use it to geocode addresses and perform other geographic data analysis tasks.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!