tawasuyu

sergio/takana

> Una distribución Linux construida con un laboratorio funcional y hermético en el > sótano, y una terminal mutable, clásica y anárquica en el piso de arriba — diseñada > desde el suelo para que una IA programadora entienda, modifique y co…

TOML 1299Shell 92Rust 63Markdown 561634 Sutichaykuna

⎇ 5e4dd7ab9d9fe9dbddb0e532e85260b81f12d1f0 recipes/helix.toml TOML · 82 siq'ikuna · 4.7 KB Ñawpa willay ch'uya

static: helix y tuc — el libgcc_s NO venía de ningún C (MIENTEN: 0 en todo el store) a8a9a396c · sergio ·

1# Importada de Alpine aports por `hammer import-alpine` (Etapa G). PUNTO DE PARTIDA — pero
2# YA trae los parches de musl de Alpine (lo que un import de nix pierde). Pendiente: el
3# sha256 del tarball (el wrapper lo calcula), y adaptar build/install del shell de abuild.
4name    = "helix"
5version = "25.07.1"
6
7[source]
8tarball = "https://github.com/helix-editor/helix/archive/25.07.1/helix-25.07.1.tar.gz"
9# FIXME sha256: el wrapper lo calcula (Alpine publica sha512). sha512 de Alpine:
10# sha512 = "a8f64782273d88cd43b1aeadf45d1fa6a913c9c0b77c1da716ffdc64ec02e89db1bfb2dde4333509c3ddb5733b8f5a450b44ca54d35f113c3c0f411c01f4ce8c"
11sha256  = "27c8bc3eba46bc7bab1e3629c6b28ff94882eeff17366b3ea69cd8ceffba7541"
12patches = ["fix-gotmpl-grammar-source.patch"]
13
14# GUETO gcc: helix trae tree-house-bindings (tree-sitter en C); cc-rs hace detección de familia
15# de compilador con `zig -E` y zig la rechaza. compiler="gcc" usa el musl gcc de Alpine.
16[build]
17compiler = "gcc"
18target   = "x86_64-linux-musl"
19link     = "static"
20flags    = []
21
22[build.phases]
23# Fase compile custom OBLIGATORIA (a diferencia de tuc, que la borró): helix necesita exportar dos
24# env vars antes de cargo, y el path default del lab no da dónde ponerlas. Pero entonces hay que
25# REPLICAR A MANO el setup estático del lab — mismo patrón que cargo-edit.
26#
27# POR QUÉ (2026-07-17, frente static-audit): el `cargo build --frozen --release` que traía la receta
28# importada de Alpine PISABA el comando del lab entero (`resolve_phases` sólo autogenera la fase si la
29# receta no la trae: `if out.compile.is_none()`). Al pisarlo se perdían las tres cosas que hacen
30# honesto al `link = "static"`: `+crt-static` (musl adentro), `relocation-model=static` (ET_EXEC en vez
31# de PIE) y `-C linker=.hammer-zig-cc` (el wrapper que sanea el triple `x86_64-alpine-linux-musl`, que
32# zig rechaza). hx salía PIE dinámico con `NEEDED: libgcc_s.so.1, libc.so`.
33#
34# Ese `libgcc_s` NO lo metían las tree-house-bindings ni ningún otro C: es el UNWINDER de la std de
35# rustc, que sin `+crt-static` se enlaza dinámico contra el libgcc_s de Alpine. El fix de C/C++
36# (`-static-libgcc`) acá no aplica. Prueba: tuc es Rust puro, sin una línea de C, y arrastraba el
37# MISMO libgcc_s por la misma causa.
38#
39# `crt-static` va TRAS `cargo rustc --` y NUNCA en RUSTFLAGS: en build nativo RUSTFLAGS alcanza también
40# a los proc-macros (un proc-macro es un dylib PIC) y rustc aborta con "cannot produce proc-macro".
41# Como `cargo rustc --` exige UN único target, se fija `--bin hx`. Y `-p helix-term` porque la raíz de
42# helix es un manifiesto VIRTUAL (workspace sin paquete propio): sin `-p`, cargo rustc corta con
43# "is a virtual manifest, but this command requires running against an actual package". helix-term es
44# quien declara `[[bin]] name = "hx"`.
45#
46# CC=gcc: el GUETO declarado arriba (cc-rs compila el tree-sitter en C y rechaza zig). El linker sigue
47# siendo zig-cc: los .o de gcc-musl y el Rust zig-musl son ABI-compatibles (ambos musl, mismo ELF).
48compile = '''
49# This path is embedded in the resulting binary so that helix can find system grammars
50# https://github.com/helix-editor/helix/blob/25.01.1/helix-loader/src/lib.rs#L64
51export HELIX_DEFAULT_RUNTIME=/usr/share/helix/runtime
52# Sandbox hermético: helix-term/build.rs intenta `git clone` de 245 gramáticas tree-sitter
53# (sin red ⇒ panic). Lo desactivamos; las gramáticas van por runtime/ (build post-install).
54export HELIX_DISABLE_AUTO_GRAMMAR_BUILD=1
55# de-Alpinizado: cargo-auditable no está en el lab de hammer; build plano (Etapa G)
56printf '%s\n' '#!/bin/sh' 'for a do' 'case "$a" in --target=*) a=--target=x86_64-linux-musl ;; esac' 'set -- "$@" "$a"' 'shift' 'done' 'exec zig cc -mcpu=baseline "$@"' > "$PWD/.hammer-zig-cc"
57chmod +x "$PWD/.hammer-zig-cc"
58RF="-C linker=$PWD/.hammer-zig-cc"
59rustc -vV | grep -q 'host: .*-alpine-' || RF="$RF -C link-self-contained=no"
60CC=gcc CXX=g++ AR=ar RUSTFLAGS="$RF" cargo rustc --release --locked --offline -p helix-term --bin hx -- -C target-feature=+crt-static -C relocation-model=static
61'''
62# de package() de Alpine (traducido $pkgdir→/out):
63install = '''
64_abuild_phase() {
65install -D -m755 target/release/hx -t "/out"/usr/bin/
66
67	install -D -m644 contrib/completion/hx.bash "/out"/usr/share/bash-completion/completions/hx
68	install -D -m644 contrib/completion/hx.fish "/out"/usr/share/fish/vendor_completions.d/hx.fish
69	install -D -m644 contrib/completion/hx.zsh "/out"/usr/share/zsh/site-functions/_hx
70
71	install -D -m644 contrib/Helix.desktop -t "/out"/usr/share/applications/
72	install -D -m644 logo.svg "/out"/usr/share/icons/hicolor/scalable/apps/Helix.svg
73
74	install -d -m755 "/out"/usr/share/"helix"
75
76	rm runtime/grammars/.gitkeep
77	rm runtime/themes/README.md
78	rm -rf runtime/grammars/sources
79	cp -r runtime "/out"/usr/share/"helix"
80}
81_abuild_phase
82'''