nix-community.nixvim/flake-modules/wrappers.nix
Matt Sturgeon 10f64e6c96
tests/test-derivation: allow tests to be modules
Use `mkTestDerivationFromNixvimModule` instead of `mkTestDerivation`,
allowing "proper" modules to be used instead of plain attr configs.

This is useful for more complex tests that wish to use `config` or
`options` arguments, e.g:

```nix
{config, options, ...}: {
  /* some cool test */
}
```

To allow `tests.dontRun` to be defined on such a test, the module is
allowed to be nested as `module`, e.g:

```nix
{
  tests.dontRun = true;
  module = {config, options, ...}: {
    /* a disabled test */
  };
}
```

Also ended up doing some general cleanup, removing an unused function,
etc.
2024-06-29 22:02:44 +01:00

64 lines
1.5 KiB
Nix

{
inputs,
modules,
getHelpers,
self,
...
}:
let
wrapperArgs = {
inherit modules;
inherit self;
inherit getHelpers;
};
in
{
perSystem =
{ system, pkgs, ... }:
{
_module.args = {
makeNixvimWithModule = import ../wrappers/standalone.nix pkgs wrapperArgs;
};
checks =
{
home-manager-module =
(import ../tests/modules/hm.nix {
inherit pkgs;
inherit (inputs) home-manager;
nixvim = self;
}).activationPackage;
}
// pkgs.lib.optionalAttrs (!pkgs.stdenv.isDarwin) {
nixos-module =
(import ../tests/modules/nixos.nix {
inherit system;
inherit (inputs) nixpkgs;
nixvim = self;
}).config.system.build.toplevel;
}
// pkgs.lib.optionalAttrs pkgs.stdenv.isDarwin {
darwin-module =
(import ../tests/modules/darwin.nix {
inherit system;
inherit (inputs) nix-darwin;
nixvim = self;
}).system;
};
};
flake = {
nixosModules = {
nixvim = import ../wrappers/nixos.nix wrapperArgs;
default = self.nixosModules.nixvim;
};
homeManagerModules = {
nixvim = import ../wrappers/hm.nix wrapperArgs;
default = self.homeManagerModules.nixvim;
};
nixDarwinModules = {
nixvim = import ../wrappers/darwin.nix wrapperArgs;
default = self.nixDarwinModules.nixvim;
};
};
}