nixpkgs/pkgs/os-specific/linux/minimal-bootstrap/bash/static.nix
Aliaksandr 338f91240f
minimal-bootstrap: trim bash-static output
Disable NLS and remove installed documentation from the static bash used in stage0. The bootstrap path keeps bash and the sh symlink only.

Size impact against upstream/staging:

- bash-static closure: 9.643 MiB -> 1.333 MiB (-8.310 MiB)

Assisted-by: codex with gpt-5.5-high
2026-06-08 00:09:35 +03:00

78 lines
1.4 KiB
Nix

{
lib,
buildPlatform,
hostPlatform,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
gnutar,
gzip,
}:
let
inherit (import ./common.nix { inherit lib; }) meta;
pname = "bash-static";
version = "5.3";
src = fetchurl {
url = "mirror://gnu/bash/bash-${version}.tar.gz";
sha256 = "sha256-DVzYaWX4aaJs9k9Lcb57lvkKO6iz104n6OnZ1VUPMbo=";
};
in
bash.runCommand "${pname}-${version}"
{
inherit pname version meta;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnused
gnugrep
gawk
diffutils
findutils
gnutar
gzip
];
passthru.tests.get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/bash --version
mkdir $out
'';
}
''
# Unpack
tar xf ${src}
cd bash-${version}
# Configure
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--without-bash-malloc \
--disable-dependency-tracking \
--disable-nls \
--enable-static-link \
CC=musl-gcc
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install-strip
rm $out/bin/bashbug
rm -rf $out/share
ln -s $out/bin/bash $out/bin/sh
''