Which package provides 'ifconfig'

I am trying to call ifconfig from a script in home.nix and need to specify the package that provides it. Does anyone know which package provides ifconfig?

Thanks.

I miss command-not-found.

2 Likes
$ readlink /run/current-system/sw/bin/ifconfig
/nix/store/mp95d7229gpvm2rkllfp8dhk9cal6v4y-net-tools-2.10/bin/ifconfig

So, https://net-tools.sourceforge.io/.

2 Likes

NixOS will set up a CNF handler, but on non-NixOS, I think the assumption is that your system package manager already has one set up.

You can use nix-index’s nix-locate command to search for packages by the names of files they contain: GitHub - nix-community/nix-index: Quickly locate nix packages with specific files [maintainers=@bennofs @figsoda @raitobezarius]

You can get a precomputed database for nix-index here: GitHub - nix-community/nix-index-database: Weekly updated nix-index database [maintainer=@Mic92]

2 Likes

I’m using NixOS. But I think because I am using flakes, command-not-found is not longer available.

1 Like

I guess the CNF handler still looks for a channel in ~/.nix-defexpr/channels_root. You can probably hack that to point to something in your Nix registry, but there may be some quirks you have to work through if channels have some files that plain Nixpkgs checkouts just don’t.

But yeah, you can use nix-index for this.

1 Like

Yes, it doesn’t work with flakes out-of-the-box.
Something like this should work, though.

2 Likes

There are other ways, that are more reproducible.

I’ll set myself a reminder to write some short blog post about my setup, later today.

I know you didn’t ask about that, but AFAIK ifconfig is a legacy command and you should use ip instead.

2 Likes

As promised, I wrote a small guide about the different ways of how to deal with flakes and CnF.

https://blog.nobbz.dev/posts/2023-02-27-nixos-flakes-command-not-found/

4 Likes

You may want to try my nix-search tool, which lets you ask exactly this question. It’s available as a flake github:peterldowns/nix-search-cli. You could also instead use the search.nixos.org website directly, but it doesn’t support searching only over installed binaries.

Using it like nix-search -p ifconfig shows that any of the following packages would install ifconfig:

unixtools.nettools 
unixtools.ifconfig 
toybox
nettools 
inetutils
cope
busybox

1 Like