forked from nix-community/nixvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhm.nix
62 lines (61 loc) · 1.42 KB
/
hm.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{
modules,
self,
getHelpers,
}:
{
pkgs,
config,
lib,
...
}@args:
let
inherit (lib)
mkEnableOption
mkOption
mkOptionType
mkMerge
mkIf
types
;
helpers = getHelpers pkgs false;
shared = import ./_shared.nix { inherit modules helpers; } args;
cfg = config.programs.nixvim;
files = shared.configFiles // {
"nvim/init.lua".text = cfg.initContent;
};
in
{
options = {
programs.nixvim = mkOption {
default = { };
type = types.submoduleWith {
shorthandOnlyDefinesConfig = true;
specialArgs = {
hmConfig = config;
inherit helpers;
};
modules = [ (import ./modules/hm.nix { inherit lib; }) ] ++ shared.topLevelModules;
};
};
nixvim.helpers = shared.helpers;
};
config = mkIf cfg.enable (mkMerge [
{
home.packages = [
cfg.finalPackage
cfg.printInitPackage
] ++ (lib.optional cfg.enableMan self.packages.${pkgs.system}.man-docs);
}
(mkIf (!cfg.wrapRc) { xdg.configFile = files; })
{
inherit (cfg) warnings assertions;
home.sessionVariables = mkIf cfg.defaultEditor { EDITOR = "nvim"; };
}
{
programs.bash.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; };
programs.fish.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; };
programs.zsh.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; };
}
]);
}