I’m having an issue with home-manager on nixOS 22.05 that I don’t know how to debug: every time I reboot, home-manager gets a new generation. Worse, the new generation is faulty in the sense that it doesn’t reflect what’s in ~/.config/nixpkgs/home.nix
.
I can reproduce this as follows. First (and as suggested in the home-manager manual I create a nix-channel for home-manager 22.05 and import it into configuration.nix
. Then I create a new user in configuration.nix
:
users.users.testuser = {
isNormalUser = true;
description = "Test User";
};
home-manager.users.testuser = { pkgs, ... }: {
programs.bash.enable = true;
};
I run sudo nixos-rebuild switch
and then create a /home/testuser/.config/nixpkgs/home.nix
configuration that’s just slightly more complicated than the barebones one from the home-manager manual. (By the way, the manual says that "A fresh install of Home Manager will generate a minimal ~/.config/nixpkgs/home.nix
", but actually I had to create that file myself.)
# Full contents of home.nix:
{ config, pkgs, ... }:
{
home.username = "testuser";
home.homeDirectory = "/home/testuser";
home.stateVersion = "22.05";
programs.home-manager.enable = true;
home.sessionVariables = {
FOO = 1;
};
}
Now I run home-manager switch
and it’s great. A new generation is created, and my home-manager config is reflected in ~/.nix-profile/etc/profile.d/hm-session-vars.sh
, which contains the line export FOO="1"
Now comes the problem. I reboot, and after logging back in as testuser, the environment variable FOO is not set, and the file ~/.nix-profile/etc/profile.d/hm-session-vars.sh
no longer contains the line export FOO="1"
. Using home-manager generations
I see that after rebooting there’s one more generation than before the reboot. If I reactivate the previous generation, I get back the line export FOO="1"
in my hm-session-vars.sh
(but again, it disappears on reboot).
Can anyone help me figure out what’s going on?