Skip to content

Commit

Permalink
refactor: allow config to use string, use mkLuaInline internally
Browse files Browse the repository at this point in the history
  • Loading branch information
nekowinston committed Mar 12, 2024
1 parent cf4479c commit b05b3cc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions modules/plugins/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
}:
with lib; let
inherit (flake-parts-lib) mkPerSystemOption;
isLuaInline = e: isAttrs e && matchAttrs {_type = "lua-inline";} e;
pluginSpec = with types; {
options = {
src = mkOption {
Expand Down Expand Up @@ -33,7 +32,7 @@ with lib; let
default = null;
};
config = mkOption {
type = nullOr (oneOf [attrs bool package path]);
type = nullOr (oneOf [attrs bool package path str]);
default = null;
};
opts = mkOption {
Expand Down Expand Up @@ -156,13 +155,16 @@ in {
// optionalAttrs (isDerivation attrs.init || isPath attrs.init) {
init = lib.generators.mkLuaInline ''dofile "${attrs.init}"'';
}
// optionalAttrs (isBool attrs.config || isLuaInline attrs.config) {
// optionalAttrs (isBool attrs.config) {
inherit (attrs) config;
}
// optionalAttrs (isString attrs.config) {
config = lib.generators.mkLuaInline attrs.config;
}
// optionalAttrs (isDerivation attrs.config || isPath attrs.config) {
config = lib.generators.mkLuaInline ''dofile "${attrs.config}"'';
}
// optionalAttrs (lib.isAttrs attrs.config && !(isLuaInline attrs.config)) {
// optionalAttrs (isAttrs attrs.config) {
config = true;
opts = attrs.config;
}
Expand Down

0 comments on commit b05b3cc

Please sign in to comment.