@layus@jonringer Do one of you know about that symlink? Is it supposed to be there? Seems like it causes the same channel to be treated like two channels, and shows the same results for “both channels”.
Still trying to get to the bottom of this. Here is an excerpt of the git log for nixos/modules/services/misc/nix-daemon.nix. This show that nixos should not appear, at least when using the new nix xxx interface.
commit 9c53116d499f930f3b79a11ba1fa696623ebfcab
Author: Eelco Dolstra <edolstra@gmail.com>
Date: Mon Sep 24 10:42:01 2018 +0200
Revert "nixos: set nixos in nixPath"
This reverts commit 67c8c4917799496dcf2ad6a500441fbbaeb918c9.
'nix run nixos.firefox' is *not* supposed to work - the Nix 2.x
interface attempts to standardize on nixpkgs.*, to get rid of the
nixos/nixpkgs confusion that existed with the channels interface. So
let's not bring that confusion back.
commit 67c8c4917799496dcf2ad6a500441fbbaeb918c9
Author: Matthew Bauer <mjbauer95@gmail.com>
Date: Sun Sep 23 00:14:27 2018 -0500
nixos: set nixos in nixPath
This makes using the nixos channel work out of the box with the new
Nix commands. For example:
$ nix run nixos.firefox -c firefox
Fixes #46536
nix run nixos.firefox actually starts compiling something on my machine. I guess I have this problem too. Unfortunately nix search -u runs out of memory and crashes on my machine (it does this when I have 2 channels set up; I don’t remember what the output looked like when I only had 1 channel) so I can’t verify that it’s showing duplicate output.
Looking at that commit, I’m assuming this is the code that populates $NIX_PATH? My $NIX_PATH doesn’t contain a nixos=… entry, so this commit is working, and yet nixos.firefox still resolves.
# nix run nixos.firefox -c firefox
[1 copied, 0.0 MiB DL]
Running Firefox as root in a regular user's session is not supported. ($XAUTHORITY is /run/user/1000/gdm/Xauthority which is owned by trusktr.)
EDIT: works fine as normal user. But either way it resolve nixos.firefox.
My assumption is nixos.firefox exists (on my machine) because $NIX_PATH contains /nix/var/nix/profiles/per-user/root/channels, which is a directory that has a symlink nixos inside it. $NIX_PATH also contains nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos, which means that <nixpkgs> and <nixos> refer to the same path. So it’s not surprising that both attribute paths work.
I guess the real question is, should nix search be returning “duplicate” results or not? I hope it’s smart enough at least to only index the path once even though it’s reachable from two different attributes.
For extra confirmation, I see this in the nix repl:
$ nix repl
Welcome to Nix version 2.3.1. Type :? for help.
nix-repl> <nixpkgs>
/nix/var/nix/profiles/per-user/root/channels/nixos
nix-repl> <nixos>
/nix/var/nix/profiles/per-user/root/channels/nixos
No, it’s not a bug. Rather, the nix command does not have a replacement for channels yet, so it’s currently left undefined where it gets its inputs from. (This is one of the main reasons why the nix CLI is marked experimental.) So currently it only uses prefixed NIX_PATH elements like nixpkgs=... .
I guess at some point Eelco changed his mind due to the number of bugs filed, and added support for channels in there. Benefit is that nix now sees them, the downside is that some entries may appear twice.
You can try to report this bug, but where, and to whom I am not sure.
Not sure if there is a proper fix in the meantime either.
Basically, this falls in the “nix command is still experimental” kind of WONTFIX (yet) issues.
When I install nix inside Ubuntu with curl, I get single results when I search for packages. After I install NixOS on a hard disk and boot into it, I get double results when I search for packages. There’s an inconsistency here, as both environments are behaving differently.
Another inconsistency is that nix-channel --list only shows nixos, which then causes search results not to match with expectations (because why we’re seeing search results for a channel that isn’t listed in the list of channels).
Seems like something needs TLC here, but I’m not experienced enough yet to be able to make that contribution.
Yeah, getting double results in nix search is not great UX, but it’s much much better than the situation before that commit where non-NixOS users were getting no results in nix search by default.
Is there any progress/news on this? I’m on nixos 20.03 and I have duplicate search results as well. Not a problem but a bit strange every once in a while when I use nix search.