feat: cross compilation package set
This commit is contained in:
parent
2989fdc4fe
commit
1c67c40213
|
@ -94,7 +94,7 @@ lib: {
|
|||
typeSet = lib.attrs.when ((shared "type") && isTypeMergeable) {
|
||||
type = mergedType;
|
||||
};
|
||||
files = builtins.map lib.modules.getFiles result.declarations;
|
||||
files = result.declarations;
|
||||
serializedFiles = builtins.concatStringsSep " and " files;
|
||||
getSubModules = option.options.type.getSubModules or null;
|
||||
submodules =
|
||||
|
|
|
@ -767,19 +767,21 @@ lib: {
|
|||
definition:
|
||||
if shorthand && builtins.isAttrs definition.value
|
||||
then let
|
||||
config =
|
||||
definition.value.config
|
||||
or (
|
||||
builtins.removeAttrs definition.value
|
||||
(builtins.filter (key: key != "config") lib.modules.VALID_KEYS)
|
||||
);
|
||||
# TODO: Figure out if we can apply additional attributes to the generated module.
|
||||
# Currently this causes issues to do with redefined options.
|
||||
rest =
|
||||
if definition.value ? config
|
||||
then builtins.removeAttrs definition.value ["config"]
|
||||
else lib.attrs.filter (name: value: builtins.elem name lib.modules.VALID_KEYS) definition.value;
|
||||
builtins.removeAttrs
|
||||
(lib.attrs.filter (name: value: builtins.elem name lib.modules.VALID_KEYS) definition.value)
|
||||
["freeform"];
|
||||
in
|
||||
rest
|
||||
// {
|
||||
if definition.value ? config
|
||||
then {
|
||||
__file__ = definition.__file__;
|
||||
config = definition.value.config;
|
||||
}
|
||||
else let
|
||||
config = builtins.removeAttrs definition.value lib.modules.VALID_KEYS;
|
||||
in {
|
||||
__file__ = definition.__file__;
|
||||
config = config;
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
},
|
||||
"locked": {
|
||||
"dir": "foundation",
|
||||
"dirtyRev": "aa1c58f6ee8a3ad6ad569f34477192462533c16b-dirty",
|
||||
"dirtyShortRev": "aa1c58f-dirty",
|
||||
"lastModified": 1718411218,
|
||||
"narHash": "sha256-LOzQGGygC2U08zNwg1YNljjrJKJxnJ8S4RkX2v81yRw=",
|
||||
"dirtyRev": "2989fdc4fe153f13e7b6b476476805b03c419f0c-dirty",
|
||||
"dirtyShortRev": "2989fdc-dirty",
|
||||
"lastModified": 1718444137,
|
||||
"narHash": "sha256-gArdjry0N4et4B+wQa31JyLJ448JWd9OFA1Roe3EOAc=",
|
||||
"type": "git",
|
||||
"url": "file:../?dir=foundation"
|
||||
},
|
||||
|
@ -24,10 +24,10 @@
|
|||
"lib": {
|
||||
"locked": {
|
||||
"dir": "lib",
|
||||
"dirtyRev": "aa1c58f6ee8a3ad6ad569f34477192462533c16b-dirty",
|
||||
"dirtyShortRev": "aa1c58f-dirty",
|
||||
"lastModified": 1718411218,
|
||||
"narHash": "sha256-LOzQGGygC2U08zNwg1YNljjrJKJxnJ8S4RkX2v81yRw=",
|
||||
"dirtyRev": "2989fdc4fe153f13e7b6b476476805b03c419f0c-dirty",
|
||||
"dirtyShortRev": "2989fdc-dirty",
|
||||
"lastModified": 1718444137,
|
||||
"narHash": "sha256-gArdjry0N4et4B+wQa31JyLJ448JWd9OFA1Roe3EOAc=",
|
||||
"type": "git",
|
||||
"url": "file:../?dir=lib"
|
||||
},
|
||||
|
|
|
@ -13,6 +13,7 @@ in {
|
|||
|
||||
packages = {
|
||||
example-x = config.packages.example.x;
|
||||
cross-example-x-x86_64-linux = config.packages.cross.x86_64-linux.example.x;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
{
|
||||
lib,
|
||||
lib',
|
||||
config,
|
||||
}: let
|
||||
lib' = config.lib;
|
||||
|
||||
doubles = lib'.systems.doubles.all;
|
||||
|
||||
packages = builtins.removeAttrs config.packages ["cross"];
|
||||
in {
|
||||
includes = [
|
||||
./aux/foundation.nix
|
||||
|
@ -13,7 +14,18 @@ in {
|
|||
options = {
|
||||
packages = lib.options.create {
|
||||
description = "The package set.";
|
||||
type = lib'.types.packages;
|
||||
type = lib.types.submodule {
|
||||
freeform = lib.modules.overrides.force (lib.types.attrs.of (lib.types.submodule {
|
||||
freeform = lib.modules.overrides.force lib'.types.alias;
|
||||
}));
|
||||
|
||||
options.cross = lib.attrs.generate doubles (system:
|
||||
lib.options.create {
|
||||
description = "The cross-compiled package set for the ${system} target.";
|
||||
type = lib'.types.packages;
|
||||
default = {};
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
preferences.packages = {
|
||||
|
@ -24,4 +36,55 @@ in {
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
config.packages.cross = lib.attrs.generate doubles (
|
||||
system:
|
||||
builtins.mapAttrs
|
||||
(
|
||||
namespace:
|
||||
builtins.mapAttrs
|
||||
(name: alias: let
|
||||
setHost = package:
|
||||
if package != {}
|
||||
then
|
||||
package.extend ({config}: {
|
||||
config = {
|
||||
platform = {
|
||||
host = lib.modules.overrides.force system;
|
||||
};
|
||||
|
||||
deps = {
|
||||
build = {
|
||||
only = setHost package.deps.build.only;
|
||||
build = setHost package.deps.build.build;
|
||||
host = setHost package.deps.build.host;
|
||||
target = setHost package.deps.build.target;
|
||||
};
|
||||
host = {
|
||||
only = setHost package.deps.host.only;
|
||||
host = setHost package.deps.host.host;
|
||||
target = setHost package.deps.host.target;
|
||||
};
|
||||
target = {
|
||||
only = setHost package.deps.target.only;
|
||||
target = setHost package.deps.target.target;
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
else package;
|
||||
|
||||
updated =
|
||||
alias
|
||||
// {
|
||||
versions =
|
||||
builtins.mapAttrs
|
||||
(version: package: setHost package)
|
||||
alias.versions;
|
||||
};
|
||||
in
|
||||
updated)
|
||||
)
|
||||
packages
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue