1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.programs.mtr;
7
8in {
9 options = {
10 programs.mtr = {
11 enable = mkOption {
12 type = types.bool;
13 default = false;
14 description = ''
15 Whether to add mtr to the global environment and configure a
16 setcap wrapper for it.
17 '';
18 };
19
20 package = mkOption {
21 type = types.package;
22 default = pkgs.mtr;
23 description = ''
24 The package to use.
25 '';
26 };
27 };
28 };
29
30 config = mkIf cfg.enable {
31 environment.systemPackages = with pkgs; [ cfg.package ];
32
33 security.wrappers.mtr-packet = {
34 source = "${cfg.package}/bin/mtr-packet";
35 capabilities = "cap_net_raw+p";
36 };
37 };
38}