2020-12-09 01:15:37 -07:00
|
|
|
{
|
|
|
|
description = "Neovim flake";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
2021-01-05 13:12:21 -07:00
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
2020-12-09 01:15:37 -07:00
|
|
|
};
|
|
|
|
|
2021-01-05 13:12:21 -07:00
|
|
|
outputs = { self, nixpkgs, flake-utils }:
|
|
|
|
{
|
|
|
|
overlay = final: prev:
|
|
|
|
let
|
|
|
|
pkgs = nixpkgs.legacyPackages.${prev.system};
|
|
|
|
in
|
|
|
|
rec {
|
|
|
|
neovim = pkgs.neovim-unwrapped.overrideAttrs (oa: {
|
|
|
|
version = "master";
|
|
|
|
src = ../.;
|
2022-05-02 03:17:38 -07:00
|
|
|
|
|
|
|
buildInputs = oa.buildInputs ++ pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [
|
|
|
|
CoreServices
|
|
|
|
]);
|
2021-01-05 13:12:21 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
# a development binary to help debug issues
|
2022-09-02 15:13:39 -07:00
|
|
|
neovim-debug =
|
|
|
|
let
|
|
|
|
stdenv = if pkgs.stdenv.isLinux then pkgs.llvmPackages_latest.stdenv else pkgs.stdenv;
|
|
|
|
in
|
2021-08-30 02:55:02 -07:00
|
|
|
((neovim.override {
|
2022-09-02 15:13:39 -07:00
|
|
|
lua = pkgs.luajit;
|
|
|
|
inherit stdenv;
|
|
|
|
}).overrideAttrs (oa: {
|
2021-08-30 02:55:02 -07:00
|
|
|
|
2022-09-02 15:13:39 -07:00
|
|
|
dontStrip = true;
|
|
|
|
NIX_CFLAGS_COMPILE = " -ggdb -Og";
|
2021-08-30 02:55:02 -07:00
|
|
|
|
2022-09-02 15:13:39 -07:00
|
|
|
cmakeBuildType = "Debug";
|
|
|
|
cmakeFlags = oa.cmakeFlags ++ [
|
|
|
|
"-DMIN_LOG_LEVEL=0"
|
|
|
|
];
|
2021-02-17 10:58:40 -07:00
|
|
|
|
2022-09-02 15:13:39 -07:00
|
|
|
disallowedReferences = [ ];
|
|
|
|
}));
|
2021-01-05 13:12:21 -07:00
|
|
|
|
2021-07-10 08:48:59 -07:00
|
|
|
# for neovim developers, beware of the slow binary
|
2021-01-05 13:12:21 -07:00
|
|
|
neovim-developer =
|
|
|
|
let
|
|
|
|
lib = nixpkgs.lib;
|
|
|
|
luacheck = pkgs.luaPackages.luacheck;
|
|
|
|
in
|
|
|
|
(neovim-debug.override ({ doCheck = pkgs.stdenv.isLinux; })).overrideAttrs (oa: {
|
|
|
|
cmakeFlags = oa.cmakeFlags ++ [
|
|
|
|
"-DLUACHECK_PRG=${luacheck}/bin/luacheck"
|
|
|
|
"-DMIN_LOG_LEVEL=0"
|
|
|
|
"-DENABLE_LTO=OFF"
|
2021-02-22 13:02:29 -07:00
|
|
|
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [
|
2021-01-05 13:12:21 -07:00
|
|
|
# https://github.com/google/sanitizers/wiki/AddressSanitizerFlags
|
|
|
|
# https://clang.llvm.org/docs/AddressSanitizer.html#symbolizing-the-reports
|
|
|
|
"-DCLANG_ASAN_UBSAN=ON"
|
|
|
|
];
|
|
|
|
});
|
|
|
|
};
|
|
|
|
} //
|
|
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
overlays = [ self.overlay ];
|
|
|
|
inherit system;
|
|
|
|
};
|
2021-07-10 08:48:59 -07:00
|
|
|
|
2022-09-02 15:13:39 -07:00
|
|
|
lua = pkgs.lua5_1;
|
|
|
|
|
|
|
|
pythonEnv = pkgs.python3.withPackages (ps: [
|
2021-07-10 08:48:59 -07:00
|
|
|
ps.msgpack
|
2022-09-02 15:13:39 -07:00
|
|
|
ps.flake8 # for 'make pylint'
|
2021-07-10 08:48:59 -07:00
|
|
|
]);
|
2020-12-09 01:15:37 -07:00
|
|
|
in
|
2021-01-05 13:12:21 -07:00
|
|
|
rec {
|
2020-12-09 01:15:37 -07:00
|
|
|
|
2021-01-05 13:12:21 -07:00
|
|
|
packages = with pkgs; {
|
|
|
|
inherit neovim neovim-debug neovim-developer;
|
|
|
|
};
|
2020-12-09 01:15:37 -07:00
|
|
|
|
2021-07-10 08:48:59 -07:00
|
|
|
checks = {
|
2022-09-02 15:13:39 -07:00
|
|
|
pylint = pkgs.runCommandNoCC "pylint"
|
|
|
|
{
|
|
|
|
nativeBuildInputs = [ pythonEnv ];
|
|
|
|
preferLocalBuild = true;
|
2021-07-10 08:48:59 -07:00
|
|
|
} "make -C ${./..} pylint > $out";
|
|
|
|
|
2022-09-02 15:13:39 -07:00
|
|
|
shlint = pkgs.runCommandNoCC "shlint"
|
|
|
|
{
|
|
|
|
nativeBuildInputs = [ pkgs.shellcheck ];
|
|
|
|
preferLocalBuild = true;
|
2021-07-10 08:48:59 -07:00
|
|
|
} "make -C ${./..} shlint > $out";
|
|
|
|
};
|
|
|
|
|
2021-01-05 13:12:21 -07:00
|
|
|
defaultPackage = pkgs.neovim;
|
2020-12-09 01:15:37 -07:00
|
|
|
|
2021-01-05 13:12:21 -07:00
|
|
|
apps = {
|
|
|
|
nvim = flake-utils.lib.mkApp { drv = pkgs.neovim; name = "nvim"; };
|
|
|
|
nvim-debug = flake-utils.lib.mkApp { drv = pkgs.neovim-debug; name = "nvim"; };
|
|
|
|
};
|
2020-12-09 01:15:37 -07:00
|
|
|
|
2021-01-05 13:12:21 -07:00
|
|
|
defaultApp = apps.nvim;
|
2020-12-09 01:15:37 -07:00
|
|
|
|
2022-09-02 15:13:39 -07:00
|
|
|
devShells = {
|
|
|
|
default = pkgs.neovim-developer.overrideAttrs (oa: {
|
|
|
|
|
|
|
|
buildInputs = with pkgs; oa.buildInputs ++ [
|
|
|
|
cmake
|
|
|
|
lua.pkgs.luacheck
|
|
|
|
sumneko-lua-language-server
|
|
|
|
pythonEnv
|
|
|
|
include-what-you-use # for scripts/check-includes.py
|
|
|
|
jq # jq for scripts/vim-patch.sh -r
|
|
|
|
shellcheck # for `make shlint`
|
|
|
|
doxygen # for script/gen_vimdoc.py
|
|
|
|
clang-tools # for clangd to find the correct headers
|
|
|
|
];
|
2021-07-10 08:48:59 -07:00
|
|
|
|
2022-09-02 15:13:39 -07:00
|
|
|
shellHook = oa.shellHook + ''
|
|
|
|
export NVIM_PYTHON_LOG_LEVEL=DEBUG
|
|
|
|
export NVIM_LOG_FILE=/tmp/nvim.log
|
|
|
|
export ASAN_SYMBOLIZER_PATH=${pkgs.llvm_11}/bin/llvm-symbolizer
|
|
|
|
|
|
|
|
# ASAN_OPTIONS=detect_leaks=1
|
|
|
|
export ASAN_OPTIONS="log_path=./test.log:abort_on_error=1"
|
|
|
|
export UBSAN_OPTIONS=print_stacktrace=1
|
|
|
|
mkdir -p build/runtime/parser
|
|
|
|
# nvim looks into CMAKE_INSTALL_DIR. Hack to avoid errors
|
|
|
|
# when running the functionaltests
|
|
|
|
mkdir -p outputs/out/share/nvim/syntax
|
|
|
|
touch outputs/out/share/nvim/syntax/syntax.vim
|
|
|
|
|
|
|
|
# for treesitter functionaltests
|
|
|
|
mkdir -p runtime/parser
|
|
|
|
cp -f ${pkgs.tree-sitter.builtGrammars.tree-sitter-c}/parser runtime/parser/c.so
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
};
|
|
|
|
});
|
2020-12-09 01:15:37 -07:00
|
|
|
}
|