-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
125 lines (124 loc) · 4.07 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable";
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
treefmt-nix.url = "github:numtide/treefmt-nix";
twoslash-queries-nvim-source = {
url = "github:marilari88/twoslash-queries.nvim";
flake = false;
};
};
outputs = {
self,
nixpkgs,
neovim-nightly-overlay,
treefmt-nix,
twoslash-queries-nvim-source,
}: let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
overlays = [
neovim-nightly-overlay.overlays.default
(final: prev: {
vimPlugins = (prev.lib.foldr (a: b: b.extend a) prev.vimPlugins) [
(import ./overlays/cmp-buffer)
(import ./overlays/cmp-nvim-lsp)
(import ./overlays/cmp-path)
];
})
];
};
in {
packages.${system}.nvim = let
# neovim-nightly-overlay overrides the neovim-unwrapped derivation, but outputs it as neovim
neovim-unwrapped = pkgs.neovim;
auvred-config = pkgs.stdenv.mkDerivation {
name = "auvred-neovim-config";
srcs = [./lua ./plugin];
sourceRoot = ".";
installPhase = ''
mkdir -p $out
cp -r ./. $out
cat << EOF > $out/lua/auvred/nix-generated.lua
local M = {
nixd_server_path = "${pkgs.nixd}/bin/nixd",
typescript_language_server_path = "${pkgs.nodePackages.typescript-language-server}/bin/typescript-language-server",
vue_typescript_plugin_path = "${pkgs.vue-language-server}/lib/node_modules/@vue/language-server/node_modules/@vue/typescript-plugin",
vue_language_server_path = "${pkgs.vue-language-server}/bin/vue-language-server",
clangd_server_path = "${pkgs.clang-tools}/bin/clangd",
}
return M
EOF
'';
};
twoslash-queries-nvim = pkgs.vimUtils.buildVimPlugin {
name = "twoslash-queries-nvim";
src = twoslash-queries-nvim-source;
};
runtimepath = let
flattenDeps = plugins: plugins ++ (pkgs.lib.unique (builtins.concatLists (builtins.map (plugin: flattenDeps (plugin.dependencies or [])) plugins)));
in
flattenDeps ([
auvred-config
twoslash-queries-nvim
]
++ (with pkgs.vimPlugins; [
catppuccin-nvim
nvim-treesitter
nvim-treesitter-context
telescope-nvim
comment-nvim
nvim-lspconfig
(nvim-cmp.overrideAttrs {dependencies = [cmp-nvim-lsp cmp-buffer cmp-path];})
(oil-nvim.overrideAttrs {dependencies = [nvim-web-devicons];})
harpoon2
])
++ builtins.filter pkgs.lib.isDerivation (builtins.attrValues pkgs.vimPlugins.nvim-treesitter-parsers));
initLua = pkgs.writeTextDir "auvred-nvim-config-init.lua" (
builtins.concatStringsSep "\n" (builtins.map (p: "vim.opt.rtp:append('${p}')") runtimepath)
+ ''
require('auvred')
''
);
makeWrapperArgs = [
"${neovim-unwrapped}/bin/nvim"
"${placeholder "out"}/bin/nvim"
"--add-flags"
"-u ${initLua}/auvred-nvim-config-init.lua"
];
in
pkgs.stdenv.mkDerivation {
name = "neovim";
dontUnpack = true;
buildPhase = ''
runHook preBuild
mkdir -p $out
for i in ${neovim-unwrapped}; do
lndir -silent $i $out
done
runHook postBuild
'';
postBuild = ''
rm $out/bin/nvim
makeWrapper ${pkgs.lib.escapeShellArgs makeWrapperArgs}
'';
nativeBuildInputs = [pkgs.makeWrapper pkgs.xorg.lndir];
};
apps.${system}.default = {
type = "app";
program = "${self.packages.${system}.nvim}/bin/nvim";
};
formatter.${system} =
(treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs = {
alejandra.enable = true;
stylua.enable = true;
};
})
.config
.build
.wrapper;
};
}