1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-04-09 10:34:44 +00:00
This commit is contained in:
nicoo 2025-03-20 09:17:20 +00:00 committed by GitHub
commit 55d5276a53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,6 +17,33 @@ in {
description = "The Alacritty package to install.";
};
theme = mkOption {
type = let
themes = with lib;
pipe pkgs.alacritty-theme [
builtins.readDir
(filterAttrs
(name: type: type == "regular" && hasSuffix ".toml" name))
attrNames
(map (removeSuffix ".toml"))
];
in with types;
nullOr (enum themes) // {
description = ''
a theme present in [`alacritty-theme`], i.e. its filename without extension
[`alacritty-theme`]: https://github.com/alacritty/alacritty-theme/tree/${pkgs.alacritty-theme.src.rev}/themes
'';
};
default = null;
example = "solarized_dark";
description = ''
A theme to import in the configuration, taken from the [`alacritty-theme`] repository,
as [packaged] in `nixpkgs`.
[`alacritty-theme`]: https://github.com/alacritty/alacritty-theme
[packaged]: https://search.nixos.org/packages?query=alacritty-theme
'';
};
settings = mkOption {
type = tomlFormat.type;
default = { };
@ -50,6 +77,12 @@ in {
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
programs.alacritty.settings.general.import =
mkIf (cfg.theme != null && lib.versionAtLeast cfg.package.version "0.14") [ "${pkgs.alacritty-theme}/${cfg.theme}.toml" ];
programs.alacritty.settings.import =
mkIf (cfg.theme != null && lib.versionOlder cfg.package.version "0.14") [ "${pkgs.alacritty-theme}/${cfg.theme}.toml" ];
xdg.configFile."alacritty/alacritty.toml" = lib.mkIf (cfg.settings != { }) {
source = (tomlFormat.generate "alacritty.toml" cfg.settings).overrideAttrs
(finalAttrs: prevAttrs: {