-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
61: Add option for defining flake-parts modules for downstream flakes. r=roberth a=shlevy Co-authored-by: Shea Levy <[email protected]>
- Loading branch information
Showing
4 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ config, self, lib, flake-parts-lib, ... }: | ||
let | ||
inherit (lib) | ||
filterAttrs | ||
mapAttrs | ||
mkOption | ||
optionalAttrs | ||
types | ||
; | ||
inherit (flake-parts-lib) | ||
mkAliasOptionModule | ||
; | ||
|
||
flakeModulesOption = mkOption { | ||
type = types.lazyAttrsOf types.deferredModule; | ||
default = { }; | ||
apply = mapAttrs (k: v: { | ||
_file = "${toString self.outPath}/flake.nix#flakeModules.${k}"; | ||
imports = [ v ]; | ||
}); | ||
description = '' | ||
flake-parts modules for use by other flakes. | ||
If the flake defines only one module, it should be flakeModules.default. | ||
You can not use this option in defining the flake's own `imports`. Instead, you can | ||
put the module in question into its own file and reference it both in `imports` and | ||
export it with this option. | ||
''; | ||
}; | ||
in | ||
{ | ||
options = { | ||
flake = mkOption { | ||
type = types.submoduleWith { | ||
modules = [ | ||
(mkAliasOptionModule [ "flakeModule" ] [ "flakeModules" "default" ]) | ||
{ | ||
options.flakeModules = flakeModulesOption; | ||
} | ||
]; | ||
}; | ||
}; | ||
}; | ||
} |