fix: resolve issue with extending cross package
This commit is contained in:
parent
0312e3c4cc
commit
9850da8aa9
|
@ -601,5 +601,115 @@ in {
|
|||
};
|
||||
in
|
||||
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"];
|
||||
in
|
||||
if definition.value ? config
|
||||
then {
|
||||
__file__ = definition.__file__;
|
||||
config = definition.value.config;
|
||||
}
|
||||
then
|
||||
rest
|
||||
// {
|
||||
__file__ = definition.__file__;
|
||||
config = definition.value.config;
|
||||
}
|
||||
else let
|
||||
config = builtins.removeAttrs definition.value lib.modules.VALID_KEYS;
|
||||
in {
|
||||
__file__ = definition.__file__;
|
||||
config = config;
|
||||
}
|
||||
in
|
||||
rest
|
||||
// {
|
||||
__file__ = definition.__file__;
|
||||
config = config;
|
||||
}
|
||||
else {
|
||||
__file__ = definition.__file__;
|
||||
includes = [definition.value];
|
||||
|
|
|
@ -22,3 +22,6 @@
|
|||
};
|
||||
in
|
||||
result.config.exported
|
||||
// {
|
||||
inherit (result) config;
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
},
|
||||
"locked": {
|
||||
"dir": "foundation",
|
||||
"dirtyRev": "6bd35bf4d5f24b8e91d8afa589ea3088796b2baa-dirty",
|
||||
"dirtyShortRev": "6bd35bf-dirty",
|
||||
"lastModified": 1718450285,
|
||||
"narHash": "sha256-/i3RlOudzZdl6UBdhMDRBAgVQTHOZDXEkSfRUw77aK8=",
|
||||
"dirtyRev": "0312e3c4cc261e2384fcf372c766a0cf245f3213-dirty",
|
||||
"dirtyShortRev": "0312e3c-dirty",
|
||||
"lastModified": 1718460525,
|
||||
"narHash": "sha256-+ToaXY8ISWLx9AtO/CjfY/6SGuKu8A/d9ncqE4h2H20=",
|
||||
"type": "git",
|
||||
"url": "file:../?dir=foundation"
|
||||
},
|
||||
|
@ -24,10 +24,10 @@
|
|||
"lib": {
|
||||
"locked": {
|
||||
"dir": "lib",
|
||||
"dirtyRev": "6bd35bf4d5f24b8e91d8afa589ea3088796b2baa-dirty",
|
||||
"dirtyShortRev": "6bd35bf-dirty",
|
||||
"lastModified": 1718450285,
|
||||
"narHash": "sha256-/i3RlOudzZdl6UBdhMDRBAgVQTHOZDXEkSfRUw77aK8=",
|
||||
"dirtyRev": "0312e3c4cc261e2384fcf372c766a0cf245f3213-dirty",
|
||||
"dirtyShortRev": "0312e3c-dirty",
|
||||
"lastModified": 1718460525,
|
||||
"narHash": "sha256-+ToaXY8ISWLx9AtO/CjfY/6SGuKu8A/d9ncqE4h2H20=",
|
||||
"type": "git",
|
||||
"url": "file:../?dir=lib"
|
||||
},
|
||||
|
|
|
@ -26,8 +26,8 @@ in {
|
|||
sorted.result;
|
||||
|
||||
system = package.platform.build.double;
|
||||
in
|
||||
builtins.derivation (
|
||||
|
||||
built = builtins.derivation (
|
||||
package.env
|
||||
// {
|
||||
inherit (package) name;
|
||||
|
@ -70,6 +70,11 @@ in {
|
|||
];
|
||||
}
|
||||
);
|
||||
in
|
||||
built
|
||||
// {
|
||||
inherit (package) meta;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,16 +6,29 @@
|
|||
}: let
|
||||
lib' = config.lib;
|
||||
in {
|
||||
freeform = lib.types.any;
|
||||
|
||||
config = {
|
||||
exports = {
|
||||
lib = config.lib;
|
||||
modules = import ./modules.nix;
|
||||
|
||||
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;
|
||||
# example-x = config.packages.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;}
|
||||
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 =
|
||||
matchers
|
||||
// validators
|
||||
// platformInfo
|
||||
// {
|
||||
{
|
||||
system = lib'.systems.from.string (
|
||||
if settings ? triple
|
||||
then settings.triple
|
||||
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;
|
||||
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;
|
||||
|
||||
assertions =
|
||||
|
@ -2178,7 +2178,7 @@ in {
|
|||
true
|
||||
(resolved.system.abi.assertions or []);
|
||||
in
|
||||
assert resolved.useAndroidPrebuild -> resolved.isAndroid;
|
||||
assert resolved.useAndroidPrebuilt -> resolved.isAndroid;
|
||||
assert assertions;
|
||||
# And finally, return the generated system info.
|
||||
resolved;
|
||||
|
|
|
@ -82,6 +82,13 @@
|
|||
extend = lib.options.create {
|
||||
description = "Extend the package's submodules with additional configuration.";
|
||||
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 {
|
||||
|
@ -291,16 +298,6 @@
|
|||
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 {
|
||||
description = "The package set.";
|
||||
type = lib.types.submodule {
|
||||
freeform = lib.modules.overrides.force (lib.types.attrs.of (lib.types.submodule {
|
||||
freeform = lib.modules.overrides.force lib'.types.alias;
|
||||
}));
|
||||
freeform = lib.types.attrs.of (lib.types.submodule {
|
||||
freeform = lib'.types.alias;
|
||||
});
|
||||
|
||||
options.cross = lib.attrs.generate doubles (system:
|
||||
lib.options.create {
|
||||
|
@ -37,7 +37,7 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config.packages.config.cross = lib.attrs.generate doubles (
|
||||
config.packages.cross = lib.attrs.generate doubles (
|
||||
system:
|
||||
builtins.mapAttrs
|
||||
(
|
||||
|
@ -47,7 +47,7 @@ in {
|
|||
setHost = package:
|
||||
if package != {}
|
||||
then
|
||||
package.extend ({config}: {
|
||||
(package.extend ({config}: {
|
||||
config = {
|
||||
platform = {
|
||||
host = lib.modules.overrides.force system;
|
||||
|
@ -72,7 +72,8 @@ in {
|
|||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
}))
|
||||
.config
|
||||
else package;
|
||||
|
||||
updated =
|
||||
|
|
|
@ -15,7 +15,10 @@
|
|||
in {
|
||||
config.packages.foundation.gcc = {
|
||||
versions = {
|
||||
"13.2.0" = {config}: {
|
||||
"13.2.0" = {
|
||||
config,
|
||||
meta,
|
||||
}: {
|
||||
options = {
|
||||
src = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
|
@ -88,23 +91,42 @@ in {
|
|||
builder = builders.basic;
|
||||
|
||||
env = {
|
||||
PATH = 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
|
||||
];
|
||||
PATH = let
|
||||
gcc =
|
||||
if config.platform.build.triple == config.platform.host.triple
|
||||
# If we're on the same system then we can use the existing GCC instance.
|
||||
then foundation.stage2-gcc
|
||||
# Otherwise we are going to need a cross-compiler.
|
||||
else
|
||||
(meta.extend (args: {
|
||||
config = {
|
||||
platform = {
|
||||
target = lib.modules.override.force config.platform.host.triple;
|
||||
};
|
||||
};
|
||||
}))
|
||||
.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
|
||||
tar xf ${config.src}
|
||||
|
@ -128,7 +150,7 @@ in {
|
|||
|
||||
configure = lib.dag.entry.between ["build"] ["patch"] ''
|
||||
# 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 CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
|
||||
export LIBRARY_PATH="${foundation.stage1-musl}/lib"
|
||||
|
@ -137,6 +159,7 @@ in {
|
|||
--prefix=$out \
|
||||
--build=${config.platform.build.triple} \
|
||||
--host=${config.platform.host.triple} \
|
||||
--target=${config.platform.target.triple} \
|
||||
--with-native-system-header-dir=/include \
|
||||
--with-sysroot=${foundation.stage1-musl} \
|
||||
--enable-languages=c,c++ \
|
||||
|
|
Loading…
Reference in a new issue