From 1aabbc1b0d4018a0a9ddb0a0b3d6e6bbefb74883 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Wed, 26 Jan 2022 13:50:35 +0100 Subject: modules : add rust support --- modules/default.nix | 3 ++- modules/rust.nix | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 modules/rust.nix (limited to 'modules') diff --git a/modules/default.nix b/modules/default.nix index ec30513..889253d 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -8,8 +8,9 @@ in { ./golang.nix ./latex.nix ./nix.nix - ./python.nix ./ocaml.nix + ./python.nix + ./rust.nix ./why3.nix ]; diff --git a/modules/rust.nix b/modules/rust.nix new file mode 100644 index 0000000..fbb9bbc --- /dev/null +++ b/modules/rust.nix @@ -0,0 +1,29 @@ +{ config, lib, pkgs, ... }: + +with lib; +with builtins; +let cfg = config.rust; +in { + options.rust = { + enable = mkEnableOption { name = "rust"; }; + packages = mkOption { + type = types.lazyAttrsOf types.package; + default = pkgs.rust.packages.stable; + defaultText = literalExample "pkgs.rust.packages.stable"; + description = '' + The set of Rust packages from which to get the toolchain. + ''; + }; + }; + + config = mkIf cfg.enable { + nativeBuildInputs = with cfg.packages; [ rustc cargo pkgs.gcc ]; + buildInputs = with cfg.packages; [ rustfmt clippy ]; + + envVars = { + RUST_SRC_PATH = { + value = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + }; + }; + }; +} -- cgit v1.2.3