Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vic/gleam-nix
Build Gleam with Nix.
https://github.com/vic/gleam-nix
gleam nix nix-flake
Last synced: 3 months ago
JSON representation
Build Gleam with Nix.
- Host: GitHub
- URL: https://github.com/vic/gleam-nix
- Owner: vic
- License: apache-2.0
- Created: 2021-12-21T00:26:02.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-20T11:57:00.000Z (6 months ago)
- Last Synced: 2024-10-11T22:24:11.655Z (4 months ago)
- Topics: gleam, nix, nix-flake
- Language: Nix
- Homepage: https://gleam.run
- Size: 166 KB
- Stars: 20
- Watchers: 2
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Reproducible builds for Gleam.
# If you already have Nix installed, try Gleam right away by using:
$ nix shell github:vic/gleam-nix
$ gleam --version
gleam 0.33.0
[![Build history](https://buildstats.info/github/chart/vic/gleam-nix?branch=main)](https://github.com/vic/gleam-nix/actions)
###### Stable releases at nixpkgs#gleam
There exists an stable-release gleam derivation on nixpkgs. To use it, simply do:```
nix shell nixpkgs#gleam
gleam --version
```The flake provided on this repo is most likely to be used by people hacking on gleam itself or
willing to build some experimental branches.##### Requirements
For using this flake you'll need `nix` version [2.8](https://discourse.nixos.org/t/nix-2-8-0-released/18714)
or latter which must have the [`flakes`](https://nixos.wiki/wiki/Flakes) feature enabled.See [nix quick-install](https://nixos.org/download.html) or the [install-nix tutorial](https://nix.dev/tutorials/install-nix)
for more in depth instructions.## Installing Gleam locally (~/.nix-profile)
```shell
# This will install Gleam from latest commit on main branch.
nix profile install github:vic/gleam-nix --override-input gleam github:gleam-lang/gleam/main
gleam --help
```## Installing Gleam on a flake.
Using the overlay provided by this flake you can add Gleam to any
NixOS system or flake-controlled project environment of yours.```nix
{
inputs.gleam-nix.url = "github:vic/gleam-nix";outputs = { gleam-nix, nixpkgs, ... }:
let
system = "aarch64-darwin"; # or anything you use.
pkgs = import nixpkgs {
inherit system;
overlays = [ gleam-nix.overlays.default ];
};
in {
packages.${system}.gleam = pkgs.gleam;
};
}
```## Developing Gleam with a Nix environment.
Also, for Gleam developers, using Nix ensures we get the same
development environment in an instant, all you have to do is
checkout the Gleam repo and run:```shell
nix develop github:vic/gleam-nix --override-input gleam path:$PWD
# open your editor and hack hack hack..
cargo run # build dependencies are loaded in your shell
```Gleam maintainers can also use this to try PR experimental features
from other contributors. Just override where the Gleam source
comes from by specifying the repository/branch name.```shell
# running gleam to try other people branches:
nix shell github:vic/gleam-nix --override-input gleam github:/gleam/ -c gleam --help
```## Contributing
Most of the time this flake should be able to build the latest Gleam source.
```
# Test that the main branch or any other commit is buildable.
nix flake run --override-input gleam github:gleam-lang/gleam/main -- --version
```However, as Gleam development progresses, this flake might get outdated since
dependencies to build Gleam might have changed. Most of the time, this should
be fixed by regenerating the Cargo.nix file as instructed bellow.If you contribute a PR, be sure to also update the latest Gleam version
known to build at the first section of this document, so that people can
use the git history if the need to find the commit that can build older versions.[Nix flakes](https://nixos.wiki/wiki/Flakes) are the secret sauce for nix reproducible builds.
Since all build dependencies get hashed, even the source code.
Every external dependency such external repos (e.g. nixpkgs),
external utilities (e.g. cargo llvm make), and any Cargo.toml
workspace dependency (read from `Cargo.nix`) gets hashed so that
nix only builds what has actually changed.If you edit the `flake.nix` file, for example to change the rust
toolchain or the nixpkgs revision, run `nix flake udpate` afterwards
to regenerate the lock file.Also run `nix run '.#fmt'` to keep al nix files formatted before sending a PR.
#### Regenerating `Cargo.nix`
From time to time the `Cargo.nix` file needs to be re-generated
by using [cargo2nix](https://github.com/cargo2nix/cargo2nix)
in order to keep Gleam's cargo deps nix-controlled.This is needed when Gleam introduces new dependencies or their versions get updated.
```shell
nix run '.#genCargoNix'
```#### Updating nixpkgs version
By default this package will build using the latest stable nixpkgs release.
If you need to update to a most recent release, edit the `nixpkgs.url` line on flake.nix.#### Updating the rust toolchain.
By default this package will build using the latest rust-stable version.
If you need to update it, edit the `rustChannel` version at flake.nix.