Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alacritty moving towards configuration with TOML format #3696

Closed
2 tasks done
oceanlewis opened this issue Feb 22, 2023 · 22 comments
Closed
2 tasks done

Alacritty moving towards configuration with TOML format #3696

oceanlewis opened this issue Feb 22, 2023 · 22 comments
Assignees

Comments

@oceanlewis
Copy link
Contributor

Are you following the right branch?

  • My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

  • I have searched the existing issues

Issue description

This isn't a "bug" exactly, but it looks like the Alacritty project is looking at migrating away from using YAML as their configuration language to TOML, which will break programs.alacritty.settings.

I don't think nixpkgs has a builtin.toTOML, but it's easy enough for me to get around this by using nushell's from yaml | to toml functionality. Probably there are better ways to fix this though.

See alacritty/alacritty#6673 for where this work is happening.

Maintainer CC

@timhae @rycee @berbiche @ncfavier

System information

N/A
@oceanlewis oceanlewis added bug triage Issues or feature request that have not been triaged yet labels Feb 22, 2023
@ncfavier
Copy link
Member

ncfavier commented Feb 22, 2023

Thanks for the heads-up. It looks like upstream will continue supporting YAML for some time so we can have a graceful transition.

Should be as simple as changing pkgs.formats.yaml to pkgs.formats.toml, and maybe that will be a good time to revisit this TODO. I think we can do the backslash substitution as a postBuild on the generated toml file, if that's still needed. See #611 (comment)

@ncfavier ncfavier added enhancement and removed bug triage Issues or feature request that have not been triaged yet labels Feb 22, 2023
@ncfavier ncfavier changed the title bug: Alacritty moving towards configuration with TOML format Alacritty moving towards configuration with TOML format Feb 23, 2023
@jperras
Copy link

jperras commented Apr 20, 2023

Tangentially related: Alacritty has already introduced a non-standard YAML import directive, which allows a YAML file to import another YAML file. One of the drivers of this was for colorscheme themes: https://github.com/alacritty/alacritty-theme#imports

The reason I mention this: the current approach of converting the YAML-based configuration to JSON fails when including an import: in your Alacritty configuration.

@kchibisov
Copy link

Tangentially related: Alacritty has already introduced a non-standard YAML import directive, which allows a YAML file to import another YAML file. One of the drivers of this was for colorscheme themes: https://github.com/alacritty/alacritty-theme#imports

It's a simple array of strings which is called import, it could be called whatever and is a plain yaml array with strings. Those strings we use as a source of other configurations which we manually merge.

foo:
  - "./foo1.yml"
  - "./foo2.yml"

@tobiasbaehr
Copy link

btw. when you enable alacritty via home manager, then it generates json for alacritty.yml.

I do not believe this is valid. ;-)

@rycee
Copy link
Member

rycee commented May 29, 2023

@tobiasbaehr YAML is a superset of JSON so any valid JSON is also valid YAML so we have historically used Nix's builtin toJSON function also for YAML output.

@kchibisov
Copy link

Should be as simple as changing pkgs.formats.yaml to pkgs.formats.toml, and maybe that will be a good time to revisit this TODO. I think we can do the backslash substitution as a postBuild on the generated toml file, if that's still needed. See #611 (comment)

@ncfavier we've updated the config to use toml, though. While there's no release with it, I wonder how to handle escaping (given how obscure nix docs are). For yml there was a conversion to string, but there's no toTOML function, so just using pkgs.format.toml is not enough, since \u can't be translated by any input syntax.

@ncfavier
Copy link
Member

I think the easiest would be something like

pkgs.runCommand "alacritty-unescaped.toml" {} ''
  sed -E 's/\\(\\[uU])/\1/g' ${toml.generate "alacritty.toml" settings} > "$out"
''

Though maybe alacritty could take care of interpreting backslash sequences itself in the relevant options? (Does it ever make sense to have a literal backslash in keybindings?)

@kchibisov
Copy link

kchibisov commented Jun 12, 2023

It's not about just keybindings, you can define arbitrary regexes to search, so user can type whatever they want, it's just an issue that you can't generate toml with \u no matter how you try with nix (unless you sed).

@kchibisov
Copy link

Besides, you'd need a

sed -E 's/\\\\/\\/g'

Otherwise other \ commands won't translate from the way it was with yml (at least my config required that to translate).

@VergeDX
Copy link
Contributor

VergeDX commented Jun 30, 2023

Maybe we can make an option of format? Because TOML theme not capable with YAML format config.
In my case theme https://github.com/rose-pine/alacritty uses TOML format, but hm still generate YAML.

@ncfavier
Copy link
Member

The TOML change has not been released yet. If you're using alacritty master, feel free to open a PR and use it and we'll merge it when the release hits nixpkgs.

@oxalica
Copy link
Contributor

oxalica commented Jul 14, 2023

I don't think nixpkgs has a builtin.toTOML

That can be implemented in Nix. I created a PR in nixpkgs: NixOS/nixpkgs#243390

@stale
Copy link

stale bot commented Oct 14, 2023

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

@stale stale bot added the status: stale label Oct 14, 2023
@Airradda
Copy link

As of Alacritty Version 0.13.0, the configuration file format is now TOML.

Configuration file now uses TOML instead of YAML
Run alacritty migrate to automatically convert all configuration files

@stale stale bot removed the status: stale label Dec 28, 2023
@flaturtha
Copy link

I upgraded this morning and when I tried to run alacritty migrate, I got the following error: "Configuration file migration failed:
"/home/h/.config/alacritty/alacritty.yml": parsing error: Yaml conversion error: unsupported unit type"

I'm not an expert but am trying to learn. Therefore, I'm obviously missing something but am unsure how to proceed. Googling hasn't help. Nor did ChatGPT! :-)

@kchibisov
Copy link

it means that the old config was not valid in the first place, as in wrong section alignments, etc.

@flaturtha
Copy link

Yeah, I figured something like that but I don't believe I ever changed it. Is there a standard file I can use?

@kchibisov
Copy link

man 5 alacritty or alacritty.org.

@flaturtha
Copy link

gee, thanks for helping a noob

@ncfavier
Copy link
Member

ncfavier commented Jan 4, 2024

Fixed by #4817

@n8henrie
Copy link
Contributor

@rycee @ncfavier -- could this be considered for backporting to 23.11? As it has the version check built-in I think it should be compatible.

I'm happy to test, though I'm not entirely sure how -- actually it looks like I should be able to use disabledModules for this. Should be able to try tomorrow and report back.

(I am pinned to release-23.11 for my system as a whole but use a handful of unstable packages for development, including alacritty.)

@n8henrie
Copy link
Contributor

I can confirm that the updated programs.alacritty works on 23.11 with alacritty <0.13 (generates yml) as well as alacritty >= 13 (generates toml) and avoid the warning message in both cases.

Can a backport be considered?

For other readers, this I have a home-manager-unstable flake input in my otherwise 23.11-pinned configuration, and I pass that input via specialArgs

{
  pkgs,
  lib,
  config,
  ...
} @ args: {
imports = [
    "${args.inputs.home-manager-unstable}/modules/programs/alacritty.nix"
];
disabledModules = ["programs/alacritty.nix"];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests