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.
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 ~/Downloads
Extract the downloaded file
$ tar -xvf graphhopper-1.4.0.tar.gz
Move the extracted directory to a new location
$ sudo mv graphhopper-1.4.0 /opt
Set the environment variable for GraphHopper
$ export GRAPHHOPPER_DIR=/opt/graphhopper-1.4.0
Now, create a GraphHopper service to start GraphHopper on boot
$ sudo vim /etc/nixos/configuration.nix
Add 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).nix
Redeploy NixOS
$ sudo nixos-rebuild switch
Start the GraphHopper service
$ sudo systemctl start graphhopper
Test 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.
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!