git.iko.soy/typeable/nixpkgs
on master help sign in
osrm service: init
commitbfc3844a152d8cec6d2080e056de30af73d618f7 authorJustin Humm <justin.humm@posteo.de> dateFri 1 Dec 2017, 20:08 (9 years ago) parentcc1d7a3
2 files changed+86
nixos/modules/module-list.nix+1 nixos/modules/services/misc/osrm.nix+85
nixos/modules/module-list.nix+1
@@ -328,6 +328,7 @@
328328 ./services/misc/nix-ssh-serve.nix
329329 ./services/misc/nzbget.nix
330330 ./services/misc/octoprint.nix
331+ ./services/misc/osrm.nix
331332 ./services/misc/packagekit.nix
332333 ./services/misc/parsoid.nix
333334 ./services/misc/phd.nix
nixos/modules/services/misc/osrm.nixnew file+85
@@ -0,0 +1,85 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.osrm;
7+in
8+
9+{
10+ options.services.osrm = {
11+ enable = mkOption {
12+ type = types.bool;
13+ default = false;
14+ description = "Enable the OSRM service.";
15+ };
16+
17+ address = mkOption {
18+ type = types.str;
19+ default = "0.0.0.0";
20+ description = "IP address on which the web server will listen.";
21+ };
22+
23+ port = mkOption {
24+ type = types.int;
25+ default = 5000;
26+ description = "Port on which the web server will run.";
27+ };
28+
29+ threads = mkOption {
30+ type = types.int;
31+ default = 4;
32+ description = "Number of threads to use.";
33+ };
34+
35+ algorithm = mkOption {
36+ type = types.enum [ "CH" "CoreCH" "MLD" ];
37+ default = "MLD";
38+ description = "Algorithm to use for the data. Must be one of CH, CoreCH, MLD";
39+ };
40+
41+ extraFlags = mkOption {
42+ type = types.listOf types.str;
43+ default = [];
44+ example = [ "--max-table-size 1000" "--max-matching-size 1000" ];
45+ description = "Extra command line arguments passed to osrm-routed";
46+ };
47+
48+ dataFile = mkOption {
49+ type = types.path;
50+ example = "/var/lib/osrm/berlin-latest.osrm";
51+ description = "Data file location";
52+ };
53+
54+ };
55+
56+ config = mkIf cfg.enable {
57+
58+ users.users.osrm = {
59+ group = config.users.users.osrm.name;
60+ description = "OSRM user";
61+ createHome = false;
62+ };
63+
64+ users.groups.osrm = { };
65+
66+ systemd.services.osrm = {
67+ description = "OSRM service";
68+ after = [ "network.target" ];
69+ wantedBy = [ "multi-user.target" ];
70+
71+ serviceConfig = {
72+ User = config.users.extraUsers.osrm.name;
73+ ExecStart = ''
74+ ${pkgs.osrm-backend}/bin/osrm-routed \
75+ --ip ${cfg.address} \
76+ --port ${toString cfg.port} \
77+ --threads ${toString cfg.threads} \
78+ --algorithm ${cfg.algorithm} \
79+ ${toString cfg.extraFlags} \
80+ ${cfg.dataFile}
81+ '';
82+ };
83+ };
84+ };
85+}