refactor: make dependencies dynamically built per-package

This commit is contained in:
Jake Hamilton 2024-07-03 00:42:34 -07:00
parent aa0fd6128b
commit 1f7ab7d09c
Signed by: jakehamilton
GPG key ID: 9762169A1B35EA68
2 changed files with 28 additions and 64 deletions

View file

@ -43,58 +43,19 @@ in {
{config}: { {config}: {
config = { config = {
__modules__ = package.__modules__; __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. platform = {
# This causes an issue because the platforms will be wrong. build = lib.modules.overrides.force build;
# deps = { host = lib.modules.overrides.force host;
# build = { target = lib.modules.overrides.force target;
# 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 = resolved = result.config;
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 in
resolved resolved
// { // {

View file

@ -74,16 +74,15 @@ in {
packages = lib.types.attrs.of (lib.types.attrs.of lib'.types.alias); packages = lib.types.attrs.of (lib.types.attrs.of lib'.types.alias);
dependencies = let dependencies = build: host: target: let
initial = initial = lib.types.attrs.any;
(lib.types.attrs.lazy lib.types.any)
// { transform = value: let
check = value: package = lib'.packages.resolve value;
lib.types.attrs.any.check value in
&& value ? versions; lib'.packages.build package build host target;
};
in 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 { alias = lib.types.submodule {
options = { options = {
@ -144,7 +143,11 @@ in {
final = lib.types.attrs.any; final = lib.types.attrs.any;
submodule = {config}: { submodule = {config}: let
build = config.platform.build;
host = config.platform.host;
target = config.platform.target;
in {
options = { options = {
__modules__ = lib.options.create { __modules__ = lib.options.create {
description = "User specified modules for the package definition."; description = "User specified modules for the package definition.";
@ -278,25 +281,25 @@ in {
build = { build = {
only = lib.options.create { only = lib.options.create {
description = "Dependencies which are only used in the build environment."; description = "Dependencies which are only used in the build environment.";
type = lib'.types.dependencies; type = lib'.types.dependencies build build build;
default.value = {}; default.value = {};
}; };
build = lib.options.create { build = lib.options.create {
description = "Dependencies which are created in the build environment and are executed in the build environment."; 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 = {}; default.value = {};
}; };
host = lib.options.create { host = lib.options.create {
description = "Dependencies which are created in the build environment and are executed in the host environment."; 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 = {}; default.value = {};
}; };
target = lib.options.create { target = lib.options.create {
description = "Dependencies which are created in the build environment and are executed in the target environment."; 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 = {}; default.value = {};
}; };
}; };
@ -304,19 +307,19 @@ in {
host = { host = {
only = lib.options.create { only = lib.options.create {
description = "Dependencies which are only used in the host environment."; description = "Dependencies which are only used in the host environment.";
type = lib'.types.dependencies; type = lib'.types.dependencies host host host;
default.value = {}; default.value = {};
}; };
host = lib.options.create { host = lib.options.create {
description = "Dependencies which are executed in the host environment."; description = "Dependencies which are executed in the host environment.";
type = lib'.types.dependencies; type = lib'.types.dependencies host host target;
default.value = {}; default.value = {};
}; };
target = lib.options.create { target = lib.options.create {
description = "Dependencies which are executed in the host environment which produces code for the target environment."; 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 = {}; default.value = {};
}; };
}; };
@ -324,13 +327,13 @@ in {
target = { target = {
only = lib.options.create { only = lib.options.create {
description = "Dependencies which are only used in the target environment."; description = "Dependencies which are only used in the target environment.";
type = lib'.types.dependencies; type = lib'.types.dependencies target target target;
default.value = {}; default.value = {};
}; };
target = lib.options.create { target = lib.options.create {
description = "Dependencies which are executed in the target environment."; description = "Dependencies which are executed in the target environment.";
type = lib'.types.dependencies; type = lib'.types.dependencies target target target;
default.value = {}; default.value = {};
}; };
}; };