So I used to use NIxOS with home-manager as well as flakes and recently after leaving Arch for the 13th time I reinstalled NixOS on my system with flakes but kept home-manager disabled for later. As I tried activating home-manager today, I came across this error when rebuilding:
[rminstrel@hp-15s-du1015tu:~/.config/nixos]$ sudo nixos-rebuild switch
warning: Git tree '/home/config/nixos' is dirty
building the system configuration...
warning: Git tree '/home/config/nixos' is dirty
activating the configuration...
setting up /etc...
reloading user units for rminstrel...
restarting sysinit-reactivation.target
the following new units were started: NetworkManager-dispatcher.service, sysinit-reactivation.target, systemd-localed.service, systemd-tmpfiles-resetup.service
warning: the following units failed: home-manager-rminstrel.service
× home-manager-rminstrel.service - Home Manager environment for rminstrel
Loaded: loaded (/etc/systemd/system/home-manager-rminstrel.service; enabled; preset: ignored)
Active: failed (Result: exit-code) since Thu 2025-02-20 21:59:21 +06; 352ms ago
Invocation: b4ed842c933e496cb227303dd392a5dd
Process: 5972 ExecStart=/nix/store/f983xlbpicjz04hw5zjmx6ip646l3r3a-hm-setup-env /nix/store/4sl6cqqz93hrpm8jkkdd27jllxvl324f-home-manager-generation (code=exited, status=1/FAILURE)
Main PID: 5972 (code=exited, status=1/FAILURE)
IP: 0B in, 0B out
IO: 16K read, 0B written
Mem peak: 6.2M
CPU: 157ms
Feb 20 21:59:21 hp-15s-du1015tu hm-activate-rminstrel[5972]: Oops, Nix failed to install your new Home Manager profile!
Feb 20 21:59:21 hp-15s-du1015tu hm-activate-rminstrel[5972]: Perhaps there is a conflict with a package that was installed using
Feb 20 21:59:21 hp-15s-du1015tu hm-activate-rminstrel[5972]: "nix-env -i"? Try running
Feb 20 21:59:21 hp-15s-du1015tu hm-activate-rminstrel[5972]: nix-env -q
Feb 20 21:59:21 hp-15s-du1015tu hm-activate-rminstrel[5972]: and if there is a conflicting package you can remove it with
Feb 20 21:59:21 hp-15s-du1015tu hm-activate-rminstrel[5972]: nix-env -e {package name}
Feb 20 21:59:21 hp-15s-du1015tu hm-activate-rminstrel[5972]: Then try activating your Home Manager configuration again.
Feb 20 21:59:21 hp-15s-du1015tu systemd[1]: home-manager-rminstrel.service: Main process exited, code=exited, status=1/FAILURE
Feb 20 21:59:21 hp-15s-du1015tu systemd[1]: home-manager-rminstrel.service: Failed with result 'exit-code'.
Feb 20 21:59:21 hp-15s-du1015tu systemd[1]: Failed to start Home Manager environment for rminstrel.
warning: error(s) occurred while switching to the new configuration
I have in fact tried running home-manager as a standalone program using nix run github:nix-community/home-manager -- switch
but still it throws the same identical error:
[rminstrel@hp-15s-du1015tu:~/.config/nixos]$ nix run github:nix-community/home-manager -- switch
warning: Git tree '/home/config/nixos' is dirty
warning: creating lock file '/home/config/nixos/home-manager/flake.lock':
• Added input 'home-manager':
'github:nix-community/home-manager/0c0b0ac8af6ca76b1fcb514483a9bd73c18f1e8c?narHash=sha256-FOC9OzJ5Ckh6VjzGSRh4F3UCUOdM8NrzQT19PQcQJ44%3D' (2025-02-20)
• Added input 'home-manager/nixpkgs':
follows 'nixpkgs'
• Added input 'nixpkgs':
'github:nixos/nixpkgs/73cf49b8ad837ade2de76f87eb53fc85ed5d4680?narHash=sha256-EO1ygNKZlsAC9avfcwHkKGMsmipUk1Uc0TbrEZpkn64%3D' (2025-02-18)
warning: Git tree '/home/config/nixos' is dirty
warning: Git tree '/home/config/nixos' is dirty
warning: Git tree '/home/config/nixos' is dirty
warning: Git tree '/home/config/nixos' is dirty
Starting Home Manager activation
Activating checkFilesChanged
Activating checkLinkTargets
Activating writeBoundary
Creating new profile generation
Activating installPackages
installing 'home-manager-path'
building '/nix/store/fqbv8bndxwmkfydwwmrqr3fvqgf32ndq-user-environment.drv'...
error: opening lock file '/home/lifium/.local/state/nix/profiles/profile.lock': No such file or directory
Oops, Nix failed to install your new Home Manager profile!
Perhaps there is a conflict with a package that was installed using
"nix-env -i"? Try running
nix-env -q
and if there is a conflicting package you can remove it with
nix-env -e {package name}
Then try activating your Home Manager configuration again.
I do not even have any Nix channels configured since I am using flakes. I have also tried using home-manager from the release-24.11 branch and I have also tried setting home.stateVersion
to 24.11 but still same error.
My NIxOS config is at this Github repo
I have noticed that error: opening lock file '/home/lifium/.local/state/nix/profiles/profile.lock': No such file or directory
is trying to pull the lock file from my previous user directory (I renamed my user and moved my home directory) for some reason even though my home directory is now at /home/rminstrel . Is this causing the issue? If so, how do I fix this? There are no references to lifium in my NixOS configuration files as well, nor in my home directory.