How to Install GraphHopper on NixOS Latest
GraphHopper is an open-source routing engine that is used to calculate road or path routes. This tutorial explains the steps to install GraphHopper on NixOS Latest.
Prerequisites
- NixOS Latest OS installed on your system.
- Java 8 or higher installed on your system.
Installation
Open a terminal and navigate to the GraphHopper website
https://graphhopper.com/.Click on the Download option, a page with the download links will appear. Choose the latest version that supports the NixOS platform.
Once the download is complete open the terminal.
Now, navigate to the directory where you downloaded the GraphHopper application.
$ cd ~/DownloadsExtract the downloaded file
$ tar -xvf graphhopper-1.4.0.tar.gzMove the extracted directory to a new location
$ sudo mv graphhopper-1.4.0 /optSet the environment variable for GraphHopper
$ export GRAPHHOPPER_DIR=/opt/graphhopper-1.4.0Now, create a GraphHopper service to start GraphHopper on boot
$ sudo vim /etc/nixos/configuration.nixAdd the following code in the configuration file
... services.graphhopper = { enable = true; dataDir = "/opt/graphhopper-1.4.0/data"; configFile = "/opt/graphhopper-1.4.0/config-example.yml"; cmd = "${GRAPHHOPPER_DIR}/graphhopper.sh start"; }; ...(Note: Ensure all of these files/subdirectories exist, otherwise you may encounter errors. If user doesn't have permission to create this directory, it's best to symlink to a directory the user owns. For example,
/mnt/data/graphhopper-1.4.0/data)Now, create a symlink for the GraphHopper service
$ sudo ln -s /etc/nixos/configuration.nix /etc/nixos/$(uname --nodename).nixRedeploy NixOS
$ sudo nixos-rebuild switchStart the GraphHopper service
$ sudo systemctl start graphhopperTest the GraphHopper service
http://localhost:8989
You have successfully installed and configured GraphHopper on NixOS Latest OS. Now, you can use it to calculate road or path routes for your maps.