Skip to content

Commit

Permalink
refactor(pops/haumea): enhace loadExtendedModule
Browse files Browse the repository at this point in the history
  • Loading branch information
GTrunSec committed Dec 8, 2023
1 parent 1cc46c3 commit abba4b5
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/haumea/nixosModules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ let
in
lazyArgsPerParameter f inputs;

callModuleLazily' =
inputs: path: importer:
let
f = toFunction (importer path);
in
lazyArgsPerParameter f inputs;

removeFileSuffix = l.removeSuffix ".nix";
removeDefault = l.removeSuffix "/default";
relModulePathWithoutDefault = relModulePathWithoutDefault' removeDefault;
Expand Down Expand Up @@ -101,14 +108,6 @@ let
loadSubmodule = path: (mkExtender (callModuleLazily baseModuleArgs path) path);
};

callArgsLazily =
attrs: extraArgs:
if (l.isFunction attrs) then
lazyArgsPerParameter attrs (moduleArgs // extraArgs)
else
attrs
;

mkExtender =
module: path:
let
Expand All @@ -130,9 +129,19 @@ let
[ ]
;

callValueModuleLazily =
v: extraArgs:
if (l.isFunction v) then
lazyArgsPerParameter v (moduleArgs // extraArgs)
else if (l.isPath v) then
callModuleLazily' (moduleArgs // extraArgs) v import
else
v
;

loadExtendModuleFromValue =
if foundItem != [ ] then
(callArgsLazily foundItem.value {
(callValueModuleLazily foundItem.value {
selfModule = module;
# add the options back in
# dmerge self' {}
Expand Down

0 comments on commit abba4b5

Please sign in to comment.