Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

standalone: Allow to pass extraSpecialArgs #665

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
- `module`: The nix module definition used to extend nixvim.
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?
When you build the module (probably using home-manager), it will install all
Expand Down
2 changes: 1 addition & 1 deletion templates/simple/config/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{self, ...}: {
# Import all your configuration modules here
imports = [
./bufferline.nix
Expand Down
5 changes: 5 additions & 0 deletions templates/simple/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
};

outputs = {
self,
nixpkgs,
nixvim,
flake-utils,
Expand All @@ -21,6 +22,10 @@
nvim = nixvim'.makeNixvimWithModule {
inherit pkgs;
module = config;
# You can use `extraSpecialArgs` to pass additional arguments to your module files
extraSpecialArgs = {
inherit self;
};
};
in {
checks = {
Expand Down
5 changes: 4 additions & 1 deletion wrappers/standalone.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
default_pkgs: modules: {
pkgs ? default_pkgs,
extraSpecialArgs ? {},
module,
}: let
inherit (pkgs) lib;
Expand All @@ -8,7 +9,9 @@ default_pkgs: modules: {

shared = import ./_shared.nix modules {
inherit pkgs lib;
config = {};
config = {
_module.args = extraSpecialArgs;
};
};

eval = lib.evalModules {
Expand Down