Skip to content

quickstart

the general flow goes like:

  1. use the gleam2nix tool to generate a gleam.nix file from your gleam project’s manifest.toml
  2. call buildGleamApplication to produce a derivation for your project

to get gleam2nix imported, pick one of the following based on your project structure:

first, pull in this repo through whatever dependency management mechanism you prefer, such as npins, niv or just a plain ol’ fetchTarball. from the repo, you can import one of the following, based on how you want to use gleam2nix:

  • default.nix (recommended): contains all the packages and functions you’ll need
  • nix/overlay.nix: an overlay function that can be added to nixpkgs.

both options will define the following:

  • gleam2nix: the gleam2nix cli tool
  • buildGleamApplication: function for building a gleam application
  • buildGleam: low-level function to compile a single gleam package
  • gleam-tool: helper tool used by buildGleam and buildGleamApplication

once setup, you can add gleam2nix whereever you need it. for example, in a nix shell:

pkgs.mkShell {
name = "devshell";
packages = [
gleam2nix
]
}

run gleam2nix in the root of your project (ie. the folder containing your manifest.toml) to get a gleam.nix file. you can then pass it to a buildGleamApplication call to get your derivation:

buildGleamApplication {
pname = "my_gleam_application";
version = "1.0.0";
src = ./.;
gleamNix = import ./gleam.nix;
}