mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
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.
This commit is contained in:
parent
c12694f4ba
commit
086873bed9
8 changed files with 157 additions and 28 deletions
|
@ -1,23 +1,37 @@
|
|||
helpers:
|
||||
{ lib, config, ... }:
|
||||
let
|
||||
inherit (lib) mkOption mkOptionType;
|
||||
inherit (lib)
|
||||
isAttrs
|
||||
listToAttrs
|
||||
map
|
||||
mkOption
|
||||
mkOptionType
|
||||
;
|
||||
cfg = config.programs.nixvim;
|
||||
extraFiles = lib.filter (file: file.enable) (lib.attrValues cfg.extraFiles);
|
||||
in
|
||||
{
|
||||
helpers = mkOption {
|
||||
type = mkOptionType {
|
||||
name = "helpers";
|
||||
description = "Helpers that can be used when writing nixvim configs";
|
||||
check = builtins.isAttrs;
|
||||
check = isAttrs;
|
||||
};
|
||||
description = "Use this option to access the helpers";
|
||||
default = helpers;
|
||||
};
|
||||
|
||||
configFiles =
|
||||
(lib.mapAttrs' (_: file: lib.nameValuePair "nvim/${file.path}" { text = file.content; }) cfg.files)
|
||||
// (lib.mapAttrs' (
|
||||
path: content: lib.nameValuePair "nvim/${path}" { text = content; }
|
||||
) cfg.extraFiles);
|
||||
# extraFiles, but nested under "nvim/" for use in etc/xdg config
|
||||
configFiles = listToAttrs (
|
||||
map (
|
||||
{ target, source, ... }:
|
||||
{
|
||||
name = "nvim/" + target;
|
||||
value = {
|
||||
inherit source;
|
||||
};
|
||||
}
|
||||
) extraFiles
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue