mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-09-19 18:37:49 +03:00
feat: use modules for builders
This commit is contained in:
parent
b54f6403f4
commit
f348abd9e5
@ -242,9 +242,9 @@ in let
|
||||
findBuilder = dreamLock: let
|
||||
subsystem = dreamLock._generic.subsystem;
|
||||
in
|
||||
if ! subsystems."${subsystem}" ? builders
|
||||
if ! framework.buildersBySubsystem.${subsystem} ? default
|
||||
then throw "Could not find any builder for subsystem '${subsystem}'"
|
||||
else subsystems."${subsystem}".builders.default;
|
||||
else framework.buildersBySubsystem.${subsystem}.default;
|
||||
|
||||
# detect if granular or combined fetching must be used
|
||||
findFetcher = dreamLock:
|
||||
@ -394,7 +394,7 @@ in let
|
||||
if builder == null
|
||||
then findBuilder dreamLock
|
||||
else if l.isString builder
|
||||
then subsystems.${dreamLock._generic.subsystem}.builders.${builder}
|
||||
then framework.buildersBySubsystem.${dreamLock._generic.subsystem}.${builder}
|
||||
else builder;
|
||||
|
||||
fetcher' =
|
||||
|
5
src/modules/builders/builder/default.nix
Normal file
5
src/modules/builders/builder/default.nix
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
imports = [
|
||||
./interface.nix
|
||||
];
|
||||
}
|
37
src/modules/builders/builder/interface.nix
Normal file
37
src/modules/builders/builder/interface.nix
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
t = lib.types;
|
||||
in {
|
||||
options = {
|
||||
disabled = lib.mkOption {
|
||||
type = t.bool;
|
||||
default = false;
|
||||
description = "Whether to disable the builder, if disabled it can't be used.";
|
||||
};
|
||||
name = lib.mkOption {
|
||||
type = t.str;
|
||||
description = "Name of the builder.";
|
||||
};
|
||||
subsystem = lib.mkOption {
|
||||
type = t.str;
|
||||
description = "Subsystem of the builder.";
|
||||
};
|
||||
build = lib.mkOption {
|
||||
type = t.function (t.functionTo t.attrs);
|
||||
default = _: _: {};
|
||||
};
|
||||
type = lib.mkOption {
|
||||
type = t.enum [
|
||||
"pure"
|
||||
"ifd"
|
||||
];
|
||||
};
|
||||
version = lib.mkOption {
|
||||
type = t.int;
|
||||
default = 2;
|
||||
};
|
||||
};
|
||||
}
|
6
src/modules/builders/default.nix
Normal file
6
src/modules/builders/default.nix
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
imports = [
|
||||
./implementation.nix
|
||||
./interface.nix
|
||||
];
|
||||
}
|
22
src/modules/builders/implementation.nix
Normal file
22
src/modules/builders/implementation.nix
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
config,
|
||||
callPackageDream,
|
||||
...
|
||||
}: let
|
||||
loader = b: b // {build = callPackageDream b.build;};
|
||||
funcs = config.functions.subsystem-loading;
|
||||
collectedModules = funcs.collect "builders";
|
||||
in {
|
||||
config = {
|
||||
# The user can add more translators by extending this attribute
|
||||
builders = funcs.import_ collectedModules;
|
||||
|
||||
/*
|
||||
translators wrapped with extra logic to add extra attributes,
|
||||
like .translateBin for pure translators
|
||||
*/
|
||||
builderInstances = funcs.instantiate config.builders loader;
|
||||
|
||||
buildersBySubsystem = funcs.structureBySubsystem config.builderInstances;
|
||||
};
|
||||
}
|
25
src/modules/builders/interface.nix
Normal file
25
src/modules/builders/interface.nix
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
lib,
|
||||
specialArgs,
|
||||
...
|
||||
}: let
|
||||
t = lib.types;
|
||||
in {
|
||||
options = {
|
||||
builders = lib.mkOption {
|
||||
type = t.attrsOf (t.submoduleWith {
|
||||
modules = [./builder/default.nix];
|
||||
inherit specialArgs;
|
||||
});
|
||||
description = ''
|
||||
builder module definitions
|
||||
'';
|
||||
};
|
||||
builderInstances = lib.mkOption {
|
||||
type = t.attrsOf t.anything;
|
||||
};
|
||||
buildersBySubsystem = lib.mkOption {
|
||||
type = t.attrsOf (t.attrsOf t.anything);
|
||||
};
|
||||
};
|
||||
}
|
@ -9,6 +9,7 @@ in {
|
||||
./functions.subsystem-loading
|
||||
./functions.translators
|
||||
./translators
|
||||
./builders
|
||||
];
|
||||
options = {
|
||||
lib = lib.mkOption {
|
||||
|
Loading…
Reference in New Issue
Block a user