nix-community.nixvim/modules/top-level/files/default.nix

59 lines
1.3 KiB
Nix
Raw Normal View History

2024-05-05 19:39:35 +02:00
{
pkgs,
config,
lib,
2024-02-09 21:14:55 +01:00
helpers,
...
2024-05-05 19:39:35 +02:00
}:
let
inherit (lib) types;
2024-02-09 21:14:55 +01:00
fileModuleType = types.submoduleWith {
shorthandOnlyDefinesConfig = true;
specialArgs = {
inherit helpers;
defaultPkgs = pkgs;
};
2024-02-09 21:14:55 +01:00
modules = [
../../.
./submodule.nix
2024-02-09 21:14:55 +01:00
];
};
2024-05-05 19:39:35 +02:00
in
{
options = {
files = lib.mkOption {
type = types.attrsOf fileModuleType;
2024-02-11 12:51:34 +00:00
description = "Files to include in the Vim config.";
2024-05-05 19:39:35 +02:00
default = { };
};
filesPlugin = lib.mkOption {
type = types.package;
2024-02-11 12:51:34 +00:00
description = "A derivation with all the files inside.";
internal = true;
readOnly = true;
};
};
2024-05-05 19:39:35 +02:00
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";
2024-05-05 19:39:35 +02:00
# 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);
};
};
}