From 193a52cbc8b3cb6c3751d7bf3536e439f97b36b8 Mon Sep 17 00:00:00 2001 From: Jake Hamilton Date: Wed, 3 Jul 2024 02:43:27 -0700 Subject: [PATCH] fix: cross-platform deps --- tidepool/src/builders/basic.nix | 1 + tidepool/src/export.nix | 3 ++- tidepool/src/lib/packages.nix | 26 +++++++++++++++++++++++++- tidepool/src/lib/types.nix | 1 + tidepool/src/packages/default.nix | 11 ++++++++++- 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/tidepool/src/builders/basic.nix b/tidepool/src/builders/basic.nix index 1a8d460..3a29186 100644 --- a/tidepool/src/builders/basic.nix +++ b/tidepool/src/builders/basic.nix @@ -83,6 +83,7 @@ in { } ); in + (builtins.trace "${package.name}: ${system}") built // { inherit (package) meta; diff --git a/tidepool/src/export.nix b/tidepool/src/export.nix index fc93d4e..9bf51bf 100644 --- a/tidepool/src/export.nix +++ b/tidepool/src/export.nix @@ -28,7 +28,8 @@ in { # platform.host = lib.modules.overrides.force "x86_64-linux"; # }; # example-x = config.packages.example.x; - # cross-example-x-x86_64-linux = config.packages.cross.x86_64-linux.example.x; + cross-aux-a-x86_64-linux = config.packages.cross.x86_64-linux.aux.a; + cross-foundation-gcc-x86_64-linux = config.packages.cross.x86_64-linux.foundation.gcc; }; }; diff --git a/tidepool/src/lib/packages.nix b/tidepool/src/lib/packages.nix index 591e966..3ea414d 100644 --- a/tidepool/src/lib/packages.nix +++ b/tidepool/src/lib/packages.nix @@ -55,7 +55,31 @@ in { ]; }; - resolved = result.config; + # Not all platform information can be effectively handled via submodules. To handle + # the case where a user copies the resolved config over we need to ensure that + # dependencies are appropriately updated. + resolved = + result.config + // { + deps = { + build = { + only = buildDependencies build build build package.deps.build.only; + build = buildDependencies build build target package.deps.build.build; + host = buildDependencies build host target package.deps.build.host; + target = buildDependencies build target target package.deps.build.target; + }; + host = { + only = buildDependencies host host host package.deps.host.only; + host = buildDependencies host host target package.deps.host.host; + target = buildDependencies host target target package.deps.host.target; + }; + target = { + only = buildDependencies target target target package.deps.target.only; + target = buildDependencies target target target package.deps.target.target; + }; + }; + }; + in resolved // { diff --git a/tidepool/src/lib/types.nix b/tidepool/src/lib/types.nix index bd16c8b..5a0ec4f 100644 --- a/tidepool/src/lib/types.nix +++ b/tidepool/src/lib/types.nix @@ -80,6 +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; in lib.types.attrs.of (lib.types.coerce initial transform lib'.types.package); diff --git a/tidepool/src/packages/default.nix b/tidepool/src/packages/default.nix index 2e688d9..6d04e32 100644 --- a/tidepool/src/packages/default.nix +++ b/tidepool/src/packages/default.nix @@ -47,7 +47,16 @@ in { builtins.mapAttrs ( name: alias: let setHost = package: - package; + package // { + __modules__ = package.__modules__ ++ [ + { + config.platform = { + host = lib.modules.override 5 system; + target = lib.modules.override 5 system; + }; + } + ]; + }; # if package != {} # then # (package.extend (