feat: expose capabilities in top-level config

This commit is contained in:
Ruby Iris Juric 2025-10-03 00:05:23 +10:00 committed by Victor Fuentes
parent b90aeab27f
commit c46d759e87
Signed by: vlinkz
GPG key ID: DF727B8D5AF99C64
4 changed files with 60 additions and 38 deletions

View file

@ -49,6 +49,7 @@ let
};
in
new [
./src/capabilities
./src/packages
./src/builders/foundation/basic.nix
]

View file

@ -0,0 +1,18 @@
{ config }:
let
inherit (config) lib;
in
{
includes = [
./make.nix
];
options = {
capabilities = lib.options.create {
description = "A set of capabilities that can be added to packages to provide build functionality.";
# TODO: define proper type
type = lib.types.attrs.of (lib.types.function lib.types.any);
default.value = { };
};
};
}

View file

@ -1,40 +1,42 @@
{ config, global }:
let
inherit (global)
lib
packages
;
in
{
options.make = {
flags = lib.options.create {
description = "List of flags to pass to make.";
type = lib.types.list.of lib.types.string;
default.value = [ ];
};
};
config = {
deps.build.build = {
gnumake =
if (config.platform.build == "i686-linux") then
packages.foundation.gnumake.versions."4.4.1-bootstrap"
else
packages.foundation.gnumake.versions."4.4.1-stage1-passthrough";
};
phases =
let
makeFlags = builtins.concatStringsSep " " config.make.flags;
in
{
makeBuild = lib.dag.entry.before [ "build" ] ''
make -j $NIX_BUILD_CORES ${makeFlags}
'';
makeInstall = lib.dag.entry.before [ "install" ] ''
make -j $NIX_BUILD_CORES install ${makeFlags}
'';
config.capabilities.make =
{ config, global, ... }:
let
inherit (global)
lib
packages
;
in
{
options.make = {
flags = lib.options.create {
description = "List of flags to pass to make.";
type = lib.types.list.of lib.types.string;
default.value = [ ];
};
};
};
config = {
deps.build.build = {
gnumake =
if (config.platform.build == "i686-linux") then
packages.foundation.gnumake.versions."4.4.1-bootstrap"
else
packages.foundation.gnumake.versions."4.4.1-stage1-passthrough";
};
phases =
let
makeFlags = builtins.concatStringsSep " " config.make.flags;
in
{
makeBuild = lib.dag.entry.before [ "build" ] ''
make -j $NIX_BUILD_CORES ${makeFlags}
'';
makeInstall = lib.dag.entry.before [ "install" ] ''
make -j $NIX_BUILD_CORES install ${makeFlags}
'';
};
};
};
}

View file

@ -3,6 +3,7 @@
let
inherit (global)
lib
capabilities
packages
builders
mirrors
@ -17,7 +18,7 @@ let
in
{
includes = [
../../../../capabilities/make.nix
capabilities.make
];
config = {