mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-24 04:35:08 +02:00
modules: refactor module bootstrapping
Let's simplify things by defining all modules in `./plugins`, `./modules` and `./wrappers/modules`. Instead of currying `pkgs` into a bootstrapping module, we can require `defaultPkgs` be provided as a special arg. This refactor allows us to completely remove `flake-modules/modules.nix`!
This commit is contained in:
parent
3d96960348
commit
d2afb176ff
16 changed files with 129 additions and 159 deletions
|
@ -5,7 +5,6 @@
|
|||
./helpers.nix
|
||||
./lib.nix
|
||||
./legacy-packages.nix
|
||||
./modules.nix
|
||||
./overlays.nix
|
||||
./packages.nix
|
||||
./templates.nix
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
{ modules, ... }:
|
||||
{
|
||||
_module.args = {
|
||||
modules =
|
||||
pkgs:
|
||||
let
|
||||
nixpkgsMaintainersList = pkgs.path + "/nixos/modules/misc/meta.nix";
|
||||
|
||||
nixvimExtraArgsModule = rec {
|
||||
_file = ./flake.nix;
|
||||
key = _file;
|
||||
config = {
|
||||
_module.args = {
|
||||
pkgs = pkgs.lib.mkForce pkgs;
|
||||
inherit (pkgs) lib;
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
[
|
||||
../modules
|
||||
nixpkgsMaintainersList
|
||||
nixvimExtraArgsModule
|
||||
(
|
||||
{ lib, ... }:
|
||||
with lib;
|
||||
{
|
||||
# Attribute may contain the following fields:
|
||||
# - path: Path to the module, e.g. [ "plugins" "<name>" ]
|
||||
# - description: A short description of the plugin
|
||||
# - url: Url for the plugin
|
||||
#
|
||||
# We need to use an attrs instead of a submodule to handle the merge.
|
||||
options.meta.nixvimInfo = mkOption {
|
||||
type = (types.nullOr types.attrs) // {
|
||||
# This will create an attrset of the form:
|
||||
#
|
||||
# { path.to.plugin.name = <info>; }
|
||||
#
|
||||
#
|
||||
# Where <info> is an attrset of the form:
|
||||
# {
|
||||
# file = "path";
|
||||
# description = null or "<DESCRIPTION>";
|
||||
# url = null or "<URL>";
|
||||
# }
|
||||
merge =
|
||||
_: defs:
|
||||
lib.foldl'
|
||||
(
|
||||
acc: def:
|
||||
lib.recursiveUpdate acc (
|
||||
setAttrByPath def.value.path {
|
||||
inherit (def) file;
|
||||
url = def.value.url or null;
|
||||
description = def.value.description or null;
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
plugins = { };
|
||||
colorschemes = { };
|
||||
}
|
||||
defs;
|
||||
};
|
||||
internal = true;
|
||||
default = null;
|
||||
description = ''
|
||||
Nixvim related information on the module
|
||||
'';
|
||||
};
|
||||
}
|
||||
)
|
||||
];
|
||||
};
|
||||
|
||||
perSystem =
|
||||
{ pkgs, config, ... }:
|
||||
{
|
||||
_module.args = {
|
||||
modules = modules pkgs;
|
||||
rawModules = modules;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -3,13 +3,12 @@
|
|||
{
|
||||
pkgsUnfree,
|
||||
config,
|
||||
rawModules,
|
||||
helpers,
|
||||
...
|
||||
}:
|
||||
{
|
||||
packages = import ../docs {
|
||||
inherit rawModules helpers;
|
||||
inherit helpers;
|
||||
# Building the docs evaluates each plugin's default package, some of which are unfree
|
||||
pkgs = pkgsUnfree;
|
||||
};
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
{
|
||||
inputs,
|
||||
modules,
|
||||
getHelpers,
|
||||
self,
|
||||
...
|
||||
}:
|
||||
let
|
||||
wrapperArgs = {
|
||||
inherit modules;
|
||||
inherit self;
|
||||
inherit getHelpers;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue