-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathshell.nix
43 lines (39 loc) · 1.07 KB
/
shell.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
{ pkgs ? import <nixpkgs> {
overlays = [
(import (fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"))
];
}
}:
let vimLspDeps =
if builtins.getEnv("NIX_VIM_LSP_ENABLED") == "yes"
then ["rust-analyzer" "nodejs-18_x"]
else [];
in
pkgs.mkShell {
nativeBuildInputs = with pkgs; (
builtins.concatLists[
[
rust-bin.stable.latest.default
pkg-config
openssl
]
(lib.attrVals vimLspDeps pkgs)
]);
shellHook = if builtins.getEnv("NIX_VIM_LSP_ENABLED") == "yes" then
''
mkdir -p .vim
coc_settings_target=.vim/coc-settings.json
[[ ! -f $coc_settings_target || -L $coc_settings_target ]] || {
echo "warn: cannot setup rust-analyzer path for vim coc, $coc_settings_target is not a symlink and may contain information that should not be overwritten" >&2
return
}
coc="`mktemp`"
cat <<EOF > "$coc"
{
"rust-analyzer.server.path": "`which rust-analyzer`"
}
EOF
ln -sf "$coc" $coc_settings_target
''
else "";
}