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:
- A nixOS Latest system
- Administrative privileges to install packages
Steps
- Update your system:
sudo nix-channel --update
sudo nixos-rebuild switch
- 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
- Clone the Nominatim source code:
git clone https://github.com/openstreetmap/Nominatim.git
cd Nominatim
- Configure the build options:
mkdir build && cd build
cmake .. -DENABLE_HTTP:BOOL=OFF -DENABLE_UNACCENT:BOOL=ON
- Build and install Nominatim:
make
sudo make install
- Configure PostgreSQL:
sudo -u postgres createuser --createdb nominatim
sudo -u postgres psql
ALTER USER nominatim WITH PASSWORD 'yourpassword';
\q
- 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>
- 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
- 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.