In this tutorial, you will learn how to add flake.nix
to a Gleam project.
Initialize a new project
Make
gleam
executable available:Terminal window nix shell nixpkgs#gleamRun
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.Enter the directory:
Terminal window cd 'your_new_project'
Add flake.nix to the project
Initialize the template from the root directory of the project:
Terminal window nix flake init github:akirak/flake-templates#gleamOpen
flake.nix
and update the Erlang version to the current one:erlang_version = "erlang_26";erlang_version = "erlang_27";Add
.envrc
:Terminal window use flakeAllow direnv:
Terminal window direnv allow