featL: builders: automatically select a default builder if none is hardcoded

This commit is contained in:
DavHau 2022-11-15 22:27:28 +01:00
parent 2a35827419
commit 8e40fba809

View File

@ -1,6 +1,8 @@
{config, ...}: let
lib = config.lib;
l = lib // builtins;
defaults = {
# TODO: define a priority in each builder and remove the defaults here.
rust = "build-rust-package";
nodejs = "granular-nodejs";
python = "simple-python";
@ -21,8 +23,11 @@ in {
(
subsystem: builders:
builders
// lib.optionalAttrs (lib.hasAttr subsystem defaults) {
default = builders.${defaults.${subsystem}};
// {
default =
if l.hasAttr subsystem defaults
then builders.${defaults.${subsystem}}
else l.head (l.attrValues builders);
}
)
(funcs.structureBySubsystem config.builders);