1
1
# rust-overlay
2
2
3
3
* Pure and reproducible* overlay for binary distributed rust toolchains.
4
- A better replacement for github: mozilla /nixpkgs-mozilla
4
+ A compatible but better replacement for rust overlay of [ github: mozilla /nixpkgs-mozilla] [ mozilla ] .
5
5
6
- Hashes of toolchain components are pre-fetched (and compressed) in ` manifests ` directory.
7
- So there's no need to have network access during nix evaluation (but nixpkgs-mozilla does).
6
+ Hashes of toolchain components are pre-fetched (and compressed) in tree (` manifests ` directory),
7
+ so the evaluation is * pure* and no need to have network (but [ nixpkgs-mozilla] [ mozilla ] does).
8
+ It also works well with [ Nix Flakes] ( https://nixos.wiki/wiki/Flakes ) .
8
9
9
- Since the evaluation is now * pure* , it also means this can work well with [ Nix Flakes] ( https://nixos.wiki/wiki/Flakes ) .
10
-
11
- - [ ] Auto-updating is TODO.
10
+ - The toolchain hashes are auto-updated daily using GitHub Actions.
12
11
- Current oldest supported version is stable 1.29.0 and nightly 2018-09-13
13
12
(which is randomly chosen).
14
13
15
- ## Use as classical nix overlay
16
-
17
- The installaction and usage are exactly the same as nixpkgs-mozilla.
18
- You can follow https://github.com/mozilla/nixpkgs-mozilla#rust-overlay and just replace the url to
19
- https://github.com/oxalica/rust-overlay
14
+ ## Use as a classic Nix overlay
20
15
21
16
You can put the code below into your ` ~/.config/nixpkgs/overlays.nix ` .
22
17
``` nix
23
- [ (import (builtins.fetchTarball https://github.com/oxalica/rust-overlay/archive/master.tar.gz)) ]
18
+ [ (import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz")) ]
19
+ ```
20
+ Then the provided attribute paths are available in nix command.
21
+ ``` bash
22
+ $ nix-env -iA rust-bin.stable.latest.rust # Do anything you like.
24
23
```
25
24
26
- Or install it into ` nix-channel ` :
27
- ``` shell
25
+ Alternatively, you can install it into nix channels.
26
+ ``` bash
28
27
$ nix-channel --add https://github.com/oxalica/rust-overlay/archive/master.tar.gz rust-overlay
28
+ $ nix-channel --update
29
29
```
30
30
And then feel free to use it anywhere like
31
- ` import <nixpkgs> { overlays = [ (import <rust-overlay>) ] } ` in your nix shell environment
31
+ ` import <nixpkgs> { overlays = [ (import <rust-overlay>) ]; } ` in your nix shell environment.
32
32
33
33
## Use with Nix Flakes
34
34
35
- This repository already has flake support. So you can simply use it as input.
36
- Here's an example of using it in nixos configuration.
35
+ This repository already has flake support.
37
36
37
+ NOTE: ** Only the output ` overlay ` is stable and preferred to be used in your flake.**
38
+ Other outputs like ` packages ` and ` defaultPackage ` are for human try and are subject to change.
39
+
40
+ For a quick play, just use ` nix shell ` to bring the latest stable rust toolchain into scope.
41
+ (All commands below requires preview version of Nix with flake support.)
42
+ ``` shell
43
+ $ nix shell github:oxalica/rust-overlay
44
+ $ rustc --version
45
+ rustc 1.49.0 (e1884a8e3 2020-12-29)
46
+ $ cargo --version
47
+ cargo 1.49.0 (d00d64df9 2020-12-05)
48
+ ```
49
+
50
+ Here's an example of using it in nixos configuration.
38
51
``` nix
39
52
{
40
53
description = "My configuration";
@@ -52,7 +65,7 @@ Here's an example of using it in nixos configuration.
52
65
./configuration.nix # Your system configuration.
53
66
({ pkgs, ... }: {
54
67
nixpkgs.overlays = [ rust-overlay.overlay ];
55
- environment.systemPackages = [ pkgs.latest.rustChannels. stable.rust ];
68
+ environment.systemPackages = [ pkgs.rust-bin. stable.latest .rust ];
56
69
})
57
70
];
58
71
};
@@ -61,31 +74,72 @@ Here's an example of using it in nixos configuration.
61
74
}
62
75
```
63
76
64
- ## Interface
77
+ ## Attributes provided by the overlay
65
78
66
- The overlay re-use many codes from nixpkgs/mozilla and the interface is ** almost the same** .
67
- It provides ` latest.rustChannels.{stable,nightly}.<toolchain-component> ` and ` rustChannelOf ` .
79
+ ``` nix
80
+ {
81
+ rust-bin = {
82
+ # The default dist url for fetching.
83
+ # Override it if you want to use a mirror server.
84
+ distRoot = "https://static.rust-lang.org/dist";
85
+
86
+ stable = {
87
+ # The latest stable toolchain.
88
+ latest = {
89
+ # Aggregate all default components. (recommended)
90
+ rust = «derivation»;
91
+ # Individial components.
92
+ rustc = «derivation»;
93
+ cargo = «derivation»;
94
+ rust-std = «derivation»;
95
+ # ... other components
96
+ };
97
+ "1.49.0" = { /* toolchain */ };
98
+ "1.48.0" = { /* toolchain */ };
99
+ # ... other versions.
100
+ };
68
101
69
- To use the latest stable or nightly rust toolchain, the easiest way is just to install
70
- ` latest.rustChannels.{stable,nightly}.rust ` , which combines ` rustc ` , ` cargo ` , ` rustfmt ` and
71
- all other default components.
102
+ nightly = {
103
+ # The latest nightly toolchain.
104
+ latest = { /* toolchain */ };
105
+ "2020-12-31" = { /* toolchain */ };
106
+ "2020-12-30" = { /* toolchain */ };
107
+ # ... other versions.
108
+ };
72
109
73
- You can also pin to specific nightly toolchain using ` rustChannelOf ` :
74
- ``` nix
75
- (nixpkgs.rustChannelOf { date = "2020-01-01"; channel = "nightly"; }).rust
76
- ```
110
+ # ... Some internal attributes omitted.
111
+ };
77
112
78
- Customize an toolchain.
79
- ``` nix
80
- nixpkgs.latest.rustChannels.stable.rust.override {
81
- extensions = [
82
- "rust-src"
83
- ];
84
- targets = [
85
- "x86_64-unknown-linux-musl"
86
- "arm-unknown-linux-gnueabihf"
87
- ];
113
+ # These are for compatibility with nixpkgs-mozilla and
114
+ # provide same toolchains as `rust-bin.*`.
115
+ latest.rustChannels = /* ... */;
116
+ rustChannelOf = /* ... */;
117
+ rustChannelOfTargets = /* ... */;
118
+ rustChannels = /* ... */;
88
119
}
89
120
```
90
121
91
- For more details, see ` ./rust-overlay.nix ` or README of https://github.com/mozilla/nixpkgs-mozilla .
122
+ Some examples (assume ` nixpkgs ` had the overlay applied):
123
+
124
+ - Latest stable rust with all default components:
125
+ ` nixpkgs.rust-bin.stable.latest.rust `
126
+ - Latest nightly rust with all default components:
127
+ ` nixpkgs.rust-bin.nightly.latest.rust `
128
+ - A specific version of stable rust:
129
+ ` nixpkgs.rust-bin.stable."1.48.0".rust `
130
+ - A specific date of nightly rust:
131
+ ` nixpkgs.rust-bin.nightly."2020-12-31".rust `
132
+ - Latest stable rust with additional component ` rust-src ` and extra target
133
+ ` arm-unknown-linux-gnueabihf ` :
134
+
135
+ ``` nix
136
+ nixpkgs.rust-bin.stable.latest.rust.override {
137
+ extensions = [ "rust-src" ];
138
+ targets = [ "arm-unknown-linux-gnueabihf" ];
139
+ }
140
+ ```
141
+
142
+ For detail about ` override ` , see the source code of ` ./rust-overlay.nix ` ,
143
+ or README of [ nixpkgs-mozilla] [ mozilla ] .
144
+
145
+ [ mozilla ] : https://github.com/mozilla/nixpkgs-mozilla
0 commit comments