-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathflake.nix
More file actions
135 lines (120 loc) · 4.01 KB
/
flake.nix
File metadata and controls
135 lines (120 loc) · 4.01 KB
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
126
127
128
129
130
131
132
133
134
135
{
description = "Tutorial Flake accompanying vimconf talk.";
# Input source for our derivation
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/master";
flake-utils.url = "github:numtide/flake-utils";
DSL.url = "github:DieracDelta/nix2lua";
nix2vim = {
url = "github:gytis-ivaskevicius/nix2vim";
inputs.nixpkgs.follows = "nixpkgs";
};
neovim = {
url =
"github:neovim/neovim?rev=88336851ee1e9c3982195592ae2fc145ecfd3369&dir=contrib";
inputs.nixpkgs.follows = "nixpkgs";
};
telescope-src = {
url =
"github:nvim-telescope/telescope.nvim?rev=b5c63c6329cff8dd8e23047eecd1f581379f1587";
flake = false;
};
dracula-nvim = {
url = "github:Mofiqul/dracula.nvim";
flake = false;
};
nvim-cmp = {
url = "github:hrsh7th/nvim-cmp";
flake = false;
};
cmp-nvim-lsp = {
url = "github:hrsh7th/cmp-nvim-lsp";
flake = false;
};
cmp-buffer = {
url = "github:hrsh7th/cmp-buffer";
flake = false;
};
rnix-lsp = {
url = "github:nix-community/rnix-lsp";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ self, flake-utils, nixpkgs, home-manager, neovim
, dracula-nvim, nix2vim, DSL, ... }:
let
# Function to override the source of a package
withSrc = pkg: src: pkg.overrideAttrs (_: { inherit src; });
# Vim2Nix DSL
dsl = nix2vim.lib.dsl;
overlay = prev: final: rec {
# Example of packaging plugin with Nix
dracula = prev.vimUtils.buildVimPluginFrom2Nix {
pname = "dracula-nvim";
version = "master";
src = dracula-nvim;
};
# Generate our init.lua from neoConfig using vim2nix transpiler
neovimConfig = let
luaConfig = prev.luaConfigBuilder {
config = import ./neoConfig.nix {
inherit (nix2vim.lib) dsl;
pkgs = prev;
};
};
in prev.writeText "init.lua" luaConfig.lua;
# Building neovim package with dependencies and custom config
customNeovim = DSL.neovimBuilderWithDeps.legacyWrapper neovim.defaultPackage.x86_64-linux {
# Dependencies to be prepended to PATH env variable at runtime. Needed by plugins at runtime.
extraRuntimeDeps = with prev; [
ripgrep
clang
rust-analyzer
inputs.rnix-lsp.defaultPackage.x86_64-linux
];
# Build with NodeJS
withNodeJs = true;
# Passing in raw lua config
configure.customRC = ''
colorscheme dracula
luafile ${neovimConfig}
'';
configure.packages.myVimPackage.start = with prev.vimPlugins; [
# Adding reference to our custom plugin
dracula
# Overwriting plugin sources with different version
(withSrc telescope-nvim inputs.telescope-src)
(withSrc cmp-buffer inputs.cmp-buffer)
(withSrc nvim-cmp inputs.nvim-cmp)
(withSrc cmp-nvim-lsp inputs.cmp-nvim-lsp)
# Plugins from nixpkgs
lsp_signature-nvim
lspkind-nvim
nerdcommenter
nvim-lspconfig
plenary-nvim
popup-nvim
# Compile syntaxes into treesitter
(prev.vimPlugins.nvim-treesitter.withPlugins
(plugins: with plugins; [ tree-sitter-nix tree-sitter-rust ]))
];
};
};
in flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ nix2vim.overlay overlay ];
};
in {
# The packages: our custom neovim and the config text file
packages = { inherit (pkgs) customNeovim neovimConfig; };
# The package built by `nix build .`
defaultPackage = pkgs.customNeovim;
# The app run by `nix run .`
defaultApp = {
type = "app";
program = "${pkgs.customNeovim}/bin/nvim";
};
});
}