about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2018-12-08 21:48:00 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2018-12-18 00:00:42 +0100
commit7490e96e38f6db4327554551c705e0a4856c5917 (patch)
treec43d9e4ad17216754c839c76b9e881e7237bc63a /nixos/modules
parentbb962eb2a2d039cb2430d0ffda51ae6a4b5467f2 (diff)
downloadnixlib-7490e96e38f6db4327554551c705e0a4856c5917.tar
nixlib-7490e96e38f6db4327554551c705e0a4856c5917.tar.gz
nixlib-7490e96e38f6db4327554551c705e0a4856c5917.tar.bz2
nixlib-7490e96e38f6db4327554551c705e0a4856c5917.tar.lz
nixlib-7490e96e38f6db4327554551c705e0a4856c5917.tar.xz
nixlib-7490e96e38f6db4327554551c705e0a4856c5917.tar.zst
nixlib-7490e96e38f6db4327554551c705e0a4856c5917.zip
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`.
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/programs/iotop.nix18
2 files changed, 19 insertions, 0 deletions
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";
+    };
+  };
+}