Skip to content

Commit c135ecd

Browse files
committedFeb 5, 2018
Merge remote-tracking branch 'origin/master' into gcc-7
2 parents f03c188 + 3917279 commit c135ecd

File tree

359 files changed

+18416
-10609
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

359 files changed

+18416
-10609
lines changed
 

Diff for: ‎doc/languages-frameworks/rust.md

+64-36
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,24 @@ an example for a minimal `hello` crate:
7979
Now, the file produced by the call to `carnix`, called `hello.nix`, looks like:
8080

8181
```
82-
with import <nixpkgs> {};
82+
# Generated by carnix 0.6.5: carnix -o hello.nix --src ./. Cargo.lock --standalone
83+
{ lib, buildPlatform, buildRustCrate, fetchgit }:
8384
let kernel = buildPlatform.parsed.kernel.name;
8485
# ... (content skipped)
85-
hello_0_1_0_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate {
86-
crateName = "hello";
87-
version = "0.1.0";
88-
authors = [ "Authorname <user@example.com>" ];
89-
src = ./.;
90-
inherit dependencies buildDependencies features;
91-
};
9286
in
9387
rec {
94-
hello_0_1_0 = hello_0_1_0_ rec {};
88+
hello = f: hello_0_1_0 { features = hello_0_1_0_features { hello_0_1_0 = f; }; };
89+
hello_0_1_0_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate {
90+
crateName = "hello";
91+
version = "0.1.0";
92+
authors = [ "pe@pijul.org <pe@pijul.org>" ];
93+
src = ./.;
94+
inherit dependencies buildDependencies features;
95+
};
96+
hello_0_1_0 = { features?(hello_0_1_0_features {}) }: hello_0_1_0_ {};
97+
hello_0_1_0_features = f: updateFeatures f (rec {
98+
hello_0_1_0.default = (f.hello_0_1_0.default or true);
99+
}) [ ];
95100
}
96101
```
97102

@@ -103,33 +108,44 @@ dependencies, for instance by adding a single line `libc="*"` to our
103108
following nix file:
104109

105110
```
106-
with import <nixpkgs> {};
111+
# Generated by carnix 0.6.5: carnix -o hello.nix --src ./. Cargo.lock --standalone
112+
{ lib, buildPlatform, buildRustCrate, fetchgit }:
107113
let kernel = buildPlatform.parsed.kernel.name;
108114
# ... (content skipped)
109-
hello_0_1_0_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate {
110-
crateName = "hello";
111-
version = "0.1.0";
112-
authors = [ "Jörg Thalheim <joerg@thalheim.io>" ];
113-
src = ./.;
114-
inherit dependencies buildDependencies features;
115-
};
116-
libc_0_2_34_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate {
117-
crateName = "libc";
118-
version = "0.2.34";
119-
authors = [ "The Rust Project Developers" ];
120-
sha256 = "11jmqdxmv0ka10ay0l8nzx0nl7s2lc3dbrnh1mgbr2grzwdyxi2s";
121-
inherit dependencies buildDependencies features;
122-
};
123115
in
124116
rec {
125-
hello_0_1_0 = hello_0_1_0_ rec {
126-
dependencies = [ libc_0_2_34 ];
117+
hello = f: hello_0_1_0 { features = hello_0_1_0_features { hello_0_1_0 = f; }; };
118+
hello_0_1_0_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate {
119+
crateName = "hello";
120+
version = "0.1.0";
121+
authors = [ "pe@pijul.org <pe@pijul.org>" ];
122+
src = ./.;
123+
inherit dependencies buildDependencies features;
124+
};
125+
libc_0_2_36_ = { dependencies?[], buildDependencies?[], features?[] }: buildRustCrate {
126+
crateName = "libc";
127+
version = "0.2.36";
128+
authors = [ "The Rust Project Developers" ];
129+
sha256 = "01633h4yfqm0s302fm0dlba469bx8y6cs4nqc8bqrmjqxfxn515l";
130+
inherit dependencies buildDependencies features;
127131
};
128-
libc_0_2_34_features."default".from_hello_0_1_0__default = true;
129-
libc_0_2_34 = libc_0_2_34_ rec {
130-
features = mkFeatures libc_0_2_34_features;
132+
hello_0_1_0 = { features?(hello_0_1_0_features {}) }: hello_0_1_0_ {
133+
dependencies = mapFeatures features ([ libc_0_2_36 ]);
131134
};
132-
libc_0_2_34_features."use_std".self_default = hasDefault libc_0_2_34_features;
135+
hello_0_1_0_features = f: updateFeatures f (rec {
136+
hello_0_1_0.default = (f.hello_0_1_0.default or true);
137+
libc_0_2_36.default = true;
138+
}) [ libc_0_2_36_features ];
139+
libc_0_2_36 = { features?(libc_0_2_36_features {}) }: libc_0_2_36_ {
140+
features = mkFeatures (features.libc_0_2_36 or {});
141+
};
142+
libc_0_2_36_features = f: updateFeatures f (rec {
143+
libc_0_2_36.default = (f.libc_0_2_36.default or true);
144+
libc_0_2_36.use_std =
145+
(f.libc_0_2_36.use_std or false) ||
146+
(f.libc_0_2_36.default or false) ||
147+
(libc_0_2_36.default or false);
148+
}) [];
133149
}
134150
```
135151

@@ -146,7 +162,7 @@ or build inputs by overriding the hello crate in a seperate file.
146162

147163
```
148164
with import <nixpkgs> {};
149-
(import ./hello.nix).hello_0_1_0.override {
165+
((import ./hello.nix).hello {}).override {
150166
crateOverrides = defaultCrateOverrides // {
151167
hello = attrs: { buildInputs = [ openssl ]; };
152168
};
@@ -166,7 +182,7 @@ patches the derivation:
166182

167183
```
168184
with import <nixpkgs> {};
169-
(import ./hello.nix).hello_0_1_0.override {
185+
((import ./hello.nix).hello {}).override {
170186
crateOverrides = defaultCrateOverrides // {
171187
hello = attrs: lib.optionalAttrs (lib.versionAtLeast attrs.version "1.0") {
172188
postPatch = ''
@@ -187,7 +203,7 @@ crate, we could do:
187203

188204
```
189205
with import <nixpkgs> {};
190-
(import hello.nix).hello_0_1_0.override {
206+
((import hello.nix).hello {}).override {
191207
crateOverrides = defaultCrateOverrides // {
192208
libc = attrs: { buildInputs = []; };
193209
};
@@ -199,23 +215,35 @@ Three more parameters can be overridden:
199215
- The version of rustc used to compile the crate:
200216

201217
```
202-
hello_0_1_0.override { rust = pkgs.rust; };
218+
(hello {}).override { rust = pkgs.rust; };
203219
```
204220

205221
- Whether to build in release mode or debug mode (release mode by
206222
default):
207223

208224
```
209-
hello_0_1_0.override { release = false; };
225+
(hello {}).override { release = false; };
210226
```
211227

212228
- Whether to print the commands sent to rustc when building
213229
(equivalent to `--verbose` in cargo:
214230

215231
```
216-
hello_0_1_0.override { verbose = false; };
232+
(hello {}).override { verbose = false; };
217233
```
218234

235+
One can also supply features switches. For example, if we want to
236+
compile `diesel_cli` only with the `postgres` feature, and no default
237+
features, we would write:
238+
239+
```
240+
(callPackage ./diesel.nix {}).diesel {
241+
default = false;
242+
postgres = true;
243+
}
244+
```
245+
246+
219247

220248
## Using the Rust nightlies overlay
221249

Diff for: ‎lib/customisation.nix

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{ lib }:
22
let
33

4-
inherit (builtins) attrNames isFunction;
4+
inherit (builtins) attrNames;
55

66
in
77

@@ -72,7 +72,7 @@ rec {
7272
makeOverridable = f: origArgs:
7373
let
7474
ff = f origArgs;
75-
overrideWith = newArgs: origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs);
75+
overrideWith = newArgs: origArgs // (if lib.isFunction newArgs then newArgs origArgs else newArgs);
7676
in
7777
if builtins.isAttrs ff then (ff // {
7878
override = newArgs: makeOverridable f (overrideWith newArgs);
@@ -81,7 +81,7 @@ rec {
8181
${if ff ? overrideAttrs then "overrideAttrs" else null} = fdrv:
8282
makeOverridable (args: (f args).overrideAttrs fdrv) origArgs;
8383
})
84-
else if builtins.isFunction ff then {
84+
else if lib.isFunction ff then {
8585
override = newArgs: makeOverridable f (overrideWith newArgs);
8686
__functor = self: ff;
8787
overrideDerivation = throw "overrideDerivation not yet supported for functors";
@@ -112,8 +112,8 @@ rec {
112112
*/
113113
callPackageWith = autoArgs: fn: args:
114114
let
115-
f = if builtins.isFunction fn then fn else import fn;
116-
auto = builtins.intersectAttrs (builtins.functionArgs f) autoArgs;
115+
f = if lib.isFunction fn then fn else import fn;
116+
auto = builtins.intersectAttrs (lib.functionArgs f) autoArgs;
117117
in makeOverridable f (auto // args);
118118

119119

@@ -122,8 +122,8 @@ rec {
122122
individual attributes. */
123123
callPackagesWith = autoArgs: fn: args:
124124
let
125-
f = if builtins.isFunction fn then fn else import fn;
126-
auto = builtins.intersectAttrs (builtins.functionArgs f) autoArgs;
125+
f = if lib.isFunction fn then fn else import fn;
126+
auto = builtins.intersectAttrs (lib.functionArgs f) autoArgs;
127127
origArgs = auto // args;
128128
pkgs = f origArgs;
129129
mkAttrOverridable = name: pkg: makeOverridable (newArgs: (f newArgs).${name}) origArgs;

0 commit comments

Comments
 (0)
Please sign in to comment.