2023-04-20 22:41:37 +02:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
2024-02-09 21:14:55 +01:00
|
|
|
helpers,
|
2023-04-20 22:41:37 +02:00
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
inherit (lib) types;
|
2024-02-09 21:14:55 +01:00
|
|
|
fileModuleType = types.submoduleWith {
|
|
|
|
shorthandOnlyDefinesConfig = true;
|
2024-07-02 13:30:29 +01:00
|
|
|
specialArgs = {
|
|
|
|
inherit helpers;
|
|
|
|
defaultPkgs = pkgs;
|
|
|
|
};
|
2024-02-09 21:14:55 +01:00
|
|
|
modules = [
|
2024-07-05 16:48:46 +01:00
|
|
|
../../.
|
|
|
|
./submodule.nix
|
2024-02-09 21:14:55 +01:00
|
|
|
];
|
|
|
|
};
|
2023-04-20 22:41:37 +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.";
|
2023-04-20 22:41:37 +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.";
|
2023-04-20 22:41:37 +02:00
|
|
|
internal = true;
|
|
|
|
readOnly = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config =
|
|
|
|
let
|
2023-05-22 15:45:47 +05:30
|
|
|
inherit (config) files;
|
|
|
|
concatFilesOption = attr: lib.flatten (lib.mapAttrsToList (_: builtins.getAttr attr) files);
|
2023-04-20 22:41:37 +02:00
|
|
|
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";
|
2023-04-21 20:04:58 +02:00
|
|
|
paths =
|
|
|
|
(lib.mapAttrsToList (_: file: file.plugin) files)
|
2023-05-22 15:45:47 +05:30
|
|
|
++ (lib.mapAttrsToList pkgs.writeTextDir config.extraFiles);
|
2024-05-05 19:39:35 +02:00
|
|
|
};
|
2023-04-20 22:41:37 +02:00
|
|
|
};
|
|
|
|
}
|