summaryrefslogtreecommitdiff
path: root/modules/rust.nix
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 /modules/rust.nix
parent3d147f1170e32c870dbb861bd26901692ced4aaf (diff)
modules : add rust support
Diffstat (limited to 'modules/rust.nix')
-rw-r--r--modules/rust.nix29
1 files changed, 29 insertions, 0 deletions
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}";
+ };
+ };
+ };
+}