1 { config, lib, pkgs, ... }:
6 cfg = config.services.osrm;
10 options.services.osrm = {
14 description = lib.mdDoc "Enable the OSRM service.";
20 description = lib.mdDoc "IP address on which the web server will listen.";
26 description = lib.mdDoc "Port on which the web server will run.";
32 description = lib.mdDoc "Number of threads to use.";
35 algorithm = mkOption {
36 type = types.enum [ "CH" "CoreCH" "MLD" ];
38 description = lib.mdDoc "Algorithm to use for the data. Must be one of CH, CoreCH, MLD";
41 extraFlags = mkOption {
42 type = types.listOf types.str;
44 example = [ "--max-table-size 1000" "--max-matching-size 1000" ];
45 description = lib.mdDoc "Extra command line arguments passed to osrm-routed";
50 example = "/var/lib/osrm/berlin-latest.osrm";
51 description = lib.mdDoc "Data file location";
56 config = mkIf cfg.enable {
59 group = config.users.users.osrm.name;
60 description = "OSRM user";
65 users.groups.osrm = { };
67 systemd.services.osrm = {
68 description = "OSRM service";
69 after = [ "network.target" ];
70 wantedBy = [ "multi-user.target" ];
73 User = config.users.users.osrm.name;
75 ${pkgs.osrm-backend}/bin/osrm-routed \
77 --port ${toString cfg.port} \
78 --threads ${toString cfg.threads} \
79 --algorithm ${cfg.algorithm} \
80 ${toString cfg.extraFlags} \