-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
144 lines (134 loc) · 3.94 KB
/
flake.nix
File metadata and controls
144 lines (134 loc) · 3.94 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
136
137
138
139
140
141
142
143
144
{
description = "My neovim flake";
# Enable binary cache from nix-community to download pre-built packages,
# such as neovim-nightly-overlay, instead of building them locally.
nixConfig.extra-substituters = [
"https://nix-community.cachix.org"
];
nixConfig.extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# Required to creates outputs for all supported systems
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
inputs.neovim-nightly-overlay.inputs.nixpkgs.follows = "nixpkgs";
outputs =
{
self,
nixpkgs,
flake-utils,
...
}@inputs:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
inputs.neovim-nightly-overlay.overlays.default
];
};
neovim-override = pkgs.neovim.override {
# withPython3 = true;
# withNodeJs = true;
# package = pkgs.neovim-nightly;
};
wrapper = with pkgs; ''
rm $out/bin/nvim
makeWrapper ${neovim-override}/bin/nvim $out/bin/nvim --prefix PATH : ${
lib.makeBinPath [
fzf
sox
typescript-language-server
bash-language-server
eslint
eslint_d
biome
vue-language-server
pyright
vscode-langservers-extracted
yaml-language-server
lua-language-server
selene
marksman
ccls
nil
alejandra
nixfmt-rfc-style
shfmt
shellcheck
shellharden
terraform-ls
gopls
delve
rust-analyzer
taplo
black
isort
stylua
harper
jsonnet-language-server
# typos-lsp
]
} \
--set XDG_CONFIG_HOME "$out/.config"
'';
neovim-dev =
{
configPath ? builtins.getEnv "NVIM_CONFIG_DIR",
}:
pkgs.symlinkJoin {
name = "nvim";
paths = [ neovim-override ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
mkdir -p $out/.config
ln -sf ${configPath} $out/.config/nvim
${wrapper}
'';
};
neovim = pkgs.symlinkJoin {
name = "nvim";
paths = [ neovim-override ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
mkdir -p $out/.config
cp -r ${./config} $out/.config/nvim
${wrapper}
'';
};
in
{
# Bundled mode
apps.default.type = "app";
apps.default.program = "${neovim}/bin/nvim";
packages.default = neovim;
# Dev mode
apps.dev.type = "app";
apps.dev.program = "${neovim-dev { }}/bin/nvim";
packages.dev.default = neovim-dev { };
packages.dev.options = neovim-dev;
devShells.default = pkgs.mkShell {
buildInputs = [
pkgs.stylua
pkgs.nixfmt-rfc-style
(pkgs.writeShellScriptBin "dev" ''
NVIM_CONFIG_DIR="$PWD/config" nix run .#dev --impure "$@"
'')
(pkgs.writeShellScriptBin "h" ''
echo "type 'dev' to run neovim in development mode"
echo "type 'bdl' to run neovim in bundled mode"
echo "type 'h' for help"
'')
(pkgs.writeShellScriptBin "bdl" ''
nix run . "$@"
'')
];
shellHook = ''
h
'';
};
}
);
}