1 { config, lib, pkgs, ... }:
3 cfg = config.services.osrm;
7 options.services.osrm = {
8 enable = lib.mkOption {
11 description = "Enable the OSRM service.";
14 address = lib.mkOption {
17 description = "IP address on which the web server will listen.";
21 type = lib.types.port;
23 description = "Port on which the web server will run.";
26 threads = lib.mkOption {
29 description = "Number of threads to use.";
32 algorithm = lib.mkOption {
33 type = lib.types.enum [ "CH" "CoreCH" "MLD" ];
35 description = "Algorithm to use for the data. Must be one of CH, CoreCH, MLD";
38 extraFlags = lib.mkOption {
39 type = lib.types.listOf lib.types.str;
41 example = [ "--max-table-size 1000" "--max-matching-size 1000" ];
42 description = "Extra command line arguments passed to osrm-routed";
45 dataFile = lib.mkOption {
46 type = lib.types.path;
47 example = "/var/lib/osrm/berlin-latest.osrm";
48 description = "Data file location";
53 config = lib.mkIf cfg.enable {
56 group = config.users.users.osrm.name;
57 description = "OSRM user";
62 users.groups.osrm = { };
64 systemd.services.osrm = {
65 description = "OSRM service";
66 after = [ "network.target" ];
67 wantedBy = [ "multi-user.target" ];
70 User = config.users.users.osrm.name;
72 ${pkgs.osrm-backend}/bin/osrm-routed \
74 --port ${toString cfg.port} \
75 --threads ${toString cfg.threads} \
76 --algorithm ${cfg.algorithm} \
77 ${toString cfg.extraFlags} \