feat: stage2 gnugrep, gnupatch, update naming

This commit is contained in:
Jake Hamilton 2024-06-07 18:32:47 -07:00
parent b2c019cf88
commit 021d531470
Signed by: jakehamilton
GPG key ID: 9762169A1B35EA68
6 changed files with 227 additions and 3 deletions

View file

@ -18,7 +18,7 @@ in {
options.aux.foundation.stages.stage1.gcc = {
package = lib.options.create {
type = lib.types.package;
description = "The package to use for gcc-cxx.";
description = "The package to use for gcc.";
};
version = lib.options.create {

View file

@ -76,7 +76,7 @@ in {
};
in
builders.bash.boot.build {
name = "gnused-boot-${cfg.version}";
name = "gnugrep-${cfg.version}";
meta = cfg.meta;
deps.build.host = [

View file

@ -64,7 +64,7 @@ in {
package = let
in
builders.bash.boot.build {
name = "gnused-boot-${cfg.version}";
name = "gzip-${cfg.version}";
meta = cfg.meta;
deps.build.host = [

View file

@ -13,6 +13,8 @@ in {
./diffutils
./findutils
./gawk
./gnugrep
./gnupatch
];
config = {
@ -26,6 +28,8 @@ in {
stage2-diffutils = stage2.diffutils.package;
stage2-findutils = stage2.findutils.package;
stage2-gawk = stage2.gawk.package;
stage2-gnugrep = stage2.gnugrep.package;
stage2-gnupatch = stage2.gnupatch.package;
};
};
};

View file

@ -0,0 +1,113 @@
{
lib,
config,
}: let
cfg = config.aux.foundation.stages.stage2.gnugrep;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
options.aux.foundation.stages.stage2.gnugrep = {
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"];
};
mainProgram = lib.options.create {
type = lib.types.string;
description = "The main program of the package.";
default.value = "grep";
};
};
};
config = {
aux.foundation.stages.stage2.gnugrep = {
version = "3.11";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/grep/grep-${cfg.version}.tar.xz";
sha256 = "HbKu3eidDepCsW2VKPiUyNFdrk4ZC1muzHj1qVEnbqs=";
};
package = builders.bash.build {
name = "gnugrep-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 grep-${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
rm $out/bin/{egrep,fgrep}
'';
};
};
};
}

View file

@ -0,0 +1,107 @@
{
lib,
config,
}: let
cfg = config.aux.foundation.stages.stage2.gnupatch;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
options.aux.foundation.stages.stage2.gnupatch = {
package = lib.options.create {
type = lib.types.package;
description = "The package to use for gnupatch.";
};
meta = {
description = lib.options.create {
type = lib.types.string;
description = "Description for the package.";
default.value = "GNU Patch, a program to apply differences to files.";
};
homepage = lib.options.create {
type = lib.types.string;
description = "Homepage for the package.";
default.value = "https://www.gnu.org/software/patch";
};
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"];
};
};
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.";
};
};
config = {
aux.foundation.stages.stage2.gnupatch = {
version = "2.7";
src = builtins.fetchurl {
url = "https://ftpmirror.gnu.org/patch/patch-${cfg.version}.tar.xz";
sha256 = "XCyR/kFUKWISbwvhUKpPo0lIXPLtwMfqfbwky4FxEa4=";
};
package = builders.bash.build {
name = "gnupatch-static-${cfg.version}";
meta = cfg.meta;
src = cfg.src;
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 patch-${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
'';
};
};
};
}