Unverified Commit ab4eda85 authored by github-actions[bot]'s avatar github-actions[bot] Committed by GitHub
Browse files

Merge master into haskell-updates

parents 50c28505 8aba57cf
Loading
Loading
Loading
Loading
+84 −53
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ into your `configuration.nix` or bring them into scope with `nix-shell -p rustc

For other versions such as daily builds (beta and nightly),
use either `rustup` from nixpkgs (which will manage the rust installation in your home directory),
or use Mozilla's [Rust nightlies overlay](#using-the-rust-nightlies-overlay).
or use a community maintained [Rust overlay](#using-community-rust-overlays).

## Compiling Rust applications with Cargo {#compiling-rust-applications-with-cargo}

@@ -411,7 +411,7 @@ you of the correct hash.

`rustPlatform` provides the following hooks to automate Cargo builds:

* `cargoSetupHook`: configure Cargo to use depenencies vendored
* `cargoSetupHook`: configure Cargo to use dependencies vendored
  through `fetchCargoTarball`. This hook uses the `cargoDeps`
  environment variable to find the vendored dependencies. If a project
  already vendors its dependencies, the variable `cargoVendorDir` can
@@ -672,7 +672,7 @@ Some crates require external libraries. For crates from
`defaultCrateOverrides` package in nixpkgs itself.

Starting from that file, one can add more overrides, to add features
or build inputs by overriding the hello crate in a seperate file.
or build inputs by overriding the hello crate in a separate file.

```nix
with import <nixpkgs> {};
@@ -871,76 +871,107 @@ rustc 1.26.0-nightly (188e693b3 2018-03-26)

To see that you are using nightly.

## Using the Rust nightlies overlay {#using-the-rust-nightlies-overlay}
## Using community Rust overlays {#using-community-rust-overlays}

Mozilla provides an overlay for nixpkgs to bring a nightly version of Rust into scope.
This overlay can _also_ be used to install recent unstable or stable versions
of Rust, if desired.
There are two community maintained approaches to Rust toolchain management:
- [oxalica's Rust overlay](https://github.com/oxalica/rust-overlay)
- [fenix](https://github.com/nix-community/fenix)

### Rust overlay installation {#rust-overlay-installation}
Oxalica's overlay allows you to select a particular Rust version and components.
See [their documentation](https://github.com/oxalica/rust-overlay#rust-overlay) for more
detailed usage.

You can use this overlay by either changing your local nixpkgs configuration,
or by adding the overlay declaratively in a nix expression,  e.g. in `configuration.nix`.
For more information see [the manual on installing overlays](#sec-overlays-install).
Fenix is an alternative to `rustup` and can also be used as an overlay.

#### Imperative rust overlay installation {#imperative-rust-overlay-installation}
Both Oxalica's overlay and fenix better integrate with nix and cache optimizations.
Because of this and ergonomics, either of those community projects
should be preferred to the Mozilla's Rust overlay (nixpkgs-mozilla).

Clone [nixpkgs-mozilla](https://github.com/mozilla/nixpkgs-mozilla),
and create a symbolic link to the file
[rust-overlay.nix](https://github.com/mozilla/nixpkgs-mozilla/blob/master/rust-overlay.nix)
in the `~/.config/nixpkgs/overlays` directory.
### How to select a specific rustc and toolchain version {#how-to-select-a-specific-rustc-and-toolchain-version}

```ShellSession
$ git clone https://github.com/mozilla/nixpkgs-mozilla.git
$ mkdir -p ~/.config/nixpkgs/overlays
$ ln -s $(pwd)/nixpkgs-mozilla/rust-overlay.nix ~/.config/nixpkgs/overlays/rust-overlay.nix
You can consume the oxalica overlay and use it to grab a specific Rust toolchain version.
Here is an example `shell.nix` showing how to grab the current stable toolchain:
```nix
{ pkgs ? import <nixpkgs> {
    overlays = [
      (import (fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"))
    ];
  }
}:
pkgs.mkShell {
  nativeBuildInputs = with pkgs; [
    pkg-config
    rust-bin.stable.latest.minimal
  ];
}
```

### Declarative rust overlay installation {#declarative-rust-overlay-installation}
You can try this out by:
1. Saving that to `shell.nix`
2. Executing `nix-shell --pure --command 'rustc --version'`

Add the following to your `configuration.nix`, `home-configuration.nix`, `shell.nix`, or similar:
As of writing, this prints out `rustc 1.56.0 (09c42c458 2021-10-18)`.

### How to use an overlay toolchain in a derivation  {#how-to-use-an-overlay-toolchain-in-a-derivation}

You can also use an overlay's Rust toolchain with `buildRustPackage`.
The below snippet demonstrates invoking `buildRustPackage` with an oxalica overlay selected Rust toolchain:
```nix
{ pkgs ? import <nixpkgs> {
with import <nixpkgs> {
  overlays = [
      (import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz))
      # Further overlays go here
    (import (fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"))
  ];
};
};
```

Note that this will fetch the latest overlay version when rebuilding your system.
rustPlatform.buildRustPackage rec {
  pname = "ripgrep";
  version = "12.1.1";
  nativeBuildInputs = [
    rust-bin.stable.latest.minimal
  ];

  src = fetchFromGitHub {
    owner = "BurntSushi";
    repo = "ripgrep";
    rev = version;
    sha256 = "1hqps7l5qrjh9f914r5i6kmcz6f1yb951nv4lby0cjnp5l253kps";
  };

### Rust overlay usage {#rust-overlay-usage}
  cargoSha256 = "03wf9r2csi6jpa7v5sw5lpxkrk4wfzwmzx7k3991q3bdjzcwnnwp";

The overlay contains attribute sets corresponding to different versions of the rust toolchain, such as:
  meta = with lib; {
    description = "A fast line-oriented regex search tool, similar to ag and ack";
    homepage = "https://github.com/BurntSushi/ripgrep";
    license = licenses.unlicense;
    maintainers = [ maintainers.tailhook ];
  };
}
```

* `latest.rustChannels.stable`
* `latest.rustChannels.nightly`
* a function `rustChannelOf`, called as `(rustChannelOf { date = "2018-04-11"; channel = "nightly"; })`, or...
* `(nixpkgs.rustChannelOf { rustToolchain = ./rust-toolchain; })` if you have a local `rust-toolchain` file (see https://github.com/mozilla/nixpkgs-mozilla#using-in-nix-expressions for an example)
Follow the below steps to try that snippet.
1. create a new directory
1. save the above snippet as `default.nix` in that directory
1. cd into that directory and run `nix-build`

Each of these contain packages such as `rust`, which contains your usual rust development tools with the respective toolchain chosen.
For example, you might want to add `latest.rustChannels.stable.rust` to the list of packages in your configuration.
### Rust overlay installation {#rust-overlay-installation}

Imperatively, the latest stable version can be installed with the following command:
You can use this overlay by either changing your local nixpkgs configuration,
or by adding the overlay declaratively in a nix expression,  e.g. in `configuration.nix`.
For more information see [the manual on installing overlays](#sec-overlays-install).

```ShellSession
$ nix-env -Ai nixpkgs.latest.rustChannels.stable.rust
```
### Declarative Rust overlay installation {#declarative-rust-overlay-installation}

Or using the attribute with nix-shell:
This snippet shows how to use oxalica's Rust overlay.
Add the following to your `configuration.nix`, `home-configuration.nix`, `shell.nix`, or similar:

```ShellSession
$ nix-shell -p nixpkgs.latest.rustChannels.stable.rust
```nix
{ pkgs ? import <nixpkgs> {
    overlays = [
      (import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"))
      # Further overlays go here
    ];
  };
};
```

Substitute the `nixpkgs` prefix with `nixos` on NixOS.
To install the beta or nightly channel, "stable" should be substituted by
"nightly" or "beta", or
use the function provided by this overlay to pull a version based on a
build date.

The overlay automatically updates itself as it uses the same source as
[rustup](https://www.rustup.rs/).
Note that this will fetch the latest overlay version when rebuilding your system.
+18 −0
Original line number Diff line number Diff line
@@ -6252,6 +6252,12 @@
    githubId = 278013;
    name = "Tomasz Kontusz";
  };
  kubukoz = {
    email = "kubukoz@gmail.com";
    github = "kubukoz";
    githubId = 894884;
    name = "Jakub Kozłowski";
  };
  kurnevsky = {
    email = "kurnevsky@gmail.com";
    github = "kurnevsky";
@@ -8904,6 +8910,12 @@
    githubId = 421510;
    name = "Noé Rubinstein";
  };
  photex = {
    email = "photex@gmail.com";
    github = "photex";
    githubId = 301903;
    name = "Chip Collier";
  };
  phreedom = {
    email = "phreedom@yandex.ru";
    github = "phreedom";
@@ -10784,6 +10796,12 @@
    github = "staccato";
    githubId = 86573128;
  };
  stackshadow = {
    email = "stackshadow@evilbrain.de";
    github = "stackshadow";
    githubId = 7512804;
    name = "Martin Langlotz";
  };
  steell = {
    email = "steve@steellworks.com";
    github = "Steell";
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ let
  keyDrv = drv: if canEval drv.drvPath then { key = drv.drvPath; value = drv; } else { };

  immediateDependenciesOf = drv:
    concatLists (mapAttrsToList (n: v: derivationsIn v) (removeAttrs drv ["meta" "passthru"]));
    concatLists (mapAttrsToList (n: v: derivationsIn v) (removeAttrs drv (["meta" "passthru"] ++ optionals (drv?passthru) (attrNames drv.passthru))));

  derivationsIn = x:
    if !canEval x then []
+2 −2
Original line number Diff line number Diff line
@@ -58,5 +58,5 @@ a while to finish.
## NixOS Boot Entries {#sect-nixos-gc-boot-entries}

If your `/boot` partition runs out of space, after clearing old profiles
you must rebuild your system with `nixos-rebuild` to update the `/boot`
partition and clear space.
you must rebuild your system with `nixos-rebuild boot` or `nixos-rebuild
switch` to update the `/boot` partition and clear space.
+2 −1
Original line number Diff line number Diff line
@@ -64,7 +64,8 @@ $ nix-store --optimise
    <para>
      If your <literal>/boot</literal> partition runs out of space,
      after clearing old profiles you must rebuild your system with
      <literal>nixos-rebuild</literal> to update the
      <literal>nixos-rebuild boot</literal> or
      <literal>nixos-rebuild switch</literal> to update the
      <literal>/boot</literal> partition and clear space.
    </para>
  </section>
Loading