# Importada de Alpine aports por `hammer import-alpine` (Etapa G). PUNTO DE PARTIDA — pero
# YA trae los parches de musl de Alpine (lo que un import de nix pierde). Pendiente: el
# sha256 del tarball (el wrapper lo calcula), y adaptar build/install del shell de abuild.
name    = "nnn"
version = "5.2"

[source]
tarball = "https://github.com/jarun/nnn/archive/v5.2/nnn-5.2.tar.gz"
# FIXME sha256: el wrapper lo calcula (Alpine publica sha512). sha512 de Alpine:
# sha512 = "343744b3bcb73e9d11a96eefe89c6d073029653e91d340b04d655504bedbadd3761d74c62652d7afa40a41ade87c4d7df5b878e35ed773f4c2db4617c883e372"
sha256  = "f166eda5093ac8dcf8cbbc6224123a32c53cf37b82c5c1cb48e2e23352754030"
patches = ["musl-fts-support.patch"]

[build]
compiler = "zig-cc"
target   = "x86_64-linux-musl"
link     = "static"
flags    = []

[build.phases]
# de build() de Alpine (traducido; el lab provee $CBUILD/$CHOST — Etapa G Fase 3; revisá --shared para estático):
compile = '''
_abuild_phase() {
make
}
_abuild_phase
'''
# de package() de Alpine (traducido $pkgdir→/out):
install = '''
_abuild_phase() {
make install DESTDIR="/out" PREFIX=/usr

	install -D -m 644 misc/auto-completion/bash/nnn-completion.bash \
		"/out"/usr/share/bash-completion/completions/nnn

	install -D -m 644 misc/auto-completion/fish/nnn.fish \
		"/out"/usr/share/fish/vendor_completions.d/nnn.fish

	install -D -m 644 misc/auto-completion/zsh/_nnn \
		"/out"/usr/share/zsh/site-functions/_nnn
}
_abuild_phase
'''

[deps]
build = ["musl-fts", "ncurses", "readline"]
