Skip to content

docs: Add example for installing AUR packages in ArchLinux images#4250

Open
estebanpuyanas wants to merge 9 commits intosystemd:mainfrom
estebanpuyanas:aur-package-arch-image-example
Open

docs: Add example for installing AUR packages in ArchLinux images#4250
estebanpuyanas wants to merge 9 commits intosystemd:mainfrom
estebanpuyanas:aur-package-arch-image-example

Conversation

@estebanpuyanas
Copy link
Copy Markdown

Add example for installing AUR packages in Arch-based images

Adds a documentation file under mkosi/docsexplaining how to install AUR packages at image build time using aurutils and mkosi's $PACKAGEDIR mechanism.

The example uses neovim-git as a worked case because it has both official-repo makedepends and AUR dependencies, which exercises the full dependency resolution pipeline.

The approach covers:

  1. Bootstrapping aurutils from the AUR at build time.
  2. Using aur depends + tsort for dependency resolution.
  3. Building packages as the nobody user to satisfy makepkg's refusal to run as root.
  4. Using $PACKAGEDIR to pass built packages from the build phase to mkosi.postinst.chroot.
  5. Configuring mirrors via reflector since the build sandbox starts with none.

Tested end-to-end on Arch Linux (EndeavourOS) with QEMU. The image builds successfully and nvim --version confirms correct installation after booting.

Closes #2578

Copy link
Copy Markdown
Contributor

@behrmann behrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is an interesting writeup, though I'm not entirely sure the upstream docs are the best place for it in this form, since advocating for any AUR helper is really mkosi's place.

A few thoughts I had while skimming it.

Comment thread docs/building-aur-packages.md Outdated
Comment thread docs/building-aur-packages.md Outdated
Comment thread docs/building-aur-packages.md Outdated
Comment thread docs/building-aur-packages.md Outdated
Comment thread docs/building-aur-packages.md Outdated
Comment thread docs/building-aur-packages.md Outdated
estebanpuyanas and others added 3 commits March 30, 2026 08:50
Minor syntax changes; removed reflector and opted for default mkosi mirror image; expanded section on nobody user to include explenation of EUID; removed systemd and bash as BuildPackage dependecies as they are included in base.
@estebanpuyanas estebanpuyanas requested a review from behrmann March 31, 2026 02:23
Comment thread docs/building-aur-packages.md Outdated
Comment thread docs/building-aur-packages.md Outdated
Comment thread docs/building-aur-packages.md Outdated
Comment on lines +79 to +81
# Pacman initialization operations:
pacman-key --init
pacman-key --populate archlinux
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary, since mkosi will have already installed the base system

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing these from either script causes pacman to fail with "Public keyring not found" and "keyring is not writable" errors when attempting to verify package signatures. Happy to remove them if there's a mkosi setting that ensures the keyring is already initialized at this point, but I wasn't able to find one.

Again, adding logs of the failed build I got when removing these lines.

pacman-keyring-failed-build.txt

Comment thread docs/building-aur-packages.md
Server = https://fastly.mirror.pkgbuild.com/$repo/os/$arch
EOF

pacman -Sy
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also not be necessary, since packages have just been installed.

Copy link
Copy Markdown
Author

@estebanpuyanas estebanpuyanas Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without these lines, pacman -S fails with "no servers configured for repository" and "database file does not exist" errors. The postinst script has the same requirement. If mkosi already handles this in a way I am missing, I'd appreciate guidance on the correct approach.

I am also attaching logs of a failed build after removing these lines where the server failed to sync databases.

pacman-sy-failed-build.txt

Comment thread docs/building-aur-packages.md Outdated
Comment thread docs/building-aur-packages.md Outdated
Comment thread docs/building-aur-packages.md Outdated
Comment thread docs/building-aur-packages.md Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Example on building Arch based image with packages from AUR?

2 participants