feat: pass through package dependencies via context

This commit is contained in:
Jake Hamilton 2024-07-08 23:18:11 -07:00
parent 62bc2f4eee
commit ea200d834e
Signed by untrusted user: jakehamilton
GPG key ID: 9762169A1B35EA68
2 changed files with 53 additions and 30 deletions

View file

@ -110,7 +110,7 @@ in
// { // {
inherit (package) meta; inherit (package) meta;
extras = { extras = {
inherit package; inherit package context;
phases = builtins.listToAttrs sorted.result; phases = builtins.listToAttrs sorted.result;
} // package.extras; } // package.extras;
}; };

View file

@ -89,39 +89,62 @@ in
let let
dependencies = lib.attrs.selectOrThrow path collected; dependencies = lib.attrs.selectOrThrow path collected;
contexts = builtins.map (dependency: dependency.context or { }) dependencies; contexts = builtins.map (dependency: dependency.context or { }) dependencies;
base = ctx // {
target = builtins.concatStringsSep "." path;
};
result = lib.modules.run { result = lib.modules.run {
modules = builtins.map modules =
(context: { config }: { builtins.map
config = context; (context: { config = context; })
}) contexts
contexts ++ [
++ [ {
{ freeform = lib.types.any;
freeform = lib.types.any;
options = config.packages.context.options // { options = config.packages.context.options // {
target = lib.options.create { target = lib.options.create {
description = "The dependency target that is being generated."; description = "The dependency target that is being generated.";
type = lib.types.enum [ type = lib.types.enum [
"build.only" "build.only"
"build.build" "build.build"
"build.host" "build.host"
"build.target" "build.target"
"host.only" "host.only"
"host.host" "host.host"
"host.target" "host.target"
"target.only" "target.only"
"target.target" "target.target"
]; ];
writable = false;
default.value = builtins.concatStringsSep "." path;
};
deps = lib.options.create {
description = "The collected dependencies.";
writable = false;
default.value = collected;
type = lib.types.submodule {
options = {
build = {
only = lib.options.create { type = lib.types.list.of lib'.types.package; };
build = lib.options.create { type = lib.types.list.of lib'.types.package; };
host = lib.options.create { type = lib.types.list.of lib'.types.package; };
target = lib.options.create { type = lib.types.list.of lib'.types.package; };
};
host = {
only = lib.options.create { type = lib.types.list.of lib'.types.package; };
host = lib.options.create { type = lib.types.list.of lib'.types.package; };
target = lib.options.create { type = lib.types.list.of lib'.types.package; };
};
target = {
only = lib.options.create { type = lib.types.list.of lib'.types.package; };
target = lib.options.create { type = lib.types.list.of lib'.types.package; };
};
};
};
};
}; };
};
config = base; config = ctx;
} }
]; ];
}; };
in in
result.config; result.config;