alacritty: cleanup after 0.13 merge in nixpkgs

This commit is contained in:
Ramses 2024-04-19 16:57:02 +02:00 committed by GitHub
parent 7ca7025cf2
commit 068dd4ae29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 21 additions and 41 deletions

View File

@ -4,9 +4,7 @@ with lib;
let let
cfg = config.programs.alacritty; cfg = config.programs.alacritty;
useToml = lib.versionAtLeast cfg.package.version "0.13";
tomlFormat = pkgs.formats.toml { }; tomlFormat = pkgs.formats.toml { };
configFileName = "alacritty.${if useToml then "toml" else "yml"}";
in { in {
options = { options = {
programs.alacritty = { programs.alacritty = {
@ -52,24 +50,15 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
xdg.configFile."alacritty/${configFileName}" = xdg.configFile."alacritty/alacritty.toml" = lib.mkIf (cfg.settings != { }) {
lib.mkIf (cfg.settings != { }) (lib.mkMerge [ source = (tomlFormat.generate "alacritty.toml" cfg.settings).overrideAttrs
(lib.mkIf useToml { (finalAttrs: prevAttrs: {
source = buildCommand = lib.concatStringsSep "\n" [
(tomlFormat.generate configFileName cfg.settings).overrideAttrs prevAttrs.buildCommand
(finalAttrs: prevAttrs: { # TODO: why is this needed? Is there a better way to retain escape sequences?
buildCommand = lib.concatStringsSep "\n" [ "substituteInPlace $out --replace '\\\\' '\\'"
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);
})
]);
}; };
} }

View File

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = { config = {
programs.alacritty.enable = true; programs.alacritty.enable = true;

View File

@ -1,5 +1,5 @@
[[keyboard.bindings]] [[keyboard.bindings]]
chars = "\x0c" chars = "\u000c"
key = "K" key = "K"
mods = "Control" mods = "Control"

View File

@ -1,12 +1,10 @@
{ config, lib, pkgs, ... }: { config, ... }:
with lib;
{ {
config = { config = {
programs.alacritty = { programs.alacritty = {
enable = true; enable = true;
package = config.lib.test.mkStubPackage { version = "0.13.0"; }; package = config.lib.test.mkStubPackage { };
settings = { settings = {
window.dimensions = { window.dimensions = {
@ -17,7 +15,7 @@ with lib;
keyboard.bindings = [{ keyboard.bindings = [{
key = "K"; key = "K";
mods = "Control"; mods = "Control";
chars = "\\x0c"; chars = "\\u000c";
}]; }];
}; };
}; };

View File

@ -1 +0,0 @@
{"font":{"bold":{"family":"SFMono"},"normal":{"family":"SFMono"}},"key_bindings":[{"chars":"\x0c","key":"K","mods":"Control"}],"window":{"dimensions":{"columns":200,"lines":3}}}

View File

@ -1,12 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, ... }:
with lib;
{ {
config = { config = {
programs.alacritty = { programs.alacritty = {
enable = true; enable = true;
package = config.lib.test.mkStubPackage { version = "0.12.3"; }; package = config.lib.test.mkStubPackage { };
settings = { settings = {
window.dimensions = { window.dimensions = {
@ -14,10 +12,10 @@ with lib;
columns = 200; columns = 200;
}; };
key_bindings = [{ keyboard.bindings = [{
key = "K"; key = "K";
mods = "Control"; mods = "Control";
chars = "\\x0c"; chars = "\\u000c";
}]; }];
font = let font = let
@ -32,8 +30,8 @@ with lib;
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \
home-files/.config/alacritty/alacritty.yml \ home-files/.config/alacritty/alacritty.toml \
${./settings-merging-expected.yml} ${./settings-toml-expected.toml}
''; '';
}; };
} }

View File

@ -4,7 +4,7 @@
config = { config = {
programs.alacritty = { programs.alacritty = {
enable = true; enable = true;
package = config.lib.test.mkStubPackage { version = "0.13.0"; }; package = config.lib.test.mkStubPackage { };
settings = { settings = {
window.dimensions = { window.dimensions = {