From e1321add05f32339d887314857e214717ae6288b Mon Sep 17 00:00:00 2001 From: Jake Hamilton Date: Fri, 14 Jun 2024 01:40:46 -0700 Subject: [PATCH] feat: dynamic cross packages generation --- potluck/src/packages/default.nix | 34 ++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/potluck/src/packages/default.nix b/potluck/src/packages/default.nix index 62f49df..67f72f8 100644 --- a/potluck/src/packages/default.nix +++ b/potluck/src/packages/default.nix @@ -8,9 +8,32 @@ generic = config.packages.generic; - targeted = { - i686-linux = generic; + getPackages = system: + builtins.mapAttrs + ( + namespace: packages: + lib.attrs.filter + (name: package: builtins.elem system package.meta.platforms) + packages + ); + + targeted' = { + i686-linux = + getPackages "i686-linux" generic + // { + cross = { + x86_64-linux = getPackages "x86_64-linux" generic; + }; + }; }; + + targeted = lib.attrs.generate lib'.systems.doubles.all (system: + getPackages system generic + // { + cross = lib.attrs.generate doubles ( + host: getPackages host generic + ); + }); in { includes = [ # ./aux/foundation.nix @@ -34,16 +57,19 @@ in { generic = { example = { x = { + meta.platforms = ["i686-linux" "x86_64-linux"]; version = "1.0.0"; + builder.build = package: derivation { name = package.name; builder = "/bin/sh"; system = package.platform.build; }; + phases = { - build = '' - make + build = package: '' + make --build ${package.platform.build} --host ${package.platform.host} ''; install = lib.dag.entry.after ["build"] ''