From dcbe11025b579031494ccc20bb89e5667b9f5fe1 Mon Sep 17 00:00:00 2001 From: Jake Hamilton Date: Thu, 6 Jun 2024 23:28:56 -0700 Subject: [PATCH] feat: gawk-boot --- foundation/src/stages/stage1/default.nix | 2 + foundation/src/stages/stage1/gawk/boot.nix | 87 +++++++++++++++++++ foundation/src/stages/stage1/gawk/default.nix | 49 +++++++++++ .../stages/stage1/gawk/patches/no-stamp.patch | 11 +++ 4 files changed, 149 insertions(+) create mode 100644 foundation/src/stages/stage1/gawk/boot.nix create mode 100644 foundation/src/stages/stage1/gawk/default.nix create mode 100644 foundation/src/stages/stage1/gawk/patches/no-stamp.patch diff --git a/foundation/src/stages/stage1/default.nix b/foundation/src/stages/stage1/default.nix index 0bfe6cf..cf92bc3 100644 --- a/foundation/src/stages/stage1/default.nix +++ b/foundation/src/stages/stage1/default.nix @@ -23,6 +23,7 @@ in { ./gnutar ./gzip ./musl + ./gawk ]; config = { @@ -49,6 +50,7 @@ in { stage1-musl-boot = stage1.musl.boot.package; stage1-tinycc-musl = stage1.tinycc.musl.compiler.package; stage1-tinycc-musl-libs = stage1.tinycc.musl.libs.package; + stage1-gawk-boot = stage1.gawk.boot.package; }; extras = { diff --git a/foundation/src/stages/stage1/gawk/boot.nix b/foundation/src/stages/stage1/gawk/boot.nix new file mode 100644 index 0000000..9c77e6b --- /dev/null +++ b/foundation/src/stages/stage1/gawk/boot.nix @@ -0,0 +1,87 @@ +{ + lib, + config, +}: let + cfg = config.aux.foundation.stages.stage1.gawk.boot; + + platform = config.aux.platform; + builders = config.aux.foundation.builders; + + stage1 = config.aux.foundation.stages.stage1; +in { + options.aux.foundation.stages.stage1.gawk.boot = { + package = lib.options.create { + type = lib.types.package; + description = "The package to use for gnutar-boot."; + }; + + 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.stage1.gawk.boot = { + version = "3.0.6"; + + src = builtins.fetchurl { + url = "https://ftpmirror.gnu.org/gawk/gawk-${cfg.version}.tar.gz"; + sha256 = "1z4bibjm7ldvjwq3hmyifyb429rs2d9bdwkvs0r171vv1khpdwmb"; + }; + + package = let + patches = [ + # for reproducibility don't generate date stamp + ./patches/no-stamp.patch + ]; + in + builders.bash.boot.build { + name = "gawk-boot-${cfg.version}"; + + meta = stage1.gawk.meta; + + deps.build.host = [ + stage1.tinycc.mes.compiler.package + stage1.gnumake.package + stage1.gnused.boot.package + stage1.gnugrep.package + stage1.gnupatch.package + ]; + + script = '' + # Unpack + ungz --file ${cfg.src} --output gawk.tar + untar --file gawk.tar + rm gawk.tar + cd gawk-${cfg.version} + + # Patch + ${lib.strings.concatMapSep "\n" (file: "patch -Np0 -i ${file}") patches} + + # Configure + export CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib" + export ac_cv_func_getpgrp_void=yes + export ac_cv_func_tzset=yes + bash ./configure \ + --build=${platform.build} \ + --host=${platform.host} \ + --disable-nls \ + --prefix=$out + + # Build + make gawk + + # Install + install -D gawk $out/bin/gawk + ln -s gawk $out/bin/awk + ''; + }; + }; + }; +} diff --git a/foundation/src/stages/stage1/gawk/default.nix b/foundation/src/stages/stage1/gawk/default.nix new file mode 100644 index 0000000..9b144bd --- /dev/null +++ b/foundation/src/stages/stage1/gawk/default.nix @@ -0,0 +1,49 @@ +{ + lib, + config, +}: let + cfg = config.aux.foundation.stages.stage1.gawk; + + builders = config.aux.foundation.builders; + + stage1 = config.aux.foundation.stages.gawk; +in { + includes = [ + ./boot.nix + ]; + + options.aux.foundation.stages.stage1.gawk = { + meta = { + description = lib.options.create { + type = lib.types.string; + description = "Description for the package."; + default.value = "GNU implementation of the Awk programming language"; + }; + + homepage = lib.options.create { + type = lib.types.string; + description = "Homepage for the package."; + default.value = "https://www.gnu.org/software/gawk"; + }; + + 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 = "awk"; + }; + }; + }; +} diff --git a/foundation/src/stages/stage1/gawk/patches/no-stamp.patch b/foundation/src/stages/stage1/gawk/patches/no-stamp.patch new file mode 100644 index 0000000..1351d4e --- /dev/null +++ b/foundation/src/stages/stage1/gawk/patches/no-stamp.patch @@ -0,0 +1,11 @@ +--- configure ++++ configure +@@ -3676,7 +3676,6 @@ cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +-date > stamp-h + exit 0 + EOF + chmod +x $CONFIG_STATUS +