summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Aristote <quentin@aristote.fr>2022-01-26 13:50:35 +0100
committerQuentin Aristote <quentin@aristote.fr>2022-01-26 13:50:35 +0100
commit1aabbc1b0d4018a0a9ddb0a0b3d6e6bbefb74883 (patch)
tree25bdb72953b6f1ba2bba7926e925148b555f17c3
parent3d147f1170e32c870dbb861bd26901692ced4aaf (diff)
modules : add rust support
-rw-r--r--modules/default.nix3
-rw-r--r--modules/rust.nix29
2 files changed, 31 insertions, 1 deletions
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}";
+ };
+ };
+ };
+}