Merge pull request #38547 from Ma27/iftop-module
nixos/iftop: add module
This commit is contained in:
commit
6fd1520e45
4 changed files with 50 additions and 0 deletions
|
@ -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
|
||||
|
|
18
nixos/modules/programs/iftop.nix
Normal file
18
nixos/modules/programs/iftop.nix
Normal file
|
@ -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";
|
||||
};
|
||||
};
|
||||
}
|
|
@ -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 {};
|
||||
|
|
30
nixos/tests/iftop.nix
Normal file
30
nixos/tests/iftop.nix
Normal file
|
@ -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'");
|
||||
};
|
||||
'';
|
||||
})
|
Loading…
Reference in a new issue