From 71c7df9b8d070a3f8b6e304e7e60718d191b12de Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Wed, 5 Jun 2024 03:10:32 +0100 Subject: [PATCH] nixvim: expose config as read-only option Allow standalone nixvim users to take advantage of stylix by exposing the generated config as `config.stylix.targets.nixvim.config`. This can be passed to the nixvim derivation's `extendNixvim` function. --- modules/nixvim/nixvim.nix | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/modules/nixvim/nixvim.nix b/modules/nixvim/nixvim.nix index b6555e0f..54c63538 100644 --- a/modules/nixvim/nixvim.nix +++ b/modules/nixvim/nixvim.nix @@ -11,11 +11,41 @@ main = lib.mkEnableOption "background transparency for the main NeoVim window"; sign_column = lib.mkEnableOption "background transparency for the NeoVim sign column"; }; + config = lib.mkOption { + type = with lib.types; attrsOf anything; + readOnly = true; + + description = '' + The stylix configuration, generated for nixvim. + + If nixvim is installed via nixos, darwin, or home-manager then this will be **automatically** + assigned to `programs.nixvim`. If you're using a "standalone" build of nixvim, then that's + not possible. Instead, you should pass this config to the `nixvimExtend` function. + + For example: + + ```nix + { config, ... }: { + environment.systemPackages = [ + (standalone-nixvim-derivation.nixvimExtend config.stylix.targets.nixvim.config) + ]; + } + ``` + + See nixvim's docs on [extending a standalone configuration](https://nix-community.github.io/nixvim/modules/standalone.html#extending-an-existing-configuration). + ''; + }; }; - config = lib.optionalAttrs (options.programs ? nixvim) (lib.mkIf config.stylix.targets.nixvim.enable { - programs.nixvim = { + config = { + programs = lib.optionalAttrs (options.programs ? nixvim) (lib.mkIf config.stylix.targets.nixvim.enable { + nixvim = config.stylix.targets.nixvim.config; + }); + + stylix.targets.nixvim.config = { colorschemes.base16 = { + enable = true; + colorscheme = let colors = config.lib.stylix.colors.withHashtag; in { @@ -36,8 +66,6 @@ base0E = colors.base0E; base0F = colors.base0F; }; - - enable = true; }; highlight = let @@ -52,5 +80,5 @@ SignColumn = lib.mkIf cfg.transparent_bg.sign_column transparent; }; }; - }); + }; }