wrappers: removed code duplication

This commit is contained in:
Alexander Nortung 2023-01-20 00:04:53 +01:00
parent 78e7d229a1
commit e0ed2eabf9
4 changed files with 25 additions and 30 deletions

16
wrappers/_shared.nix Normal file
View file

@ -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; };
};
}

View file

@ -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 {

View file

@ -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

View file

@ -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