Nix-channel not found in nixos server

Hey,

What could be wrong in my setup? I can see nix-env in my $PATH but nix-channel seems to be missing.

[root@localhost:~]# nix-env
error: no operation specified
Try 'nix-env --help' for more information.

[root@localhost:~]# nix-env -iA nixos.pciutils
error: attribute 'nixos' in selection path 'nixos.pciutils' not found

[root@localhost:~]# nix-channel --list
-bash: nix-channel: command not found

[root@localhost:~]# find / -iname '*nix-channel*'
/nix/store/5n4lxkk11vybd28sh1w5mvyl221q3108-nix-2.18.5-man/share/man/man1/nix-channel.1.gz
/nix/store/wvc6qirf5kzn5ygb7wvfh5kzfa5x03g5-system-path/share/bash-completion/completions/nix-channel
/nix/store/y0wpvk2x441cyybq123mnbvkjfvpkaqn-source/nixos/modules/config/nix-channel
/nix/store/y0wpvk2x441cyybq123mnbvkjfvpkaqn-source/nixos/modules/config/nix-channel.nix
/nix/store/y0wpvk2x441cyybq123mnbvkjfvpkaqn-source/nixos/tests/activation/nix-channel.nix
/nix/store/r7jaz4mgzmpk1cszjgcq9k0mzjh6qsl4-system-path/share/bash-completion/completions/nix-channel
/nix/store/fxp8d1dbaxv2fhc4pm5wm4a669x2zb3q-nix-2.18.5/bin/nix-channel
/nix/store/3akigz15cy67pyv7g9rwcc9pacs6xr8h-nix-bash-completions-0.6.8/share/bash-completion/completions/nix-channel
/nix/store/cjz8w4dgc3rd2n3dqv5c208vygndjyba-source/nixos/tests/activation/nix-channel.nix
/nix/store/cjz8w4dgc3rd2n3dqv5c208vygndjyba-source/nixos/modules/config/nix-channel
/nix/store/cjz8w4dgc3rd2n3dqv5c208vygndjyba-source/nixos/modules/config/nix-channel.nix

[root@localhost:~]# /nix/store/fxp8d1dbaxv2fhc4pm5wm4a669x2zb3q-nix-2.18.5/bin/nix-channel --list

[root@localhost:~]# echo $PATH
/run/wrappers/bin:/root/.nix-profile/bin:/nix/profile/bin:/root/.local/state/nix/profile/bin:/etc/profiles/per-user/root/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin

You can see my setup here: GitHub - onnimonni/hetzner-auction-nixos-example

Try setting nix.channel.enable = lib.mkForce true? (What is setting it to false tho?)

1 Like

Don’t use nix-env for installing software this way, anything else is better

You’re talking to a NixOS beginner and it will be helpful if you will replace anything with the actual steps needed :bowing_man:

I would want to run lspci to get more information about my hardware and understood it’s provided with the nixos.pciutils package.

nix shell nixpkgs#pciutils with -c lspci if you want

1 Like

If you don’t use the unstable nix-command feature, you’ll have to use the traditional nix-shell instead of the nix shell subcommand.

The best practice is probably:

  • If you just need the command temporarily, e.g. to look at something which you don’t expect to inspect regularly, use nix-shell or nix shell. It will disappear once you close the shell, and eventually be cleaned up when you collect garbage.
  • Otherwise, add it to your configuration’s environment.systemPackages and use nixos-rebuild switch

The reason nix-env is discouraged is that it adds packages to a “profile” imperatively, which results in all kinds of confusion on an otherwise declarative system. Besides this, it has many weird idiosyncracies and poor design decisions from a decade ago that are basically just footguns for folks who don’t know in detail how the command works.

I’d elaborate, but this page does a better job: https://stop-using-nix-env.privatevoid.net/

Indeed probably good advice, but not the issue at hand. Did the setting work?

Per the repo they linked, they use flakes already, and per the question asked, their channels are a bit borked :slight_smile:

In any case, I was trying to answer the implicit question to unblock them, since the question about channels was already answered and IMO it’s pointless for me to repeat that.

2 Likes

Thanks! This was great advice :100:

Also after forcing the nix.channel.enable I can see the nix-channel perfectly :+1: