refactor: format
This commit is contained in:
parent
ea200d834e
commit
3f9d287065
7 changed files with 237 additions and 196 deletions
|
|
@ -36,10 +36,7 @@ in
|
|||
hooks.target.target
|
||||
];
|
||||
in
|
||||
builtins.foldl'
|
||||
(final: defaults: lib.dag.apply.defaults final defaults)
|
||||
package.phases
|
||||
all;
|
||||
builtins.foldl' (final: defaults: lib.dag.apply.defaults final defaults) package.phases all;
|
||||
|
||||
phases = lib.dag.apply.defaults phasesWithHooks {
|
||||
unpack = lib.dag.entry.before [ "patch" ] "";
|
||||
|
|
@ -55,9 +52,7 @@ in
|
|||
|
||||
sorted = lib.dag.sort.topological phases;
|
||||
|
||||
script = lib.strings.concatMapSep "\n"
|
||||
(entry: entry.value)
|
||||
sorted.result;
|
||||
script = lib.strings.concatMapSep "\n" (entry: entry.value) sorted.result;
|
||||
|
||||
built = builtins.derivation (
|
||||
package.env
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ in
|
|||
get =
|
||||
dependencies:
|
||||
let
|
||||
exists = value: ! (builtins.isNull value);
|
||||
exists = value: !(builtins.isNull value);
|
||||
available = builtins.filter exists dependencies;
|
||||
in
|
||||
builtins.map (dependency: dependency.package) available;
|
||||
|
|
@ -18,46 +18,55 @@ in
|
|||
build': host': target':
|
||||
builtins.mapAttrs (name: dep: lib'.packages.build dep build' host' target');
|
||||
|
||||
collect = package:
|
||||
collect =
|
||||
package:
|
||||
let
|
||||
isPropagated = name: package: package.propagate or false;
|
||||
getPropagatedDependencies = target: builtins.attrValues (lib.attrs.filter isPropagated target);
|
||||
|
||||
process = dependencies:
|
||||
process =
|
||||
dependencies:
|
||||
let
|
||||
getDeps = name: dependency:
|
||||
getDeps =
|
||||
name: dependency:
|
||||
let
|
||||
deps =
|
||||
{
|
||||
build = {
|
||||
only = getPropagatedDependencies dependency.deps.build.only ++ process dependency.deps.build.only;
|
||||
build = getPropagatedDependencies dependency.deps.build.build ++ process dependency.deps.build.build;
|
||||
host = getPropagatedDependencies dependency.deps.build.host ++ process dependency.deps.build.host;
|
||||
target = getPropagatedDependencies dependency.deps.build.target ++ process dependency.deps.build.target;
|
||||
};
|
||||
host = {
|
||||
only = getPropagatedDependencies dependency.deps.host.only ++ process dependency.deps.host.only;
|
||||
host = getPropagatedDependencies dependency.deps.host.host ++ process dependency.deps.host.host;
|
||||
target = getPropagatedDependencies dependency.deps.host.target ++ process dependency.deps.host.target;
|
||||
};
|
||||
target = {
|
||||
only = getPropagatedDependencies dependency.deps.target.only ++ process dependency.deps.target.only;
|
||||
target = getPropagatedDependencies dependency.deps.target.target ++ process dependency.deps.target.target;
|
||||
};
|
||||
deps = {
|
||||
build = {
|
||||
only = getPropagatedDependencies dependency.deps.build.only ++ process dependency.deps.build.only;
|
||||
build =
|
||||
getPropagatedDependencies dependency.deps.build.build
|
||||
++ process dependency.deps.build.build;
|
||||
host = getPropagatedDependencies dependency.deps.build.host ++ process dependency.deps.build.host;
|
||||
target =
|
||||
getPropagatedDependencies dependency.deps.build.target
|
||||
++ process dependency.deps.build.target;
|
||||
};
|
||||
host = {
|
||||
only = getPropagatedDependencies dependency.deps.host.only ++ process dependency.deps.host.only;
|
||||
host = getPropagatedDependencies dependency.deps.host.host ++ process dependency.deps.host.host;
|
||||
target =
|
||||
getPropagatedDependencies dependency.deps.host.target
|
||||
++ process dependency.deps.host.target;
|
||||
};
|
||||
target = {
|
||||
only = getPropagatedDependencies dependency.deps.target.only ++ process dependency.deps.target.only;
|
||||
target =
|
||||
getPropagatedDependencies dependency.deps.target.target
|
||||
++ process dependency.deps.target.target;
|
||||
};
|
||||
};
|
||||
in
|
||||
lib.lists.flatten
|
||||
[
|
||||
deps.build.only
|
||||
deps.build.build
|
||||
deps.build.host
|
||||
deps.build.target
|
||||
deps.host.only
|
||||
deps.host.host
|
||||
deps.host.target
|
||||
deps.target.only
|
||||
deps.target.target
|
||||
];
|
||||
lib.lists.flatten [
|
||||
deps.build.only
|
||||
deps.build.build
|
||||
deps.build.host
|
||||
deps.build.target
|
||||
deps.host.only
|
||||
deps.host.host
|
||||
deps.host.target
|
||||
deps.target.only
|
||||
deps.target.target
|
||||
];
|
||||
|
||||
propagated = lib.attrs.mapToList getDeps dependencies;
|
||||
in
|
||||
|
|
@ -83,122 +92,176 @@ in
|
|||
};
|
||||
|
||||
context = {
|
||||
create = collected: ctx:
|
||||
create =
|
||||
collected: ctx:
|
||||
let
|
||||
process = path:
|
||||
process =
|
||||
path:
|
||||
let
|
||||
dependencies = lib.attrs.selectOrThrow path collected;
|
||||
contexts = builtins.map (dependency: dependency.context or { }) dependencies;
|
||||
result = lib.modules.run {
|
||||
modules =
|
||||
builtins.map
|
||||
(context: { config = context; })
|
||||
contexts
|
||||
++ [
|
||||
{
|
||||
freeform = lib.types.any;
|
||||
modules = builtins.map (context: { config = context; }) contexts ++ [
|
||||
{
|
||||
freeform = lib.types.any;
|
||||
|
||||
options = config.packages.context.options // {
|
||||
target = lib.options.create {
|
||||
description = "The dependency target that is being generated.";
|
||||
type = lib.types.enum [
|
||||
"build.only"
|
||||
"build.build"
|
||||
"build.host"
|
||||
"build.target"
|
||||
"host.only"
|
||||
"host.host"
|
||||
"host.target"
|
||||
"target.only"
|
||||
"target.target"
|
||||
];
|
||||
writable = false;
|
||||
default.value = builtins.concatStringsSep "." path;
|
||||
};
|
||||
options = config.packages.context.options // {
|
||||
target = lib.options.create {
|
||||
description = "The dependency target that is being generated.";
|
||||
type = lib.types.enum [
|
||||
"build.only"
|
||||
"build.build"
|
||||
"build.host"
|
||||
"build.target"
|
||||
"host.only"
|
||||
"host.host"
|
||||
"host.target"
|
||||
"target.only"
|
||||
"target.target"
|
||||
];
|
||||
writable = false;
|
||||
default.value = builtins.concatStringsSep "." path;
|
||||
};
|
||||
|
||||
deps = lib.options.create {
|
||||
description = "The collected dependencies.";
|
||||
writable = false;
|
||||
default.value = collected;
|
||||
type = lib.types.submodule {
|
||||
options = {
|
||||
build = {
|
||||
only = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
build = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
host = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
target = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
};
|
||||
host = {
|
||||
only = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
host = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
target = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
};
|
||||
target = {
|
||||
only = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
target = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
};
|
||||
deps = lib.options.create {
|
||||
description = "The collected dependencies.";
|
||||
writable = false;
|
||||
default.value = collected;
|
||||
type = lib.types.submodule {
|
||||
options = {
|
||||
build = {
|
||||
only = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
build = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
host = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
target = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
};
|
||||
host = {
|
||||
only = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
host = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
target = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
};
|
||||
target = {
|
||||
only = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
target = lib.options.create { type = lib.types.list.of lib'.types.package; };
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = ctx;
|
||||
}
|
||||
];
|
||||
config = ctx;
|
||||
}
|
||||
];
|
||||
};
|
||||
in
|
||||
result.config;
|
||||
in
|
||||
{
|
||||
build = {
|
||||
only = process [ "build" "only" ];
|
||||
build = process [ "build" "build" ];
|
||||
host = process [ "build" "host" ];
|
||||
target = process [ "build" "target" ];
|
||||
only = process [
|
||||
"build"
|
||||
"only"
|
||||
];
|
||||
build = process [
|
||||
"build"
|
||||
"build"
|
||||
];
|
||||
host = process [
|
||||
"build"
|
||||
"host"
|
||||
];
|
||||
target = process [
|
||||
"build"
|
||||
"target"
|
||||
];
|
||||
};
|
||||
host = {
|
||||
only = process [ "host" "only" ];
|
||||
host = process [ "host" "host" ];
|
||||
target = process [ "host" "target" ];
|
||||
only = process [
|
||||
"host"
|
||||
"only"
|
||||
];
|
||||
host = process [
|
||||
"host"
|
||||
"host"
|
||||
];
|
||||
target = process [
|
||||
"host"
|
||||
"target"
|
||||
];
|
||||
};
|
||||
target = {
|
||||
only = process [ "target" "only" ];
|
||||
target = process [ "target" "target" ];
|
||||
only = process [
|
||||
"target"
|
||||
"only"
|
||||
];
|
||||
target = process [
|
||||
"target"
|
||||
"target"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
hooks = {
|
||||
create = collected: ctx:
|
||||
create =
|
||||
collected: ctx:
|
||||
let
|
||||
process = path:
|
||||
process =
|
||||
path:
|
||||
let
|
||||
dependencies = lib.attrs.selectOrThrow path collected;
|
||||
hooks = builtins.map
|
||||
(dependency:
|
||||
let
|
||||
getHooks = dependency.hooks or (lib.fp.const { });
|
||||
in
|
||||
getHooks ctx)
|
||||
dependencies;
|
||||
hooks = builtins.map (
|
||||
dependency:
|
||||
let
|
||||
getHooks = dependency.hooks or (lib.fp.const { });
|
||||
in
|
||||
getHooks ctx
|
||||
) dependencies;
|
||||
in
|
||||
hooks;
|
||||
in
|
||||
{
|
||||
build = {
|
||||
only = process [ "build" "only" ];
|
||||
build = process [ "build" "build" ];
|
||||
host = process [ "build" "host" ];
|
||||
target = process [ "build" "target" ];
|
||||
only = process [
|
||||
"build"
|
||||
"only"
|
||||
];
|
||||
build = process [
|
||||
"build"
|
||||
"build"
|
||||
];
|
||||
host = process [
|
||||
"build"
|
||||
"host"
|
||||
];
|
||||
target = process [
|
||||
"build"
|
||||
"target"
|
||||
];
|
||||
};
|
||||
host = {
|
||||
only = process [ "host" "only" ];
|
||||
host = process [ "host" "host" ];
|
||||
target = process [ "host" "target" ];
|
||||
only = process [
|
||||
"host"
|
||||
"only"
|
||||
];
|
||||
host = process [
|
||||
"host"
|
||||
"host"
|
||||
];
|
||||
target = process [
|
||||
"host"
|
||||
"target"
|
||||
];
|
||||
};
|
||||
target = {
|
||||
only = process [ "target" "only" ];
|
||||
target = process [ "target" "target" ];
|
||||
only = process [
|
||||
"target"
|
||||
"only"
|
||||
];
|
||||
target = process [
|
||||
"target"
|
||||
"target"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,11 +30,7 @@ in
|
|||
cflags = [ "-I $AUX_B/include" ];
|
||||
};
|
||||
|
||||
hooks = ctx: {
|
||||
"aux:b:env" = lib.dag.entry.after
|
||||
[ "unpack" ]
|
||||
''export AUX_B=${config.package}'';
|
||||
};
|
||||
hooks = ctx: { "aux:b:env" = lib.dag.entry.after [ "unpack" ] ''export AUX_B=${config.package}''; };
|
||||
|
||||
phases = {
|
||||
install = ''
|
||||
|
|
|
|||
|
|
@ -55,34 +55,32 @@ in
|
|||
config = {
|
||||
packages.cross = lib.attrs.generate doubles (
|
||||
system:
|
||||
builtins.mapAttrs
|
||||
(
|
||||
namespace:
|
||||
builtins.mapAttrs (
|
||||
name: alias:
|
||||
let
|
||||
setHost =
|
||||
package:
|
||||
package
|
||||
// {
|
||||
__modules__ = package.__modules__ ++ [
|
||||
{
|
||||
config.platform = {
|
||||
host = lib.modules.override 5 system;
|
||||
target = lib.modules.override 5 system;
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
builtins.mapAttrs (
|
||||
namespace:
|
||||
builtins.mapAttrs (
|
||||
name: alias:
|
||||
let
|
||||
setHost =
|
||||
package:
|
||||
package
|
||||
// {
|
||||
__modules__ = package.__modules__ ++ [
|
||||
{
|
||||
config.platform = {
|
||||
host = lib.modules.override 5 system;
|
||||
target = lib.modules.override 5 system;
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
updated = alias // {
|
||||
versions = builtins.mapAttrs (version: package: setHost package) alias.versions;
|
||||
};
|
||||
in
|
||||
updated
|
||||
)
|
||||
updated = alias // {
|
||||
versions = builtins.mapAttrs (version: package: setHost package) alias.versions;
|
||||
};
|
||||
in
|
||||
updated
|
||||
)
|
||||
packages
|
||||
) packages
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue