2020-01-12 23:11:02 -08:00
|
|
|
# modules/dev/rust.nix --- https://rust-lang.org
|
|
|
|
#
|
|
|
|
# Oh Rust. The light of my life, fire of my loins. Years of C++ has conditioned
|
|
|
|
# me to believe there was no hope left, but the gods have heard us. Sure, you're
|
|
|
|
# not going to replace C/C++. Sure, your starlight popularity has been
|
|
|
|
# overblown. Sure, macros aren't namespaced, cargo bypasses crates.io, and there
|
|
|
|
# is no formal proof of your claims for safety, but who said you have to solve
|
|
|
|
# all the world's problems to be wonderful?
|
|
|
|
|
2020-03-28 22:48:43 -07:00
|
|
|
{ config, options, lib, pkgs, ... }:
|
2020-10-01 15:46:04 -07:00
|
|
|
|
2020-03-28 22:48:43 -07:00
|
|
|
with lib;
|
2020-10-01 15:46:04 -07:00
|
|
|
with lib.my;
|
|
|
|
let cfg = config.modules.dev.rust;
|
|
|
|
in {
|
2020-03-28 22:48:43 -07:00
|
|
|
options.modules.dev.rust = {
|
2020-10-01 15:46:04 -07:00
|
|
|
enable = mkBoolOpt false;
|
2021-08-05 22:30:07 -07:00
|
|
|
enableGlobally = mkBoolOpt false;
|
2020-03-28 22:48:43 -07:00
|
|
|
};
|
|
|
|
|
2021-08-05 22:30:07 -07:00
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
|
|
(mkIf cfg.enableGlobally {
|
|
|
|
user.packages = [ pkgs.rustup ];
|
2020-01-12 16:47:33 -08:00
|
|
|
|
2021-08-05 22:30:07 -07:00
|
|
|
env.PATH = [ "$(${pkgs.yarn}/bin/yarn global bin)" ];
|
|
|
|
})
|
2020-01-12 16:47:33 -08:00
|
|
|
|
2021-08-05 22:30:07 -07:00
|
|
|
{
|
|
|
|
env.RUSTUP_HOME = "$XDG_DATA_HOME/rustup";
|
|
|
|
env.CARGO_HOME = "$XDG_DATA_HOME/cargo";
|
|
|
|
env.PATH = [ "$CARGO_HOME/bin" ];
|
|
|
|
|
|
|
|
environment.shellAliases = {
|
|
|
|
rs = "rustc";
|
|
|
|
rsp = "rustup";
|
|
|
|
ca = "cargo";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]);
|
2019-12-13 00:06:52 -08:00
|
|
|
}
|