nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 102 lines 2.9 kB view raw
1{ 2 lib, 3 stdenv, 4 rustPlatform, 5 fetchFromGitHub, 6 makeWrapper, 7 pkg-config, 8 cmake, 9 libiconv, 10 cargo, 11 gcc, 12 mold, 13 rustc, 14 nix-update-script, 15 16 # On non-darwin, `mold` is the default linker, but it's broken on Darwin. 17 withMold ? with stdenv.hostPlatform; isUnix && !isDarwin, 18}: 19 20rustPlatform.buildRustPackage (finalAttrs: { 21 pname = "evcxr"; 22 version = "0.21.1"; 23 24 src = fetchFromGitHub { 25 owner = "google"; 26 repo = "evcxr"; 27 rev = "v${finalAttrs.version}"; 28 sha256 = "sha256-8dV+NNtU4HFerrgRyc1kO+MSsMTJJItTtJylEIN014g="; 29 }; 30 31 cargoHash = "sha256-HJrEXt6O7qCNJ/xOh4kjmqKJ22EVwBTzV1S+q98k0VQ="; 32 33 RUST_SRC_PATH = "${rustPlatform.rustLibSrc}"; 34 35 nativeBuildInputs = [ 36 pkg-config 37 makeWrapper 38 cmake 39 ]; 40 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ 41 libiconv 42 ]; 43 44 checkFlags = [ 45 # outdated rust-analyzer (disabled, upstream) 46 # https://github.com/evcxr/evcxr/blob/fcdac75f49dcab3229524e671d4417d36c12130b/evcxr/tests/integration_tests.rs#L741 47 # https://github.com/evcxr/evcxr/issues/295 48 "--skip=partially_inferred_variable_type" 49 # fail, but can't reproduce in the REPL 50 "--skip=code_completion" 51 "--skip=save_and_restore_variables" 52 ]; 53 54 # Some tests fail when types aren't explicitly specified, but which can't be 55 # reproduced inside the REPL. 56 # Likely related to https://github.com/evcxr/evcxr/issues/295 57 postConfigure = '' 58 substituteInPlace evcxr/tests/integration_tests.rs \ 59 --replace-fail "let var2 = String" "let var2: String = String" `# code_completion` \ 60 --replace-fail "let a = vec" "let a: Vec<i32> = vec" `# function_panics_{with,without}_variable_preserving` \ 61 --replace-fail "let a = Some(" "let a: Option<String> = Some(" `# moved_value` \ 62 --replace-fail "let a = \"foo\"" "let a: String = \"foo\"" `# statement_and_expression` \ 63 --replace-fail "let owned = \"owned\"" "let owned:String = \"owned\"" `# question_mark_operator` \ 64 --replace-fail "let mut owned_mut =" "let mut owned_mut: String =" 65 ''; 66 67 postInstall = 68 let 69 wrap = exe: '' 70 wrapProgram $out/bin/${exe} \ 71 --prefix PATH : ${ 72 lib.makeBinPath ( 73 [ 74 cargo 75 gcc 76 rustc 77 ] 78 ++ lib.optional withMold mold 79 ) 80 } \ 81 --set-default RUST_SRC_PATH "$RUST_SRC_PATH" 82 ''; 83 in 84 '' 85 ${wrap "evcxr"} 86 ${wrap "evcxr_jupyter"} 87 rm $out/bin/testing_runtime 88 ''; 89 90 passthru.updateScript = nix-update-script { }; 91 92 meta = { 93 description = "Evaluation context for Rust"; 94 homepage = "https://github.com/google/evcxr"; 95 license = lib.licenses.asl20; 96 maintainers = with lib.maintainers; [ 97 protoben 98 ma27 99 ]; 100 mainProgram = "evcxr"; 101 }; 102})