Skip to content

Developing a Gleam application

In this tutorial, you will learn how to add flake.nix to a Gleam project.

Initialize a new project

  1. Make gleam executable available:

    Terminal window
    nix shell nixpkgs#gleam
  2. Run gleam new to scaffold a new project:

    Terminal window
    gleam new --skip-github 'your_new_project'

    By default, gleam new generates .github directory containing a CI workflow for running tests, but we don't need it as we will install Gleam using Nix.

  3. Enter the directory:

    Terminal window
    cd 'your_new_project'

Add flake.nix to the project

  1. Initialize the template from the root directory of the project:

    Terminal window
    nix flake init github:akirak/flake-templates#gleam
  2. Open flake.nix and update the Erlang version to the current one:

    erlang_version = "erlang_26";
    erlang_version = "erlang_27";
  3. Add .envrc:

    Terminal window
    use flake
  4. Allow direnv:

    Terminal window
    direnv allow