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
@@ -1,6 +1,7 @@
|
||||
|
||||
## Layout
|
||||
```
|
||||
|
||||
.
|
||||
├── dock # MacOS dock configuration
|
||||
├── casks.nix # List of homebrew casks
|
||||
@@ -9,3 +10,16 @@
|
||||
├── home-manager.nix # Defines user programs
|
||||
├── packages.nix # List of packages to install for MacOS
|
||||
```
|
||||
|
||||
## Dock activation
|
||||
|
||||
Dock setup runs only when `olaf` is the active console user. Each `dockutil`
|
||||
command runs as that user in their GUI session, avoiding the root-mode
|
||||
`defaults export` pipe deadlock in dockutil 3.1.3. Commands have a 30-second
|
||||
timeout (with a forced stop after another 5 seconds) and report failures.
|
||||
A failed Dock listing aborts activation before resetting any entries.
|
||||
The Dock is restarted through its user launchd service.
|
||||
|
||||
If setup is skipped because no matching desktop session is active, run
|
||||
`sudo darwin-rebuild switch --flake .#aarch64-darwin` again after logging in
|
||||
(use `x86_64-darwin` on Intel).
|
||||
@@ -1,8 +1,4 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
emacsOverlaySha256 = "149iwabscwrndxmrfy1c4jcyh4hqz6i8gvja4jv752y7lcm7h9kq";
|
||||
in
|
||||
{ config, pkgs, emacs-overlay, ... }:
|
||||
{
|
||||
home-manager.backupFileExtension = "nix-backup";
|
||||
nixpkgs = {
|
||||
@@ -23,10 +19,6 @@ in
|
||||
pathExists (path + ("/" + n + "/default.nix")))
|
||||
(attrNames (readDir path)))
|
||||
|
||||
++ [(import (builtins.fetchTarball {
|
||||
url = "https://github.com/nix-community/emacs-overlay/archive/master.tar.gz";
|
||||
sha256 = emacsOverlaySha256;
|
||||
}))
|
||||
];
|
||||
++ [ emacs-overlay.overlays.default ];
|
||||
};
|
||||
}
|
||||
@@ -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