mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-26 18:58:43 +02:00
This means we no longer need to spoof the module in the docs implementation. Instead, we supply the (optional) special arg `isDocs` to `evalModules`.
72 lines
1.7 KiB
Nix
72 lines
1.7 KiB
Nix
{
|
|
pkgs,
|
|
config,
|
|
lib,
|
|
helpers,
|
|
specialArgs,
|
|
...
|
|
}:
|
|
let
|
|
inherit (lib) types;
|
|
isDocs = specialArgs.isDocs or false;
|
|
|
|
fileModuleType = types.submoduleWith {
|
|
shorthandOnlyDefinesConfig = true;
|
|
specialArgs = {
|
|
inherit helpers;
|
|
defaultPkgs = pkgs;
|
|
};
|
|
# Don't include the modules in the docs, as that'd be redundant
|
|
modules = lib.optionals (!isDocs) [
|
|
../../.
|
|
./submodule.nix
|
|
];
|
|
description = "Nixvim configuration";
|
|
};
|
|
in
|
|
{
|
|
options = {
|
|
files = lib.mkOption {
|
|
type = types.attrsOf fileModuleType;
|
|
description = "Extra files to add to the runtimepath";
|
|
default = { };
|
|
example = {
|
|
"ftplugin/nix.lua" = {
|
|
opts = {
|
|
tabstop = 2;
|
|
shiftwidth = 2;
|
|
expandtab = true;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
filesPlugin = lib.mkOption {
|
|
type = types.package;
|
|
description = "A derivation with all the files inside.";
|
|
internal = true;
|
|
readOnly = true;
|
|
};
|
|
};
|
|
|
|
config =
|
|
let
|
|
inherit (config) files;
|
|
concatFilesOption = attr: lib.flatten (lib.mapAttrsToList (_: builtins.getAttr attr) files);
|
|
in
|
|
{
|
|
# Each file can declare plugins/packages/warnings/assertions
|
|
extraPlugins = concatFilesOption "extraPlugins";
|
|
extraPackages = concatFilesOption "extraPackages";
|
|
warnings = concatFilesOption "warnings";
|
|
assertions = concatFilesOption "assertions";
|
|
|
|
# A directory with all the files in it
|
|
filesPlugin = pkgs.buildEnv {
|
|
name = "nixvim-config";
|
|
paths =
|
|
(lib.mapAttrsToList (_: file: file.plugin) files)
|
|
++ (lib.mapAttrsToList pkgs.writeTextDir config.extraFiles);
|
|
};
|
|
};
|
|
}
|