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
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,11 +50,8 @@ 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
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
@ -64,12 +59,6 @@ in {
"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 = {
programs.alacritty.enable = true;

View file

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

View file

@ -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";
}];
};
};

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, ... }:
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}
'';
};
}

View file

@ -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 = {