Install this version:
emerge -a =www-apps/grafana-13.0.2
If this version is masked, you can unmask it using the autounmask tool or standard emerge options:
autounmask =www-apps/grafana-13.0.2
Or alternatively:
emerge --autounmask-write -a =www-apps/grafana-13.0.2
| Version | EAPI | Keywords | Slot |
|---|---|---|---|
| 13.0.2 | 8 | ~amd64 | 13/ |
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit check-reqs go-module systemd tmpfiles
MY_PV=${PV/_beta/-beta}
S=${WORKDIR}/${PN}-${MY_PV}
DESCRIPTION="The open-source platform for monitoring and observability"
HOMEPAGE="https://grafana.com"
yarn_version="4.3.1"
## building vendor and yarn vendors (@WilliamH - ping me!)
# >> git clone https://github.com/grafana/grafana -b v<version> /tmp/grafana
# >> cd /tmp/grafana && version=git describe --tags | sed -E "s/v([0-9.]+)/\1/g"
# >> GOWORK=off go mod vendor && go work vendor && mkdir grafana-${version} && mv vendor grafana-${version}/vendor
# >> tar -caf grafana-${version}-vendor.tar.xz grafana-${version}/vendor
# >> echo -e "enableMirror: true\ncacheFolder: ./vendor_yarn" >> .yarnrc.yml
# >> sed -i 's/enableGlobalCache: true/enableGlobalCache: false/' .yarnrc.yml
# >> CYPRESS_INSTALL_BINARY=0 yarn set version 4.3.1
# >> CYPRESS_INSTALL_BINARY=0 yarn cache clean --mirror && yarn install
# >> mv vendor_yarn grafana-${version}/vendor_yarn
# >> tar -caf grafana-${version}-vendor_yarn.tar.xz grafana-${version}/vendor_yarn
SRC_URI="
https://github.com/grafana/grafana/archive/v${MY_PV}.tar.gz -> ${P}.tar.gz
https://vendors.simple-co.de/${PN}/${P}-vendor.tar.xz
https://vendors.simple-co.de/${PN}/${P}-vendor_yarn.tar.xz
https://repo.yarnpkg.com/${yarn_version}/packages/yarnpkg-cli/bin/yarn.js -> yarn-${yarn_version}.cjs
"
LICENSE="AGPL-3.0 Apache-2.0 BSD-2 BSD-3 BSD-4 BSL-1.0 ImageMagick ISC LGPL-3.0 MIT MPL-2.0 OpenSSL Zlib"
SLOT="13/"${PV}
KEYWORDS="~amd64"
IUSE="systemd"
RESTRICT="test" # Tests not working (a proper fix would take too long)
# needed for webpack (nodejs)
CHECKREQS_MEMORY="8G"
DEPEND="!www-apps/${PN}-bin
acct-group/${PN}
acct-user/${PN}
media-libs/fontconfig
net-libs/nodejs[icu]
sys-apps/yarn
>=dev-lang/go-1.26
>=dev-go/wire-0.6.0"
PN_S="${PN}-${SLOT%/*}"
src_prepare() {
sed -i "s:;reporting_enabled = .*:reporting_enabled = false:" \
conf/sample.ini || die "prepare failed"
sed -i "s:;check_for_updates = .*:check_for_updates = false:" \
conf/sample.ini || die "prepare failed"
mkdir "plugins-bundled/external"
## offline/cache installation
echo -e "enableMirror: true\ncacheFolder: ./vendor_yarn" >> .yarnrc.yml
sed -i 's/enableGlobalCache: true/enableGlobalCache: false/' .yarnrc.yml
sed -i '/^yarnPath/d' .yarnrc.yml
echo "yarnPath: .yarn/releases/yarn-${yarn_version}.cjs" >> .yarnrc.yml
cp ${DISTDIR}/yarn-${yarn_version}.cjs .yarn/releases/ || die "could not copy yarn-${yarn_version}.cjs"
## preparing files (and replace the version)
mkdir -p "files"
cp -a "${FILESDIR}/${PN}".* files || die "couldn't copy needed files!"
sed -i "s/~PN_S~/${PN_S}/g" files/* || die "couldn't apply slot-patches!"
sed -i 's/grafana-server/grafana server/g' files/* || die "couldn't rename legacy bindings!"
## setting build-info
sed -i 's/unknown-dev/gentoo/g' pkg/build/git.go
default
}
src_compile() {
## install yarn deps (offline)..
CYPRESS_INSTALL_BINARY=0 yarn install || die "prepare failed"
einfo "Wiring everything up.."
# Grafana 13+ uses its own wire wrapper instead of the standalone wire binary
go run ./pkg/build/wire/cmd/wire/main.go gen -tags "oss" -gen_tags "(!enterprise && !pro)" ./pkg/server || die "wiring failed"
einfo "Building backend using go.."
# Grafana 13+ dropped build.go — direct go build against ./pkg/cmd/grafana
go build -mod=vendor \
-ldflags "-X main.version=${PV} -X main.commit=gentoo -X main.buildBranch=gentoo -X main.buildstamp=$(date +%s)" \
-o bin/grafana \
./pkg/cmd/grafana || die "compile failed"
einfo "Building frontend using webpack.."
# beware, we need at least 8G RAM (@32T)
export NODE_OPTIONS="--max-old-space-size=8192"
yarn run build || die "compile failed"
yarn run plugins:build-bundled || die "compile failed"
}
src_install() {
insinto /etc/${PN_S}
newins conf/sample.ini ${PN}.ini
newins conf/ldap.toml ldap.toml
exeinto /usr/libexec/${PN_S}
# Grafana 13+ ships a single binary — grafana-cli and grafana-server are subcommands
newexe bin/grafana ${PN}
exeinto /usr/bin
echo -e "#"'!'"'/bin/sh\nPATH=\"/usr/libexec/${PN_S}:\${PATH}\" && ${PN} \$@" >> ${D}/usr/bin/${PN_S}
echo -e "#"'!'"'/bin/sh\nPATH=\"/usr/libexec/${PN_S}:\${PATH}\" && ${PN} cli --homepath /var/lib/${PN_S} --pluginsDir /var/lib/${PN_S}/plugins \$@" >> ${D}/usr/bin/${PN_S}-cli
echo -e "#"'!'"'/bin/sh\nPATH=\"/usr/libexec/${PN_S}:\${PATH}\" && ${PN} server --homepath /var/lib/${PN_S} \$@" >> ${D}/usr/bin/${PN_S}-server
fperms +x /usr/bin/${PN_S}
fperms +x /usr/bin/${PN_S}-cli
fperms +x /usr/bin/${PN_S}-server
insinto "/usr/share/${PN_S}"
doins -r public conf tools
## for the initd thingies we should take a look into:
# https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#override-configuration-with-environment-variables
newconfd "${S}/files/${PN}.confd" "${PN_S}"
newinitd "${S}/files/${PN}.initd" "${PN_S}"
use systemd && systemd_newunit "${S}/files/${PN}.service" "${PN_S}.service"
newtmpfiles "${S}/files"/${PN}.conf ${PN_S}.conf
keepdir /var/{lib,log}/${PN_S}
fowners ${PN}:${PN} /var/{lib,log}/${PN_S}
fperms 0750 /var/{lib,log}/${PN_S}
keepdir /var/lib/${PN_S}/{dashboards,plugins}
fowners ${PN}:${PN} /var/lib/${PN_S}/{dashboards,plugins}
fperms 0750 /var/lib/${PN_S}/{dashboards,plugins}
keepdir /etc/${PN_S}
fowners ${PN}:${PN} /etc/${PN_S}/{${PN}.ini,ldap.toml}
fperms 0640 /etc/${PN_S}/{${PN}.ini,ldap.toml}
}
pkg_postinst() {
tmpfiles_process ${PN_S}.conf
if [ -d /var/lib/${PN} ]; then
# found non-slotted grafana installation
ewarn "We found an old ${PN} installation in '/var/lib/${PN}'!"
ewarn "Make sure to adjust the confs and do a data-migration, the"
ewarn "new ${PN} data-dir is '/var/lib/${PN_S}'."
fi
einfo "${PN} has built-in log rotation. Please see [log.file] section of"
einfo "/etc/${PN_S}/${PN}.ini for related settings."
einfo
einfo "You may add your own custom configuration for app-admin/logrotate if you"
einfo "wish to use external rotation of logs. In this case, you also need to make"
einfo "sure the built-in rotation is turned off."
}
Manage flags for this package:
euse -i <flag> -p www-apps/grafana |
euse -E <flag> -p www-apps/grafana |
euse -D <flag> -p www-apps/grafana
!www-apps/grafana-bin acct-group/grafana acct-user/grafana media-libs/fontconfig net-libs/nodejs[icu] sys-apps/yarn >=dev-lang/go-1.26 >=dev-go/wire-0.6.0
| Type | File | Size | Source URLs |
|---|---|---|---|
| DIST | grafana-13.0.2-vendor.tar.xz | 52680944 bytes | https://vendors.simple-co.de/grafana/grafana-13.0.2-vendor.tar.xz |
| DIST | grafana-13.0.2-vendor_yarn.tar.xz | 352200076 bytes | https://vendors.simple-co.de/grafana/grafana-13.0.2-vendor_yarn.tar.xz |
| DIST | grafana-13.0.2.tar.gz | 45749186 bytes | https://github.com/grafana/grafana/archive/v13.0.2.tar.gz |
| DIST | yarn-4.3.1.cjs | 2745559 bytes | https://repo.yarnpkg.com/4.3.1/packages/yarnpkg-cli/bin/yarn.js |