feat: apply platform to deps inside submodules
This commit is contained in:
parent
7385b21950
commit
e76e67fe58
|
@ -23,7 +23,7 @@ in {
|
|||
# }))
|
||||
# .config;
|
||||
foundation-gcc = config.packages.foundation.gcc;
|
||||
# foundation-binutils = config.packages.foundation.binutils;
|
||||
foundation-binutils = config.packages.foundation.binutils;
|
||||
# foundation-linux-headers = config.packages.foundation.linux-headers.versions.latest.extend {
|
||||
# platform.host = lib.modules.overrides.force "x86_64-linux";
|
||||
# };
|
||||
|
|
|
@ -13,6 +13,10 @@ in {
|
|||
);
|
||||
in
|
||||
builtins.map (dependency: dependency.package) available;
|
||||
|
||||
build = build': host': target':
|
||||
builtins.mapAttrs
|
||||
(name: dep: lib'.packages.build dep build' host' target');
|
||||
};
|
||||
|
||||
getLatest = alias: let
|
||||
|
@ -34,7 +38,13 @@ in {
|
|||
buildDependencies = build': host': target':
|
||||
builtins.mapAttrs (name: dep: lib'.packages.build dep build' host' target');
|
||||
|
||||
result = lib.modules.run {
|
||||
platform = {
|
||||
build = lib.modules.overrides.force build;
|
||||
host = lib.modules.overrides.force host;
|
||||
target = lib.modules.overrides.force target;
|
||||
};
|
||||
|
||||
withPlatform = lib.modules.run {
|
||||
modules =
|
||||
package.__modules__
|
||||
++ [
|
||||
|
@ -44,11 +54,7 @@ in {
|
|||
config = {
|
||||
__modules__ = package.__modules__;
|
||||
|
||||
platform = {
|
||||
build = lib.modules.overrides.force build;
|
||||
host = lib.modules.overrides.force host;
|
||||
target = lib.modules.overrides.force target;
|
||||
};
|
||||
inherit platform;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
@ -58,33 +64,50 @@ in {
|
|||
# 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
|
||||
withDeps =
|
||||
withPlatform.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;
|
||||
only = buildDependencies build build build withPlatform.config.deps.build.only;
|
||||
build = buildDependencies build build target withPlatform.config.deps.build.build;
|
||||
host = buildDependencies build host target withPlatform.config.deps.build.host;
|
||||
target = buildDependencies build target target withPlatform.config.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;
|
||||
only = buildDependencies host host host withPlatform.config.deps.host.only;
|
||||
host = buildDependencies host host target withPlatform.config.deps.host.host;
|
||||
target = buildDependencies host target target withPlatform.config.deps.host.target;
|
||||
};
|
||||
target = {
|
||||
only = buildDependencies target target target package.deps.target.only;
|
||||
target = buildDependencies target target target package.deps.target.target;
|
||||
only = buildDependencies target target target withPlatform.config.deps.target.only;
|
||||
target = buildDependencies target target target withPlatform.config.deps.target.target;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
resolved
|
||||
// {
|
||||
package = resolved.builder.build resolved;
|
||||
withPackage = lib.modules.run {
|
||||
modules =
|
||||
package.__modules__
|
||||
++ [
|
||||
lib'.types.package.children.submodule
|
||||
(
|
||||
{config}: {
|
||||
config = {
|
||||
__modules__ = package.__modules__;
|
||||
|
||||
inherit platform;
|
||||
|
||||
deps = lib.modules.overrides.force withDeps.deps;
|
||||
|
||||
package = lib.modules.overrides.force (withDeps.builder.build withDeps);
|
||||
};
|
||||
}
|
||||
)
|
||||
];
|
||||
};
|
||||
in
|
||||
withPackage.config;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -75,13 +75,17 @@ in {
|
|||
packages = lib.types.attrs.of (lib.types.attrs.of lib'.types.alias);
|
||||
|
||||
dependencies = build: host: target: let
|
||||
initial = lib.types.attrs.any;
|
||||
initial = lib.types.raw;
|
||||
|
||||
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;
|
||||
(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);
|
||||
|
||||
|
@ -142,7 +146,79 @@ in {
|
|||
in
|
||||
result.config;
|
||||
|
||||
final = lib.types.attrs.any;
|
||||
final = lib.types.raw;
|
||||
|
||||
deps = build: host: target:
|
||||
lib.types.submodule {
|
||||
options = {
|
||||
build = {
|
||||
only = lib.options.create {
|
||||
description = "Dependencies which are only used in the build environment.";
|
||||
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 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 build host target;
|
||||
default.value = {};
|
||||
# apply = value:
|
||||
# if value ? b then
|
||||
# (builtins.trace value.b.platform.build.triple)
|
||||
# (builtins.trace config.platform.build.triple)
|
||||
# value
|
||||
# else
|
||||
# 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 build target target;
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
|
||||
host = {
|
||||
only = lib.options.create {
|
||||
description = "Dependencies which are only used in the host environment.";
|
||||
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 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 host target target;
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
|
||||
target = {
|
||||
only = lib.options.create {
|
||||
description = "Dependencies which are only used in the target environment.";
|
||||
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 target target target;
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
submodule = {config}: let
|
||||
build = config.platform.build;
|
||||
|
@ -278,64 +354,25 @@ in {
|
|||
default.value = config.builder.build config;
|
||||
};
|
||||
|
||||
deps = {
|
||||
build = {
|
||||
only = lib.options.create {
|
||||
description = "Dependencies which are only used in the build environment.";
|
||||
type = lib'.types.dependencies build build build;
|
||||
default.value = {};
|
||||
deps = lib.options.create {
|
||||
description = "The dependencies for the package.";
|
||||
type = deps build host target;
|
||||
default.value = {};
|
||||
apply = value: {
|
||||
build = {
|
||||
only = lib'.packages.dependencies.build build build build value.build.only;
|
||||
build = lib'.packages.dependencies.build build build target value.build.build;
|
||||
host = lib'.packages.dependencies.build build host target value.build.host;
|
||||
target = lib'.packages.dependencies.build build target target value.build.target;
|
||||
};
|
||||
|
||||
build = lib.options.create {
|
||||
description = "Dependencies which are created in the build environment and are executed in the build environment.";
|
||||
type = lib'.types.dependencies build build target;
|
||||
default.value = {};
|
||||
host = {
|
||||
only = lib'.packages.dependencies.build host host host value.host.only;
|
||||
host = lib'.packages.dependencies.build host host target value.host.host;
|
||||
target = lib'.packages.dependencies.build host target target value.host.target;
|
||||
};
|
||||
|
||||
host = lib.options.create {
|
||||
description = "Dependencies which are created in the build environment and are executed in the host environment.";
|
||||
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 build target target;
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
|
||||
host = {
|
||||
only = lib.options.create {
|
||||
description = "Dependencies which are only used in the host environment.";
|
||||
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 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 host target target;
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
|
||||
target = {
|
||||
only = lib.options.create {
|
||||
description = "Dependencies which are only used in the target environment.";
|
||||
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 target target target;
|
||||
default.value = {};
|
||||
target = {
|
||||
only = lib'.packages.dependencies.build target target target value.target.only;
|
||||
target = lib'.packages.dependencies.build target target target value.target.target;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -25,7 +25,7 @@ in {
|
|||
|
||||
phases = {
|
||||
install = ''
|
||||
echo "a" > $out
|
||||
echo "a with b: ${config.deps.build.host.b.package.system}" > $out
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
@ -34,13 +34,13 @@ in {
|
|||
|
||||
builder = builders.basic;
|
||||
|
||||
# deps = {
|
||||
# build = {
|
||||
# host = {
|
||||
# inherit (packages.foundation) gcc;
|
||||
# };
|
||||
# };
|
||||
# };
|
||||
deps = {
|
||||
build = {
|
||||
host = {
|
||||
inherit (packages.foundation) gcc;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
env = {
|
||||
PATH = lib.paths.bin [
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
lib',
|
||||
config,
|
||||
options,
|
||||
}:
|
||||
{
|
||||
}: {
|
||||
includes = [
|
||||
./gcc
|
||||
./binutils
|
||||
./linux-headers
|
||||
./glibc
|
||||
# ./xz
|
||||
];
|
||||
|
||||
config = {
|
||||
|
|
Loading…
Reference in a new issue