Skip to content

Commit 76c7b8a

Browse files
authored
Update contributing docs. (#5)
1 parent 19aa55a commit 76c7b8a

File tree

1 file changed

+44
-37
lines changed

1 file changed

+44
-37
lines changed

README.md

+44-37
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
# Reproducible builds for Gleam.
22

3-
```
4-
nix run github:vic/gleam-nix -- --version
5-
gleam [0.29.0-rc1](https://github.com/gleam-lang/gleam/commit/9ba0a5f)
6-
```
3+
<pre>
4+
<code>
5+
# If you already have Nix installed, try Gleam right away by using:
6+
$ nix shell github:vic/gleam-nix
7+
$ gleam --version
8+
gleam <a href="https://github.com/gleam-lang/gleam/commit/9ba0a5f">0.29.0-rc1</a>
9+
</code>
10+
</pre>
711

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

10-
[nix](https://nixos.org/) is a purely functional package manager with
11-
fully-cacheable, to-the-byte reproducible builds.
12-
13-
This guide documents how people using the Nix package manager or
14-
NixOS systems can easily build every version of Gleam with just
15-
a single command.
16-
17-
18-
<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">
19-
20-
2114
##### Requirements
2215

2316
For using this guide you'll need `nix` version [2.8](https://discourse.nixos.org/t/nix-2-8-0-released/18714)
@@ -26,45 +19,58 @@ or latter which must have the [`flakes`](https://nixos.wiki/wiki/Flakes) feature
2619
See [nix quick-install](https://nixos.org/download.html) or the [install-nix tutorial](https://nix.dev/tutorials/install-nix)
2720
for more in depth instructions.
2821

22+
2923
## Installing Gleam locally (~/.nix-profile)
3024

3125
```shell
32-
# This will install gleam from latest commit on main branch.
26+
# This will install Gleam from latest commit on main branch.
3327
nix profile install github:vic/gleam-nix --override-input gleam github:gleam-lang/gleam/main
3428
gleam --help
3529
```
3630

37-
## Running Gleam nightly. (or any branch/commit)
31+
## Installing Gleam on a flake.
3832

39-
The following command runs `gleam --help` on the build from
40-
the latest commit on `main` branch.
33+
Using the overlay provided by this flake you can add Gleam to any
34+
NixOS system or flake-controlled project environment of yours.
4135

42-
```shell
43-
# The latest commit from Gleam's main branch. (can be a commit hash, tag or branch name)
44-
nix shell github:vic/gleam-nix --override-input gleam github:gleam-lang/gleam/main -c gleam --help
45-
```
4636

47-
Gleam maintainers can also use this to try PR experimental features
48-
from other contributors just by overriding where the Gleam source
49-
comes from specifying the repository/branch name.
37+
```nix
38+
{
39+
inputs.gleam-nix.url = "github:vic/gleam-nix";
5040
51-
```shell
52-
# running gleam to try other people branches:
53-
nix shell github:vic/gleam-nix --override-input gleam github:<someone>/gleam/<cool-feature> -c gleam --help
41+
outputs = { gleam-nix, nixpkgs, ... }:
42+
let
43+
system = "aarch64-darwin"; # or anything you use.
44+
pkgs = import nixpkgs {
45+
inherit system;
46+
overlays = [ gleam-nix.overlays.default ];
47+
};
48+
in {
49+
packages.${system}.gleam = pkgs.gleam;
50+
};
51+
}
5452
```
5553

54+
5655
## Developing Gleam with a Nix environment.
5756

5857
Also, for Gleam developers, using Nix ensures we get the same
5958
development environment in an instant, all you have to do is
6059
checkout the Gleam repo and run:
6160

6261
```shell
63-
nix develop github:vic/gleam-nix --override-input gleam path:$PWD # -c fish # you might use your preferred shell
62+
nix develop github:vic/gleam-nix --override-input gleam path:$PWD
6463
# open your editor and hack hack hack..
65-
cargo build # build dependencies are loaded in your shell
66-
# or
67-
nix run github:vic/gleam-nix --override-input gleam path:$PWD -- --help # runs your local `gleam --help`
64+
cargo run # build dependencies are loaded in your shell
65+
```
66+
67+
Gleam maintainers can also use this to try PR experimental features
68+
from other contributors. Just override where the Gleam source
69+
comes from by specifying the repository/branch name.
70+
71+
```shell
72+
# running gleam to try other people branches:
73+
nix shell github:vic/gleam-nix --override-input gleam github:<someone>/gleam/<cool-branch> -c gleam --help
6874
```
6975

7076
## Contributing
@@ -81,7 +87,8 @@ dependencies to build Gleam might have changed. Most of the time, this should
8187
be fixed by regenerating the Cargo.nix file as instructed bellow.
8288

8389
If you contribute a PR, be sure to also update the latest Gleam version
84-
known to build at the first section of this document.
90+
known to build at the first section of this document, so that people can
91+
use the git history if the need to find the commit that can build older versions.
8592

8693

8794
[Nix flakes](https://nixos.wiki/wiki/Flakes) are the secret sauce for nix reproducible builds.
@@ -97,7 +104,7 @@ to regenerate the lock file.
97104

98105
Also run `nix run '.#fmt'` to keep al nix files formatted before sending a PR.
99106

100-
## Regenerating `Cargo.nix`
107+
#### Regenerating `Cargo.nix`
101108

102109
From time to time the `Cargo.nix` file needs to be re-generated
103110
by using [cargo2nix](https://github.com/cargo2nix/cargo2nix)
@@ -109,12 +116,12 @@ This is needed when Gleam introduces new dependencies or their versions get upda
109116
nix run '.#genCargoNix'
110117
```
111118

112-
## Updating nixpkgs version
119+
#### Updating nixpkgs version
113120

114121
By default this package will build using the latest stable nixpkgs release.
115122
If you need to update to a most recent release, edit the `nixpkgs.url` line on flake.nix.
116123

117-
## Updating the rust toolchain.
124+
#### Updating the rust toolchain.
118125

119126
By default this package will build using the latest rust-stable version.
120127
If you need to update it, edit the `rustChannel` version at flake.nix.

0 commit comments

Comments
 (0)