How can I upgrade my packages in home-manager?

Ahoy,

for various reasons beyond my control, I currently work professionally mainly inside a (SUSE) Linux shell. To make my life easier there, I decided to let home-manager in a user chroot manage my user account’s software. So far, so good. However, most of my work is done inside GNU Emacs. In the nixpkgs I can now find GNU Emacs 31, which would give me a few relevant improvements over GNU Emacs 30.

As far as I know, home-manager uses the “latest” version of the Nix packages by default; I have actively set nixpkgs to point to unstable either way.

My update script:

nix-channel --update >/dev/null
home-manager switch >/dev/null

Currently, that fetches the .11pre version of the nixpkgs. But emacs-nox is still on version 30.2 afterwards, not 31.1. What am I missing here?

Nixpkgs, has a few channels, and the main two are a stable channel and an unstable channel. It looks like the version of emacs-nox in Nixpkgs stable 26.05, is 30.2

nixpkgs-unstable, however, has emacs-nox 31.

If you run: nix-channel -–list then you can see what channels are in use. (Or you might have to run sudo nix-channel if the channels are managed as root, in which case you need to run nix-channel –update with root.

Thank you - I did, indeed, check the list of channels: The channels that are in use are home-manager’s master.tar.gz and nixpkgs unstable, so I thought that my script would upgrade my packages. (No root on this system, I’m afraid.)

I also emptied the .cache, but I’m still stuck with emacs-nox 30.2. Confusing…

What about the channels of the root within the nix user chroot?

Otherwise, that’s strange. Can you confirm that the versions of other packages you have installed have the stable version, and not the unstable version, or is it specific to emacs-nox?

You can use https://search.nixos.org/ to search and check.

Please share the exact output of nix-channel --list, do not paraphrase or shorten.

Also please share the output of nix-instantiate --eval --expr "(import <nixpkgs> {}).lib.version". Again without leaving out or paraphrasing anything.

❯ nix-channel --list
home-manager https://github.com/nix-community/home-manager/archive/master.tar.gz
nixpkgs https://nixos.org/channels/nixpkgs-unstable

❯ nix-instantiate --eval --expr "(import <nixpkgs> {}).lib.version"
"26.11pre1063758.e8be7818e19a"

It seems to be specific to emacs-nox:

❯ fzf --version
0.74.3 (refs/tags/v0.74.3)

❯ exa --version
eza eza - A modern, maintained replacement for ls
v0.23.5 [+git]
https://github.com/eza-community/eza

Weird. I have not pinned emacs-nox to any specific version as far as I know.

Please post the output of which emacs, realpath emacs, and share how you put emacs-nox into your config.

That particular commit is still on emacs 30.2:

$ nix eval nixpkgs/e8be7818e19a#emacs-nox.version
"30.2"

If you’d update to a newer commit on nixpkgs-unstable, you’d see 31.1:

$ nix eval nixpkgs/nixpkgs-unstable#emacs-nox.version
"31.1"
❯ which emacs
/home/USERNAME/.nix-profile/bin/emacs

❯ realpath emacs
/home/USERNAME/emacs

❯ cat .config/home-manager/home.nix
{ config, pkgs, ... }:

{
  home.stateVersion = "26.05";

  home.packages = with pkgs; [
    emacs-nox
    fzf
    # and a dozen of other packages, 
  ];

  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;
}

Then why doesn’t nix-channel --update update it?

I can only imagine, that the channel and its backing branch are slightly out of sync.

Though right now the channel URL you use for nixpkgs points at nixpkgs-unstable release nixpkgs-26.11pre1066425.9387b3fcc0c2, which is a commit with 31.1:

$ nix eval nixpkgs/9387b3fcc0c2#emacs-nox.version
"31.1"

If nix-channel --update does not solve your issue, then you will have to share more information about your setup.

Like, I had similar issues debugged in the past, and eventually we figured that those users used flakes without realizing or some other pinning, but only for some things and forgot about it.

Hmmm…

❯ nix-channel --update -vvvv
using cache entry 'file:{"name":"master.tar.gz","store":"/nix/store","url":"https://github.com/nix-community/home-manager/archive/master.tar.gz"}' -> '{"etag":"W/\"26a6fc0993cdf925aa2534f69b6b7b116952392893b45d46683428a2f7e4d78c\"","storePath":"zfyg1g9bzi7i4r1aja1c1f6aafjwdlc2-master.tar.gz","url":"https://codeload.github.com/nix-community/home-manager/tar.gz/refs/heads/master"}'
acquiring write lock on "/nix/var/nix/temproots/87831"
using cache entry 'file:{"name":"master.tar.gz","store":"/nix/store","url":"https://github.com/nix-community/home-manager/archive/master.tar.gz"}' -> '{"etag":"W/\"26a6fc0993cdf925aa2534f69b6b7b116952392893b45d46683428a2f7e4d78c\"","url":"https://codeload.github.com/nix-community/home-manager/tar.gz/refs/heads/master"}', '/nix/store/zfyg1g9bzi7i4r1aja1c1f6aafjwdlc2-master.tar.gz'
using cache entry 'file:{"name":"nixpkgs-unstable","store":"/nix/store","url":"https://nixos.org/channels/nixpkgs-unstable"}' -> '{"etag":"\"df6689a5e3ead3abdf671bde08105d1d\"","storePath":"g9jwpml0if20z72bh6h2j805gs4dwhg7-nixpkgs-unstable","url":"https://releases.nixos.org/nixpkgs/nixpkgs-26.11pre1066425.9387b3fcc0c2"}'
using cache entry 'file:{"name":"nixpkgs-unstable","store":"/nix/store","url":"https://nixos.org/channels/nixpkgs-unstable"}' -> '{"etag":"\"df6689a5e3ead3abdf671bde08105d1d\"","url":"https://releases.nixos.org/nixpkgs/nixpkgs-26.11pre1066425.9387b3fcc0c2"}', '/nix/store/g9jwpml0if20z72bh6h2j805gs4dwhg7-nixpkgs-unstable'
using cache entry 'file:{"name":"nixexprs.tar.xz","store":"/nix/store","url":"https://releases.nixos.org/nixpkgs/nixpkgs-26.11pre1066425.9387b3fcc0c2/nixexprs.tar.xz"}' -> '{"etag":"\"d2f5d3b50c320dcc68f5627a5fba4cb7\"","storePath":"iv384bz1ks6kah6rcfmp52hhbwk0y7jn-nixexprs.tar.xz","url":"https://releases.nixos.org/nixpkgs/nixpkgs-26.11pre1066425.9387b3fcc0c2/nixexprs.tar.xz"}'
using cache entry 'file:{"name":"nixexprs.tar.xz","store":"/nix/store","url":"https://releases.nixos.org/nixpkgs/nixpkgs-26.11pre1066425.9387b3fcc0c2/nixexprs.tar.xz"}' -> '{"etag":"\"d2f5d3b50c320dcc68f5627a5fba4cb7\"","url":"https://releases.nixos.org/nixpkgs/nixpkgs-26.11pre1066425.9387b3fcc0c2/nixexprs.tar.xz"}', '/nix/store/iv384bz1ks6kah6rcfmp52hhbwk0y7jn-nixexprs.tar.xz'
unpacking 2 channels...

❯ nix-instantiate --eval --expr "(import <nixpkgs> {}).lib.version"
"26.11pre1066425.9387b3fcc0c2"

❯ home-manager switch
...

❯ emacs --version
GNU Emacs 31.1

I honestly don’t know why it did that. I’ve been updating a dozen times without any good results.

Maybe that was it? :face_with_raised_eyebrow:

So…. fixed, I guess. Phew.