Emacs now uses flake pinning and cached packages. And dock stall workaround

This commit is contained in:
Olaf committed 2026-10-21 17:50:46 +02:00
1 parent ca6ddc4b48
commit 5e24c62d7b
8 files changed
+632 -35

No files matched your search

-1
View File
@@ -2,7 +2,6 @@ README.md~
.DS_Store
result
dump.txt
flake.lock
*~
Platformio - NixOS Wiki*
.platformio/
+26
View File
@@ -7,3 +7,29 @@ Started with a configuration generated from [this nixos config template](https:/
Initialy created 'with secrets' but stripped out the git/agenix in favor of sops
Refactored the configuration to remove nixos but keep the shared modules and Darwin host setup, with no NixOS trees or Linux app targets.
## Emacs and binary caches
The Emacs overlay is a flake input pinned in `flake.lock`. Keep the lock file
in version control so builds use the same input revisions. Update only the
overlay with:
```sh
nix flake update emacs-overlay
```
Emacs uses the unmodified release package from each architecture's nixpkgs,
rather than `emacs-git`, to reuse builds from `https://cache.nixos.org`.
The overlay still supplies `emacsWithPackagesFromUsePackage` and the Lisp
package definitions. The installed Emacs and launchd daemon share the same
configured package; client launchers use the matching release Emacs client.
Both the NixOS and nix-community caches are configured in the Darwin host.
Cache availability depends on the locked revisions and architecture. Check the
base Emacs build without compiling (substitute `x86_64-darwin` for Intel):
```sh
nix build --dry-run '.#darwinConfigurations.aarch64-darwin.pkgs.emacs'
```
The custom Lisp package collection and wrapper may still need local builds.
Generated
+533
View File
@@ -0,0 +1,533 @@
{
"nodes": {
"brew-src": {
"flake": false,
"locked": {
"lastModified": 1792568047,
"narHash": "sha256-3t+GIzv/Shf6JZN6GhZmOdTgI8UCOcVASV5PMXVuqdk=",
"owner": "Homebrew",
"repo": "brew",
"rev": "1ef73bbf695bfa42a4a26b19eeeb3f890f3cfbee",
"type": "github"
},
"original": {
"owner": "Homebrew",
"ref": "main",
"repo": "brew",
"type": "github"
}
},
"bun2nix": {
"inputs": {
"flake-parts": [
"llm-agents",
"flake-parts"
],
"nixpkgs": [
"llm-agents",
"nixpkgs"
],
"systems": [
"llm-agents",
"systems"
],
"treefmt-nix": [
"llm-agents",
"treefmt-nix"
]
},
"locked": {
"lastModified": 1790001035,
"narHash": "sha256-1/SLBjSYBzDdDhvLQ83wrzBakyS/xNGgtxHGNuveOEQ=",
"owner": "Mic92",
"repo": "bun2nix",
"rev": "07a5bfc8ac36c5370199343fa620b69f63186e33",
"type": "github"
},
"original": {
"owner": "Mic92",
"ref": "llm-agents",
"repo": "bun2nix",
"type": "github"
}
},
"catppuccin": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1792238796,
"narHash": "sha256-mRsa8oJ8R7fkvR5K+uQYfuxX9Np0ai/KvzTE8FYVx7E=",
"owner": "catppuccin",
"repo": "nix",
"rev": "30c87b95a628e81ec82a4fa0ed4db85d7c7d46d6",
"type": "github"
},
"original": {
"owner": "catppuccin",
"repo": "nix",
"type": "github"
}
},
"darwinAarch64": {
"inputs": {
"nixpkgs": [
"nixpkgsAarch64"
]
},
"locked": {
"lastModified": 1792366139,
"narHash": "sha256-jto4pdsl0bgErQ5vaMc3gOyj//PILLRJuqX3I7fUk6s=",
"owner": "nix-darwin",
"repo": "nix-darwin",
"rev": "f0ec2b3fae4df92ea7788359aef9e07bb88d720f",
"type": "github"
},
"original": {
"owner": "nix-darwin",
"repo": "nix-darwin",
"type": "github"
}
},
"darwinX86": {
"inputs": {
"nixpkgs": [
"nixpkgsX86"
]
},
"locked": {
"lastModified": 1783744694,
"narHash": "sha256-2cp6N3rrwnGYLTx9l6N+NI+kwrCWxvJUbj5WJhvB29A=",
"owner": "nix-darwin",
"repo": "nix-darwin",
"rev": "c3e90c89649b07d1a96e4b9dd6cd0d6e44b91a74",
"type": "github"
},
"original": {
"owner": "nix-darwin",
"ref": "nix-darwin-26.05",
"repo": "nix-darwin",
"type": "github"
}
},
"emacs-overlay": {
"inputs": {
"nixpkgs": [
"nixpkgsAarch64"
],
"nixpkgs-stable": [
"nixpkgsX86"
]
},
"locked": {
"lastModified": 1792556335,
"narHash": "sha256-G9mIKKECDAZRzbBWtV8UgcVePr9A6/njVj2VQT02DhE=",
"owner": "nix-community",
"repo": "emacs-overlay",
"rev": "1c943e86dcb4e8e4971b0b3db15e2067fe4454b7",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "emacs-overlay",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"llm-agents",
"nixpkgs"
]
},
"locked": {
"lastModified": 1790898470,
"narHash": "sha256-zTwuwezD0w3hpga6a6P8emidzAZFyWqlNeRBlpWOOl8=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "024633cd702b10285db5cb19b40ad48d2399ba60",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_2": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1790898470,
"narHash": "sha256-zTwuwezD0w3hpga6a6P8emidzAZFyWqlNeRBlpWOOl8=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "024633cd702b10285db5cb19b40ad48d2399ba60",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"homeManagerAarch64": {
"inputs": {
"nixpkgs": [
"nixpkgsAarch64"
]
},
"locked": {
"lastModified": 1792495086,
"narHash": "sha256-TyoYH983Nsc++1scw0SoOEKshPSJWJDxK7tTmuZ974M=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "ec80131710bffcdf3b8498cf41f3a0579833b023",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"homeManagerX86": {
"inputs": {
"nixpkgs": [
"nixpkgsX86"
]
},
"locked": {
"lastModified": 1792438572,
"narHash": "sha256-5mQQOcggBRBXB7NlzUxO0dbvQN4euJOISjNybrtfxPk=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "24f8f8e786f87d6a818e1746cb2389bf922afdab",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-26.05",
"repo": "home-manager",
"type": "github"
}
},
"homebrew-cask": {
"flake": false,
"locked": {
"lastModified": 1792588409,
"narHash": "sha256-9cnhu5dCgHml3CDQ6z7NIxs9wPNi+lSgbhZ+3BFU8Kc=",
"owner": "homebrew",
"repo": "homebrew-cask",
"rev": "9475b270ce47ed3985c1df096041e5a363c2eeb3",
"type": "github"
},
"original": {
"owner": "homebrew",
"repo": "homebrew-cask",
"type": "github"
}
},
"homebrew-core": {
"flake": false,
"locked": {
"lastModified": 1792588123,
"narHash": "sha256-fKKwQn8v+qn4U6T0RFhg18ASE6mdPIM3+8wab6l+Ox4=",
"owner": "homebrew",
"repo": "homebrew-core",
"rev": "9d40ca63d343b014026e7e30f7f0851130df1473",
"type": "github"
},
"original": {
"owner": "homebrew",
"repo": "homebrew-core",
"type": "github"
}
},
"llm-agents": {
"inputs": {
"bun2nix": "bun2nix",
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs_2",
"systems": "systems",
"treefmt-nix": "treefmt-nix"
},
"locked": {
"lastModified": 1792577217,
"narHash": "sha256-YRvnXVnyZGr6+v118Lb4pTtzLzeJet2Y69qf00katjQ=",
"owner": "numtide",
"repo": "llm-agents.nix",
"rev": "4c0e549dab7167b1fe7433af15adf892a299fb83",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "llm-agents.nix",
"type": "github"
}
},
"nix-homebrew": {
"inputs": {
"brew-src": [
"brew-src"
]
},
"locked": {
"lastModified": 1789928041,
"narHash": "sha256-iV37ieTcE4ZLOYEe0VznW6dWMBe4lEL8AbK1vblyZGM=",
"owner": "zhaofengli-wip",
"repo": "nix-homebrew",
"rev": "c11cccfdd36dd69b5323d70d354b2853379c2426",
"type": "github"
},
"original": {
"owner": "zhaofengli-wip",
"repo": "nix-homebrew",
"type": "github"
}
},
"nix-vscode-extensions": {
"inputs": {
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1792555615,
"narHash": "sha256-hgkjMS7s4GRhZiHAgzF1UHFrXwu+2dcBohgF57Wrgps=",
"owner": "nix-community",
"repo": "nix-vscode-extensions",
"rev": "2a46f9d8fac507c47e8a659d5a4e91676d06273c",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nix-vscode-extensions",
"type": "github"
}
},
"nixd": {
"inputs": {
"flake-parts": "flake-parts_2",
"nixpkgs": "nixpkgs_4",
"treefmt-nix": "treefmt-nix_2"
},
"locked": {
"lastModified": 1791202410,
"narHash": "sha256-rhfHJ+F9IU7G2pbRWnlyJvHEfwW7Ezm7SHhBrteoVYc=",
"owner": "nix-community",
"repo": "nixd",
"rev": "bdb467082c4ecb467f7818f7a84d1f69db53784f",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixd",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1790652569,
"narHash": "sha256-k8Fu4c9Z+4Nh7mUr0cfw++ITQiyEhlWxoJBOkI3tOcQ=",
"rev": "b6c8664de9b6cc07fe5666a29f91884ba81197c4",
"type": "tarball",
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.11pre1082290.b6c8664de9b6/nixexprs.tar.xz"
},
"original": {
"type": "tarball",
"url": "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1790477367,
"narHash": "sha256-oujbxmVKDhci2E4EM3KyAbRUgp5/IsCoiA/LfEF7OOk=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "f7cd230690d9fc982d06129f9189b101fddcfa3b",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixpkgsAarch64": {
"locked": {
"lastModified": 1792506237,
"narHash": "sha256-Q/8KLB6jNfpaUN1HAedE/u/Et9feE/zYSsutBLKrCFk=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "5adc50831c259f87faeb09ddf930d43597197473",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgsX86": {
"locked": {
"lastModified": 1792526774,
"narHash": "sha256-+qjpjRPb6ak1rkodfh7wEtgQB3DaAI5tg0kSklSUmio=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "36fd15bbb657815e2028e31d715c2e43a1230c91",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-26.05-darwin",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1792116957,
"narHash": "sha256-EjZqHKObBfIOeHZnMRVV87HB3pPq/WBkmRJWyFxmZu8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f20cd90e28fe0403873f473b29e42662cd86e8c4",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1784564315,
"narHash": "sha256-7OpsHHIZFUBLbeHNQ0oC40DZRQjsmGWodXge+OqgPgk=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0c2094806c9e542f31785ef3569ab9e900e3ce9c",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0c2094806c9e542f31785ef3569ab9e900e3ce9c",
"type": "github"
}
},
"nixpkgs_4": {
"locked": {
"lastModified": 1790463110,
"narHash": "sha256-VZHcT2wKLkApBCACQ2SH4P1jVZUbbOA7jWAGi1MIViw=",
"rev": "e158d9ed9b51c98974c5e66e1ba1c9e0255fecaa",
"type": "tarball",
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1080189.e158d9ed9b51/nixexprs.tar.xz"
},
"original": {
"type": "tarball",
"url": "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz"
}
},
"root": {
"inputs": {
"brew-src": "brew-src",
"catppuccin": "catppuccin",
"darwinAarch64": "darwinAarch64",
"darwinX86": "darwinX86",
"emacs-overlay": "emacs-overlay",
"homeManagerAarch64": "homeManagerAarch64",
"homeManagerX86": "homeManagerX86",
"homebrew-cask": "homebrew-cask",
"homebrew-core": "homebrew-core",
"llm-agents": "llm-agents",
"nix-homebrew": "nix-homebrew",
"nix-vscode-extensions": "nix-vscode-extensions",
"nixd": "nixd",
"nixpkgsAarch64": "nixpkgsAarch64",
"nixpkgsX86": "nixpkgsX86",
"sops-nix": "sops-nix"
}
},
"sops-nix": {
"inputs": {
"nixpkgs": [
"nixpkgsAarch64"
]
},
"locked": {
"lastModified": 1792056300,
"narHash": "sha256-YU1LjDe1o2Ymg5zEiCHbmMXLkDCtxHQRiVqZ3nC5GGk=",
"owner": "Mic92",
"repo": "sops-nix",
"rev": "44931708c62937c2b1bf7953902989fa5bb9ee1b",
"type": "github"
},
"original": {
"owner": "Mic92",
"repo": "sops-nix",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1791244623,
"narHash": "sha256-uuanbkFk8a313Zfrxdcz8Us/yQtaxNnKJtX8v0ZPpd8=",
"owner": "nix-systems",
"repo": "default",
"rev": "d36eeed142f88b5a636f2e3856a53c61654cf29b",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"llm-agents",
"nixpkgs"
]
},
"locked": {
"lastModified": 1791885023,
"narHash": "sha256-C3alQ2MEt0zVrUSho5NUDo3jmhbff72++bfwoqT9Omo=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "0d6d739a833ba9a9c93034862e4a7b061a062a1c",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
},
"treefmt-nix_2": {
"inputs": {
"nixpkgs": [
"nixd",
"nixpkgs"
]
},
"locked": {
"lastModified": 1786901030,
"narHash": "sha256-WSFCsDSE5ffgD2MqzkM2CYjeFiKhRF/dJUN8uedb6YE=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "27b3b12a8e6375f28ebe122f07d230ca5459bbfa",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
+6
View File
@@ -10,6 +10,12 @@
url = "github:nixos/nixpkgs//nixpkgs-26.05-darwin";
};
emacs-overlay = {
url = "github:nix-community/emacs-overlay";
inputs.nixpkgs.follows = "nixpkgsAarch64";
inputs.nixpkgs-stable.follows = "nixpkgsX86";
};
homeManagerAarch64 = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgsAarch64";
+15 -14
View File
@@ -7,6 +7,19 @@
let
user = "olaf";
configuredEmacs = pkgs.emacsWithPackagesFromUsePackage {
config = ../config/emacs/emacs.el;
defaultInitFile = true;
package = pkgs.emacs;
alwaysEnsure = true;
extraEmacsPackages =
epkgs: with epkgs; [
magit
company
nix-mode
use-package
];
};
in
{
@@ -101,19 +114,7 @@ in
with pkgs;
[
# Emacs with automatic package management from overlay
(emacsWithPackagesFromUsePackage {
config = ../config/emacs/emacs.el;
defaultInitFile = true;
package = emacs-git;
alwaysEnsure = true;
extraEmacsPackages =
epkgs: with epkgs; [
magit
company
nix-mode
use-package
];
})
configuredEmacs
]
++ (import ../../modules/darwin/packages.nix { inherit pkgs llm-agents; })
@@ -125,7 +126,7 @@ in
ProgramArguments = [
"/bin/sh"
"-c"
"/bin/wait4path ${pkgs.emacs}/bin/emacs && exec ${pkgs.emacs}/bin/emacs --fg-daemon"
"/bin/wait4path ${configuredEmacs}/bin/emacs && exec ${configuredEmacs}/bin/emacs --fg-daemon"
];
StandardErrorPath = "/tmp/emacs.err.log";
StandardOutPath = "/tmp/emacs.out.log";
+14
View File
@@ -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).
+2 -10
View File
@@ -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 ];
};
}
+36 -10
View File
@@ -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
}
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
'';
}