1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-24 18:00:58 +01:00
home-manager/tests/modules/programs/neovim/wrapper-args.nix
Austin Horstman 0a583021ea tests/neovim: add wrapper args test
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2025-12-20 17:11:31 -06:00

83 lines
2.4 KiB
Nix

{
lib,
pkgs,
...
}:
let
inherit (pkgs.stdenv.hostPlatform) isLinux;
dummyDep = pkgs.runCommand "dummy-dep" { } ''
mkdir -p $out/bin
echo "echo dummy" > $out/bin/dummy-dep-bin
chmod +x $out/bin/dummy-dep-bin
'';
dummyPlugin = pkgs.vimUtils.buildVimPlugin {
pname = "dummy-plugin";
version = "1.0";
src = pkgs.writeTextDir "plugin/dummy.vim" "\" dummy";
runtimeDeps = [ dummyDep ];
};
in
{
imports = [ ./stubs.nix ];
tests.stubs.wl-clipboard = { };
programs.neovim = {
enable = true;
extraName = "-my-suffix";
withPerl = true;
withPython3 = true;
withRuby = true;
withNodeJs = true;
autowrapRuntimeDeps = true;
waylandSupport = isLinux;
plugins = [ dummyPlugin ];
};
nmt.script = ''
nvimBin="home-path/bin/nvim"
assertBinaryContains() {
local file="$TESTED/$1"
if [[ $1 == /* ]]; then file="$1"; fi
if ! grep -a -qF -- "$2" "$file"; then
fail "Expected binary file '$1' to contain '$2' but it did not."
fi
}
# Ensure the main binary exists
assertFileExists "$nvimBin"
# 1. extraName: Check if the suffix is in the rplugin manifest path within the wrapper
assertBinaryContains "$nvimBin" "-my-suffix/rplugin.vim"
# 2. withPerl: Check if nvim-perl binary exists and host prog is set
assertFileExists "home-path/bin/nvim-perl"
assertBinaryContains "$nvimBin" "perl_host_prog="
# 3. withPython3: Check if nvim-python3 binary exists and host prog is set
assertFileExists "home-path/bin/nvim-python3"
assertBinaryContains "$nvimBin" "python3_host_prog="
# 4. withRuby: Check if nvim-ruby binary exists, GEM_HOME and host prog are set
assertFileExists "home-path/bin/nvim-ruby"
assertBinaryContains "$nvimBin" "GEM_HOME="
assertBinaryContains "$nvimBin" "ruby_host_prog="
# 5. withNodeJs: Check if nvim-node binary exists and host prog is set
assertFileExists "home-path/bin/nvim-node"
assertBinaryContains "$nvimBin" "node_host_prog="
# 6. waylandSupport: Check for wl-clipboard path in wrapper's PATH modification
# We check for the store path of wl-clipboard in the current pkgs
${lib.optionalString isLinux ''
assertBinaryContains "$nvimBin" "wl-clipboard-"
''}
# 7. autowrapRuntimeDeps: Check for dummyDep path in wrapper's PATH modification
assertBinaryContains "$nvimBin" "${dummyDep}/bin"
'';
}