nixible/lib/flakeModule.nix

34 lines
807 B
Nix
Raw Normal View History

2025-07-15 19:28:42 +02:00
{
flake-parts-lib,
lib,
...
}: let
inherit (lib) mkOption types;
in {
options.perSystem = flake-parts-lib.mkPerSystemOption (
{
config,
pkgs,
...
}: let
nixible-lib = import ./. {inherit pkgs lib;};
in {
options.nixible = mkOption {
type = types.attrsOf (types.submodule (args:
# needed to get pkgs in there, weirdly enough
import nixible-lib.module (args
// {
inherit pkgs;
})));
default = {};
};
config.legacyPackages = lib.fold (playbook: acc: acc // playbook) {} (
map (playbook_name: {
"nixible:${playbook_name}" = (builtins.getAttr playbook_name config.nixible).cli;
}) (builtins.attrNames config.nixible)
);
}
);
}