vic/gleam-nix
{ "defaultBranch": "main", "description": "Build Gleam with Nix.", "fullName": "vic/gleam-nix", "homepage": "https://github.com/vic/gleam-nix/wiki/Historic-Builds", "language": "Nix", "name": "gleam-nix", "pushedAt": "2025-11-25T05:18:42Z", "stargazersCount": 30, "updatedAt": "2025-11-25T05:18:45Z", "url": "https://github.com/vic/gleam-nix"}Gleam on Nix
Section titled “Gleam on Nix”This repo provides packages and [development shells][devshell] for working with [Gleam] projects using Nix.
# running `gleam --version`$ nix run github:vic/gleam-nix -- --versiongleam 1.9.0
# you can also override to use any gleam revision (commit,branch,release) and any rust version (prefer stable releases)$ nix run github:vic/gleam-nix --override-input gleam github:gleam-lang/gleam/v1.9.1 --override-input rust-manifest file+https://static.rust-lang.org/dist/channel-rust-1.85.0.toml -- --versiongleam 1.9.1For previous versions see Historic Builds
Hack with Gleam
Section titled “Hack with Gleam”If you are creating a new awesome project with Gleam,
this flake can provide you with a development environment
containing gleam and two of its run-times: erlang and nodejs.
$ nix run github:vic/gleam-nix -- new my-new-project$ cd my-new-project$ nix develop github:vic/gleam-nix -c $SHELL -lIf you are using [direnv], create an .envrc file with
the following content:
use flake github:vic/gleam-nixHack on Gleam
Section titled “Hack on Gleam”If you are willing to contribute to Gleam development, this flake can provide you an entire development environment ready for you to focus only on making Gleam awesome.
$ git clone https://github.com/gleam-lang/gleam$ cd gleam$ nix develop github:vic/gleam-nix#hack-on-gleam --override-input gleam "path:$PWD" -c $SHELL -lIf you are using [direnv], create an .envrc file with
the following content:
use flake github:vic/gleam-nix#hack-on-gleam --override-input gleam "path:$PWD"Hack on this repo
Section titled “Hack on this repo”$ nix develop .#hack-on-gleam-nix -c $SHELL -lIf you are using [direnv] this repo already contains an .envrc you can load.
Contributing
Section titled “Contributing”Yes, please :).
See [hack-on-gleam-nix]!(devshells/hack-on-gleam-nix.md)
Try not to change gleam pinned release unless it no longer builds with
the current Rust toolchain. In that case, update the rust-manifest input
and the gleam pinned release. And please update Historic Builds with the range of known versions able to build.
-
How is this different from the
gleampackage provided bynixpkgs.This flake existed before we had an official
gleampackage onnixpkgs. And most people would indeed only use that package.However, for gleam hackers, this flake would be better suited since it provides a development shell with dependencies based on Gleam’s source.
Also people trying to use a more recent or experimental version of Gleam will benefit from this flake.
-
I’m getting a
option 'allow-import-from-derivation' is disablederror.Old versions of this repo bundled a
Cargo.nixfile containing all of Gleam’s dependencies in order for nix to know how to fetch them and how to build the Gleam cargo workspace.However, one inconvenience of this was that the
Cargo.nixfile was tied to a particular Gleam revision, and since Gleam is improving quite rapidly, it was not uncommon to find theCargo.nixfile on this repo being outdated with respect to Gleam’s source code.People had to regularly re-create the
Cargo.nixfile withcargo2nix.Now, instead of using
cargo2nix, we usecrate2nixwhich allows us to generate theCargo.nixfile as part of the build. Thus not requiring we to bundle it on this repo, and prevent it from getting outdated. One advantage is that using--override-input gleam <some-gleam-url>will automatically generateCargo.nixfor that particular gleam revision.This repo will only need to be updated when we have to bump the rust toolchain as expected by Gleam.
On the other side, by not bundling a
Cargo.nix, building withcrate2nixrequires theallow-import-from-derivationnix option to be enabled.This flake enables this option as part of
flake.nixand will be activated if you are listed as trusted-user in yournix.confor provide--accept-flake-configexplicitly.
[devshell] !: https://numtide.github.io/devshell [direnv] !: https://direnv.net [gleam] !: https://gleam.run