Open imincik opened 1 year ago
Hi,
Can you post the full journal log of the service?
journalctl --no-pager --full --user -u home-manager-auto-upgrade.service --since=-7d
Hi @berbiche , thanks for looking and the problem.
Full log is here:
$ journalctl --no-pager --full --user -u home-manager-auto-upgrade.service --since=-7d
aug 04 10:52:03 imincik-nx systemd[2344]: Started Home Manager upgrade.
aug 04 10:52:03 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[876631]: Update Nix's channels
aug 04 10:52:03 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[876633]: unpacking channels...
aug 04 10:52:03 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[876631]: Upgrade Home Manager
aug 04 10:52:03 imincik-nx systemd[2344]: home-manager-auto-upgrade.service: Main process exited, code=exited, status=127/n/a
aug 04 10:52:03 imincik-nx systemd[2344]: home-manager-auto-upgrade.service: Failed with result 'exit-code'.
aug 04 11:13:44 imincik-nx systemd[2344]: Started Home Manager upgrade.
aug 04 11:13:44 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[906969]: Update Nix's channels
aug 04 11:13:44 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[906976]: unpacking channels...
aug 04 11:13:44 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[906969]: Upgrade Home Manager
aug 04 11:13:44 imincik-nx systemd[2344]: home-manager-auto-upgrade.service: Main process exited, code=exited, status=127/n/a
aug 04 11:13:44 imincik-nx systemd[2344]: home-manager-auto-upgrade.service: Failed with result 'exit-code'.
aug 04 11:15:50 imincik-nx systemd[2344]: Started Home Manager upgrade.
aug 04 11:15:50 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[949644]: Update Nix's channels
aug 04 11:15:57 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[949646]: unpacking channels...
aug 04 11:15:57 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[949644]: Upgrade Home Manager
aug 04 11:15:57 imincik-nx systemd[2344]: home-manager-auto-upgrade.service: Main process exited, code=exited, status=127/n/a
aug 04 11:15:57 imincik-nx systemd[2344]: home-manager-auto-upgrade.service: Failed with result 'exit-code'.
aug 04 11:16:53 imincik-nx systemd[2344]: Started Home Manager upgrade.
aug 04 11:16:53 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[949952]: Update Nix's channels
aug 04 11:16:53 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[949959]: unpacking channels...
aug 04 11:16:53 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[949952]: Upgrade Home Manager
aug 04 11:16:53 imincik-nx systemd[2344]: home-manager-auto-upgrade.service: Main process exited, code=exited, status=127/n/a
aug 04 11:16:53 imincik-nx systemd[2344]: home-manager-auto-upgrade.service: Failed with result 'exit-code'.
aug 04 11:24:47 imincik-nx systemd[2344]: Started Home Manager upgrade.
aug 04 11:24:47 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[962733]: Update Nix's channels
aug 04 11:24:47 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[962740]: unpacking channels...
aug 04 11:24:47 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[962733]: Upgrade Home Manager
aug 04 11:24:47 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[962818]: /nix/store/zjcpc7dp2k1ya82rb7c9lca9zkqp4891-home-manager/bin/home-manager: line 201: nix-build: command not found
aug 04 11:24:47 imincik-nx systemd[2344]: home-manager-auto-upgrade.service: Main process exited, code=exited, status=127/n/a
aug 04 11:24:47 imincik-nx systemd[2344]: home-manager-auto-upgrade.service: Failed with result 'exit-code'.
aug 04 11:38:16 imincik-nx systemd[2344]: Started Home Manager upgrade.
aug 04 11:38:16 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[1048703]: Update Nix's channels
aug 04 11:38:16 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[1048705]: unpacking channels...
aug 04 11:38:16 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[1048703]: Upgrade Home Manager
aug 04 11:38:16 imincik-nx systemd[2344]: home-manager-auto-upgrade.service: Main process exited, code=exited, status=127/n/a
aug 04 11:38:16 imincik-nx systemd[2344]: home-manager-auto-upgrade.service: Failed with result 'exit-code'.
aug 04 12:25:09 imincik-nx systemd[2344]: Started Home Manager upgrade.
aug 04 12:25:09 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[1157762]: Update Nix's channels
aug 04 12:25:10 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[1157769]: unpacking channels...
aug 04 12:25:10 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[1157762]: Upgrade Home Manager
aug 04 12:25:10 imincik-nx 8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[1157850]: /nix/store/zjcpc7dp2k1ya82rb7c9lca9zkqp4891-home-manager/bin/home-manager: line 201: nix-build: command not found
aug 04 12:25:10 imincik-nx systemd[2344]: home-manager-auto-upgrade.service: Main process exited, code=exited, status=127/n/a
aug 04 12:25:10 imincik-nx systemd[2344]: home-manager-auto-upgrade.service: Failed with result 'exit-code'.
nix-build: command not found
That is really surprising.
I think at some point the activation script was changed to use the nix commands from the local environment instead of using a specific version of nix in the script. The auto-upgrade service runs in a systemd unit and therefore does not have nix in its PATH.
I think an easy solution would be to add a fallback nix in the activation script if there are none in the PATH. Alternatively, the systemd script could use a wrapper that does the logic mentioned above to avoid modifying the activation script.
In case it helps, content of: /nix/store/8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade
$ cat /nix/store/8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade
#!/nix/store/iffl6dlplhv22i2xy7n1w51a5r631kmi-bash-5.1-p16/bin/bash
echo "Update Nix's channels"
/nix/store/3vpyn2qz5ay057nq9x68sh0r328d77ng-nix-2.8.1/bin/nix-channel --update
echo "Upgrade Home Manager"
/nix/store/zjcpc7dp2k1ya82rb7c9lca9zkqp4891-home-manager/bin/home-manager switch
I was checking the git history of home-manager-auto-upgrade.nix
and there is none since it was merged in to repository.
Is this module working for anybody or am I the first person trying to use it ?
I added path to the nix
binary by adding following to my configuration:
systemd.user.services.home-manager-auto-upgrade.Service.Environment = let
path = with pkgs;
lib.makeSearchPath "bin" [ nix ]; in [ "PATH=${path}" ];
and now service fails on following error:
8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade[1469724]: error: file 'home-manager/home-manager/home-manager.nix' was not found in the Nix search path (add it using $NIX_PATH or -I)
What is the best way to set correct NIX_PATH
?
NIX_PATH
for my user systemd environment is following
$ systemctl --user show-environment | grep NIX_PATH
NIX_PATH=nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
Here is configuration which works for me:
# automatic home upgrades
# fix for https://github.com/nix-community/home-manager/issues/3127
systemd.user.sessionVariables = {
NIX_PATH = "/home/imincik/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels";
};
systemd.user.services.home-manager-auto-upgrade.Service.Environment = let
path = with pkgs;
lib.makeSearchPath "bin" [ nix ];
in [ "PATH=${path}" ];
services.home-manager.autoUpgrade = {
enable = true;
frequency = "*-*-* 03:00:00";
};
I guess the same should be added in to home-manager-auto-upgrade module.
I don't really understand what could have happened, but it sounds interesting
Would you be willing to do a PR to add your fix?
I will try to create PR.
My current config version is:
# automatic home upgrades
# fix for https://github.com/nix-community/home-manager/issues/3127
systemd.user.sessionVariables = {
NIX_PATH = "$HOME/.nix-defexpr/channels:$NIX_PATH";
};
systemd.user.services.home-manager-auto-upgrade.Service.Environment = let
path = lib.makeSearchPath "bin" [ pkgs.nix ];
in [
"PATH=${path}"
];
Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.
* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.
I'm using Kubuntu 22.04 with Home Manager and I encountered this same bug. Although in my case I didn't need to set the NIX_PATH, adding nix package to PATH was the only thing required to overcome this:
services.home-manager.autoUpgrade = {
enable = true;
frequency = "weekly";
};
systemd.user.services.home-manager-auto-upgrade.Service.Environment = [
"PATH=${lib.makeSearchPath "bin" [ pkgs.nix ]}"
];
Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.
* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.
Are you following the right branch?
Is there an existing issue for this?
Issue description
home-manager-auto-upgrade.service
is failing with following error message when executed byhome-manager-auto-upgrade.timer
.BUT executing script called by this service by hand (in my case
/nix/store/8fgs2az0z3hw1c8j46fkcynkcqb0mhq3-home-manager-auto-upgrade
) works as expected - with no error, only reporting thathome-manager-auto-upgrade.service
is failing which is the point of this bug report.My configuration:
Maintainer CC
@pinage404
System information