-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
nixvim: support standalone config as read-only option #795
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -22,6 +22,26 @@ in | |||||
main = lib.mkEnableOption "background transparency for the main NeoVim window"; | ||||||
signColumn = 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 `extend` function. | ||||||
For example: | ||||||
```nix | ||||||
{ config, ... }: { | ||||||
environment.systemPackages = [ | ||||||
(inputs.<your-nixvim-input>.<your-system>.default.extend config.stylix.targets.nixvim.config) | ||||||
]; | ||||||
} | ||||||
``` | ||||||
See nixvim's docs on [extending a standalone configuration](https://nix-community.github.io/nixvim/platforms/standalone.html?highlight=extend#extending-an-existing-configuration). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Probably better without the highlight? |
||||||
''; | ||||||
}; | ||||||
}; | ||||||
|
||||||
imports = [ | ||||||
|
@@ -63,80 +83,78 @@ in | |||||
}) | ||||||
]; | ||||||
|
||||||
config = | ||||||
lib.mkIf (config.stylix.enable && cfg.enable && (config.programs ? nixvim)) | ||||||
( | ||||||
lib.optionalAttrs (builtins.hasAttr "nixvim" options.programs) ( | ||||||
lib.mkMerge [ | ||||||
(lib.mkIf (cfg.plugin == "base16-nvim") { | ||||||
programs.nixvim.colorschemes.base16 = { | ||||||
enable = true; | ||||||
config = lib.mkIf (config.stylix.enable && cfg.enable) { | ||||||
stylix.targets.nixvim.config = lib.mkMerge [ | ||||||
Comment on lines
+86
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This option def shouldn't need to be conditional. Rather, only the For comparison, my impl looks like: config = {
programs = lib.mkIf (config.stylix.enable && cfg.enable) (
lib.optionalAttrs (options.programs ? nixvim) {
nixvim = config.lib.stylix.nixvim.config;
}
);
lib.stylix.nixvim.config = lib.mkMerge [ |
||||||
(lib.mkIf (cfg.plugin == "base16-nvim") { | ||||||
colorschemes.base16 = { | ||||||
enable = true; | ||||||
colorscheme = { | ||||||
inherit (config.lib.stylix.colors.withHashtag) | ||||||
base00 | ||||||
base01 | ||||||
base02 | ||||||
base03 | ||||||
base04 | ||||||
base05 | ||||||
base06 | ||||||
base07 | ||||||
base08 | ||||||
base09 | ||||||
base0A | ||||||
base0B | ||||||
base0C | ||||||
base0D | ||||||
base0E | ||||||
base0F | ||||||
; | ||||||
}; | ||||||
}; | ||||||
}) | ||||||
(lib.mkIf (cfg.plugin == "mini.base16") { | ||||||
plugins.mini = { | ||||||
enable = true; | ||||||
modules.base16.palette = { | ||||||
inherit (config.lib.stylix.colors.withHashtag) | ||||||
base00 | ||||||
base01 | ||||||
base02 | ||||||
base03 | ||||||
base04 | ||||||
base05 | ||||||
base06 | ||||||
base07 | ||||||
base08 | ||||||
base09 | ||||||
base0A | ||||||
base0B | ||||||
base0C | ||||||
base0D | ||||||
base0E | ||||||
base0F | ||||||
; | ||||||
}; | ||||||
}; | ||||||
}) | ||||||
{ | ||||||
highlight = | ||||||
let | ||||||
transparent = { | ||||||
bg = "none"; | ||||||
ctermbg = "none"; | ||||||
}; | ||||||
in | ||||||
{ | ||||||
Normal = lib.mkIf cfg.transparentBackground.main transparent; | ||||||
NonText = lib.mkIf cfg.transparentBackground.main transparent; | ||||||
SignColumn = lib.mkIf cfg.transparentBackground.signColumn transparent; | ||||||
}; | ||||||
} | ||||||
]; | ||||||
|
||||||
colorscheme = { | ||||||
inherit (config.lib.stylix.colors.withHashtag) | ||||||
base00 | ||||||
base01 | ||||||
base02 | ||||||
base03 | ||||||
base04 | ||||||
base05 | ||||||
base06 | ||||||
base07 | ||||||
base08 | ||||||
base09 | ||||||
base0A | ||||||
base0B | ||||||
base0C | ||||||
base0D | ||||||
base0E | ||||||
base0F | ||||||
; | ||||||
}; | ||||||
}; | ||||||
}) | ||||||
(lib.mkIf (cfg.plugin == "mini.base16") { | ||||||
programs.nixvim.plugins.mini = { | ||||||
enable = true; | ||||||
|
||||||
modules.base16.palette = { | ||||||
inherit (config.lib.stylix.colors.withHashtag) | ||||||
base00 | ||||||
base01 | ||||||
base02 | ||||||
base03 | ||||||
base04 | ||||||
base05 | ||||||
base06 | ||||||
base07 | ||||||
base08 | ||||||
base09 | ||||||
base0A | ||||||
base0B | ||||||
base0C | ||||||
base0D | ||||||
base0E | ||||||
base0F | ||||||
; | ||||||
}; | ||||||
}; | ||||||
}) | ||||||
{ | ||||||
programs.nixvim = { | ||||||
highlight = | ||||||
let | ||||||
transparent = { | ||||||
bg = "none"; | ||||||
ctermbg = "none"; | ||||||
}; | ||||||
in | ||||||
{ | ||||||
Normal = lib.mkIf cfg.transparentBackground.main transparent; | ||||||
NonText = lib.mkIf cfg.transparentBackground.main transparent; | ||||||
SignColumn = lib.mkIf cfg.transparentBackground.signColumn transparent; | ||||||
}; | ||||||
}; | ||||||
} | ||||||
] | ||||||
) | ||||||
); | ||||||
programs = lib.optionalAttrs (builtins.hasAttr "nixvim" options.programs) ( | ||||||
lib.mkIf config.stylix.targets.nixvim.enable { | ||||||
nixvim = config.stylix.targets.nixvim.config; | ||||||
} | ||||||
); | ||||||
}; | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #415, the consensus seemed to be that we should assign the nixvim config to
config.lib.stylix.nixvim.config
.Doing that is incompatible with declaring an option, though. So it would be more difficult to document.