diff options
Diffstat (limited to 'modules/rust.nix')
| -rw-r--r-- | modules/rust.nix | 29 |
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}"; + }; + }; + }; +} |
