-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkModule.nix
47 lines (47 loc) · 1.17 KB
/
mkModule.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
{nixos ? false}: {
lib,
pkgs,
config,
...
}:
with lib; let
cfg = config.programs.nvim;
mkNvimPkg = pkgs.callPackage (import ./package);
neovimPackage = mkNvimPkg {
inherit (cfg) package configuration modules;
};
in {
options.programs.nvim = {
enable = mkEnableOption (lib.mdDoc "A lazy.nvim-based neovim configuration");
package = mkOption {
type = types.package;
default = pkgs.neovim-unwrapped;
description = "Neovim package to use in the underlying derivation";
};
modules = mkOption {
# TODO: stricter typechecking?
type = types.listOf types.anything;
default = [];
description = "Additional modules to pass to the underlying derivation";
};
configuration = mkOption {
type = types.attrs;
default = {};
description = "Top-level plugin configuration to pass to the underlying derivation";
};
};
config = let
homeConfiguration = {
home.packages = [neovimPackage];
};
nixosConfiguration = {
environment.systemPackages = [neovimPackage];
};
in
mkIf cfg.enable
(
if nixos
then nixosConfiguration
else homeConfiguration
);
}