Skip to content

Instantly share code, notes, and snippets.

@FliiFe
Created May 29, 2024 15:39
Show Gist options
  • Save FliiFe/adcf68c912e450ebf43ff5ee0ba932ea to your computer and use it in GitHub Desktop.
Save FliiFe/adcf68c912e450ebf43ff5ee0ba932ea to your computer and use it in GitHub Desktop.
Custom caddy modules with portage on gentoo

Caddy ebuild override for custom modules

Use at your own risks! This hook is basically hijacking the $MY_MODULES variable used in the caddy ebuild. Disabling the network sandbox is required to allow go to pull in custom modules at compile time.

Untested with live ebuild.

# /etc/portage/env/www-servers/caddy
post_src_unpack() {
echo ":: Custom hook: Adding custom modules"
MY_MODULES="${MY_MODULES} github.com/caddy-dns/cloudflare"
MY_MODULES="${MY_MODULES} github.com/mholt/caddy-webdav"
echo ":: Custom hook: New list of modules"
for moo in ${MY_MODULES}; do
echo " - ${moo}"
done
}
post_src_prepare() {
echo ":: Custom hook: Using go get on custom modules"
for moo in ${MY_MODULES}; do
ego get $moo
done
echo ":: Custom hook: Calling go mod vendor"
ego mod vendor
echo ":: Custom hook: Done!"
}
# vim: set ft=bash:
# /etc/portage/env/disable-network-sandbox.conf
FEATURES="-network-sandbox"
# /etc/portage/package.env
www-servers/caddy disable-network-sandbox.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment