0

Which package should I add to extraPackages property to make ping command available? I have tried

extraPackages = with pkgs; [ ping ];

But it didnot work, it installs completely different package.

George Shalvashvili
  • 1,263
  • 13
  • 21
  • 1
    `ping` needs a setuid wrapper, so you'll have to add `/run/wrappers/bin` to its `PATH` rather than adding a package, as store contents can't have setuid. Setuid in packages would make Nix not "policy-free", which is core to its design and enables safe user-requested builds. – Robert Hensing Feb 16 '22 at 20:42

2 Answers2

0

If you mean this ping, it's in the iputils package:

bash-5.1# ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.075 ms
^C
--- 127.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.075/0.075/0.075/0.000 ms
bash-5.1# which ping
/sbin/ping
bash-5.1# ls -l /sbin/ping 
lrwxrwxrwx 1 root root 69 Jan  1  1980 /sbin/ping -> /nix/store/c8i7qgcvnj3123n8k7yilimgvdl23a31-iputils-20211215/bin/ping
Mike Playle
  • 387
  • 3
  • 6
0

ping is part of iputils so adding this package to extraPackages will make it available. You can find an executable with the tool like nix-locate <bin/executable> from the package nix-index

However keep in mind that ping normally requires the SUID bit set. This tool is available in /run/wrappers/bin/ping ( command -v ping ). This wrapper is created in nixos/modules/tasks/network-interfaces.nix:

security.wrappers = {
  ping = {
    owner = "root";
    group = "root";
    capabilities = "cap_net_raw+p";
    source = "${pkgs.iputils.out}/bin/ping";
  };
};
makefu
  • 116
  • 5