fix: resolve issue with extending cross package
This commit is contained in:
parent
0312e3c4cc
commit
9850da8aa9
|
@ -601,5 +601,115 @@ in {
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
evaluated.config.aux.message == evaluated.config.aux.message2;
|
evaluated.config.aux.message == evaluated.config.aux.message2;
|
||||||
|
|
||||||
|
"base level submodule" = let
|
||||||
|
expected = "Hello, World!";
|
||||||
|
evaluated = lib.modules.run {
|
||||||
|
modules = [
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
aux = lib.options.create {
|
||||||
|
type = lib.types.submodule {
|
||||||
|
options.message = lib.options.create {
|
||||||
|
type = lib.types.string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = {
|
||||||
|
aux = args: {
|
||||||
|
options.message2 = lib.options.create {
|
||||||
|
type = lib.types.string;
|
||||||
|
};
|
||||||
|
|
||||||
|
config.message = expected;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
aux.message2 = expected;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
evaluated.config.aux.message == evaluated.config.aux.message2;
|
||||||
|
|
||||||
|
"base level submodule (freeform)" = let
|
||||||
|
expected = "Hello, World!";
|
||||||
|
evaluated = lib.modules.run {
|
||||||
|
modules = [
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
aux = lib.options.create {
|
||||||
|
type = lib.types.submodule {
|
||||||
|
freeform = lib.types.any;
|
||||||
|
|
||||||
|
options.message = lib.options.create {
|
||||||
|
type = lib.types.string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = {
|
||||||
|
aux = args: {
|
||||||
|
options.message2 = lib.options.create {
|
||||||
|
type = lib.types.string;
|
||||||
|
};
|
||||||
|
|
||||||
|
config.message = expected;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
aux.exists = true;
|
||||||
|
aux.message2 = expected;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
(evaluated.config.aux.message == evaluated.config.aux.message2)
|
||||||
|
&& evaluated.config.aux.exists;
|
||||||
|
|
||||||
|
"nested submodules" = let
|
||||||
|
expected = "Hello, World!";
|
||||||
|
evaluated = lib.modules.run {
|
||||||
|
modules = [
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
aux = lib.options.create {
|
||||||
|
type = lib.types.submodule {
|
||||||
|
freeform = lib.types.any;
|
||||||
|
|
||||||
|
options.message = lib.options.create {
|
||||||
|
type = lib.types.string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = {
|
||||||
|
aux = args: {
|
||||||
|
options.message2 = lib.options.create {
|
||||||
|
type = lib.types.string;
|
||||||
|
};
|
||||||
|
|
||||||
|
config.message = expected;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
aux.exists = true;
|
||||||
|
aux.message2 = expected;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
(evaluated.config.aux.message == evaluated.config.aux.message2)
|
||||||
|
&& evaluated.config.aux.exists;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -775,16 +775,20 @@ lib: {
|
||||||
["freeform"];
|
["freeform"];
|
||||||
in
|
in
|
||||||
if definition.value ? config
|
if definition.value ? config
|
||||||
then {
|
then
|
||||||
__file__ = definition.__file__;
|
rest
|
||||||
config = definition.value.config;
|
// {
|
||||||
}
|
__file__ = definition.__file__;
|
||||||
|
config = definition.value.config;
|
||||||
|
}
|
||||||
else let
|
else let
|
||||||
config = builtins.removeAttrs definition.value lib.modules.VALID_KEYS;
|
config = builtins.removeAttrs definition.value lib.modules.VALID_KEYS;
|
||||||
in {
|
in
|
||||||
__file__ = definition.__file__;
|
rest
|
||||||
config = config;
|
// {
|
||||||
}
|
__file__ = definition.__file__;
|
||||||
|
config = config;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
__file__ = definition.__file__;
|
__file__ = definition.__file__;
|
||||||
includes = [definition.value];
|
includes = [definition.value];
|
||||||
|
|
|
@ -22,3 +22,6 @@
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
result.config.exported
|
result.config.exported
|
||||||
|
// {
|
||||||
|
inherit (result) config;
|
||||||
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "foundation",
|
"dir": "foundation",
|
||||||
"dirtyRev": "6bd35bf4d5f24b8e91d8afa589ea3088796b2baa-dirty",
|
"dirtyRev": "0312e3c4cc261e2384fcf372c766a0cf245f3213-dirty",
|
||||||
"dirtyShortRev": "6bd35bf-dirty",
|
"dirtyShortRev": "0312e3c-dirty",
|
||||||
"lastModified": 1718450285,
|
"lastModified": 1718460525,
|
||||||
"narHash": "sha256-/i3RlOudzZdl6UBdhMDRBAgVQTHOZDXEkSfRUw77aK8=",
|
"narHash": "sha256-+ToaXY8ISWLx9AtO/CjfY/6SGuKu8A/d9ncqE4h2H20=",
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "file:../?dir=foundation"
|
"url": "file:../?dir=foundation"
|
||||||
},
|
},
|
||||||
|
@ -24,10 +24,10 @@
|
||||||
"lib": {
|
"lib": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "lib",
|
"dir": "lib",
|
||||||
"dirtyRev": "6bd35bf4d5f24b8e91d8afa589ea3088796b2baa-dirty",
|
"dirtyRev": "0312e3c4cc261e2384fcf372c766a0cf245f3213-dirty",
|
||||||
"dirtyShortRev": "6bd35bf-dirty",
|
"dirtyShortRev": "0312e3c-dirty",
|
||||||
"lastModified": 1718450285,
|
"lastModified": 1718460525,
|
||||||
"narHash": "sha256-/i3RlOudzZdl6UBdhMDRBAgVQTHOZDXEkSfRUw77aK8=",
|
"narHash": "sha256-+ToaXY8ISWLx9AtO/CjfY/6SGuKu8A/d9ncqE4h2H20=",
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "file:../?dir=lib"
|
"url": "file:../?dir=lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -26,8 +26,8 @@ in {
|
||||||
sorted.result;
|
sorted.result;
|
||||||
|
|
||||||
system = package.platform.build.double;
|
system = package.platform.build.double;
|
||||||
in
|
|
||||||
builtins.derivation (
|
built = builtins.derivation (
|
||||||
package.env
|
package.env
|
||||||
// {
|
// {
|
||||||
inherit (package) name;
|
inherit (package) name;
|
||||||
|
@ -70,6 +70,11 @@ in {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
in
|
||||||
|
built
|
||||||
|
// {
|
||||||
|
inherit (package) meta;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,16 +6,29 @@
|
||||||
}: let
|
}: let
|
||||||
lib' = config.lib;
|
lib' = config.lib;
|
||||||
in {
|
in {
|
||||||
|
freeform = lib.types.any;
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
exports = {
|
exports = {
|
||||||
lib = config.lib;
|
lib = config.lib;
|
||||||
modules = import ./modules.nix;
|
modules = import ./modules.nix;
|
||||||
|
|
||||||
packages = {
|
packages = {
|
||||||
|
# foundation-gcc-x86_64 =
|
||||||
|
# (config.packages.foundation.gcc.versions."13.2.0".extend (args: {
|
||||||
|
# config = {
|
||||||
|
# platform = {
|
||||||
|
# target = lib.modules.overrides.force "x86_64-linux";
|
||||||
|
# };
|
||||||
|
# };
|
||||||
|
# }))
|
||||||
|
# .config;
|
||||||
foundation-gcc = config.packages.foundation.gcc;
|
foundation-gcc = config.packages.foundation.gcc;
|
||||||
# example-x = config.packages.example.x;
|
# example-x = config.packages.example.x;
|
||||||
# cross-example-x-x86_64-linux = config.packages.cross.x86_64-linux.example.x;
|
# cross-example-x-x86_64-linux = config.packages.cross.x86_64-linux.example.x;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# exported.packages.i686-linux.cross-foundation-gcc-x86_64-linux = config.packages.cross.x86_64-linux.foundation.gcc.package;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1909,28 +1909,26 @@ in {
|
||||||
then {system = args;}
|
then {system = args;}
|
||||||
else args;
|
else args;
|
||||||
|
|
||||||
matchers = builtins.mapAttrs (name: match: match resolved.system) lib'.systems.match;
|
|
||||||
validators = builtins.mapAttrs (name: validate: validate (resolved.gcc.arch or "default")) lib'.systems.match.architecture;
|
|
||||||
|
|
||||||
platformInfo =
|
|
||||||
{
|
|
||||||
linux-kernel = settings.linux-kernel or {};
|
|
||||||
gcc = settings.gcc or {};
|
|
||||||
rustc = settings.rustc or {};
|
|
||||||
}
|
|
||||||
// lib'.systems.platforms.select resolved;
|
|
||||||
|
|
||||||
resolved =
|
resolved =
|
||||||
matchers
|
{
|
||||||
// validators
|
|
||||||
// platformInfo
|
|
||||||
// {
|
|
||||||
system = lib'.systems.from.string (
|
system = lib'.systems.from.string (
|
||||||
if settings ? triple
|
if settings ? triple
|
||||||
then settings.triple
|
then settings.triple
|
||||||
else settings.system
|
else settings.system
|
||||||
);
|
);
|
||||||
|
|
||||||
|
inherit
|
||||||
|
({
|
||||||
|
linux-kernel = settings.linux-kernel or {};
|
||||||
|
gcc = settings.gcc or {};
|
||||||
|
rustc = settings.rustc or {};
|
||||||
|
}
|
||||||
|
// lib'.systems.platforms.select resolved)
|
||||||
|
linux-kernel
|
||||||
|
gcc
|
||||||
|
rust
|
||||||
|
;
|
||||||
|
|
||||||
double = lib'.systems.into.double resolved.system;
|
double = lib'.systems.into.double resolved.system;
|
||||||
triple = lib'.systems.into.triple resolved.system;
|
triple = lib'.systems.into.triple resolved.system;
|
||||||
|
|
||||||
|
@ -2162,6 +2160,8 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
// builtins.mapAttrs (name: match: match resolved.system) lib'.systems.match
|
||||||
|
// builtins.mapAttrs (name: validate: validate (resolved.gcc.arch or "default")) lib'.systems.validate.architecture
|
||||||
// settings;
|
// settings;
|
||||||
|
|
||||||
assertions =
|
assertions =
|
||||||
|
@ -2178,7 +2178,7 @@ in {
|
||||||
true
|
true
|
||||||
(resolved.system.abi.assertions or []);
|
(resolved.system.abi.assertions or []);
|
||||||
in
|
in
|
||||||
assert resolved.useAndroidPrebuild -> resolved.isAndroid;
|
assert resolved.useAndroidPrebuilt -> resolved.isAndroid;
|
||||||
assert assertions;
|
assert assertions;
|
||||||
# And finally, return the generated system info.
|
# And finally, return the generated system info.
|
||||||
resolved;
|
resolved;
|
||||||
|
|
|
@ -82,6 +82,13 @@
|
||||||
extend = lib.options.create {
|
extend = lib.options.create {
|
||||||
description = "Extend the package's submodules with additional configuration.";
|
description = "Extend the package's submodules with additional configuration.";
|
||||||
type = lib.types.function lib.types.raw;
|
type = lib.types.function lib.types.raw;
|
||||||
|
default.value = value:
|
||||||
|
meta.extend {
|
||||||
|
modules =
|
||||||
|
if builtins.isAttrs value
|
||||||
|
then [{config = value;}]
|
||||||
|
else lib.lists.from.any value;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
name = lib.options.create {
|
name = lib.options.create {
|
||||||
|
@ -291,16 +298,6 @@
|
||||||
default.value = config.builder.build config;
|
default.value = config.builder.build config;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
|
||||||
extend = value:
|
|
||||||
meta.extend {
|
|
||||||
modules =
|
|
||||||
if builtins.isAttrs value
|
|
||||||
then [{config = value;}]
|
|
||||||
else lib.lists.from.any value;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,9 +15,9 @@ in {
|
||||||
packages = lib.options.create {
|
packages = lib.options.create {
|
||||||
description = "The package set.";
|
description = "The package set.";
|
||||||
type = lib.types.submodule {
|
type = lib.types.submodule {
|
||||||
freeform = lib.modules.overrides.force (lib.types.attrs.of (lib.types.submodule {
|
freeform = lib.types.attrs.of (lib.types.submodule {
|
||||||
freeform = lib.modules.overrides.force lib'.types.alias;
|
freeform = lib'.types.alias;
|
||||||
}));
|
});
|
||||||
|
|
||||||
options.cross = lib.attrs.generate doubles (system:
|
options.cross = lib.attrs.generate doubles (system:
|
||||||
lib.options.create {
|
lib.options.create {
|
||||||
|
@ -37,7 +37,7 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config.packages.config.cross = lib.attrs.generate doubles (
|
config.packages.cross = lib.attrs.generate doubles (
|
||||||
system:
|
system:
|
||||||
builtins.mapAttrs
|
builtins.mapAttrs
|
||||||
(
|
(
|
||||||
|
@ -47,7 +47,7 @@ in {
|
||||||
setHost = package:
|
setHost = package:
|
||||||
if package != {}
|
if package != {}
|
||||||
then
|
then
|
||||||
package.extend ({config}: {
|
(package.extend ({config}: {
|
||||||
config = {
|
config = {
|
||||||
platform = {
|
platform = {
|
||||||
host = lib.modules.overrides.force system;
|
host = lib.modules.overrides.force system;
|
||||||
|
@ -72,7 +72,8 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
})
|
}))
|
||||||
|
.config
|
||||||
else package;
|
else package;
|
||||||
|
|
||||||
updated =
|
updated =
|
||||||
|
|
|
@ -15,7 +15,10 @@
|
||||||
in {
|
in {
|
||||||
config.packages.foundation.gcc = {
|
config.packages.foundation.gcc = {
|
||||||
versions = {
|
versions = {
|
||||||
"13.2.0" = {config}: {
|
"13.2.0" = {
|
||||||
|
config,
|
||||||
|
meta,
|
||||||
|
}: {
|
||||||
options = {
|
options = {
|
||||||
src = lib.options.create {
|
src = lib.options.create {
|
||||||
type = lib.types.derivation;
|
type = lib.types.derivation;
|
||||||
|
@ -88,23 +91,42 @@ in {
|
||||||
builder = builders.basic;
|
builder = builders.basic;
|
||||||
|
|
||||||
env = {
|
env = {
|
||||||
PATH = lib.paths.bin [
|
PATH = let
|
||||||
foundation.stage2-gcc
|
gcc =
|
||||||
foundation.stage2-binutils
|
if config.platform.build.triple == config.platform.host.triple
|
||||||
foundation.stage2-gnumake
|
# If we're on the same system then we can use the existing GCC instance.
|
||||||
foundation.stage2-gnused
|
then foundation.stage2-gcc
|
||||||
foundation.stage2-gnugrep
|
# Otherwise we are going to need a cross-compiler.
|
||||||
foundation.stage2-gawk
|
else
|
||||||
foundation.stage2-diffutils
|
(meta.extend (args: {
|
||||||
foundation.stage2-findutils
|
config = {
|
||||||
foundation.stage2-gnutar
|
platform = {
|
||||||
foundation.stage2-gzip
|
target = lib.modules.override.force config.platform.host.triple;
|
||||||
foundation.stage2-bzip2
|
};
|
||||||
foundation.stage1-xz
|
};
|
||||||
];
|
}))
|
||||||
|
.config
|
||||||
|
.package;
|
||||||
|
in
|
||||||
|
lib.paths.bin [
|
||||||
|
foundation.stage2-gcc
|
||||||
|
foundation.stage2-binutils
|
||||||
|
foundation.stage2-gnumake
|
||||||
|
foundation.stage2-gnused
|
||||||
|
foundation.stage2-gnugrep
|
||||||
|
foundation.stage2-gawk
|
||||||
|
foundation.stage2-diffutils
|
||||||
|
foundation.stage2-findutils
|
||||||
|
foundation.stage2-gnutar
|
||||||
|
foundation.stage2-gzip
|
||||||
|
foundation.stage2-bzip2
|
||||||
|
foundation.stage1-xz
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
phases = {
|
phases = let
|
||||||
|
host = lib'.systems.withBuildInfo config.platform.host;
|
||||||
|
in {
|
||||||
unpack = lib.dag.entry.before ["patch"] ''
|
unpack = lib.dag.entry.before ["patch"] ''
|
||||||
# Unpack
|
# Unpack
|
||||||
tar xf ${config.src}
|
tar xf ${config.src}
|
||||||
|
@ -128,7 +150,7 @@ in {
|
||||||
|
|
||||||
configure = lib.dag.entry.between ["build"] ["patch"] ''
|
configure = lib.dag.entry.between ["build"] ["patch"] ''
|
||||||
# Configure
|
# Configure
|
||||||
export CC="gcc -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
export CC="gcc -Wl,-dynamic-linker -march=${host.gcc.arch or host.system.cpu.arch} -Wl,${foundation.stage1-musl}/lib/libc.so"
|
||||||
export CXX="g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
export CXX="g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
||||||
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
||||||
export LIBRARY_PATH="${foundation.stage1-musl}/lib"
|
export LIBRARY_PATH="${foundation.stage1-musl}/lib"
|
||||||
|
@ -137,6 +159,7 @@ in {
|
||||||
--prefix=$out \
|
--prefix=$out \
|
||||||
--build=${config.platform.build.triple} \
|
--build=${config.platform.build.triple} \
|
||||||
--host=${config.platform.host.triple} \
|
--host=${config.platform.host.triple} \
|
||||||
|
--target=${config.platform.target.triple} \
|
||||||
--with-native-system-header-dir=/include \
|
--with-native-system-header-dir=/include \
|
||||||
--with-sysroot=${foundation.stage1-musl} \
|
--with-sysroot=${foundation.stage1-musl} \
|
||||||
--enable-languages=c,c++ \
|
--enable-languages=c,c++ \
|
||||||
|
|
Loading…
Reference in a new issue