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
.
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
.
$ readlink /run/current-system/sw/bin/ifconfig
/nix/store/mp95d7229gpvm2rkllfp8dhk9cal6v4y-net-tools-2.10/bin/ifconfig
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]
I’m using NixOS. But I think because I am using flakes, command-not-found
is not longer available.
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.
Yes, it doesn’t work with flakes out-of-the-box.
Something like this should work, though.
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.
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/
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