Skip to content

How do I bring helpers into scope? #1283

Answered by MattSturgeon
Kodlak15 asked this question in Q&A
Discussion options

You must be logged in to vote

There's two ways to approach this.

Using a submodule definition

You can assign a module-function to programs.nixvim and that module function has access to nixvim's modules args.

{
  programs.nixvim =
    {
      lib,
      ...
    }:
    {
      enable = true;
      someOption = lib.nixvim.mkRaw ''
        print('Hi!');
      '';
    };
}

Via the lib option

Alternatively, we make most of our lib extensions available to the "host" modules (in this case, home-manager) via the lib config option.

Note that the lib config option is entirely unrelated to the lib module arg.

{ lib, config, ... }:
let
  # Access our helpers via config.lib
  helpers = config.lib.nixvim;
in
{
  programs.nixvim.some…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@careb0t
Comment options

@MattSturgeon
Comment options

@MattSturgeon
Comment options

Answer selected by Kodlak15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants