1 { config, lib, pkgs, ... }:
3 cfg = config.services.birdwatcher;
7 services.birdwatcher = {
8 package = lib.mkPackageOption pkgs "birdwatcher" { };
9 enable = lib.mkEnableOption "Birdwatcher";
10 flags = lib.mkOption {
12 type = lib.types.listOf lib.types.str;
13 example = [ "-worker-pool-size 16" "-6" ];
15 Flags to append to the program call
19 settings = lib.mkOption {
20 type = lib.types.lines;
23 birdwatcher configuration, for configuration options see the example on [github](https://github.com/alice-lg/birdwatcher/blob/master/etc/birdwatcher/birdwatcher.conf)
25 example = lib.literalExpression ''
28 allow_uncached = false
29 modules_enabled = ["status",
36 "routes_table_filtered",
41 "routes_pipe_filtered_count",
42 "routes_pipe_filtered"
46 reconfig_timestamp_source = "bird"
47 reconfig_timestamp_match = "# created: (.*)"
52 listen = "0.0.0.0:29184"
53 config = "/etc/bird/bird2.conf"
54 birdc = "''${pkgs.bird}/bin/birdc"
55 ttl = 5 # time to live (in minutes) for caching of cli output
61 use_redis = false # if not using redis cache, activate housekeeping to save memory!
65 force_release_memory = true
72 let flagsStr = lib.escapeShellArgs cfg.flags;
73 in lib.mkIf cfg.enable {
74 environment.etc."birdwatcher/birdwatcher.conf".source = pkgs.writeTextFile {
75 name = "birdwatcher.conf";
80 wants = [ "network.target" ];
81 after = [ "network.target" ];
82 wantedBy = [ "multi-user.target" ];
83 description = "Birdwatcher";
86 Restart = "on-failure";
88 ExecStart = "${cfg.package}/bin/birdwatcher";
89 StateDirectoryMode = "0700";
91 NoNewPrivileges = true;
92 ProtectSystem = "strict";
94 PrivateDevices = true;
95 ProtectHostname = true;
97 ProtectKernelTunables = true;
98 ProtectKernelModules = true;
99 ProtectKernelLogs = true;
100 ProtectControlGroups = true;
101 RestrictAddressFamilies = [ "AF_UNIX AF_INET AF_INET6" ];
102 LockPersonality = true;
103 MemoryDenyWriteExecute = true;
104 RestrictRealtime = true;
105 RestrictSUIDSGID = true;
106 PrivateMounts = true;
107 SystemCallArchitectures = "native";
108 SystemCallFilter = "~@clock @privileged @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io @reboot @setuid @swap";
109 BindReadOnlyPaths = [
111 "-/etc/nsswitch.conf"
113 "-/etc/static/ssl/certs"