nix-community.nixvim/modules/top-level/files/submodule.nix
Matt Sturgeon 086873bed9
modules: refactor extraFiles
Moved `extraFiles` from `modules/output.nix` into its own file `modules/files.nix`.

Users should now assign text to a `text` attribute, however they could
also assign a file path to a `source` attribute instead.

The old method of directly assigning a string still works, and is
coerced to the new type along with a deprecation warning.
2024-07-07 16:42:47 +01:00

27 lines
604 B
Nix

{
name,
config,
lib,
pkgs,
...
}:
{
options = {
plugin = lib.mkOption {
type = lib.types.package;
description = "A derivation with the content of the file in it";
readOnly = true;
internal = true;
};
};
config =
let
derivationName = "nvim-" + lib.replaceStrings [ "/" ] [ "-" ] name;
in
{
path = lib.mkDefault name;
type = lib.mkDefault (if lib.hasSuffix ".vim" name then "vim" else "lua");
# No need to use mkDerivedConfig; this option is readOnly.
plugin = pkgs.writeText derivationName config.content;
};
}