summaryrefslogtreecommitdiff
path: root/app-shells/direnv/direnv-2.34.0-r0.ebuild
blob: e34d8f722bd316b4727c2d4e7a92412af8f3f004 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit go-module greadme

DESCRIPTION="Environment variable manager for shell"
HOMEPAGE="https://github.com/direnv/direnv"
SRC_URI="https://github.com/direnv/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
SRC_URI+=" https://share.terinstock.com/${P}-vendor.tar.xz"

LICENSE="MIT"
LICENSE+=" BSD"
SLOT="0"
KEYWORDS="~amd64"
RESTRICT="test" # fails

src_prepare() {
	default
	sed -i -e "/selfPath, err/cselfPath := \"${EPREFIX}/usr/bin/direnv\"" internal/cmd/cmd_hook.go || die
}

src_compile() {
	emake all

	mkdir shell-init || die
	for shell in bash zsh fish elvish pwsh tcsh; do
		./direnv hook ${shell} > shell-init/${shell} || die
	done
}

src_install() {
	einstalldocs
	emake DESTDIR="${ED}" PREFIX="/usr" install

	insinto "/usr/share/${PN}"
	doins -r shell-init

	greadme_stdin <<-EOF
	Gentoo installs direnv's shell-init code under
		/usr/share/direnv/shell-init/
	Therefore, instead of using, e.g. 'eval \"\$(direnv hook zsh)\"' in
	your .zshrc you can put \"source /usr/share/direnv/shell-init/zsh\"
	there, which avoids the cost of forking a process. Although direnv
	does that a lot anyways.
EOF
}