templates: add homebrew-macos

Fix issue 4729

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda committed 2026-03-16 18:24:46 +09:00
1 parent dd5c5af544
commit 27ea56119e
5 files changed
+54 -4

No files matched your search

+2 -1
View File
@@ -80,7 +80,8 @@ NOTE: support for non-Linux OSes is [experimental](https://lima-vm.io/docs/relea
### Alternative package managers
- [`linuxbrew`](./linuxbrew.yaml): [Homebrew](https://brew.sh) on Linux (Ubuntu)
- [`linuxbrew`](./linuxbrew.yaml), `homebrew-linux`: [Homebrew](https://brew.sh) on Linux (Ubuntu)
- [`homebrew-macos`](./homebrew-macos.yaml): [Homebrew](https://brew.sh) on macOS
### Containers
+1
View File
@@ -0,0 +1 @@
linuxbrew.yaml
+42
View File
@@ -0,0 +1,42 @@
# Homebrew on macOS.
#
# Useful for sandboxing `brew` in an isolated environment.
minimumLimaVersion: 2.1.0
base:
- template:_images/macos
# Remove this line to disable the mounts
- template:_default/mounts
# The macOS installer seems to require the display device to be present.
video:
display: "default"
message: |
The user password for GUI session is stored in the `~/password` file in the guest.
Consider changing it after the first login.
provision:
- mode: data
path: /usr/local/bin/lima-sudo-askpass.sh
permissions: 755
content: |
#!/bin/sh
set -eu
# This script is expected to be used only for the initial setup.
# This script stops working after the user changes the password.
cat "$HOME/password"
- mode: user
script: |
#!/bin/bash
set -eux -o pipefail
[ -e /opt/homebrew ] && exit 0
curl -o homebrew-install.sh -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
SUDO_ASKPASS=/usr/local/bin/lima-sudo-askpass.sh NONINTERACTIVE=1 /bin/bash homebrew-install.sh
rm -f homebrew-install.sh
# No /etc/profile.d on macOS
echo >> ~/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv zsh)"' >> ~/.zprofile
echo >> ~/.bash_profile
echo 'eval "$(/opt/homebrew/bin/brew shellenv bash)"' >> ~/.bash_profile
-3
View File
@@ -1,9 +1,6 @@
# Homebrew on Linux.
#
# Useful for sandboxing `brew` in an isolated environment.
#
# This template does not use macOS as the guest OS, because installation of
# Xcode Command Line Tools (`xcode-select --install`) requires GUI desktop session.
minimumLimaVersion: 2.0.0
@@ -8,9 +8,18 @@ weight: 2
Running macOS guests is experimentally supported since Lima v2.1.
{{< tabpane text=true >}}
{{% tab header="macOS only" %}}
```bash
limactl start template:macos
```
{{% /tab %}}
{{% tab header="With Homebrew" %}}
```bash
limactl start template:homebrew-macos
```
{{% /tab %}}
{{< /tabpane >}}
The user password is randomly generated and stored in the `~/password` file in the VM.
Consider changing it after the first login.