diff --git a/wrappers/_shared.nix b/wrappers/_shared.nix new file mode 100644 index 00000000..6ebe609f --- /dev/null +++ b/wrappers/_shared.nix @@ -0,0 +1,16 @@ +{ lib, ... }: + +let + inherit (lib) mkEnableOption mkOption mkOptionType mkForce mkMerge mkIf types; +in +{ + helpers = mkOption { + type = mkOptionType { + name = "helpers"; + description = "Helpers that can be used when writing nixvim configs"; + check = builtins.isAttrs; + }; + description = "Use this option to access the helpers"; + default = import ../plugins/helpers.nix { inherit (pkgs) lib; }; + }; +} diff --git a/wrappers/darwin.nix b/wrappers/darwin.nix index 75365711..1a51535b 100644 --- a/wrappers/darwin.nix +++ b/wrappers/darwin.nix @@ -1,8 +1,9 @@ modules: -{ pkgs, config, lib, ... }: +{ pkgs, config, lib, ... }@args: let inherit (lib) mkEnableOption mkOption mkOptionType mkForce mkMerge mkIf types; + shared = import ./_shared.nix args; cfg = config.programs.nixvim; in { @@ -13,15 +14,7 @@ in config.wrapRc = mkForce true; }]); }; - nixvim.helpers = mkOption { - type = mkOptionType { - name = "helpers"; - description = "Helpers that can be used when writing nixvim configs"; - check = builtins.isAttrs; - }; - description = "Use this option to access the helpers"; - default = import ../plugins/helpers.nix { inherit (pkgs) lib; }; - }; + nixvim.helpers = shared.helpers; }; config = mkIf cfg.enable { diff --git a/wrappers/hm.nix b/wrappers/hm.nix index e10b63ca..82dd8245 100644 --- a/wrappers/hm.nix +++ b/wrappers/hm.nix @@ -1,8 +1,9 @@ modules: -{ pkgs, config, lib, ... }: +{ pkgs, config, lib, ... }@args: let inherit (lib) mkEnableOption mkOption mkOptionType mkMerge mkIf types; + shared = import ./_shared.nix args; cfg = config.programs.nixvim; in { @@ -12,15 +13,7 @@ in options.enable = mkEnableOption "nixvim"; }]); }; - nixvim.helpers = mkOption { - type = mkOptionType { - name = "helpers"; - description = "Helpers that can be used when writing nixvim configs"; - check = builtins.isAttrs; - }; - description = "Use this option to access the helpers"; - default = import ../plugins/helpers.nix { inherit (pkgs) lib; }; - }; + nixvim.helpers = shared.helpers; }; config = mkIf cfg.enable diff --git a/wrappers/nixos.nix b/wrappers/nixos.nix index f0474eea..cfd1f905 100644 --- a/wrappers/nixos.nix +++ b/wrappers/nixos.nix @@ -1,8 +1,9 @@ modules: -{ pkgs, config, lib, ... }: +{ pkgs, config, lib, ... }@args: let inherit (lib) mkEnableOption mkOption mkOptionType mkMerge mkIf types; + shared = import ./_shared.nix args; cfg = config.programs.nixvim; in { @@ -12,15 +13,7 @@ in options.enable = mkEnableOption "nixvim"; }]); }; - nixvim.helpers = mkOption { - type = mkOptionType { - name = "helpers"; - description = "Helpers that can be used when writing nixvim configs"; - check = builtins.isAttrs; - }; - description = "Use this option to access the helpers"; - default = import ../plugins/helpers.nix { inherit (pkgs) lib; }; - }; + nixvim.helpers = shared.helpers; }; config = mkIf cfg.enable