Skip to content

Commit

Permalink
Adding some comments on how to contribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
vic committed May 17, 2023
1 parent 3b67e0a commit 71de352
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions README.md
@@ -1,5 +1,10 @@
# Reproducible builds for Gleam.

```
nix run github:vic/gleam-nix -- --version
gleam [0.29.0-rc1](https://github.com/gleam-lang/gleam/commit/9ba0a5f)
```

[![Build history](https://buildstats.info/github/chart/vic/gleam-nix?branch=main)](https://github.com/vic/gleam-nix/actions)

[nix](https://nixos.org/) is a purely functional package manager with
Expand All @@ -9,6 +14,7 @@ This guide documents how people using the Nix package manager or
NixOS systems can easily build every version of Gleam with just
a single command.


<img width="1027" alt="Screen Shot 2021-12-20 at 18 31 47" src="https://user-images.githubusercontent.com/331/146850903-6fd42dda-cef3-4f3b-a720-1916ba91ca22.png">


Expand Down Expand Up @@ -61,9 +67,24 @@ cargo build # build dependencies are loaded in your shell
nix run github:vic/gleam-nix --override-input gleam path:$PWD -- --help # runs your local `gleam --help`
```

## flake.nix
## 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.

[Nix flakes] are the secret sauce for nix reproducible builds.

[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
Expand All @@ -74,12 +95,28 @@ 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
make generate
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.


0 comments on commit 71de352

Please sign in to comment.