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 = lib.mdDoc ''
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 defaultText = literalExpression "pkgs.mtr";
24 description = lib.mdDoc ''
25 The package to use.
26 '';
27 };
28 };
29 };
30
31 config = mkIf cfg.enable {
32 environment.systemPackages = with pkgs; [ cfg.package ];
33
34 security.wrappers.mtr-packet = {
35 owner = "root";
36 group = "root";
37 capabilities = "cap_net_raw+p";
38 source = "${cfg.package}/bin/mtr-packet";
39 };
40 };
41}