git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #38547 from Ma27/iftop-module

nixos/iftop: add module

commit6fd1520e452556315520ff1e197348d293e0ca6d authorJörg Thalheim <Mic92@users.noreply.github.com> dateSun 8 Apr 2018, 14:05 (9 years ago) parentb21487450a34e5
4 files changed+50
nixos/modules/module-list.nix+1 nixos/modules/programs/iftop.nix+18 nixos/release.nix+1 nixos/tests/iftop.nix+30
nixos/modules/module-list.nix+1
@@ -86,6 +86,7 @@
8686 ./programs/freetds.nix
8787 ./programs/gnupg.nix
8888 ./programs/gphoto2.nix
89+ ./programs/iftop.nix
8990 ./programs/java.nix
9091 ./programs/kbdlight.nix
9192 ./programs/less.nix
nixos/modules/programs/iftop.nixnew file+18
@@ -0,0 +1,18 @@
1+{ config, pkgs, lib, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.programs.iftop;
7+in {
8+ options = {
9+ programs.iftop.enable = mkEnableOption "iftop + setcap wrapper";
10+ };
11+ config = mkIf cfg.enable {
12+ environment.systemPackages = [ pkgs.iftop ];
13+ security.wrappers.iftop = {
14+ source = "${pkgs.iftop}/bin/iftop";
15+ capabilities = "cap_net_raw+p";
16+ };
17+ };
18+}
nixos/release.nix+1
@@ -295,6 +295,7 @@ in rec {
295295 tests.hound = callTest tests/hound.nix {};
296296 tests.hocker-fetchdocker = callTest tests/hocker-fetchdocker {};
297297 tests.i3wm = callTest tests/i3wm.nix {};
298+ tests.iftop = callTest tests/iftop.nix {};
298299 tests.initrd-network-ssh = callTest tests/initrd-network-ssh {};
299300 tests.installer = callSubTests tests/installer.nix {};
300301 tests.influxdb = callTest tests/influxdb.nix {};
nixos/tests/iftop.nixnew file+30
@@ -0,0 +1,30 @@
1+import ./make-test.nix ({ pkgs, lib, ... }:
2+
3+with lib;
4+
5+{
6+ name = "iftop";
7+ meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ma27 ];
8+
9+ nodes = {
10+ withIftop = {
11+ imports = [ ./common/user-account.nix ];
12+
13+ programs.iftop.enable = true;
14+ };
15+ withoutIftop = {
16+ imports = [ ./common/user-account.nix ];
17+ };
18+ };
19+
20+ testScript = ''
21+ subtest "machine with iftop enabled", sub {
22+ $withIftop->start;
23+ $withIftop->succeed("su -l alice -c 'iftop -t -s 1'");
24+ };
25+ subtest "machine without iftop", sub {
26+ $withoutIftop->start;
27+ $withoutIftop->mustFail("su -l alice -c 'iftop -t -s 1'");
28+ };
29+ '';
30+})