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 }:
|
2023-06-09 13:50:23 -07:00
|
|
|
let
|
|
|
|
inherit (builtins)
|
|
|
|
elemAt
|
|
|
|
foldl'
|
|
|
|
mapAttrs
|
|
|
|
match
|
|
|
|
readFile
|
|
|
|
;
|
|
|
|
inherit (nixpkgs.lib)
|
|
|
|
const
|
|
|
|
flip
|
|
|
|
pipe
|
|
|
|
remove
|
|
|
|
splitString
|
|
|
|
toLower
|
|
|
|
;
|
|
|
|
in
|
2021-01-05 13:12:21 -07:00
|
|
|
{
|
2022-12-28 06:26:59 -07:00
|
|
|
overlay = final: prev: {
|
2022-09-30 10:25:12 -07:00
|
|
|
|
2023-06-09 13:50:23 -07:00
|
|
|
neovim = (final.neovim-unwrapped.override {
|
|
|
|
treesitter-parsers = pipe ../cmake.deps/deps.txt [
|
|
|
|
readFile
|
|
|
|
(splitString "\n")
|
|
|
|
(map (match "TREESITTER_([A-Z_]+)_(URL|SHA256)[[:space:]]+([^[:space:]]+)[[:space:]]*"))
|
|
|
|
(remove null)
|
|
|
|
(flip foldl' { }
|
|
|
|
(acc: matches:
|
|
|
|
let
|
|
|
|
lang = toLower (elemAt matches 0);
|
|
|
|
type = toLower (elemAt matches 1);
|
|
|
|
value = elemAt matches 2;
|
|
|
|
in
|
|
|
|
acc // {
|
|
|
|
${lang} = acc.${lang} or { } // {
|
|
|
|
${type} = value;
|
|
|
|
};
|
|
|
|
}))
|
|
|
|
(mapAttrs (const final.fetchurl))
|
2023-07-01 21:09:30 -07:00
|
|
|
(self: self // {
|
|
|
|
markdown = final.stdenv.mkDerivation {
|
|
|
|
inherit (self.markdown) name;
|
|
|
|
src = self.markdown;
|
|
|
|
installPhase = ''
|
|
|
|
mv tree-sitter-markdown $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
})
|
2023-06-09 13:50:23 -07:00
|
|
|
];
|
|
|
|
}).overrideAttrs (oa: rec {
|
2022-12-30 10:24:40 -07:00
|
|
|
version = self.shortRev or "dirty";
|
2022-09-30 10:25:12 -07:00
|
|
|
src = ../.;
|
2023-06-09 13:50:23 -07:00
|
|
|
preConfigure = oa.preConfigure or "" + ''
|
2022-12-30 10:24:40 -07:00
|
|
|
sed -i cmake.config/versiondef.h.in -e 's/@NVIM_VERSION_PRERELEASE@/-dev-${version}/'
|
|
|
|
'';
|
2023-04-07 01:26:52 -07:00
|
|
|
nativeBuildInputs = oa.nativeBuildInputs ++ [
|
|
|
|
final.libiconv
|
|
|
|
];
|
2022-09-30 10:25:12 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
# a development binary to help debug issues
|
|
|
|
neovim-debug = let
|
|
|
|
stdenv = if final.stdenv.isLinux then
|
|
|
|
final.llvmPackages_latest.stdenv
|
|
|
|
else
|
|
|
|
final.stdenv;
|
2022-12-28 06:26:59 -07:00
|
|
|
in (final.neovim.override {
|
2022-09-30 10:25:12 -07:00
|
|
|
lua = final.luajit;
|
|
|
|
inherit stdenv;
|
|
|
|
}).overrideAttrs (oa: {
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
NIX_CFLAGS_COMPILE = " -ggdb -Og";
|
|
|
|
|
|
|
|
cmakeBuildType = "Debug";
|
|
|
|
|
|
|
|
disallowedReferences = [ ];
|
2022-12-28 06:26:59 -07:00
|
|
|
});
|
2022-09-30 10:25:12 -07:00
|
|
|
|
|
|
|
# for neovim developers, beware of the slow binary
|
2022-12-28 06:26:59 -07:00
|
|
|
neovim-developer = let inherit (final.luaPackages) luacheck;
|
|
|
|
in (final.neovim-debug.override {
|
2022-09-30 10:25:12 -07:00
|
|
|
doCheck = final.stdenv.isLinux;
|
2022-12-28 06:26:59 -07:00
|
|
|
}).overrideAttrs (oa: {
|
2022-09-30 10:25:12 -07:00
|
|
|
cmakeFlags = oa.cmakeFlags ++ [
|
|
|
|
"-DLUACHECK_PRG=${luacheck}/bin/luacheck"
|
|
|
|
"-DENABLE_LTO=OFF"
|
|
|
|
] ++ final.lib.optionals final.stdenv.isLinux [
|
|
|
|
# https://github.com/google/sanitizers/wiki/AddressSanitizerFlags
|
|
|
|
# https://clang.llvm.org/docs/AddressSanitizer.html#symbolizing-the-reports
|
2023-03-16 11:24:04 -07:00
|
|
|
"-DENABLE_ASAN_UBSAN=ON"
|
2022-09-30 10:25:12 -07:00
|
|
|
];
|
|
|
|
});
|
|
|
|
};
|
|
|
|
} // flake-utils.lib.eachDefaultSystem (system:
|
2021-01-05 13:12:21 -07:00
|
|
|
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-30 10:25:12 -07:00
|
|
|
in {
|
2021-01-05 13:12:21 -07:00
|
|
|
packages = with pkgs; {
|
2022-09-05 02:41:42 -07:00
|
|
|
default = neovim;
|
2021-01-05 13:12:21 -07:00
|
|
|
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-30 10:25:12 -07:00
|
|
|
shlint = pkgs.runCommand "shlint" {
|
|
|
|
nativeBuildInputs = [ pkgs.shellcheck ];
|
|
|
|
preferLocalBuild = true;
|
|
|
|
} "make -C ${./..} shlint > $out";
|
2021-07-10 08:48:59 -07:00
|
|
|
};
|
|
|
|
|
2022-09-05 02:41:42 -07:00
|
|
|
# kept for backwards-compatibility
|
2021-01-05 13:12:21 -07:00
|
|
|
defaultPackage = pkgs.neovim;
|
2020-12-09 01:15:37 -07:00
|
|
|
|
2022-09-02 15:13:39 -07:00
|
|
|
devShells = {
|
|
|
|
default = pkgs.neovim-developer.overrideAttrs (oa: {
|
|
|
|
|
2022-09-30 10:25:12 -07:00
|
|
|
buildInputs = with pkgs;
|
|
|
|
oa.buildInputs ++ [
|
|
|
|
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`
|
2024-01-12 13:12:43 -07:00
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = with pkgs;
|
|
|
|
oa.nativeBuildInputs ++ [
|
2022-09-30 10:25:12 -07:00
|
|
|
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"
|
|
|
|
|
|
|
|
# for treesitter functionaltests
|
|
|
|
mkdir -p runtime/parser
|
2022-12-28 06:26:59 -07:00
|
|
|
cp -f ${pkgs.vimPlugins.nvim-treesitter.builtGrammars.c}/parser runtime/parser/c.so
|
2022-09-02 15:13:39 -07:00
|
|
|
'';
|
|
|
|
});
|
|
|
|
};
|
|
|
|
});
|
2020-12-09 01:15:37 -07:00
|
|
|
}
|