-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflake.nix
101 lines (90 loc) · 2.89 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
{
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?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 {
# 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; [ ];
# Build with NodeJS
withNodeJs = true;
# Passing in raw lua config
configure.customRC = ''
luafile ${neovimConfig}
'';
configure.packages.myVimPackage.start = with prev.vimPlugins; [ ];
};
};
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";
};
});
}