diff --git a/modules/programs/alacritty.nix b/modules/programs/alacritty.nix index edcd073e1..e799e2696 100644 --- a/modules/programs/alacritty.nix +++ b/modules/programs/alacritty.nix @@ -4,9 +4,7 @@ with lib; let cfg = config.programs.alacritty; - useToml = lib.versionAtLeast cfg.package.version "0.13"; tomlFormat = pkgs.formats.toml { }; - configFileName = "alacritty.${if useToml then "toml" else "yml"}"; in { options = { programs.alacritty = { @@ -52,24 +50,15 @@ in { config = mkIf cfg.enable { home.packages = [ cfg.package ]; - xdg.configFile."alacritty/${configFileName}" = - lib.mkIf (cfg.settings != { }) (lib.mkMerge [ - (lib.mkIf useToml { - source = - (tomlFormat.generate configFileName cfg.settings).overrideAttrs - (finalAttrs: prevAttrs: { - buildCommand = lib.concatStringsSep "\n" [ - prevAttrs.buildCommand - # TODO: why is this needed? Is there a better way to retain escape sequences? - "substituteInPlace $out --replace '\\\\' '\\'" - ]; - }); - }) - # TODO remove this once we don't need to support Alacritty < 0.12 anymore - (lib.mkIf (!useToml) { - text = - replaceStrings [ "\\\\" ] [ "\\" ] (builtins.toJSON cfg.settings); - }) - ]); + xdg.configFile."alacritty/alacritty.toml" = lib.mkIf (cfg.settings != { }) { + source = (tomlFormat.generate "alacritty.toml" cfg.settings).overrideAttrs + (finalAttrs: prevAttrs: { + buildCommand = lib.concatStringsSep "\n" [ + prevAttrs.buildCommand + # TODO: why is this needed? Is there a better way to retain escape sequences? + "substituteInPlace $out --replace '\\\\' '\\'" + ]; + }); + }; }; } diff --git a/tests/modules/programs/alacritty/empty-settings.nix b/tests/modules/programs/alacritty/empty-settings.nix index ecc6df35a..c587018e5 100644 --- a/tests/modules/programs/alacritty/empty-settings.nix +++ b/tests/modules/programs/alacritty/empty-settings.nix @@ -1,7 +1,3 @@ -{ config, lib, pkgs, ... }: - -with lib; - { config = { programs.alacritty.enable = true; diff --git a/tests/modules/programs/alacritty/example-settings-expected.toml b/tests/modules/programs/alacritty/example-settings-expected.toml index 723f1874c..7b08aae84 100644 --- a/tests/modules/programs/alacritty/example-settings-expected.toml +++ b/tests/modules/programs/alacritty/example-settings-expected.toml @@ -1,5 +1,5 @@ [[keyboard.bindings]] -chars = "\x0c" +chars = "\u000c" key = "K" mods = "Control" diff --git a/tests/modules/programs/alacritty/example-settings.nix b/tests/modules/programs/alacritty/example-settings.nix index 8aa013808..c8ecb206c 100644 --- a/tests/modules/programs/alacritty/example-settings.nix +++ b/tests/modules/programs/alacritty/example-settings.nix @@ -1,12 +1,10 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ config, ... }: { config = { programs.alacritty = { enable = true; - package = config.lib.test.mkStubPackage { version = "0.13.0"; }; + package = config.lib.test.mkStubPackage { }; settings = { window.dimensions = { @@ -17,7 +15,7 @@ with lib; keyboard.bindings = [{ key = "K"; mods = "Control"; - chars = "\\x0c"; + chars = "\\u000c"; }]; }; }; diff --git a/tests/modules/programs/alacritty/settings-merging-expected.yml b/tests/modules/programs/alacritty/settings-merging-expected.yml deleted file mode 100644 index 49d92a614..000000000 --- a/tests/modules/programs/alacritty/settings-merging-expected.yml +++ /dev/null @@ -1 +0,0 @@ -{"font":{"bold":{"family":"SFMono"},"normal":{"family":"SFMono"}},"key_bindings":[{"chars":"\x0c","key":"K","mods":"Control"}],"window":{"dimensions":{"columns":200,"lines":3}}} \ No newline at end of file diff --git a/tests/modules/programs/alacritty/settings-merging.nix b/tests/modules/programs/alacritty/settings-merging.nix index 76aedf4f6..e08c96ebc 100644 --- a/tests/modules/programs/alacritty/settings-merging.nix +++ b/tests/modules/programs/alacritty/settings-merging.nix @@ -1,12 +1,10 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ config, lib, ... }: { config = { programs.alacritty = { enable = true; - package = config.lib.test.mkStubPackage { version = "0.12.3"; }; + package = config.lib.test.mkStubPackage { }; settings = { window.dimensions = { @@ -14,10 +12,10 @@ with lib; columns = 200; }; - key_bindings = [{ + keyboard.bindings = [{ key = "K"; mods = "Control"; - chars = "\\x0c"; + chars = "\\u000c"; }]; font = let @@ -32,8 +30,8 @@ with lib; nmt.script = '' assertFileContent \ - home-files/.config/alacritty/alacritty.yml \ - ${./settings-merging-expected.yml} + home-files/.config/alacritty/alacritty.toml \ + ${./settings-toml-expected.toml} ''; }; } diff --git a/tests/modules/programs/alacritty/toml_config.nix b/tests/modules/programs/alacritty/toml_config.nix index 02d5aabfe..7094f9a9d 100644 --- a/tests/modules/programs/alacritty/toml_config.nix +++ b/tests/modules/programs/alacritty/toml_config.nix @@ -4,7 +4,7 @@ config = { programs.alacritty = { enable = true; - package = config.lib.test.mkStubPackage { version = "0.13.0"; }; + package = config.lib.test.mkStubPackage { }; settings = { window.dimensions = {