home-manager: show full script path on activation error

Run the activation script in its original nix-store location so that
Bash error messages show the real script location instead of 'wrkdir',
which gets deleted right after the script exits.

(cherry picked from commit 02a501705a)
This commit is contained in:
Cornelius Mika 2017-08-17 10:16:26 +02:00 committed by Robert Helgesson
parent 463d6db90b
commit 758d2ef9c1
No known key found for this signature in database
GPG key ID: C3DB11069E65DC86

View file

@ -91,8 +91,9 @@ function doSwitch() {
local wrkdir
wrkdir="$(mktemp -d)"
local generation
local exitCode=0
doBuild "$wrkdir/generation" && "$wrkdir/generation/activate" || exitCode=1
generation=$(doBuild "$wrkdir/result") && $generation/activate || exitCode=1
# Because the previous command never fails, the script keeps running and
# $wrkdir is always removed.