standalone: Allow to pass extraSpecialArgs (#665)

This commit is contained in:
traxys 2023-10-23 14:11:29 +02:00 committed by GitHub
parent 2f06f921e0
commit 0c5dcb56d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 2 deletions

View file

@ -202,6 +202,8 @@ It takes a set with the following keys:
- `pkgs`: The nixpkgs to use (defaults to the nixpkgs pointed at by the nixvim flake) - `pkgs`: The nixpkgs to use (defaults to the nixpkgs pointed at by the nixvim flake)
- `module`: The nix module definition used to extend nixvim. - `module`: The nix module definition used to extend nixvim.
This is useful to pass additional module machinery like `options` or `imports`. This is useful to pass additional module machinery like `options` or `imports`.
- `extraSpecialArgs`: Extra arguments to pass to the modules when using functions.
Can be `self` in a flake for example.
## How does it work? ## How does it work?
When you build the module (probably using home-manager), it will install all When you build the module (probably using home-manager), it will install all

View file

@ -1,4 +1,4 @@
{ {self, ...}: {
# Import all your configuration modules here # Import all your configuration modules here
imports = [ imports = [
./bufferline.nix ./bufferline.nix

View file

@ -7,6 +7,7 @@
}; };
outputs = { outputs = {
self,
nixpkgs, nixpkgs,
nixvim, nixvim,
flake-utils, flake-utils,
@ -21,6 +22,10 @@
nvim = nixvim'.makeNixvimWithModule { nvim = nixvim'.makeNixvimWithModule {
inherit pkgs; inherit pkgs;
module = config; module = config;
# You can use `extraSpecialArgs` to pass additional arguments to your module files
extraSpecialArgs = {
inherit self;
};
}; };
in { in {
checks = { checks = {

View file

@ -1,5 +1,6 @@
default_pkgs: modules: { default_pkgs: modules: {
pkgs ? default_pkgs, pkgs ? default_pkgs,
extraSpecialArgs ? {},
module, module,
}: let }: let
inherit (pkgs) lib; inherit (pkgs) lib;
@ -8,7 +9,9 @@ default_pkgs: modules: {
shared = import ./_shared.nix modules { shared = import ./_shared.nix modules {
inherit pkgs lib; inherit pkgs lib;
config = {}; config = {
_module.args = extraSpecialArgs;
};
}; };
eval = lib.evalModules { eval = lib.evalModules {