From dfef0d0735754caa81ad2a4c003437dec6d5f23f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pacana?= Date: Tue, 4 Aug 2026 18:43:32 +0200 Subject: [PATCH] Add Elasticsearch ramdisk volume * Create a launchd daemon on cm so Elasticsearch has a predictable APFS ramdisk volume at boot. * Keep ownership and permissions stable after creation so local Elasticsearch can write to the volume without manual setup. --- hosts/cm.nix | 1 + modules/elasticsearch-volume.nix | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 modules/elasticsearch-volume.nix diff --git a/hosts/cm.nix b/hosts/cm.nix index 7aae9a1..3e14846 100644 --- a/hosts/cm.nix +++ b/hosts/cm.nix @@ -9,6 +9,7 @@ ../modules/homebrew.nix ../modules/account.nix ../modules/rosetta.nix + ../modules/elasticsearch-volume.nix ]; }; diff --git a/modules/elasticsearch-volume.nix b/modules/elasticsearch-volume.nix new file mode 100644 index 0000000..291f2e1 --- /dev/null +++ b/modules/elasticsearch-volume.nix @@ -0,0 +1,24 @@ +{ pkgs, ... }: + +let + volume = "elasticsearch"; + sectors = "131072"; + ensureRamdisk = pkgs.writeShellScript "ensure-elasticsearch-volume" '' + set -euo pipefail + + if [ ! -d "/Volumes/${volume}" ]; then + device=$(/usr/bin/hdiutil attach -nomount ram://${sectors} | tr -d '[:space:]') + /usr/sbin/diskutil erasevolume APFS "${volume}" "$device" + fi + + /bin/mkdir -p "/Volumes/${volume}" + /usr/sbin/chown mostlyobvious:staff "/Volumes/${volume}" + /bin/chmod 755 "/Volumes/${volume}" + ''; +in +{ + launchd.daemons.elasticsearch-volume = { + command = "${ensureRamdisk}"; + serviceConfig.RunAtLoad = true; + }; +} -- 2.51.2