-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
87 lines (76 loc) · 2.46 KB
/
flake.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{
description = "A very basic NeoVim flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
nixvim = {
url = "github:nix-community/nixvim";
inputs = {
nixpkgs.follows = "nixpkgs";
# https://github.com/nix-community/nixvim/blob/main/flake.nix#L12-L34
nuschtosSearch.follows = "";
};
};
};
outputs = { self, flake-utils, nixpkgs, nixvim, ... }:
let
mkModules = { config, lib, pkgs }: [
./modules/nixos.nix
# partly copied from https://github.com/nix-community/nixvim/blob/main/wrappers/nixos.nix#L31-L49
{
options.programs.nixvim = lib.mkOption {
type = lib.types.submoduleWith {
modules = [{
imports = [ ./modules ];
}];
};
};
config.programs.nixvim = {
# this unfortunately needs to be here as we cannot access the nixos options inside of nixvim
extraPackages = map (let
mapping = with pkgs; {
golangcilint = golangci-lint;
jsonlint = nodePackages.jsonlint;
nix = config.nix.package;
};
in pkg: if lib.hasAttr pkg mapping then mapping.${pkg} else pkgs.${pkg})
(lib.flatten (lib.attrValues config.programs.nixvim.plugins.lint.lintersByFt));
};
}
];
in
{
homeManagerModules = {
nvim = { config, lib, pkgs, ... }: {
imports = [
nixvim.homeManagerModules.nixvim
] ++ mkModules { inherit config lib pkgs; };
};
default = self.homeManagerModules.nvim;
};
nixosModules = {
nvim = { config, lib, pkgs, ... }: {
imports = [
nixvim.nixosModules.nixvim
] ++ mkModules { inherit config lib pkgs; };
};
default = self.nixosModules.nvim;
};
} // flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
packages = {
nixvimWithOptions = { pkgs, options ? { } } : nixvim.legacyPackages.${system}.makeNixvimWithModule {
module.imports = [
./modules
options
];
inherit pkgs;
};
nixvim = self.packages.${system}.nixvimWithOptions {
inherit pkgs;
};
default = self.packages.${system}.nixvim;
};
});
}