From 7490e96e38f6db4327554551c705e0a4856c5917 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sat, 8 Dec 2018 21:48:00 +0100 Subject: [PATCH] nixos/iotop: add module The `iotop` program can't be started by an unprivileged user because of missing root privileges. The issue can be fixed by creating a setcap wrapper for `iotop` which contains `cap_net_admin`. --- nixos/modules/module-list.nix | 1 + nixos/modules/programs/iotop.nix | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 nixos/modules/programs/iotop.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 5ffb0c5ab223..8fa6117d2f56 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -98,6 +98,7 @@ ./programs/gnupg.nix ./programs/gphoto2.nix ./programs/iftop.nix + ./programs/iotop.nix ./programs/java.nix ./programs/kbdlight.nix ./programs/less.nix diff --git a/nixos/modules/programs/iotop.nix b/nixos/modules/programs/iotop.nix new file mode 100644 index 000000000000..986d562ad0f8 --- /dev/null +++ b/nixos/modules/programs/iotop.nix @@ -0,0 +1,18 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.programs.iotop; +in { + options = { + programs.iotop.enable = mkEnableOption "iotop + setcap wrapper"; + }; + config = mkIf cfg.enable { + environment.systemPackages = [ pkgs.iotop ]; + security.wrappers.iotop = { + source = "${pkgs.iotop}/bin/iotop"; + capabilities = "cap_net_admin+p"; + }; + }; +}