feat: stage 2 gcc, gnused, gnutar, gzip

This commit is contained in:
Jake Hamilton 2024-06-07 19:50:46 -07:00
parent 021d531470
commit bfe8d4e268
Signed by: jakehamilton
GPG key ID: 9762169A1B35EA68
5 changed files with 562 additions and 4 deletions

View file

@ -6,30 +6,38 @@
in { in {
includes = [ includes = [
./bash ./bash
./gnumake
./binutils ./binutils
./coreutils
./bzip2 ./bzip2
./coreutils
./diffutils ./diffutils
./findutils ./findutils
./gawk ./gawk
./gcc
./gnugrep ./gnugrep
./gnumake
./gnupatch ./gnupatch
./gnused
./gnutar
./gzip
]; ];
config = { config = {
exports = { exports = {
packages = { packages = {
stage2-bash = stage2.bash.package; stage2-bash = stage2.bash.package;
stage2-gnumake = stage2.gnumake.package;
stage2-binutils = stage2.binutils.package; stage2-binutils = stage2.binutils.package;
stage2-coreutils = stage2.coreutils.package;
stage2-bzip2 = stage2.bzip2.package; stage2-bzip2 = stage2.bzip2.package;
stage2-coreutils = stage2.coreutils.package;
stage2-diffutils = stage2.diffutils.package; stage2-diffutils = stage2.diffutils.package;
stage2-findutils = stage2.findutils.package; stage2-findutils = stage2.findutils.package;
stage2-gawk = stage2.gawk.package; stage2-gawk = stage2.gawk.package;
stage2-gcc = stage2.gcc.package;
stage2-gnugrep = stage2.gnugrep.package; stage2-gnugrep = stage2.gnugrep.package;
stage2-gnumake = stage2.gnumake.package;
stage2-gnupatch = stage2.gnupatch.package; stage2-gnupatch = stage2.gnupatch.package;
stage2-gnused = stage2.gnused.package;
stage2-gnutar = stage2.gnutar.package;
stage2-gzip = stage2.gzip.package;
}; };
}; };
}; };

View file

@ -0,0 +1,218 @@
{
lib,
config,
}: let
cfg = config.aux.foundation.stages.stage2.gcc;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
options.aux.foundation.stages.stage2.gcc = {
package = lib.options.create {
type = lib.types.package;
description = "The package to use for gcc.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.package;
description = "Source for the package.";
};
cc = {
src = lib.options.create {
type = lib.types.package;
description = "The cc source for the package.";
};
};
gmp = {
src = lib.options.create {
type = lib.types.package;
description = "The gmp source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of gmp.";
};
};
mpfr = {
src = lib.options.create {
type = lib.types.package;
description = "The mpfr source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpfr.";
};
};
mpc = {
src = lib.options.create {
type = lib.types.package;
description = "The mpc source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of mpc.";
};
};
isl = {
src = lib.options.create {
type = lib.types.package;
description = "The isl source for the package.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of isl.";
};
};
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "GNU Compiler Collection.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://gcc.gnu.org";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
};
};
};
config = {
aux.foundation.stages.stage2.gcc = {
version = "13.2.0";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/gcc/gcc-${cfg.version}/gcc-${cfg.version}.tar.xz";
sha256 = "4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o=";
};
gmp = {
version = "6.3.0";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/gmp/gmp-${cfg.gmp.version}.tar.xz";
sha256 = "o8K4AgG4nmhhb0rTC8Zq7kknw85Q4zkpyoGdXENTiJg=";
};
};
mpfr = {
version = "4.2.1";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/mpfr/mpfr-${cfg.mpfr.version}.tar.xz";
sha256 = "J3gHNTpnJpeJlpRa8T5Sgp46vXqaW3+yeTiU4Y8fy7I=";
};
};
mpc = {
version = "1.3.1";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/mpc/mpc-${cfg.mpc.version}.tar.gz";
sha256 = "q2QkkvXPiCt0qgy3MM1BCoHtzb7IlRg86TDnBsHHWbg=";
};
};
isl = {
version = "0.24";
src = builtins.fetchurl {
url = "https://gcc.gnu.org/pub/gcc/infrastructure/isl-${cfg.isl.version}.tar.bz2";
sha256 = "/PeN2WVsEOuM+fvV9ZoLawE4YgX+GTSzsoegoYmBRcA=";
};
};
package = builders.bash.build {
name = "gcc-static-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.gcc.package
stage1.binutils.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gawk.boot.package
stage1.diffutils.package
stage1.findutils.package
stage1.gnutar.package
stage1.gzip.package
stage1.bzip2.package
stage1.xz.package
];
script = ''
# Unpack
tar xf ${cfg.src}
tar xf ${cfg.gmp.src}
tar xf ${cfg.mpfr.src}
tar xf ${cfg.mpc.src}
tar xf ${cfg.isl.src}
cd gcc-${cfg.version}
ln -s ../gmp-${cfg.gmp.version} gmp
ln -s ../mpfr-${cfg.mpfr.version} mpfr
ln -s ../mpc-${cfg.mpc.version} mpc
ln -s ../isl-${cfg.isl.version} isl
# Patch
# force musl even if host triple is gnu
sed -i 's|"os/gnu-linux"|"os/generic"|' libstdc++-v3/configure.host
# Configure
export CC="gcc -Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export CXX="g++ -Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export LIBRARY_PATH="${stage1.musl.package}/lib"
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host} \
--with-native-system-header-dir=/include \
--with-sysroot=${stage1.musl.package} \
--enable-languages=c,c++ \
--disable-bootstrap \
--disable-libsanitizer \
--disable-lto \
--disable-multilib \
--disable-plugin \
CFLAGS=-static
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install-strip
'';
};
};
};
}

View file

@ -0,0 +1,114 @@
{
lib,
config,
}: let
cfg = config.aux.foundation.stages.stage2.gnused;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
options.aux.foundation.stages.stage2.gnused = {
package = lib.options.create {
type = lib.types.package;
description = "The package to use for gnumake.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.package;
description = "Source for the package.";
};
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "GNU sed, a batch stream editor.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/sed";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["x86_64-linux" "aarch64-linux" "i686-linux"];
};
mainProgram = lib.options.create {
type = lib.types.string;
description = "The main program of the package.";
default.value = "sed";
};
};
};
config = {
aux.foundation.stages.stage2.gnused = {
version = "4.9";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/sed/sed-${cfg.version}.tar.xz";
sha256 = "biJrcy4c1zlGStaGK9Ghq6QteYKSLaelNRljHSSXUYE=";
};
package = builders.bash.build {
name = "gnused-static-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.gcc.package
stage1.musl.package
stage1.binutils.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gnutar.package
stage1.gawk.package
stage1.gzip.package
stage1.diffutils.package
stage1.findutils.package
stage1.xz.package
];
script = ''
# Unpack
tar xf ${cfg.src}
cd sed-${cfg.version}
# Configure
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host} \
CC=musl-gcc \
CFLAGS=-static
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install
'';
};
};
};
}

View file

@ -0,0 +1,112 @@
{
lib,
config,
}: let
cfg = config.aux.foundation.stages.stage2.gnutar;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
options.aux.foundation.stages.stage2.gnutar = {
package = lib.options.create {
type = lib.types.package;
description = "The package to use for gnutar.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.package;
description = "Source for the package.";
};
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "GNU implementation of the `tar` archiver";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/tar";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["x86_64-linux" "aarch64-linux" "i686-linux"];
};
mainProgram = lib.options.create {
type = lib.types.string;
description = "The main program of the package.";
default.value = "tar";
};
};
};
config = {
aux.foundation.stages.stage2.gnutar = {
version = "1.35";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/tar/tar-${cfg.version}.tar.gz";
sha256 = "FNVeMgY+qVJuBX+/Nfyr1TN452l4fv95GcN1WwLStX4=";
};
package = builders.bash.build {
name = "gnutar-static-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.gcc.package
stage1.musl.package
stage1.binutils.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gawk.package
stage1.gzip.package
stage1.gnutar.package
stage1.diffutils.package
stage1.findutils.package
];
script = ''
# Unpack
tar xzf ${cfg.src}
cd tar-${cfg.version}
# Configure
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host} \
CC=musl-gcc \
CFLAGS=-static
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install
'';
};
};
};
}

View file

@ -0,0 +1,106 @@
{
lib,
config,
}: let
cfg = config.aux.foundation.stages.stage2.gzip;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
options.aux.foundation.stages.stage2.gzip = {
package = lib.options.create {
type = lib.types.package;
description = "The package to use for gnugrep.";
};
version = lib.options.create {
type = lib.types.string;
description = "Version of the package.";
};
src = lib.options.create {
type = lib.types.package;
description = "Source for the package.";
};
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "GNU implementation of the Unix grep command";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/grep";
};
license = lib.options.create {
# TODO: Add a proper type for licenses.
type = lib.types.attrs.any;
description = "License for the package.";
default.value = lib.licenses.gpl3Plus;
};
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["x86_64-linux" "aarch64-linux" "i686-linux"];
};
};
};
config = {
aux.foundation.stages.stage2.gzip = {
version = "1.13";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/gzip/gzip-${cfg.version}.tar.xz";
sha256 = "dFTraTXbF8ZlVXbC4bD6vv04tNCTbg+H9IzQYs6RoFc=";
};
package = builders.bash.build {
name = "gzip-static-${cfg.version}";
meta = cfg.meta;
deps.build.host = [
stage1.gcc.package
stage1.musl.package
stage1.binutils.package
stage1.gnumake.package
stage1.gnused.package
stage1.gnugrep.package
stage1.gawk.package
stage1.diffutils.package
stage1.findutils.package
stage1.gnutar.package
stage1.xz.package
];
script = ''
# Unpack
tar xf ${cfg.src}
cd gzip-${cfg.version}
# Configure
bash ./configure \
--prefix=$out \
--build=${platform.build} \
--host=${platform.host} \
CC=musl-gcc \
CFLAGS=-static
# Build
make -j $NIX_BUILD_CORES bin_SCRIPTS=
# Install
make -j $NIX_BUILD_CORES bin_SCRIPTS= install
'';
};
};
};
}