Emacs now uses flake pinning and cached packages. And dock stall workaround
This commit is contained in:
1 parent
ca6ddc4b48
commit
5e24c62d7b
8 files changed
+632
-35
No files matched your search
@@ -78,23 +78,49 @@ in
|
||||
wantURIs = concatMapStrings (entry: "${entryURI entry.path}\n") cfg.entries;
|
||||
createEntries = concatMapStrings (
|
||||
entry:
|
||||
"if [ -e '${entry.path}' ]; then ${dockutil}/bin/dockutil --no-restart --add '${entry.path}' --section ${entry.section} ${entry.options} /Users/${user} ; fi \n "
|
||||
''
|
||||
if [ -e ${escapeShellArg entry.path} ]; then
|
||||
runDockutil --no-restart --add ${escapeShellArg entry.path} --section ${escapeShellArg entry.section} ${entry.options} /Users/${user} || exit 1
|
||||
fi
|
||||
''
|
||||
) cfg.entries;
|
||||
in
|
||||
{
|
||||
system.activationScripts.postActivation.text = ''
|
||||
echo >&2 "Setting up the Dock for ${user}..."
|
||||
haveURIs="$(${dockutil}/bin/dockutil --list /Users/${user} | ${pkgs.coreutils}/bin/cut -f2)"
|
||||
|
||||
if ! diff -wu <(echo "$haveURIs") <(echo -n '${wantURIs}') >&2 ; then
|
||||
{
|
||||
echo >&2 "Resetting Dock."
|
||||
${dockutil}/bin/dockutil --no-restart --remove all /Users/${user}
|
||||
${createEntries}
|
||||
killall Dock
|
||||
if [ "$(/usr/bin/stat -f %Su /dev/console)" = ${escapeShellArg user} ]; then
|
||||
dockUid="$(/usr/bin/id -u ${escapeShellArg user})"
|
||||
runDockutil() {
|
||||
# Avoid dockutil's root-only defaults-export pipe deadlock.
|
||||
local status
|
||||
if ${pkgs.coreutils}/bin/timeout --kill-after=5s 30s \
|
||||
/bin/launchctl asuser "$dockUid" \
|
||||
/usr/bin/sudo -H -n -u ${escapeShellArg user} \
|
||||
${dockutil}/bin/dockutil "$@"; then
|
||||
return 0
|
||||
else
|
||||
status=$?
|
||||
echo >&2 "Dock setup failed: dockutil $* exited with status $status (timeout: 30s)."
|
||||
return "$status"
|
||||
fi
|
||||
}
|
||||
else
|
||||
|
||||
dockListing="$(runDockutil --list /Users/${user})" || exit 1
|
||||
haveURIs="$(printf '%s\n' "$dockListing" | ${pkgs.coreutils}/bin/cut -f2)"
|
||||
|
||||
if ! diff -wu <(echo "$haveURIs") <(echo -n ${escapeShellArg wantURIs}) >&2; then
|
||||
echo >&2 "Resetting Dock."
|
||||
runDockutil --no-restart --remove all /Users/${user} || exit 1
|
||||
${createEntries}
|
||||
if ! ${pkgs.coreutils}/bin/timeout --kill-after=5s 30s \
|
||||
/bin/launchctl kickstart -k "gui/$dockUid/com.apple.Dock.agent"; then
|
||||
echo >&2 "Dock setup failed: could not restart the Dock for ${user}."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
echo >&2 "Dock setup complete."
|
||||
else
|
||||
echo >&2 "Skipping Dock setup: ${user} is not the active console user. Re-run activation after logging in."
|
||||
fi
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user