feat: package extend, dynamic propagation
This commit is contained in:
parent
3f9d287065
commit
7d94b7f665
9 changed files with 251 additions and 134 deletions
|
|
@ -20,8 +20,6 @@ in
|
|||
|
||||
hooks = lib.packages.hooks.create dependencies context;
|
||||
|
||||
cflags = builtins.concatStringsSep " " (context.build.host.cflags or [ ]);
|
||||
|
||||
phasesWithHooks =
|
||||
let
|
||||
all = lib.lists.flatten [
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ in
|
|||
dependencies = lib.attrs.selectOrThrow path collected;
|
||||
contexts = builtins.map (dependency: dependency.context or { }) dependencies;
|
||||
result = lib.modules.run {
|
||||
prefix = [ "<package>" ];
|
||||
modules = builtins.map (context: { config = context; }) contexts ++ [
|
||||
{
|
||||
freeform = lib.types.any;
|
||||
|
|
@ -210,13 +211,15 @@ in
|
|||
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
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ in
|
|||
};
|
||||
|
||||
submodule =
|
||||
{ config }:
|
||||
{ config, meta }:
|
||||
let
|
||||
build = config.platform.build;
|
||||
host = config.platform.host;
|
||||
|
|
@ -230,6 +230,34 @@ in
|
|||
default.value = [ ];
|
||||
};
|
||||
|
||||
extend = lib.options.create {
|
||||
description = "Extend the package definition.";
|
||||
type = lib.types.function lib.types.raw;
|
||||
internal = true;
|
||||
writable = false;
|
||||
default.value = module:
|
||||
let
|
||||
normalized =
|
||||
if builtins.isList module then
|
||||
module
|
||||
else if builtins.isFunction module || module ? config then
|
||||
[ module ]
|
||||
else
|
||||
[{
|
||||
config = module;
|
||||
}];
|
||||
result = meta.extend {
|
||||
modules =
|
||||
normalized ++ [
|
||||
{
|
||||
config.__modules__ = lib.modules.overrides.force (config.__modules__ ++ normalized);
|
||||
}
|
||||
];
|
||||
};
|
||||
in
|
||||
result.config;
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = lib.options.create {
|
||||
description = "The description for the package.";
|
||||
|
|
|
|||
|
|
@ -26,8 +26,18 @@ in
|
|||
|
||||
builder = builders.basic;
|
||||
|
||||
deps = {
|
||||
build = {
|
||||
host = {
|
||||
c = packages.aux.c.versions.latest.extend {
|
||||
propagate = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
context = {
|
||||
cflags = [ "-I $AUX_B/include" ];
|
||||
"foundation:cflags" = [ "-I $AUX_B/include" ];
|
||||
};
|
||||
|
||||
hooks = ctx: { "aux:b:env" = lib.dag.entry.after [ "unpack" ] ''export AUX_B=${config.package}''; };
|
||||
|
|
|
|||
44
tidepool/src/packages/aux/c.nix
Normal file
44
tidepool/src/packages/aux/c.nix
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
{ config }:
|
||||
let
|
||||
inherit (config) lib builders packages;
|
||||
in
|
||||
{
|
||||
config.packages.aux.c = {
|
||||
versions = {
|
||||
"latest" =
|
||||
{ config }:
|
||||
{
|
||||
options = {
|
||||
custom = lib.options.create { type = lib.types.bool; };
|
||||
};
|
||||
|
||||
config = {
|
||||
meta = {
|
||||
platforms = [ "i686-linux" ];
|
||||
};
|
||||
|
||||
name = "${config.pname}-${config.version}";
|
||||
|
||||
custom = true;
|
||||
|
||||
pname = "c";
|
||||
version = "1.0.0";
|
||||
|
||||
builder = builders.basic;
|
||||
|
||||
context = {
|
||||
"foundation:cflags" = [ "-I $AUX_C/include" ];
|
||||
};
|
||||
|
||||
hooks = ctx: { "aux:c:env" = lib.dag.entry.after [ "unpack" ] ''export AUX_C=${config.package}''; };
|
||||
|
||||
phases = {
|
||||
install = ''
|
||||
echo "c" > $out
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ in
|
|||
./foundation
|
||||
./aux/a.nix
|
||||
./aux/b.nix
|
||||
./aux/c.nix
|
||||
];
|
||||
|
||||
options = {
|
||||
|
|
@ -55,32 +56,34 @@ 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
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,13 @@ let
|
|||
;
|
||||
in
|
||||
{
|
||||
config.packages.context.options = {
|
||||
"foundation:cflags" = lib.options.create {
|
||||
type = lib.types.list.of lib.types.string;
|
||||
default.value = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
config.packages.foundation.gcc = {
|
||||
versions = {
|
||||
"latest" =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue