nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
7.2k stars 1.85k forks source link

bug: Error starting home-manager environment for user #5054

Open jellu-cat opened 9 months ago

jellu-cat commented 9 months ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

Hello. I'm using NixOS and I want to use home-manager, but I'm having problems doing this. My first approach was to follow the configuration in nixos-wiki as this:

let
  home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-23.11.tar.gz";
in
{
  imports = [
    ./hardware-configuration.nix
    (import "${home-manager}/nixos")
  ];

Doing sudo nixos-rebuild switch results in this:

building Nix...
building the system configuration...
these 3 derivations will be built:
  /nix/store/x49jjdlh1ziv5iz2rrc9pipmglysls4l-system-units.drv
  /nix/store/yhyvsaghxa4g9xwk8b579mmwa7ihmnvf-etc.drv
  /nix/store/dq4l0hrqrwsjdbqalkn09sdhgh72qrfs-nixos-system-vostro-23.11.4315.c68a9fc85c2c.drv
building '/nix/store/x49jjdlh1ziv5iz2rrc9pipmglysls4l-system-units.drv'...
building '/nix/store/yhyvsaghxa4g9xwk8b579mmwa7ihmnvf-etc.drv'...
building '/nix/store/dq4l0hrqrwsjdbqalkn09sdhgh72qrfs-nixos-system-vostro-23.11.4315.c68a9fc85c2c.drv'...
activating the configuration...
setting up /etc...
reloading user units for jellu...
Unable to connect to X11 display. Is $DISPLAY set?
login shell
setting up tmpfiles
warning: the following units failed: home-manager-jellu.service

× home-manager-jellu.service - Home Manager environment for jellu
     Loaded: loaded (/etc/systemd/system/home-manager-jellu.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Sat 2024-02-24 12:15:00 CST; 56ms ago
    Process: 255864 ExecStart=/nix/store/wcf178rx6zgfrwg52cpbqzz9b1xfwp74-hm-setup-env /nix/store/7izgd7290blydcp683hpf26cwi04h2il-home-manager-generation (code=exited, status=1/FAILURE)
   Main PID: 255864 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
        CPU: 92ms

Feb 24 12:15:00 vostro hm-activate-jellu[255864]: Oops, Nix failed to install your new Home Manager profile!
Feb 24 12:15:00 vostro hm-activate-jellu[255864]: Perhaps there is a conflict with a package that was installed using
Feb 24 12:15:00 vostro hm-activate-jellu[255864]: "nix-env -i"? Try running
Feb 24 12:15:00 vostro hm-activate-jellu[255864]:     nix-env -q
Feb 24 12:15:00 vostro hm-activate-jellu[255864]: and if there is a conflicting package you can remove it with
Feb 24 12:15:00 vostro hm-activate-jellu[255864]:     nix-env -e {package name}
Feb 24 12:15:00 vostro hm-activate-jellu[255864]: Then try activating your Home Manager configuration again.
Feb 24 12:15:00 vostro systemd[1]: home-manager-jellu.service: Main process exited, code=exited, status=1/FAILURE
Feb 24 12:15:00 vostro systemd[1]: home-manager-jellu.service: Failed with result 'exit-code'.
Feb 24 12:15:00 vostro systemd[1]: Failed to start Home Manager environment for jellu.
warning: error(s) occurred while switching to the new configuration

I have tried the solution provided in #1140, and checked #3910, but the problem in either issues seem different. I'm guessing is a problem with the lock files, but I'm stuck.

Any help would be appreciated!

Maintainer CC

No response

System information

- system: `"x86_64-linux"`
 - host os: `Linux 6.7.4, NixOS, 23.11 (Tapir), 23.11.4315.c68a9fc85c2c`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
scientiac commented 2 months ago

I did as it said and set the backup file extension, the first time it worked but the error came back again upon other updates to home manager.

[scientiac@einstein:~/Einstein]$ sudo nixos-rebuild switch --flake .
[sudo] password for scientiac: 
building the system configuration...
activating the configuration...
setting up /etc...
reloading user units for scientiac...
restarting sysinit-reactivation.target
warning: the following units failed: home-manager-scientiac.service
× home-manager-scientiac.service - Home Manager environment for scientiac
     Loaded: loaded (/etc/systemd/system/home-manager-scientiac.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Sat 2024-09-28 21:27:41 +0545; 287ms ago
   Duration: 37min 16.572s
 Invocation: ef154fdd388241deb53162559c5af09e
    Process: 34022 ExecStart=/nix/store/hh1d3nhigpky6d6shbnpxmhv4385fhgs-hm-setup-env /nix/store/cam2wz85y9c8ifpir71c8n4jgpipr59d-home-manager-generation (code=exited, status=1/FAILURE)
   Main PID: 34022 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
   Mem peak: 6.6M
        CPU: 149ms

Sep 28 21:27:41 einstein hm-activate-scientiac[34044]: Please do one of the following:
Sep 28 21:27:41 einstein hm-activate-scientiac[34044]: - Move or remove the above files and try again.
Sep 28 21:27:41 einstein hm-activate-scientiac[34044]: - In standalone mode, use 'home-manager switch -b backup' to back up
Sep 28 21:27:41 einstein hm-activate-scientiac[34044]:   files automatically.
Sep 28 21:27:41 einstein hm-activate-scientiac[34044]: - When used as a NixOS or nix-darwin module, set
Sep 28 21:27:41 einstein hm-activate-scientiac[34044]:     'home-manager.backupFileExtension'
Sep 28 21:27:41 einstein hm-activate-scientiac[34044]:   to, for example, 'backup' and rebuild.
Sep 28 21:27:41 einstein systemd[1]: home-manager-scientiac.service: Main process exited, code=exited, status=1/FAILURE
Sep 28 21:27:41 einstein systemd[1]: home-manager-scientiac.service: Failed with result 'exit-code'.
Sep 28 21:27:41 einstein systemd[1]: Failed to start Home Manager environment for scientiac.
warning: error(s) occurred while switching to the new configuration