fix: allow modules modules that are not functions
This commit is contained in:
parent
63a1abf65b
commit
1ee256fa62
3 changed files with 27 additions and 7 deletions
|
|
@ -18,7 +18,7 @@ core-inputs: user-options: let
|
|||
|
||||
user-inputs = user-options.inputs // {src = user-options.src;};
|
||||
|
||||
inherit (core-inputs.nixpkgs.lib) assertMsg fix filterAttrs mergeAttrs fold recursiveUpdate callPackageWith;
|
||||
inherit (core-inputs.nixpkgs.lib) assertMsg fix filterAttrs mergeAttrs fold recursiveUpdate callPackageWith isFunction;
|
||||
|
||||
# Recursively merge a list of attribute sets.
|
||||
# Type: [Attrs] -> Attrs
|
||||
|
|
@ -58,7 +58,7 @@ core-inputs: user-options: let
|
|||
core-inputs-libs = get-libs (without-self core-inputs);
|
||||
user-inputs-libs = get-libs (without-self user-inputs);
|
||||
|
||||
# NOTE: This root is different to accomodate the creation
|
||||
# NOTE: This root is different to accommodate the creation
|
||||
# of a fake user-lib in order to run documentation on this flake.
|
||||
snowfall-lib-root = "${core-inputs.src}/snowfall-lib";
|
||||
snowfall-lib-dirs = let
|
||||
|
|
@ -103,7 +103,15 @@ core-inputs: user-options: let
|
|||
};
|
||||
libs =
|
||||
builtins.map
|
||||
(path: callPackageWith attrs path {})
|
||||
(
|
||||
path: let
|
||||
imported-module = import path;
|
||||
in
|
||||
if isFunction imported-module
|
||||
then callPackageWith attrs path {}
|
||||
# the only difference is that there is no `override` and `overrideDerivation` on returned value
|
||||
else imported-module
|
||||
)
|
||||
user-lib-modules;
|
||||
in
|
||||
merge-deep libs
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
snowfall-lib,
|
||||
snowfall-config,
|
||||
}: let
|
||||
inherit (core-inputs.nixpkgs.lib) assertMsg fix fold filterAttrs callPackageWith;
|
||||
inherit (core-inputs.nixpkgs.lib) fix filterAttrs callPackageWith isFunction;
|
||||
|
||||
core-inputs-libs = snowfall-lib.flake.get-libs (snowfall-lib.flake.without-self core-inputs);
|
||||
user-inputs-libs = snowfall-lib.flake.get-libs (snowfall-lib.flake.without-self user-inputs);
|
||||
|
|
@ -34,7 +34,15 @@
|
|||
};
|
||||
libs =
|
||||
builtins.map
|
||||
(path: callPackageWith attrs path {})
|
||||
(
|
||||
path: let
|
||||
imported-module = import path;
|
||||
in
|
||||
if isFunction imported-module
|
||||
then callPackageWith attrs path {}
|
||||
# the only difference is that there is no `override` and `overrideDerivation` on returned value
|
||||
else imported-module
|
||||
)
|
||||
user-lib-modules;
|
||||
in
|
||||
snowfall-lib.attrs.merge-deep libs
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
snowfall-config,
|
||||
}: let
|
||||
inherit (builtins) baseNameOf;
|
||||
inherit (core-inputs.nixpkgs.lib) assertMsg foldl mapAttrs hasPrefix;
|
||||
inherit (core-inputs.nixpkgs.lib) foldl mapAttrs hasPrefix isFunction;
|
||||
|
||||
user-modules-root = snowfall-lib.fs.get-snowfall-file "modules";
|
||||
in {
|
||||
|
|
@ -67,7 +67,11 @@ in {
|
|||
|
||||
inputs = snowfall-lib.flake.without-src user-inputs;
|
||||
};
|
||||
user-module = import metadata.path modified-args;
|
||||
imported-user-module = import metadata.path;
|
||||
user-module =
|
||||
if isFunction imported-user-module
|
||||
then imported-user-module modified-args
|
||||
else imported-user-module;
|
||||
in
|
||||
user-module // {_file = metadata.path;};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue