1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.services.fakeroute;
7 routeConf = pkgs.writeText "route.conf" (concatStringsSep "\n" cfg.route);
8
9in
10
11{
12
13 ###### interface
14
15 options = {
16
17 services.fakeroute = {
18
19 enable = mkOption {
20 type = types.bool;
21 default = false;
22 description = lib.mdDoc ''
23 Whether to enable the fakeroute service.
24 '';
25 };
26
27 route = mkOption {
28 type = types.listOf types.str;
29 default = [];
30 example = [
31 "216.102.187.130"
32 "4.0.1.122"
33 "198.116.142.34"
34 "63.199.8.242"
35 ];
36 description = lib.mdDoc ''
37 Fake route that will appear after the real
38 one to any host running a traceroute.
39 '';
40 };
41
42 };
43
44 };
45
46
47 ###### implementation
48
49 config = mkIf cfg.enable {
50 systemd.services.fakeroute = {
51 description = "Fakeroute Daemon";
52 after = [ "network.target" ];
53 wantedBy = [ "multi-user.target" ];
54 serviceConfig = {
55 Type = "forking";
56 User = "root";
57 ExecStart = "${pkgs.fakeroute}/bin/fakeroute -f ${routeConf}";
58 };
59 };
60
61 };
62
63 meta.maintainers = with lib.maintainers; [ rnhmjoj ];
64
65}