Skip to main content

idt/installers/
alacritty.rs

1use std::path::Path;
2
3use ytil_cmd::silent_cmd;
4
5use crate::installers::Installer;
6
7pub struct Alacritty<'a> {
8    pub dev_tools_dir: &'a Path,
9    pub bin_dir: &'a Path,
10}
11
12impl Installer for Alacritty<'_> {
13    fn bin_name(&self) -> &'static str {
14        "alacritty"
15    }
16
17    /// Builds Alacritty from source, symlinks the binary into `bin_dir`, and
18    /// copies `Alacritty.app` into `/Applications` (atomic swap).
19    fn install(&self) -> rootcause::Result<()> {
20        let source_dir = self.dev_tools_dir.join(self.bin_name()).join("source");
21
22        silent_cmd("sh")
23            .args([
24                "-c",
25                &format!(
26                    r#"
27                        ([ ! -d "{0}" ] && \
28                            git clone --depth=1 https://github.com/alacritty/alacritty.git {0} || true) && \
29                        cd {0} && \
30                        git fetch origin master --depth=1 && \
31                        git checkout origin/master && \
32                        rustup toolchain install stable --profile default && \
33                        rustup override set stable && \
34                        make app
35                    "#,
36                    source_dir.display(),
37                ),
38            ])
39            .status()?
40            .exit_ok()?;
41
42        let app = source_dir
43            .join("target")
44            .join("release")
45            .join("osx")
46            .join("Alacritty.app");
47
48        crate::installers::install_macos_app(&app, self.bin_dir, self.bin_name())?;
49
50        Ok(())
51    }
52
53    fn health_check_args(&self) -> Option<&[&str]> {
54        Some(&["--version"])
55    }
56
57    fn should_verify_checksum(&self) -> bool {
58        false
59    }
60}