Cant rebuild after adding home manager to config

At the top of my configuration.nix imports I have <home-manager/nixos>
Then further down I have

  home-manager.users.mike = { pkgs, ... }: {
    home.stateVersion = "23.05"; 
    home.packages = with pkgs; [ 
      git # etc..
    programs.bash.enable = true;

This is the only changes I have made prior to successful rebuild.
When I run the rebuild I get:

sudo nixos-rebuild switch
[sudo] password for mike:
building Nix…
building the system configuration…
trace: warning: optionsDocBook is deprecated since 23.11 and will be removed in 24.05
… while calling the ‘head’ builtin

     at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:820:11:

      819|         || pred here (elemAt values 1) (head values) then
      820|           head values
         |           ^
      821|         else

   … while evaluating the attribute 'value'

     at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:768:9:

      767|     in warnDeprecation opt //
      768|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
         |         ^
      769|         inherit (res.defsFinal') highestPrio;

   (stack trace truncated; use '--show-trace' to show the full trace)

   error: The type `types.string` is deprecated. See for better alternative types.

Oh and any ideas about how to solve optionsDocBook warning?
Help needed.

  1. Find where you declare an option that has a type of types.string or a container type that includes types.string and use a more appropriate type instead.
  2. The docbook warning needs to be fixed in HM. There is an open ticket for that, but they are currently blocked on that as far as I understand. See bug: Getting 'optionsDocBook is deprecated since 23.11 and will be removed in 24.05' on most runs · Issue #4273 · nix-community/home-manager · GitHub for more information
1 Like

Hi, thanks for the reply. But I have nothing that relates to types.string or container type.

When I simply comment out the home-manager block as shown the problem disappears but no home manager. I have tried commenting out just the home.packages line but still causes an error. I have tried another Nix Starter config but this still throws an error.

Yep, apparently it’s a bug caused by a recent change to nixpkgs (that has already been resolved on the correct branch of home-manager): Nix build errors out Nixos unstable

Considering you’re having issues with home-manager, I would assume you made the exact same mistake as the OP in the other thread. If you use nixpkgs-stable, use home-manager stable, and vice versa.

Not only make sure to use the correct channel, but also to update it.

A lot of HM as a system module users with a channel based setup, have a lingering/stale HM channel as nixos-rebuild --update only updates the nixos channel, not the HM one.

So one should prefer updating through nix-channel --update

1 Like

I had the same problem, when updating. My problem was that I used the emacs-overlay flake that had a older version of nixpkgs as input. You don’t seem to be using flakes so the issue is likely that you are using an version of nixpkgs incompatible with the current home-manager.

To resolve this you can either pin home-manager to an old version until you update your nixpkgs
or update nixpkgs.

1 Like

It’s almost certainly an outdated home-manager in this case, since it is using types.string, which was deprecated in recent nixpkgs unstable; Therefore nixpkgs must be ahead of home-manager, either because the channel is following the stable branch or because only nixpkgs has been updated due to use of nixos-rebuild --upgrade as @NobbZ says. The real solution is likely something like this:

$ sudo nix-channel --remove home-manager
$ sudo nix-channel --add home-manager
$ sudo nix-channel --update
$ sudo nixos-rebuild switch

home-manager is fixed as of last week: modules: types.string throws error now (#4324) · nix-community/home-manager@7b8d43f · GitHub

Don’t downgrade or pin things at this point, it’s been resolved.

1 Like

Thanks that worked for me :sunny:

1 Like