From 9d2fd0077a4fd8615bcc1dff60372e2ac29eb9dd Mon Sep 17 00:00:00 2001 From: nicoo Date: Sun, 7 Apr 2024 08:03:45 +0000 Subject: [PATCH] alacritty: add `theme` option --- modules/programs/alacritty.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/modules/programs/alacritty.nix b/modules/programs/alacritty.nix index e799e269..adc1559e 100644 --- a/modules/programs/alacritty.nix +++ b/modules/programs/alacritty.nix @@ -17,6 +17,27 @@ 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); + 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 +71,9 @@ in { config = mkIf cfg.enable { home.packages = [ cfg.package ]; + programs.alacritty.settings.import = + mkIf (cfg.theme != null) [ "${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: {