https://github.com/gleam-lang/mix_gleam
⚗️ Build Gleam code with mix
https://github.com/gleam-lang/mix_gleam
build-tool elixir gleam mix
Last synced: 6 days ago
JSON representation
⚗️ Build Gleam code with mix
- Host: GitHub
- URL: https://github.com/gleam-lang/mix_gleam
- Owner: gleam-lang
- License: apache-2.0
- Created: 2020-05-29T12:46:43.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-02-12T02:18:25.000Z (about 1 year ago)
- Last Synced: 2025-02-08T19:11:05.509Z (13 days ago)
- Topics: build-tool, elixir, gleam, mix
- Language: Elixir
- Homepage:
- Size: 63.5 KB
- Stars: 179
- Watchers: 6
- Forks: 20
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# MixGleam
[](https://hex.pm/packages/mix_gleam)
[](https://hexdocs.pm/mix_gleam/)
[](https://github.com/gleam-lang/mix_gleam/blob/main/LICENCE)
[](https://github.com/gleam-lang/mix_gleam/actions)An Elixir archive that teaches `Mix` how to work with Gleam code and
dependencies!## Installation
Install the Gleam compiler onto your machine.
[Installation instructions can be found here](https://gleam.run/getting-started/installing-gleam.html).Install or update the `MixGleam` archive from Hex:
```shell
$ mix archive.install hex mix_gleam
```To install or update from source:
```shell
$ mix archive.uninstall mix_gleam # if this archive was previously installed
$ git clone https://github.com/gleam-lang/mix_gleam.git
$ cd mix_gleam
$ MIX_ENV=prod mix do archive.build, archive.install
```Configure your `Mix` project to use the `MixGleam` archive to work with Gleam's
compiler and Gleam dependencies:```elixir
# in mix.exs
# ...
@app :my_gleam_appdef project do
[
app: @app,
# ...
archives: [mix_gleam: "~> 0.6"],
compilers: [:gleam | Mix.compilers()],
aliases: [
# Or add this to your aliases function
"deps.get": ["deps.get", "gleam.deps.get"]
],
erlc_paths: [
"build/dev/erlang/#{@app}/_gleam_artefacts",
# For Gleam < v0.25.0
"build/dev/erlang/#{@app}/build"
],
erlc_include_path: "build/dev/erlang/#{@app}/include",
# For Elixir >= v1.15.0
prune_code_paths: false,
# ...
]
end
# ...
```To see an entire example `mix.exs` file you can adapt to your existing `Mix`
project:```shell
$ mix gleam.new --retro
```If you want to write Gleam code in your project, it's a good idea to add
`gleam_stdlib` and `gleeunit` to your project's dependencies:```elixir
# in mix.exs
# ...
defp deps do
[
# ...
{:gleam_stdlib, "~> 0.34 or ~> 1.0"},
{:gleeunit, "~> 1.0", only: [:dev, :test], runtime: false},
# ...
]
end
# ...
```Make a `src` directory for your Gleam code to live in:
```shell
$ mkdir src
```And add the `build` directory to your `.gitignore` file so Gleam's build
artefacts are not included in your project.To run Gleam tests from the `test/` directory with `:gleeunit`, you can run:
```shell
$ mix gleam.test
```## Example
Check the [test project](test_projects/basic_project/) for an example that
contains both Elixir and Gleam code. See the
[Elixir](test_projects/basic_project/test/basic_project_test.exs) and
[Gleam](test_projects/basic_project/test/basic_project_test.gleam) test files to
find examples on calling Gleam code from Elixir, and vice-versa.