Files
nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/musl/headers.nix
2026-07-27 21:12:08 +03:00

61 lines
1.2 KiB
Nix

{
lib,
buildPlatform,
hostPlatform,
fetchurl,
bash,
gcc,
binutils,
gnumake,
gnugrep,
gnused,
gnutar,
gzip,
}:
let
inherit (import ./common.nix { inherit lib; }) pname meta;
version = "1.2.6";
src = fetchurl {
url = "https://musl.libc.org/releases/musl-${version}.tar.gz";
hash = "sha256-1YX9O2E8ZhUfwySejtRPdwIMtebB5jWmFtP5+CRgUSo=";
};
in
bash.runCommand "${pname}-${version}"
{
inherit pname version meta;
nativeBuildInputs = [
gcc
binutils
gnumake
gnused
gnugrep
gnutar
gzip
];
}
''
# Unpack
tar xzf ${src}
cd musl-${version}
# Patch
# https://github.com/ZilchOS/bootstrap-from-tcc/blob/2e0c68c36b3437386f786d619bc9a16177f2e149/using-nix/2a3-intermediate-musl.nix
sed -i 's|/bin/sh|${bash}/bin/bash|' \
tools/*.sh
# Configure
# Use build-gcc, since we won't be compiling anything
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--syslibdir=$out/lib \
--enable-wrapper \
CC=gcc
# Install
make -j $NIX_BUILD_CORES install-headers
''