Skip to content

Commit

Permalink
nixvim: expose config as read-only option
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MattSturgeon committed Jun 5, 2024
1 parent e5c11e9 commit 71c7df9
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions modules/nixvim/nixvim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -36,8 +66,6 @@
base0E = colors.base0E;
base0F = colors.base0F;
};

enable = true;
};

highlight = let
Expand All @@ -52,5 +80,5 @@
SignColumn = lib.mkIf cfg.transparent_bg.sign_column transparent;
};
};
});
};
}

0 comments on commit 71c7df9

Please sign in to comment.