14

I installed the nix package manager on my machine (macOS 10.12.6 Sierra) several weeks ago.

I want to update mylocal nixpkgs collection to bring it in sync with any upstream updates in the channel. My understanding is that this can be achieved by running: nix-channel --update. However when I run this I get the following output:

unpacking channels... created 0 symlinks in user environment

Suggesting no expressions were updated in the channels my system is subscribed to. If I run nix-channel --list I don't see any channels listed. What channel is my system subscribed to by default? and should I expect it to be listed?

Is it the case that generally nix-channel --update will only produce local changes if I have modified the channels I'm subscribed to or if I'm subscribed to the unstable channel?

b73
  • 1,377
  • 2
  • 14
  • 25

2 Answers2

17

The following might be specific to OSX:

Nix channels are managed on a per-user basis (source). nix-channel --list's output is empty because by default you are not subscribed to any channels - only root is subscribed to nixpkgs-unstable (source).

You can run nix-channel --list as root to see his subscriptions. But

  1. do not run it through sudo (see: https://github.com/NixOS/nix/issues/1548) and
  2. do not use a simple sudo su because it doesn't load /etc/profile (source) and thus will not have the nix env variables set up (variables-setup).

Working example:

    user$ nix-channel --list

    user$ sudo su -
    root# nix-channel --list
    nixpkgs https://nixos.org/channels/nixpkgs-unstable
fghibellini
  • 636
  • 4
  • 15
4

Your nix-channel --update suggests that you have zero channels in your channel list, not zero packages. You can see your channel configuration with nix-channel --list. You probably need to configure a channel.

The Nix install script currently configures a single channel with the name nixpkgs:

"$nix/bin/nix-channel" --add https://nixos.org/channels/nixpkgs-unstable

So that's the default channel and it should be listed in nix-channel --list after installation, until you nix-channel --remove nixpkgs or rm ~/.nix-channels.

The nix-channel command only updates your Nix expressions. It will not update any package installations. It will only affect future invocations of nix-build, nix-env and everything else that uses $NIX_PATH. (It resembles apt-get update in this respect, or brew update, except nix-channel will not update the installed version of Nix.)

Robert Hensing
  • 6,708
  • 18
  • 23
  • Thanks Robert, I think my terminology was slightly off - I was using the term "packages" interchangeably with "expressions". I have updated my post accordingly. `nix-channel --list` does not list any channels for me. Does this suggest that something is miss-configured on my system? I have not added/removed any channels since installation. When `nix-channel --update` reports `created 0 symlinks in user environment` does this mean zero expressions were updated upstream? (not what I would expect for the unstable channel - given it's setup for continuous builds). – b73 Dec 18 '17 at 12:29
  • 2
    The `created 0 symlinks in user environment` message indicates that it has built an empty environment for your `~/.nix-defexpr/channels`. That makes sense because your configuration (`nix-channel --list`) is empty. I suggest running `nix-channel --add https://nixos.org/channels/nixpkgs-unstable` to fix your configuration. – Robert Hensing Dec 19 '17 at 13:35
  • 1
    Thanks Robert, that all makes total sense. As always your help is very greatly appreciated :) – b73 Dec 20 '17 at 17:11