Home-manager: Add rustup support

Created on 16 Mar 2019  路  7Comments  路  Source: nix-community/home-manager

I only recently encountered home-manager, so forgive me if this is out of scope. I鈥檓 thinking it would be nice to let home-manager take care of rust toolchains, i.e., something like this:

programs.rustup = {
    enable = true;
    toolchains = {
        stable = {
            components = [ "clippy"];
        };
    };
    defaultToolchain = "stable";
};

I鈥檓 not so sure about overrides. There is also the question of how home-manager generations would interact with toolchain updates.

Most helpful comment

I use a nix-shell with direnv to do this

  moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
  nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; };
  rustNightlyChannel = (nixpkgs.rustChannelOf { date = "2019-01-26"; channel = "nightly"; }).rust;
        rustStableChannel = nixpkgs.latest.rustChannels.stable.rust.override {
                extensions = [
                        "rust-src"
                        "rls-preview"
                        "clippy-preview"
                        "rustfmt-preview"
                ];
  };
in
with nixpkgs;
  stdenv.mkDerivation {
    name = "moz_overlay_shell";
    buildInputs = [
      rustNightlyChannel
    ];
  }

All 7 comments

I use a nix-shell with direnv to do this

  moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
  nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; };
  rustNightlyChannel = (nixpkgs.rustChannelOf { date = "2019-01-26"; channel = "nightly"; }).rust;
        rustStableChannel = nixpkgs.latest.rustChannels.stable.rust.override {
                extensions = [
                        "rust-src"
                        "rls-preview"
                        "clippy-preview"
                        "rustfmt-preview"
                ];
  };
in
with nixpkgs;
  stdenv.mkDerivation {
    name = "moz_overlay_shell";
    buildInputs = [
      rustNightlyChannel
    ];
  }

I'm not familiar with rustup but if this module would configure rustup in some way then it seems to me a good fit 馃檪

@dali99 Hi and thank you. Can you provide your solution as a PR?

@LinArcX The solution isnt a special thing for home-manager. it's a basic nix shell. That can be loaded via direnv, by including it in the folder of your project.

So should this issue be closed with the motivation that nix-shell is the better choice?

Probably, yes.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wedens picture wedens  路  6Comments

throwup picture throwup  路  6Comments

pmiddend picture pmiddend  路  3Comments

rschulman picture rschulman  路  5Comments

mightybyte picture mightybyte  路  5Comments