File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ { lib , config , pkgs , ... } :
2+ let
3+ cfg = config . language . rust ;
4+ in
5+ with lib ;
6+ {
7+ options . language . rust = {
8+ packageSet = mkOption {
9+ # FIXME: how to make the selection possible in TOML?
10+ type = types . attrs ;
11+ default = pkgs . rustPackages ;
12+ defaultText = "pkgs.rustPlatform" ;
13+ description = "Which rust package set to use" ;
14+ } ;
15+
16+ tools = mkOption {
17+ type = types . listOf types . str ;
18+ default = [
19+ "rustc"
20+ "cargo"
21+ "clippy"
22+ "rustfmt"
23+ ] ;
24+ description = "Which rust tools to pull from the platform package set" ;
25+ } ;
26+ } ;
27+
28+ config = {
29+ env = [ {
30+ # Used by tools like rust-analyzer
31+ name = "RUST_SRC_PATH" ;
32+ value = toString cfg . packageSet . rustPlatform . rustLibSrc ;
33+ } ] ;
34+
35+ devshell . packages = map ( tool : cfg . packageSet . ${ tool } ) cfg . tools ;
36+ } ;
37+ }
Original file line number Diff line number Diff line change 1+ { pkgs , devshell , runTest } :
2+ {
3+ # Basic test
4+ simple =
5+ let
6+ shell = devshell . mkShell {
7+ imports = [ ../../modules_extra/language/rust.nix ] ;
8+ devshell . name = "language-rust-simple" ;
9+ } ;
10+ in
11+ runTest "simple" { } ''
12+ # Load the devshell
13+ source ${ shell }
14+
15+ # Has a rust compiler
16+ type -p rustc
17+ '' ;
18+ }
You can’t perform that action at this time.
0 commit comments