Skip to content

Commit

Permalink
feat: use a custom loader for haumea
Browse files Browse the repository at this point in the history
This patch replaces the scoped loader used in `load` with a custom
version that can resolve module arguments as well.
  • Loading branch information
korrat committed Mar 15, 2024
1 parent a976da4 commit 32b53a0
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,30 @@
src,
}:
# modules/profiles are always functions
args @ {pkgs, ...}: let
args @ {
config,
pkgs,
...
}: let
cr = cell.__cr ++ [(baseNameOf src)];
file = "${self.outPath}#${lib.concatStringsSep "/" cr}";

defaultWith = importer: inputs: path: lib.modules.applyModuleArgsIfFunction file (importer path) inputs;
loader = inputs: defaultWith (scopedImport inputs) inputs;
i = args // {inherit cell inputs;};
defaultWith = import (haumea + /src/loaders/__defaultWith.nix) {inherit lib;};
loader = defaultWith (scopedImport i) i;
in
if lib.pathIsDirectory src
then
lib.setDefaultModuleLocation file (haumea.lib.load {
inherit src;
loader = haumea.lib.loaders.scoped;
inherit loader src;
transformer = with haumea.lib.transformers; [
liftDefault
(hoistLists "_imports" "imports")
];
inputs = i;
})
# Mimic haumea for a regular file
else lib.setDefaultModuleLocation file (loader src);
else lib.setDefaultModuleLocation file (loader i src);

findLoad = {
inputs,
Expand Down

0 comments on commit 32b53a0

Please sign in to comment.