refactor: make dependencies dynamically built per-package
This commit is contained in:
parent
aa0fd6128b
commit
1f7ab7d09c
|
@ -43,58 +43,19 @@ in {
|
|||
{config}: {
|
||||
config = {
|
||||
__modules__ = package.__modules__;
|
||||
platform = {
|
||||
build = lib.modules.overrides.force (lib'.systems.withBuildInfo build);
|
||||
host = lib.modules.overrides.force (lib'.systems.withBuildInfo host);
|
||||
target = lib.modules.overrides.force (lib'.systems.withBuildInfo target);
|
||||
};
|
||||
|
||||
# NOTE: This does not seem to work and instead the pre-existing deps are used.
|
||||
# This causes an issue because the platforms will be wrong.
|
||||
# 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;
|
||||
# };
|
||||
# };
|
||||
platform = {
|
||||
build = lib.modules.overrides.force build;
|
||||
host = lib.modules.overrides.force host;
|
||||
target = lib.modules.overrides.force target;
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
];
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
};
|
||||
};
|
||||
resolved = result.config;
|
||||
in
|
||||
resolved
|
||||
// {
|
||||
|
|
|
@ -74,16 +74,15 @@ in {
|
|||
|
||||
packages = lib.types.attrs.of (lib.types.attrs.of lib'.types.alias);
|
||||
|
||||
dependencies = let
|
||||
initial =
|
||||
(lib.types.attrs.lazy lib.types.any)
|
||||
// {
|
||||
check = value:
|
||||
lib.types.attrs.any.check value
|
||||
&& value ? versions;
|
||||
};
|
||||
dependencies = build: host: target: let
|
||||
initial = lib.types.attrs.any;
|
||||
|
||||
transform = value: let
|
||||
package = lib'.packages.resolve value;
|
||||
in
|
||||
lib'.packages.build package build host target;
|
||||
in
|
||||
lib.types.attrs.of (lib.types.coerce initial lib'.packages.resolve lib'.types.package);
|
||||
lib.types.attrs.of (lib.types.coerce initial transform lib'.types.package);
|
||||
|
||||
alias = lib.types.submodule {
|
||||
options = {
|
||||
|
@ -144,7 +143,11 @@ in {
|
|||
|
||||
final = lib.types.attrs.any;
|
||||
|
||||
submodule = {config}: {
|
||||
submodule = {config}: let
|
||||
build = config.platform.build;
|
||||
host = config.platform.host;
|
||||
target = config.platform.target;
|
||||
in {
|
||||
options = {
|
||||
__modules__ = lib.options.create {
|
||||
description = "User specified modules for the package definition.";
|
||||
|
@ -278,25 +281,25 @@ in {
|
|||
build = {
|
||||
only = lib.options.create {
|
||||
description = "Dependencies which are only used in the build environment.";
|
||||
type = lib'.types.dependencies;
|
||||
type = lib'.types.dependencies build build build;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
build = lib.options.create {
|
||||
description = "Dependencies which are created in the build environment and are executed in the build environment.";
|
||||
type = lib'.types.dependencies;
|
||||
type = lib'.types.dependencies build build target;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
host = lib.options.create {
|
||||
description = "Dependencies which are created in the build environment and are executed in the host environment.";
|
||||
type = lib'.types.dependencies;
|
||||
type = lib'.types.dependencies build host target;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
description = "Dependencies which are created in the build environment and are executed in the target environment.";
|
||||
type = lib'.types.dependencies;
|
||||
type = lib'.types.dependencies build target target;
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
|
@ -304,19 +307,19 @@ in {
|
|||
host = {
|
||||
only = lib.options.create {
|
||||
description = "Dependencies which are only used in the host environment.";
|
||||
type = lib'.types.dependencies;
|
||||
type = lib'.types.dependencies host host host;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
host = lib.options.create {
|
||||
description = "Dependencies which are executed in the host environment.";
|
||||
type = lib'.types.dependencies;
|
||||
type = lib'.types.dependencies host host target;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
description = "Dependencies which are executed in the host environment which produces code for the target environment.";
|
||||
type = lib'.types.dependencies;
|
||||
type = lib'.types.dependencies host target target;
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
|
@ -324,13 +327,13 @@ in {
|
|||
target = {
|
||||
only = lib.options.create {
|
||||
description = "Dependencies which are only used in the target environment.";
|
||||
type = lib'.types.dependencies;
|
||||
type = lib'.types.dependencies target target target;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
description = "Dependencies which are executed in the target environment.";
|
||||
type = lib'.types.dependencies;
|
||||
type = lib'.types.dependencies target target target;
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue