I’m trying to keep my server synced to my work laptop
They share a flake so its really easy I manually upgrade and push the lock file on my laptop and the server just needs to pull and rebuild and it will follow the lock file
I don’t want to have to manually rebuild the server all the time so I’m trying to put it on a systemd timer here is my current module config
I tried a lot of stuff before that but home manager never seems to be able to be ran from systemd
always getting error 127
mai 28 16:29:53 fujiserver systemd[602394]: Starting Rebuild Home Manager configuration from flake...
mai 28 16:29:53 fujiserver systemd[602394]: home-manager-rebuild.service: Main process exited, code=exited, status=127/n/a
mai 28 16:29:53 fujiserver systemd[602394]: home-manager-rebuild.service: Failed with result 'exit-code'.
mai 28 16:29:53 fujiserver systemd[602394]: Failed to start Rebuild Home Manager configuration from flake.
as you can see my home manager is written as ${pkgs.home-manager}/bin/home-manager so the service sees it as an absolute path to the nix store therefore I dont understand how it can get an executable not found error
I’m calling home-manager switch in a script that first removes the oldest generation at greater-than-or-equal-to 90% disk-usage. The scripts runs as a user service:
#!/run/current-system/sw/bin/bash
set -auEeo pipefail
PATH="$PATH:/run/current-system/sw/bin:/home/$USER/.nix-profile/bin"
if test -n "$(df -h ~/. | grep -E '9[0-9]%|100%')"
then
df -h ~/.
home-manager remove-generations "$(home-manager generations | tail -1 | sed 's/^.* id //; s/ -> .*$//')"
nix-collect-garbage
nix-store --gc
nix-store --optimise
fi
home-manager switch
Exactly my situation. I sync both flake.lock and all *.nix configuration between several laptops, servers and workstations, including the laptop of my daughter.
None of these will work because home-manager isn’t on the PATH for the systemd service. Use the full path to the hm binary, for example: ${lib.getExe pkgs.home-manager}
yes but I have a line that imports my user PATH in the service
if I have only ${lib.getExe pkgs.home-manager} in the exec start I get the help message in the logs as expected but adding switch after and im back at exit code 127
I think there is some step in the home manager switch operation that expects something to be in path that isnt in my service