Files
omarchy-pkgs/pkgbuilds/omarchy-nvim/PKGBUILD
T
David Heinemeier HanssonandClaude Opus 5 655b78764d Ship the omarchy-nvim plugin cache once
package() staged the LazyVim data tree twice: once at
/usr/share/omarchy-nvim/data and again at /etc/skel/.local/share/nvim. Only
the /etc/skel copy is ever read — new users are seeded from it, and
omarchy-nvim-setup prefers it — so the /usr/share copy was dead weight worth
close to half the package, which today is 243 MB installed and 178 MB read off
the ISO on every install. That made omarchy-nvim the largest package in an
Omarchy install after noto-fonts-cjk.

Drop it once /etc/skel has its copy, after the chmod and worktree restore that
copy inherits. config/ stays: both the Omarchy 4 remote-clipboard migration and
the 3.x disable-news-alert migration read it from there.

omarchy-nvim-setup's package-dir fallback narrows to config/ to match. It could
never have fired for data anyway — the setup script and /etc/skel ship in the
same package, so a new script can't pair with an old layout — and the remaining
way to lose the seed, hand-clearing /etc/skel, now says which directory is
missing and that pacman owns it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-27 15:21:33 -07:00

94 lines
3.4 KiB
Bash

# Maintainer: Ryan Hughes <ryan@omarchy.org>
pkgname=omarchy-nvim
pkgver=2026.7.27
pkgrel=1
pkgdesc="Pre-built LazyVim configuration with cached plugins"
arch=('any')
url="https://github.com/LazyVim/LazyVim"
license=('MIT')
depends=('neovim>=0.9.0' 'git')
makedepends=('git' 'nodejs' 'npm' 'tree-sitter-cli')
conflicts=('omarchy-lazyvim')
options=('!debug')
source=("https://github.com/LazyVim/starter/archive/refs/heads/main.tar.gz")
sha256sums=('d865d50211358358d3c3c1e356773c1e3de1e8964215d85eb1b4c77521e17488')
build() {
cd "$srcdir"
# Create isolated environment for building
export HOME="$srcdir/build-home"
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"
export XDG_CACHE_HOME="$HOME/.cache"
mkdir -p "$XDG_CONFIG_HOME" "$XDG_DATA_HOME" "$XDG_STATE_HOME" "$XDG_CACHE_HOME"
# Setup LazyVim starter
cp -r "$srcdir/starter-main" "$XDG_CONFIG_HOME/nvim"
rm -rf "$XDG_CONFIG_HOME/nvim/.git"
# Copy our custom configs
cp -r "$startdir/lua" "$XDG_CONFIG_HOME/nvim/"
cp -r "$startdir/plugin" "$XDG_CONFIG_HOME/nvim/"
cp "$startdir/lazyvim.json" "$XDG_CONFIG_HOME/nvim/"
echo "Installing LazyVim plugins..."
nvim --headless \
"+Lazy! sync" \
"+qa!" || true
}
restore_lazy_worktrees() {
local data_dir="$1"
local dir
for dir in "$data_dir"/lazy/*/; do
[[ -d "$dir/.git" ]] || continue
git --git-dir="$dir/.git" --work-tree="$dir" restore .
done
}
package() {
cd "$srcdir"
install -dm755 "$pkgdir/usr/share/$pkgname"
cp -a "$XDG_CONFIG_HOME/nvim" "$pkgdir/usr/share/$pkgname/config"
cp -a "$XDG_DATA_HOME/nvim" "$pkgdir/usr/share/$pkgname/data"
# Remove everything from site/ directory but keep the directory to prevent error
rm -rf "$pkgdir/usr/share/$pkgname/data/site"/*
mkdir -p "$pkgdir/usr/share/$pkgname/data/site"
# Fix permissions to be readable by all users
chmod -R 755 "$pkgdir/usr/share/$pkgname"
find "$pkgdir/usr/share/$pkgname" -type f -exec chmod 644 {} \;
# Restore plugin worktree modes after the package-wide chmod so users seeded
# from /etc/skel do not need a first-login omarchy-nvim-setup cleanup pass.
restore_lazy_worktrees "$pkgdir/usr/share/$pkgname/data"
# Seed new users via /etc/skel. The installer installs omarchy-nvim before
# creating the first user, so this handles initial ISO installs and future
# users without an extra overwrite step.
install -dm755 "$pkgdir/etc/skel/.config" "$pkgdir/etc/skel/.local/share"
cp -a "$pkgdir/usr/share/$pkgname/config" "$pkgdir/etc/skel/.config/nvim"
cp -a "$pkgdir/usr/share/$pkgname/data" "$pkgdir/etc/skel/.local/share/nvim"
ln -snf "../../../../.local/state/omarchy/current/theme/neovim.lua" \
"$pkgdir/etc/skel/.config/nvim/lua/plugins/theme.lua"
# Ship the plugin cache once, now that /etc/skel has its copy. Keeping a
# second one under /usr/share made omarchy-nvim the largest package in an
# Omarchy install after noto-fonts-cjk — ~116 MiB installed, ~88 MB of it read
# off the ISO on every install. config/ stays: migrations read it from there.
rm -rf "$pkgdir/usr/share/$pkgname/data"
# Install setup/refresh commands to /usr/bin. setup fills missing pieces;
# refresh explicitly backs up and overwrites with the same /etc/skel defaults
# used for newly-created users.
install -Dm755 "$startdir/omarchy-nvim-setup" "$pkgdir/usr/bin/omarchy-nvim-setup"
ln -s omarchy-nvim-setup "$pkgdir/usr/bin/omarchy-nvim-refresh"
}