mirror of
https://github.com/nix-community/nixvim.git
synced 2025-08-03 01:25:22 +02:00
tests/platforms: move out of flake wrappers
module
These should be set up in a dedicated test file, owned by `tests/default.nix`. Also refactored to use `callTest`.
This commit is contained in:
parent
115994f18e
commit
77c78bd04e
7 changed files with 40 additions and 51 deletions
18
tests/platforms/darwin.nix
Normal file
18
tests/platforms/darwin.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
self,
|
||||
system,
|
||||
}:
|
||||
self.inputs.nix-darwin.lib.darwinSystem {
|
||||
modules = [
|
||||
{
|
||||
nixpkgs.hostPlatform = system;
|
||||
|
||||
programs.nixvim = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
system.stateVersion = 5;
|
||||
}
|
||||
self.nixDarwinModules.nixvim
|
||||
];
|
||||
}
|
21
tests/platforms/default.nix
Normal file
21
tests/platforms/default.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
callTest,
|
||||
lib,
|
||||
stdenv,
|
||||
}:
|
||||
let
|
||||
inherit (stdenv.hostPlatform)
|
||||
isLinux
|
||||
isDarwin
|
||||
;
|
||||
in
|
||||
{
|
||||
home-manager-module = (callTest ./hm.nix { }).activationPackage;
|
||||
home-manager-extra-files-byte-compiling = callTest ./hm-extra-files-byte-compiling.nix { };
|
||||
}
|
||||
// lib.optionalAttrs isLinux {
|
||||
nixos-module = (callTest ./nixos.nix { }).config.system.build.toplevel;
|
||||
}
|
||||
// lib.optionalAttrs isDarwin {
|
||||
darwin-module = (callTest ./darwin.nix { }).system;
|
||||
}
|
107
tests/platforms/hm-extra-files-byte-compiling.nix
Normal file
107
tests/platforms/hm-extra-files-byte-compiling.nix
Normal file
|
@ -0,0 +1,107 @@
|
|||
{
|
||||
self,
|
||||
pkgs,
|
||||
}:
|
||||
let
|
||||
inherit (self.inputs.home-manager.lib)
|
||||
homeManagerConfiguration
|
||||
;
|
||||
|
||||
config = {
|
||||
home = {
|
||||
username = "nixvim";
|
||||
homeDirectory = "/invalid/dir";
|
||||
stateVersion = "24.11";
|
||||
};
|
||||
|
||||
programs.nixvim = {
|
||||
enable = true;
|
||||
|
||||
performance.byteCompileLua.enable = true;
|
||||
|
||||
extraFiles = {
|
||||
"extra-files/test1.lua".text = "vim.opt.tabstop = 2";
|
||||
"extra-files/test2.lua".source = builtins.toFile "file_source.lua" "vim.opt.tabstop = 2";
|
||||
"extra-files/test3.lua".source = pkgs.writeText "test3.lua" "vim.opt.tabstop = 2";
|
||||
"extra-files/test.vim".text = "set tabstop=2";
|
||||
"extra-files/test.json".text = builtins.toJSON { a = 1; };
|
||||
};
|
||||
|
||||
files = {
|
||||
"files/test.lua".opts.tabstop = 2;
|
||||
"files/test.vim".opts.tabstop = 2;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
homeFilesByteCompilingEnabled =
|
||||
(homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
|
||||
modules = [
|
||||
self.homeManagerModules.nixvim
|
||||
config
|
||||
{ programs.nixvim.performance.byteCompileLua.configs = true; }
|
||||
];
|
||||
}).config.home-files;
|
||||
|
||||
homeFilesByteCompilingDisabled =
|
||||
(homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
|
||||
modules = [
|
||||
self.homeManagerModules.nixvim
|
||||
config
|
||||
{ programs.nixvim.performance.byteCompileLua.configs = false; }
|
||||
];
|
||||
}).config.home-files;
|
||||
in
|
||||
pkgs.runCommand "home-manager-extra-files-byte-compiling" { } ''
|
||||
is_binary() {
|
||||
! grep -qI . "$1"
|
||||
}
|
||||
test_byte_compiled() {
|
||||
if ! is_binary "$home_files/.config/nvim/$1"; then
|
||||
echo "File $1 is expected to be byte compiled, but it's not"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
test_not_byte_compiled() {
|
||||
if is_binary "$home_files/.config/nvim/$1"; then
|
||||
echo "File $1 is not expected to be byte compiled, but it is"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Test directory with extraFiles byte compiling enabled
|
||||
home_files="${homeFilesByteCompilingEnabled}"
|
||||
|
||||
echo "Testing home-files with extraFiles byte compiling enabled"
|
||||
|
||||
# extraFiles
|
||||
test_byte_compiled extra-files/test1.lua
|
||||
test_byte_compiled extra-files/test2.lua
|
||||
test_byte_compiled extra-files/test3.lua
|
||||
test_not_byte_compiled extra-files/test.vim
|
||||
test_not_byte_compiled extra-files/test.json
|
||||
# files
|
||||
test_byte_compiled files/test.lua
|
||||
test_not_byte_compiled files/test.vim
|
||||
|
||||
# Test directory with extraFiles byte compiling disabled
|
||||
home_files="${homeFilesByteCompilingDisabled}"
|
||||
|
||||
echo "Testing home-files with extraFiles byte compiling disabled"
|
||||
|
||||
# extraFiles
|
||||
test_not_byte_compiled extra-files/test1.lua
|
||||
test_not_byte_compiled extra-files/test2.lua
|
||||
test_not_byte_compiled extra-files/test3.lua
|
||||
test_not_byte_compiled extra-files/test.vim
|
||||
test_not_byte_compiled extra-files/test.json
|
||||
# files
|
||||
test_not_byte_compiled files/test.lua
|
||||
test_not_byte_compiled files/test.vim
|
||||
|
||||
touch $out
|
||||
''
|
23
tests/platforms/hm.nix
Normal file
23
tests/platforms/hm.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
self,
|
||||
pkgs,
|
||||
}:
|
||||
self.inputs.home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
|
||||
modules = [
|
||||
{
|
||||
home.username = "nixvim";
|
||||
home.homeDirectory = "/invalid/dir";
|
||||
|
||||
home.stateVersion = "24.11";
|
||||
|
||||
programs.nixvim = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
programs.home-manager.enable = true;
|
||||
}
|
||||
self.homeManagerModules.nixvim
|
||||
];
|
||||
}
|
22
tests/platforms/nixos.nix
Normal file
22
tests/platforms/nixos.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
self,
|
||||
system,
|
||||
}:
|
||||
self.inputs.nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
|
||||
modules = [
|
||||
{
|
||||
system.stateVersion = "24.11";
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
fileSystems."/" = {
|
||||
device = "/non/existent/device";
|
||||
};
|
||||
|
||||
programs.nixvim = {
|
||||
enable = true;
|
||||
};
|
||||
}
|
||||
self.nixosModules.nixvim
|
||||
];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue