diff --git a/modules/programs/alacritty.nix b/modules/programs/alacritty.nix index 2f0ad3643..78f28d450 100644 --- a/modules/programs/alacritty.nix +++ b/modules/programs/alacritty.nix @@ -7,26 +7,6 @@ let cfg = config.programs.alacritty; tomlFormat = pkgs.formats.toml { }; - - alacrittyTheme = pkgs.alacritty-theme.overrideAttrs (prevAttrs: { - name = "alacritty-theme-for-home-manager"; - postInstall = - let - inherit (config.programs.alacritty) theme; - in - lib.concatStringsSep "\n" [ - prevAttrs.postInstall - (lib.optionalString (theme != null) - # bash - '' - if [ ! -f "$out/share/alacritty-theme/${theme}.toml" ]; then - echo "error: alacritty theme '${theme}' does not exist" - exit 1 - fi - '' - ) - ]; - }); in { options = { @@ -35,6 +15,8 @@ in package = lib.mkPackageOption pkgs "alacritty" { nullable = true; }; + themePackage = lib.mkPackageOption pkgs "alacritty-theme" { }; + theme = lib.mkOption { type = with lib.types; nullOr str; default = null; @@ -86,6 +68,28 @@ in programs.alacritty.settings = let + # We want to check that the theme actually exists. + # We need to do this at build time, to avoid IFD. + alacrittyTheme = cfg.themePackage.overrideAttrs (prevAttrs: { + name = "alacritty-theme-for-home-manager"; + postInstall = + let + inherit (config.programs.alacritty) theme; + in + lib.concatStringsSep "\n" [ + prevAttrs.postInstall + (lib.optionalString (theme != null) + # bash + '' + if [ ! -f "$out/share/alacritty-theme/${theme}.toml" ]; then + echo "error: alacritty theme '${theme}' does not exist" + exit 1 + fi + '' + ) + ]; + }); + theme = "${alacrittyTheme}/share/alacritty-theme/${cfg.theme}.toml"; in lib.mkIf (cfg.theme != null) {