feat: add a warning when collecting modules if two modules have same names

This commit is contained in:
Yusuf Bera Ertan 2022-09-25 22:41:56 +03:00
parent 16d9dde731
commit 3a6ebd75ef
No known key found for this signature in database
GPG Key ID: 1D8F8FAF2294D6EA
3 changed files with 16 additions and 1 deletions

View File

@ -10,6 +10,7 @@
python = "simple-python";
php = "granular-php";
haskell = "simple-haskell";
debian = "simple-debian";
};
loader = b: b // {build = callPackageDream b.build {};};
funcs = config.functions.subsystem-loading;

View File

@ -44,7 +44,21 @@ modules:
(name: description:
(import description.path {inherit dlib lib;})
// {inherit (description) name subsystem;})
(lib.listToAttrs collectedModules);
(
lib.foldl'
(
all: el:
if lib.hasAttr el.name all
then
throw ''
module named ${el.name} in subsystem ${el.value.subsystem} conflicts
with a module with the same name from subsystem ${all.${el.name}.subsystem}
''
else all // {${el.name} = el.value;}
)
{}
collectedModules
);
instantiate = importedModules: loader:
lib.mapAttrs