From af571a03a4c37f98e44aa4ab37d499a7ffc0c77c Mon Sep 17 00:00:00 2001 From: Jake Hamilton Date: Thu, 4 Jul 2024 17:36:31 -0700 Subject: [PATCH] refactor: minor cleanup --- tidepool/src/lib/types.nix | 14 +- .../packages/foundation/binutils/default.nix | 10 +- .../src/packages/foundation/gcc/default.nix | 10 +- .../foundation/linux-headers/default.nix | 132 +++++++++--------- 4 files changed, 75 insertions(+), 91 deletions(-) diff --git a/tidepool/src/lib/types.nix b/tidepool/src/lib/types.nix index baa7928..cac0fd1 100644 --- a/tidepool/src/lib/types.nix +++ b/tidepool/src/lib/types.nix @@ -80,12 +80,7 @@ in { transform = value: let package = lib'.packages.resolve value; in - (builtins.trace "building dependency ${package.name}: build=${build.triple} host=${host.triple} target=${target.triple}") - lib'.packages.build - package - build - host - target; + lib'.packages.build package build host target; in lib.types.attrs.of (lib.types.coerce initial transform lib'.types.package); @@ -168,13 +163,6 @@ in { description = "Dependencies which are created in the build environment and are executed in the host environment."; type = lib'.types.dependencies build host target; default.value = {}; - # apply = value: - # if value ? b then - # (builtins.trace value.b.platform.build.triple) - # (builtins.trace config.platform.build.triple) - # value - # else - # value; }; target = lib.options.create { diff --git a/tidepool/src/packages/foundation/binutils/default.nix b/tidepool/src/packages/foundation/binutils/default.nix index 91b9e49..08e1c2f 100644 --- a/tidepool/src/packages/foundation/binutils/default.nix +++ b/tidepool/src/packages/foundation/binutils/default.nix @@ -90,24 +90,24 @@ in { "--disable-multilib" ]; in { - unpack = lib.dag.entry.before ["patch"] '' + unpack = '' tar xf ${config.src} cd binutils-${config.version} ''; - patch = lib.dag.entry.between ["configure"] ["unpack"] '' + patch = '' ${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches} ''; - configure = lib.dag.entry.between ["build"] ["patch"] '' + configure = '' bash ./configure ${builtins.concatStringsSep " " configureFlags} ''; - build = lib.dag.entry.between ["install"] ["configure"] '' + build = '' make -j $NIX_BUILD_CORES ''; - install = lib.dag.entry.after ["build"] '' + install = '' make -j $NIX_BUILD_CORES install-strip ''; }; diff --git a/tidepool/src/packages/foundation/gcc/default.nix b/tidepool/src/packages/foundation/gcc/default.nix index db8abab..21292f9 100644 --- a/tidepool/src/packages/foundation/gcc/default.nix +++ b/tidepool/src/packages/foundation/gcc/default.nix @@ -118,7 +118,7 @@ in { else "-m32" else ""; in { - unpack = lib.dag.entry.before ["patch"] '' + unpack = '' # Unpack tar xf ${config.src} tar xf ${config.gmp.src} @@ -133,13 +133,13 @@ in { ln -s ../isl-${config.isl.version} isl ''; - patch = lib.dag.entry.between ["configure"] ["unpack"] '' + patch = '' # Patch # force musl even if host triple is gnu sed -i 's|"os/gnu-linux"|"os/generic"|' libstdc++-v3/configure.host ''; - configure = lib.dag.entry.between ["build"] ["patch"] '' + configure = '' # Configure export CC="gcc -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so" export CXX="g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so" @@ -163,12 +163,12 @@ in { CXXFLAGS=-static ''; - build = lib.dag.entry.between ["install"] ["configure"] '' + build = '' # Build make -j $NIX_BUILD_CORES ''; - install = lib.dag.entry.after ["build"] '' + install = '' # Install make -j $NIX_BUILD_CORES install-strip ''; diff --git a/tidepool/src/packages/foundation/linux-headers/default.nix b/tidepool/src/packages/foundation/linux-headers/default.nix index cb85a6f..3a04996 100644 --- a/tidepool/src/packages/foundation/linux-headers/default.nix +++ b/tidepool/src/packages/foundation/linux-headers/default.nix @@ -3,83 +3,79 @@ lib', config, options, -}: -let - inherit (config) +}: let + inherit + (config) mirrors builders # These are the upstream foundational packages exported from the Aux Foundation project. - + foundation ; -in -{ +in { config.packages.foundation.linux-headers = { versions = { - "latest" = - { config, meta }: - { - options = { - src = lib.options.create { - type = lib.types.derivation; - description = "Source for the package."; - }; - }; - - config = { - meta = { - platforms = [ "i686-linux" ]; - }; - - pname = "linux-headers"; - version = "6.5.6"; - - builder = builders.basic; - - env = { - PATH = lib.paths.bin [ - foundation.stage2-gcc - foundation.stage1-musl - foundation.stage2-binutils - foundation.stage2-gnumake - foundation.stage2-gnupatch - foundation.stage2-gnused - foundation.stage2-gnugrep - foundation.stage2-gawk - foundation.stage2-diffutils - foundation.stage2-findutils - foundation.stage2-gnutar - foundation.stage1-xz - ]; - }; - - phases = { - unpack = lib.dag.entry.before [ "patch" ] '' - tar xf ${config.src} - cd linux-${config.version} - ''; - - patch = lib.dag.entry.between [ "configure" ] [ "unpack" ] ''''; - - configure = lib.dag.entry.between [ "build" ] [ "patch" ] ''''; - - build = lib.dag.entry.between [ "install" ] [ "configure" ] '' - make -j $NIX_BUILD_CORES CC=musl-gcc HOSTCC=musl-gcc ARCH=${config.platform.host.linux.arch} headers - ''; - - install = lib.dag.entry.after [ "build" ] '' - find usr/include -name '.*' -exec rm {} + - mkdir -p $out - cp -rv usr/include $out/ - ''; - }; - - src = builtins.fetchurl { - url = "https://cdn.kernel.org/pub/linux/kernel/v${lib.versions.major config.version}.x/linux-${config.version}.tar.xz"; - sha256 = "eONtQhRUcFHCTfIUD0zglCjWxRWtmnGziyjoCUqV0vY="; - }; + "latest" = { + config, + meta, + }: { + options = { + src = lib.options.create { + type = lib.types.derivation; + description = "Source for the package."; }; }; + + config = { + meta = { + platforms = ["i686-linux"]; + }; + + pname = "linux-headers"; + version = "6.5.6"; + + builder = builders.basic; + + env = { + PATH = lib.paths.bin [ + foundation.stage2-gcc + foundation.stage1-musl + foundation.stage2-binutils + foundation.stage2-gnumake + foundation.stage2-gnupatch + foundation.stage2-gnused + foundation.stage2-gnugrep + foundation.stage2-gawk + foundation.stage2-diffutils + foundation.stage2-findutils + foundation.stage2-gnutar + foundation.stage1-xz + ]; + }; + + phases = { + unpack = '' + tar xf ${config.src} + cd linux-${config.version} + ''; + + build = '' + make -j $NIX_BUILD_CORES CC=musl-gcc HOSTCC=musl-gcc ARCH=${config.platform.host.linux.arch} headers + ''; + + install = '' + find usr/include -name '.*' -exec rm {} + + mkdir -p $out + cp -rv usr/include $out/ + ''; + }; + + src = builtins.fetchurl { + url = "https://cdn.kernel.org/pub/linux/kernel/v${lib.versions.major config.version}.x/linux-${config.version}.tar.xz"; + sha256 = "eONtQhRUcFHCTfIUD0zglCjWxRWtmnGziyjoCUqV0vY="; + }; + }; + }; }; }; }