1
1
# Reproducible builds for Gleam.
2
2
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 >
7
11
8
12
[ ![ Build history] ( https://buildstats.info/github/chart/vic/gleam-nix?branch=main )] ( https://github.com/vic/gleam-nix/actions )
9
13
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
-
21
14
##### Requirements
22
15
23
16
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
26
19
See [ nix quick-install] ( https://nixos.org/download.html ) or the [ install-nix tutorial] ( https://nix.dev/tutorials/install-nix )
27
20
for more in depth instructions.
28
21
22
+
29
23
## Installing Gleam locally (~ /.nix-profile)
30
24
31
25
``` shell
32
- # This will install gleam from latest commit on main branch.
26
+ # This will install Gleam from latest commit on main branch.
33
27
nix profile install github:vic/gleam-nix --override-input gleam github:gleam-lang/gleam/main
34
28
gleam --help
35
29
```
36
30
37
- ## Running Gleam nightly. (or any branch/commit)
31
+ ## Installing Gleam on a flake.
38
32
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 .
41
35
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
- ```
46
36
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";
50
40
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
+ }
54
52
```
55
53
54
+
56
55
## Developing Gleam with a Nix environment.
57
56
58
57
Also, for Gleam developers, using Nix ensures we get the same
59
58
development environment in an instant, all you have to do is
60
59
checkout the Gleam repo and run:
61
60
62
61
``` 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
64
63
# 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
68
74
```
69
75
70
76
## Contributing
@@ -81,7 +87,8 @@ dependencies to build Gleam might have changed. Most of the time, this should
81
87
be fixed by regenerating the Cargo.nix file as instructed bellow.
82
88
83
89
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.
85
92
86
93
87
94
[ Nix flakes] ( https://nixos.wiki/wiki/Flakes ) are the secret sauce for nix reproducible builds.
@@ -97,7 +104,7 @@ to regenerate the lock file.
97
104
98
105
Also run ` nix run '.#fmt' ` to keep al nix files formatted before sending a PR.
99
106
100
- ## Regenerating ` Cargo.nix `
107
+ #### Regenerating ` Cargo.nix `
101
108
102
109
From time to time the ` Cargo.nix ` file needs to be re-generated
103
110
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
109
116
nix run ' .#genCargoNix'
110
117
```
111
118
112
- ## Updating nixpkgs version
119
+ #### Updating nixpkgs version
113
120
114
121
By default this package will build using the latest stable nixpkgs release.
115
122
If you need to update to a most recent release, edit the ` nixpkgs.url ` line on flake.nix.
116
123
117
- ## Updating the rust toolchain.
124
+ #### Updating the rust toolchain.
118
125
119
126
By default this package will build using the latest rust-stable version.
120
127
If you need to update it, edit the ` rustChannel ` version at flake.nix.
0 commit comments