Loading doc/languages-frameworks/rust.section.md +11 −0 Original line number Diff line number Diff line Loading @@ -842,6 +842,17 @@ general. A number of other parameters can be overridden: (hello { }).override { extraRustcOpts = "-Z debuginfo=2"; } ``` - The lint level cap passed to `rustc` (`allow` by default, which silences all lints). Because `rustc` only honours the first `--cap-lints` it receives, this cannot be changed via `extraRustcOpts`; use this attribute instead. Useful when overriding the `rust` attribute to point at `clippy-driver`, since clippy lints are also capped by this flag: ```nix (hello { }).override { capLints = "warn"; } ``` - Phases, just like in any other derivation, can be specified using the following attributes: `preUnpack`, `postUnpack`, `prePatch`, `patches`, `postPatch`, `preConfigure` (in the case of a Rust crate, Loading pkgs/build-support/rust/build-rust-crate/build-crate.nix +2 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ colors, buildTests, codegenUnits, capLints, }: let Loading Loading @@ -73,6 +74,7 @@ in LIB_EXT="${stdenv.hostPlatform.extensions.library}" LIB_PATH="${libPath}" LIB_NAME="${libName}" CAP_LINTS="${capLints}" CRATE_NAME='${lib.replaceStrings [ "-" ] [ "_" ] libName}' Loading pkgs/build-support/rust/build-rust-crate/configure-crate.nix +2 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ crateVersion, extraLinkFlags, extraRustcOptsForBuildRs, capLints, libName, libPath, release, Loading Loading @@ -195,7 +196,7 @@ in fi noisily rustc --crate-name build_script_build $BUILD --crate-type bin ${rustcOpts} \ ${mkRustcFeatureArgs crateFeatures} --out-dir target/build/${crateName} --emit=dep-info,link \ -L dependency=target/buildDeps ${buildDeps} --cap-lints allow $EXTRA_BUILD_FLAGS --color ${colors} -L dependency=target/buildDeps ${buildDeps} --cap-lints ${capLints} $EXTRA_BUILD_FLAGS --color ${colors} mkdir -p target/build/${crateName}.out export RUST_BACKTRACE=1 Loading pkgs/build-support/rust/build-rust-crate/default.nix +16 −0 Original line number Diff line number Diff line Loading @@ -196,6 +196,16 @@ lib.makeOverridable # Example: [ "-Z debuginfo=2" ] # Default: [] extraRustcOptsForBuildRs, # The lint level cap passed to rustc via `--cap-lints`. # See <https://doc.rust-lang.org/rustc/lints/levels.html#capping-lints>. # # rustc honours only the first `--cap-lints` it sees, so appending a # second one via `extraRustcOpts` has no effect. Use this parameter # instead if you need lints to fire (e.g. when running clippy). # # Example: "warn" # Default: "allow" capLints, # Whether to enable building tests. # Use true to enable. # Default: false Loading Loading @@ -249,12 +259,14 @@ lib.makeOverridable "buildTests" "codegenUnits" "links" "capLints" ]; extraDerivationAttrs = removeAttrs crate processedAttrs; nativeBuildInputs_ = nativeBuildInputs; buildInputs_ = buildInputs; extraRustcOpts_ = extraRustcOpts; extraRustcOptsForBuildRs_ = extraRustcOptsForBuildRs; capLints_ = capLints; buildTests_ = buildTests; # crate2nix has a hack for the old bash based build script that did split Loading Loading @@ -383,6 +395,7 @@ lib.makeOverridable lib.optionals (crate ? extraRustcOptsForBuildRs) crate.extraRustcOptsForBuildRs ++ extraRustcOptsForBuildRs_ ++ (lib.optional (edition != null) "--edition ${edition}"); capLints = crate.capLints or capLints_; configurePhase = configureCrate { inherit Loading @@ -403,6 +416,7 @@ lib.makeOverridable crateLinks extraLinkFlags extraRustcOptsForBuildRs capLints crateLicense crateLicenseFile crateReadme Loading Loading @@ -433,6 +447,7 @@ lib.makeOverridable extraRustcOpts buildTests codegenUnits capLints ; }; dontStrip = !release; Loading Loading @@ -472,6 +487,7 @@ lib.makeOverridable verbose = crate_.verbose or true; extraRustcOpts = [ ]; extraRustcOptsForBuildRs = [ ]; capLints = "allow"; features = [ ]; nativeBuildInputs = [ ]; buildInputs = [ ]; Loading pkgs/build-support/rust/build-rust-crate/lib.sh +2 −2 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ build_lib() { $lib_src \ --out-dir target/lib \ -L dependency=target/deps \ --cap-lints allow \ --cap-lints $CAP_LINTS \ $LINK \ $EXTRA_LINK_ARGS \ $EXTRA_LINK_ARGS_LIB \ Loading Loading @@ -52,7 +52,7 @@ build_bin() { $EXTRA_LINK_ARGS \ $EXTRA_LINK_ARGS_BINS \ $EXTRA_LIB \ --cap-lints allow \ --cap-lints $CAP_LINTS \ $BUILD_OUT_DIR \ $EXTRA_BUILD \ $EXTRA_FEATURES \ Loading Loading
doc/languages-frameworks/rust.section.md +11 −0 Original line number Diff line number Diff line Loading @@ -842,6 +842,17 @@ general. A number of other parameters can be overridden: (hello { }).override { extraRustcOpts = "-Z debuginfo=2"; } ``` - The lint level cap passed to `rustc` (`allow` by default, which silences all lints). Because `rustc` only honours the first `--cap-lints` it receives, this cannot be changed via `extraRustcOpts`; use this attribute instead. Useful when overriding the `rust` attribute to point at `clippy-driver`, since clippy lints are also capped by this flag: ```nix (hello { }).override { capLints = "warn"; } ``` - Phases, just like in any other derivation, can be specified using the following attributes: `preUnpack`, `postUnpack`, `prePatch`, `patches`, `postPatch`, `preConfigure` (in the case of a Rust crate, Loading
pkgs/build-support/rust/build-rust-crate/build-crate.nix +2 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ colors, buildTests, codegenUnits, capLints, }: let Loading Loading @@ -73,6 +74,7 @@ in LIB_EXT="${stdenv.hostPlatform.extensions.library}" LIB_PATH="${libPath}" LIB_NAME="${libName}" CAP_LINTS="${capLints}" CRATE_NAME='${lib.replaceStrings [ "-" ] [ "_" ] libName}' Loading
pkgs/build-support/rust/build-rust-crate/configure-crate.nix +2 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ crateVersion, extraLinkFlags, extraRustcOptsForBuildRs, capLints, libName, libPath, release, Loading Loading @@ -195,7 +196,7 @@ in fi noisily rustc --crate-name build_script_build $BUILD --crate-type bin ${rustcOpts} \ ${mkRustcFeatureArgs crateFeatures} --out-dir target/build/${crateName} --emit=dep-info,link \ -L dependency=target/buildDeps ${buildDeps} --cap-lints allow $EXTRA_BUILD_FLAGS --color ${colors} -L dependency=target/buildDeps ${buildDeps} --cap-lints ${capLints} $EXTRA_BUILD_FLAGS --color ${colors} mkdir -p target/build/${crateName}.out export RUST_BACKTRACE=1 Loading
pkgs/build-support/rust/build-rust-crate/default.nix +16 −0 Original line number Diff line number Diff line Loading @@ -196,6 +196,16 @@ lib.makeOverridable # Example: [ "-Z debuginfo=2" ] # Default: [] extraRustcOptsForBuildRs, # The lint level cap passed to rustc via `--cap-lints`. # See <https://doc.rust-lang.org/rustc/lints/levels.html#capping-lints>. # # rustc honours only the first `--cap-lints` it sees, so appending a # second one via `extraRustcOpts` has no effect. Use this parameter # instead if you need lints to fire (e.g. when running clippy). # # Example: "warn" # Default: "allow" capLints, # Whether to enable building tests. # Use true to enable. # Default: false Loading Loading @@ -249,12 +259,14 @@ lib.makeOverridable "buildTests" "codegenUnits" "links" "capLints" ]; extraDerivationAttrs = removeAttrs crate processedAttrs; nativeBuildInputs_ = nativeBuildInputs; buildInputs_ = buildInputs; extraRustcOpts_ = extraRustcOpts; extraRustcOptsForBuildRs_ = extraRustcOptsForBuildRs; capLints_ = capLints; buildTests_ = buildTests; # crate2nix has a hack for the old bash based build script that did split Loading Loading @@ -383,6 +395,7 @@ lib.makeOverridable lib.optionals (crate ? extraRustcOptsForBuildRs) crate.extraRustcOptsForBuildRs ++ extraRustcOptsForBuildRs_ ++ (lib.optional (edition != null) "--edition ${edition}"); capLints = crate.capLints or capLints_; configurePhase = configureCrate { inherit Loading @@ -403,6 +416,7 @@ lib.makeOverridable crateLinks extraLinkFlags extraRustcOptsForBuildRs capLints crateLicense crateLicenseFile crateReadme Loading Loading @@ -433,6 +447,7 @@ lib.makeOverridable extraRustcOpts buildTests codegenUnits capLints ; }; dontStrip = !release; Loading Loading @@ -472,6 +487,7 @@ lib.makeOverridable verbose = crate_.verbose or true; extraRustcOpts = [ ]; extraRustcOptsForBuildRs = [ ]; capLints = "allow"; features = [ ]; nativeBuildInputs = [ ]; buildInputs = [ ]; Loading
pkgs/build-support/rust/build-rust-crate/lib.sh +2 −2 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ build_lib() { $lib_src \ --out-dir target/lib \ -L dependency=target/deps \ --cap-lints allow \ --cap-lints $CAP_LINTS \ $LINK \ $EXTRA_LINK_ARGS \ $EXTRA_LINK_ARGS_LIB \ Loading Loading @@ -52,7 +52,7 @@ build_bin() { $EXTRA_LINK_ARGS \ $EXTRA_LINK_ARGS_BINS \ $EXTRA_LIB \ --cap-lints allow \ --cap-lints $CAP_LINTS \ $BUILD_OUT_DIR \ $EXTRA_BUILD \ $EXTRA_FEATURES \ Loading