mirror of
https://github.com/hercules-ci/flake-parts.git
synced 2024-12-15 17:50:53 +00:00
Add lib.defaultModule for extracting the default flakeModule
This commit is contained in:
parent
f3c79bef3b
commit
3c60ce7d7e
1 changed files with 17 additions and 0 deletions
17
lib.nix
17
lib.nix
|
@ -22,6 +22,12 @@ let
|
||||||
submoduleWith
|
submoduleWith
|
||||||
;
|
;
|
||||||
|
|
||||||
|
# Polyfill isFlake until Nix with https://github.com/NixOS/nix/pull/7207 is common
|
||||||
|
isFlake = maybeFlake:
|
||||||
|
if maybeFlake ? _type
|
||||||
|
then maybeFlake._type == "flake"
|
||||||
|
else maybeFlake ? inputs && maybeFlake ? outputs && maybeFlake ? sourceInfo;
|
||||||
|
|
||||||
# Polyfill functionTo to make sure it has type merging.
|
# Polyfill functionTo to make sure it has type merging.
|
||||||
# Remove 2022-12
|
# Remove 2022-12
|
||||||
functionTo =
|
functionTo =
|
||||||
|
@ -118,6 +124,17 @@ let
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Function to extract the default flakeModule from
|
||||||
|
# what may be a flake, returning the argument unmodified
|
||||||
|
# if it's not a flake.
|
||||||
|
#
|
||||||
|
# Useful to map over an 'imports' list to make it less
|
||||||
|
# verbose in the common case.
|
||||||
|
defaultModule = maybeFlake:
|
||||||
|
if isFlake maybeFlake
|
||||||
|
then maybeFlake.flakeModules.default or maybeFlake
|
||||||
|
else maybeFlake;
|
||||||
|
|
||||||
mkFlake = args: module:
|
mkFlake = args: module:
|
||||||
(flake-parts-lib.evalFlakeModule args module).config.flake;
|
(flake-parts-lib.evalFlakeModule args module).config.flake;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue