mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
alacritty: add package option for the theme package
This commit is contained in:
parent
f8e0560734
commit
87f75c1044
1 changed files with 24 additions and 20 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue