forked from auxolotl/labs
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) {
|
typeSet = lib.attrs.when ((shared "type") && isTypeMergeable) {
|
||||||
type = mergedType;
|
type = mergedType;
|
||||||
};
|
};
|
||||||
files = builtins.map lib.modules.getFiles result.declarations;
|
files = result.declarations;
|
||||||
serializedFiles = builtins.concatStringsSep " and " files;
|
serializedFiles = builtins.concatStringsSep " and " files;
|
||||||
getSubModules = option.options.type.getSubModules or null;
|
getSubModules = option.options.type.getSubModules or null;
|
||||||
submodules =
|
submodules =
|
||||||
|
|
|
@ -767,19 +767,21 @@ lib: {
|
||||||
definition:
|
definition:
|
||||||
if shorthand && builtins.isAttrs definition.value
|
if shorthand && builtins.isAttrs definition.value
|
||||||
then let
|
then let
|
||||||
config =
|
# TODO: Figure out if we can apply additional attributes to the generated module.
|
||||||
definition.value.config
|
# Currently this causes issues to do with redefined options.
|
||||||
or (
|
|
||||||
builtins.removeAttrs definition.value
|
|
||||||
(builtins.filter (key: key != "config") lib.modules.VALID_KEYS)
|
|
||||||
);
|
|
||||||
rest =
|
rest =
|
||||||
if definition.value ? config
|
builtins.removeAttrs
|
||||||
then builtins.removeAttrs definition.value ["config"]
|
(lib.attrs.filter (name: value: builtins.elem name lib.modules.VALID_KEYS) definition.value)
|
||||||
else lib.attrs.filter (name: value: builtins.elem name lib.modules.VALID_KEYS) definition.value;
|
["freeform"];
|
||||||
in
|
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__;
|
__file__ = definition.__file__;
|
||||||
config = config;
|
config = config;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "foundation",
|
"dir": "foundation",
|
||||||
"dirtyRev": "aa1c58f6ee8a3ad6ad569f34477192462533c16b-dirty",
|
"dirtyRev": "2989fdc4fe153f13e7b6b476476805b03c419f0c-dirty",
|
||||||
"dirtyShortRev": "aa1c58f-dirty",
|
"dirtyShortRev": "2989fdc-dirty",
|
||||||
"lastModified": 1718411218,
|
"lastModified": 1718444137,
|
||||||
"narHash": "sha256-LOzQGGygC2U08zNwg1YNljjrJKJxnJ8S4RkX2v81yRw=",
|
"narHash": "sha256-gArdjry0N4et4B+wQa31JyLJ448JWd9OFA1Roe3EOAc=",
|
||||||
"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": "aa1c58f6ee8a3ad6ad569f34477192462533c16b-dirty",
|
"dirtyRev": "2989fdc4fe153f13e7b6b476476805b03c419f0c-dirty",
|
||||||
"dirtyShortRev": "aa1c58f-dirty",
|
"dirtyShortRev": "2989fdc-dirty",
|
||||||
"lastModified": 1718411218,
|
"lastModified": 1718444137,
|
||||||
"narHash": "sha256-LOzQGGygC2U08zNwg1YNljjrJKJxnJ8S4RkX2v81yRw=",
|
"narHash": "sha256-gArdjry0N4et4B+wQa31JyLJ448JWd9OFA1Roe3EOAc=",
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "file:../?dir=lib"
|
"url": "file:../?dir=lib"
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,6 +13,7 @@ in {
|
||||||
|
|
||||||
packages = {
|
packages = {
|
||||||
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;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
|
lib',
|
||||||
config,
|
config,
|
||||||
}: let
|
}: let
|
||||||
lib' = config.lib;
|
|
||||||
|
|
||||||
doubles = lib'.systems.doubles.all;
|
doubles = lib'.systems.doubles.all;
|
||||||
|
|
||||||
|
packages = builtins.removeAttrs config.packages ["cross"];
|
||||||
in {
|
in {
|
||||||
includes = [
|
includes = [
|
||||||
./aux/foundation.nix
|
./aux/foundation.nix
|
||||||
|
@ -13,7 +14,18 @@ in {
|
||||||
options = {
|
options = {
|
||||||
packages = lib.options.create {
|
packages = lib.options.create {
|
||||||
description = "The package set.";
|
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 = {
|
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