My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
oxalica cc5400bc8e
Add README and license
3 years ago
.vscode Init 3 years ago
manifests manifest: update nightly 3 years ago
.gitignore Init 3 years ago
LICENSE Add README and license 3 years ago
README.md Add README and license 3 years ago
all.nix Add nightly support 3 years ago
default.nix Add nightly support 3 years ago
fetch.py Add nightly support 3 years ago
flake.lock Init 3 years ago
flake.nix Add nightly support 3 years ago
rust-overlay.nix Add nightly support 3 years ago

README.md

rust-overlay

Pure and reproducible overlay for binary distributed rust toolchains. A better replacement for github:mozilla/nixpkgs-mozilla

Hashes of toolchain components are pre-fetched (and compressed) in manifests directory. So there's no need to have network access during nix evaluation (but nixpkgs-mozilla does).

Since the evaluation is now pure, it also means this can work well with Nix Flakes.

  • Auto-updating is TODO.
  • Current oldest supported version is stable 1.29.0 and nightly 2018-09-13 (which is randomly chosen).

Use as classical nix overlay

The installaction and usage are exactly the same as nixpkgs-mozilla. You can follow https://github.com/mozilla/nixpkgs-mozilla#rust-overlay and just replace the url to https://github.com/oxalica/rust-overlay

You can put the code below into your ~/.config/nixpkgs/overlays.nix.

[ (import (builtins.fetchTarball https://github.com/oxalica/rust-overlay/archive/master.tar.gz)) ]

Or install it into nix-channel:

$ nix-channel --add https://github.com/oxalica/rust-overlay/archive/master.tar.gz rust-overlay

And then feel free to use it anywhere like import <nixpkgs> { overlays = [ (import <rust-overlay>) ] } in your nix shell environment

Use with Nix Flakes

This repository already has flake support. So you can simply use it as input. Here's an example of using it in nixos configuration.

{
  description = "My configuration";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    rust-overlay.url = "github:oxalica/rust-overlay";
  };

  outputs = { nixpkgs, rust-overlay, ... }: {
    nixosConfigurations = {
      hostname = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          ./configuration.nix # Your system configuration.
          ({ pkgs, ... }: {
            nixpkgs.overlays = [ rust-overlay.overlay ];
            environment.systemPackages = [ pkgs.latest.rustChannels.stable.rust ];
          })
        ];
      };
    };
  };
}

Interface

The overlay re-use many codes from nixpkgs/mozilla and the interface is almost the same. It provides latest.rustChannels.{stable,nightly}.<toolchain-component> and rustChannelOf.

To use the latest stable or nightly rust toolchain, the easiest way is just to install latest.rustChannels.{stable,nightly}.rust, which combines rustc, cargo, rustfmt and all other default components.

You can also pin to specific nightly toolchain using rustChannelOf:

(nixpkgs.rustChannelOf { date = "2020-01-01"; channel = "nightly"; }).rust

Customize an toolchain.

nixpkgs.latest.rustChannels.stable.rust.override {
  extensions = [
    "rust-src"
  ];
  targets = [
    "x86_64-unknown-linux-musl"
    "arm-unknown-linux-gnueabihf"
  ];
}

For more details, see ./rust-overlay.nix or README of https://github.com/mozilla/nixpkgs-mozilla.