diff options
author | Jörg Thalheim <Mic92@users.noreply.github.com> | 2018-04-08 14:05:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-08 14:05:20 +0100 |
commit | 6fd1520e452556315520ff1e197348d293e0ca6d (patch) | |
tree | d5ee75b6f7dcffe324387e2de996b7e22e710ebd /nixos | |
parent | b214874bda69226cc8896050eb856630659991c9 (diff) | |
parent | 50a34e55b20764fe0ff638a9c15312b5be9ceca1 (diff) | |
download | nixpkgs-6fd1520e452556315520ff1e197348d293e0ca6d.tar nixpkgs-6fd1520e452556315520ff1e197348d293e0ca6d.tar.gz nixpkgs-6fd1520e452556315520ff1e197348d293e0ca6d.tar.bz2 nixpkgs-6fd1520e452556315520ff1e197348d293e0ca6d.tar.lz nixpkgs-6fd1520e452556315520ff1e197348d293e0ca6d.tar.xz nixpkgs-6fd1520e452556315520ff1e197348d293e0ca6d.tar.zst nixpkgs-6fd1520e452556315520ff1e197348d293e0ca6d.zip |
Merge pull request #38547 from Ma27/iftop-module
nixos/iftop: add module
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/programs/iftop.nix | 18 | ||||
-rw-r--r-- | nixos/release.nix | 1 | ||||
-rw-r--r-- | nixos/tests/iftop.nix | 30 |
4 files changed, 50 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 3a8b1014553..46ec2022195 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -86,6 +86,7 @@ ./programs/freetds.nix ./programs/gnupg.nix ./programs/gphoto2.nix + ./programs/iftop.nix ./programs/java.nix ./programs/kbdlight.nix ./programs/less.nix diff --git a/nixos/modules/programs/iftop.nix b/nixos/modules/programs/iftop.nix new file mode 100644 index 00000000000..a98a9a8187d --- /dev/null +++ b/nixos/modules/programs/iftop.nix @@ -0,0 +1,18 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.programs.iftop; +in { + options = { + programs.iftop.enable = mkEnableOption "iftop + setcap wrapper"; + }; + config = mkIf cfg.enable { + environment.systemPackages = [ pkgs.iftop ]; + security.wrappers.iftop = { + source = "${pkgs.iftop}/bin/iftop"; + capabilities = "cap_net_raw+p"; + }; + }; +} diff --git a/nixos/release.nix b/nixos/release.nix index c84853a142c..4fd77e6471c 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -295,6 +295,7 @@ in rec { tests.hound = callTest tests/hound.nix {}; tests.hocker-fetchdocker = callTest tests/hocker-fetchdocker {}; tests.i3wm = callTest tests/i3wm.nix {}; + tests.iftop = callTest tests/iftop.nix {}; tests.initrd-network-ssh = callTest tests/initrd-network-ssh {}; tests.installer = callSubTests tests/installer.nix {}; tests.influxdb = callTest tests/influxdb.nix {}; diff --git a/nixos/tests/iftop.nix b/nixos/tests/iftop.nix new file mode 100644 index 00000000000..21ff3cafed7 --- /dev/null +++ b/nixos/tests/iftop.nix @@ -0,0 +1,30 @@ +import ./make-test.nix ({ pkgs, lib, ... }: + +with lib; + +{ + name = "iftop"; + meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ma27 ]; + + nodes = { + withIftop = { + imports = [ ./common/user-account.nix ]; + + programs.iftop.enable = true; + }; + withoutIftop = { + imports = [ ./common/user-account.nix ]; + }; + }; + + testScript = '' + subtest "machine with iftop enabled", sub { + $withIftop->start; + $withIftop->succeed("su -l alice -c 'iftop -t -s 1'"); + }; + subtest "machine without iftop", sub { + $withoutIftop->start; + $withoutIftop->mustFail("su -l alice -c 'iftop -t -s 1'"); + }; + ''; +}) |