aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/index/tectonic/init.lua
blob: c2bbaade1619b62967aff7548ee57e0f2843f81c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
local Optional = require "mason-core.optional"
local Pkg = require "mason-core.package"
local _ = require "mason-core.functional"
local github = require "mason-core.managers.github"
local platform = require "mason-core.platform"
local std = require "mason-core.managers.std"

local coalesce, when = _.coalesce, _.when

return Pkg.new {
    name = "tectonic",
    desc = [[Tectonic is a modernized, complete, self-contained TeX/LaTeX engine, powered by XeTeX and TeXLive.]],
    homepage = "https://tectonic-typesetting.github.io",
    languages = { Pkg.Lang.LaTeX },
    categories = { Pkg.Cat.Compiler },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        local repo = "tectonic-typesetting/tectonic"
        local function format_release_file(file)
            return _.compose(_.format(file), _.gsub("^tectonic@", ""))
        end

        platform.when {
            unix = function()
                github
                    .untargz_release_file({
                        repo = repo,
                        version = Optional.of "tectonic@0.12.0",
                        asset_file = coalesce(
                            when(platform.is.mac_x64, format_release_file "tectonic-%s-x86_64-apple-darwin.tar.gz"),
                            when(platform.is.mac_arm64, format_release_file "tectonic-%s-aarch64-apple-darwin.tar.gz"),
                            when(
                                platform.is.linux_x64_gnu,
                                format_release_file "tectonic-%s-x86_64-unknown-linux-gnu.tar.gz"
                            ),
                            when(
                                platform.is.linux_x64,
                                format_release_file "tectonic-%s-x86_64-unknown-linux-musl.tar.gz"
                            ),
                            when(
                                platform.is.linux_arm,
                                format_release_file "tectonic-%s-arm-unknown-linux-musleabihf.tar.gz"
                            )
                        ),
                    })
                    .with_receipt()
                std.chmod("+x", { "tectonic" })
                ctx:link_bin("tectonic", "tectonic")
            end,
            win = function()
                github
                    .unzip_release_file({
                        repo = repo,
                        asset_file = format_release_file "tectonic-%s-x86_64-pc-windows-msvc.zip",
                    })
                    .with_receipt()
                ctx:link_bin("tectonic", "tectonic.exe")
            end,
        }
    end,
}