In order to save disk space by reducing my store’s (/nix/store/) disk usage, I’d like to use a single channel for both my system (whatever is used for nixos-rebuild) and for my only (real) user’s nix-env.
I’m not sure I got right what’s documented hence I’m asking here. Here’s some info of my current channels state:
maybe just remove user channel? It will fallback to system one
What’s the meaning of the symlink to default-5-link in the profiles directory?
each time you rebuild profile, a new symlink is created - system-1-link, system-2-link, … The system symlink just refers to latest system-NN-link. When you nix-collect-garbage -d, it removes those intermediate unused symlinks, so you are left with only latest and link to latest.
maybe just remove user channel? It will fallback to system one
It seems that nix-channel --remove nixpkgs didn’t make nix-env --upgrade fail but I think now I’m left with no updates at all. I ran nixos-rebuild and I think it upgraded every possible package. Yet nix-env --upgrade hasn’t updated a single one.
But it’s impossible that I’ve had only 5 generations through out my usage of packages - I’m using NixOS for at least a year and I’ve tested hundreds of times programs using nix-env -iA and then nix-env -e.
With the nixpkgs channel I had from before, I get 1 update. Maybe that’s a sign of that small gap between nixos-unstable and nixpkgs-unstable… Meaning it’s OK that nix-env --upgrade think there’s nothing to upgrade.
(EDIT) Moreover, I’m trying to investigate while at it, the issue of multiple search results in nix search - Why now, even with only 1 channel for root and no channels for myself, I get 3 search results from 3 channels:
* nixos-unstable.blender (blender)
3D Creation/Animation/Publishing System
* nixos.blender (blender)
3D Creation/Animation/Publishing System
* nixpkgs.blender (blender)
3D Creation/Animation/Publishing System
not sure if you talk about user profile or root profile. Because default-5-link is root profile, that is sudo nix-env -i .... It might be you rarely install anything as root.
The nixos-unstable channel looks like a bug. It should have been removed by nix tools… But duplication nixos/nixpkgs is kinda expected - I believe this is an old bug.
The nixos-unstable channel looks like a bug. It should have been removed by nix tools… But duplication nixos/nixpkgs is kinda expected - I believe this is an old bug.
I see. Say @danbst I’d like to file a bug in https://github.com/NixOS/nix/issues , where should I start? What info is relevant? Should I tell them my $NIX_PATH as well? It is set by /etc/set-environment as generated by my NixOS config… Currently:
$HOME/.nix-defexpr/channels lets you use <channelname> to refer to user channels you got from nix-channels, and /nix/var/nix/profiles/per-user/root/channels also does that but lets regular users use root's channels, that is those configured with sudo nix-channels. nixos-config=/etc/nixos/configuration.nix lets nixos-rebuild, nixos-options etc. find the configuration file.
It does not. $NIX_PATH is several ‘things’ separated by :, and each ‘thing’ is either path or name=path. Please see my earlier reply again for what /nix/var/nix/profiles/per-user/root/channels does, and also the relevant section in the Nix manual.
Do you think @dramforever I’d miss something with this $NIX_PATH? Would I have trouble if I’d want to use all kinds of default.nix files in development repos that use import <channelname>?
Actually IIRC the default configuration is exactly what you described in your original post title: only 1 channel for user nix-env and system nixos-rebuild. If the user doesn’t configure any channels, root's ones are used. You didn’t really have to do anything .
$NIX_PATH is like that because nix-channel is a completely separate mechanism. It would actually complicate things if in Nix <foo> referred to some ‘channel’ mechanism rather than just a path configured by an environment variable.
As of your NIX_PATH, I don’t see a problem. If it’s working for you then it’s most likely fine. The only NIX_PATH you can expect existing from most installations is <nixpkgs> anyway, so I think it’s okay.
I agree with you it is all complicated. I think this is one of reasons why nix-channel and nix-env were not ported to Nix2, and why all this flakes + flake locks stuff is going on. So maybe don’t report a bug, but let’s just wait until flakes+nix2 stabilize.
My default $NIX_PATH includes paths without a something= and I think that’s what caused the multiple search results in nix search. As for the original issue of this thread, I can testify that currently:
$ nix-channel --list
Outputs nothing but:
$ ls -l ~/.nix-defexpr/channels/
total 12
lrwxrwxrwx 2 root root 99 Jan 1 1970 binary-caches -> /nix/store/n8q83dx47i6n562l9q23ppf2c92i0112-nixos-unstable-19.09pre186563.b5f5c97f7d6/binary-caches
lrwxrwxrwx 2 root root 60 Jan 1 1970 manifest.nix -> /nix/store/fshsa1v74jv8b9ssjnq1yf783lfdissg-env-manifest.nix
lrwxrwxrwx 2 root root 100 Jan 1 1970 nixos-unstable -> /nix/store/n8q83dx47i6n562l9q23ppf2c92i0112-nixos-unstable-19.09pre186563.b5f5c97f7d6/nixos-unstable
Maybe that’s the bug @danbst talked about in post #5? I expect the nixos-unstable directory not to be there.
That’s definitely helpful @danbst . It’ll take me some time though to get my head wrapped around it along @tohl2’s suggestion. What perplexes me the most is the fact that nix-env doesn’t care about $NIX_PATH. That’s pretty insane. Hence I’m considering:
Yes this does not look right to me. If you can cause this without doing anything funny like editing ~/.nix-channels by hand then it’s a bug. If you did do something funny though, you might consider it a bug but I guess you’re supposed to clean up after yourself…
I suppose it could be set via nix.nixPath (as @tohl2 suggested):
In the current state:
I don’t get duplicate search results from nix search and only the nixos. attribute prefix is used in it’s results.
nix-env -qa --json is showing only nixos. attributes which are all derived from the packages defined in /nix/var/nix/profiles/per-user/root/channels/nixos.
command-not-found is using the nixos. attribute to instruct how to install a package.