feat: rich platform information

This commit is contained in:
Jake Hamilton 2024-06-15 04:18:05 -07:00
parent 1c67c40213
commit 6bd35bf4d5
Signed by: jakehamilton
GPG key ID: 9762169A1B35EA68
6 changed files with 33 additions and 8 deletions

View file

@ -25,7 +25,7 @@ in {
)
sorted.result;
system = package.platform.build;
system = package.platform.build.double;
in
builtins.derivation (
package.env

View file

@ -34,7 +34,7 @@
platform = {
build = system;
host = cross;
target = cross;
target = lib.modules.override 150 cross;
};
deps = {

View file

@ -1460,8 +1460,8 @@ in {
lib.strings.when
(kernel.name == "netbsd" && netbsdExec != kernel.exec)
kernel.exec.name;
abi = lib.strings.when (abi != types.abis.unknown) "-${abi.name}";
in "${cpu.name}-${vendor.name}-${kernelName}${exec}${abi}";
abi' = lib.strings.when (abi != types.abis.unknown) "-${abi.name}";
in "${cpu.name}-${vendor.name}-${kernelName}${exec}${abi'}";
};
create = components:

View file

@ -169,19 +169,43 @@
build = lib.options.create {
description = "The build platform for the package.";
type = lib.types.string;
default.value = "unknown";
default.value = "x86_64-linux";
apply = raw: let
system = lib'.systems.from.string raw;
in {
inherit raw system;
double = lib'.systems.into.double system;
triple = lib'.systems.into.triple system;
};
};
host = lib.options.create {
description = "The host platform for the package.";
type = lib.types.string;
default.value = "unknown";
default.value = "x86_64-linux";
apply = raw: let
system = lib'.systems.from.string raw;
in {
inherit raw system;
double = lib'.systems.into.double system;
triple = lib'.systems.into.triple system;
};
};
target = lib.options.create {
description = "The target platform for the package.";
type = lib.types.string;
default.value = "unknown";
default.value = "x86_64-linux";
apply = raw: let
system = lib'.systems.from.string raw;
in {
inherit raw system;
double = lib'.systems.into.double system;
triple = lib'.systems.into.triple system;
};
};
};

View file

@ -24,7 +24,7 @@ in {
phases = {
build = ''
make --build ${config.platform.build} --host ${config.platform.host}
make --build ${config.platform.build.double} --host ${config.platform.host.double}
'';
install = lib.dag.entry.after ["build"] ''

View file

@ -51,6 +51,7 @@ in {
config = {
platform = {
host = lib.modules.overrides.force system;
target = lib.modules.overrides.default system;
};
deps = {