Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
Unreleased
Changed
mkDummySrcnow acceptsdummyBuildrsto customize the dummy source used for build scripts specifically. If not specified, the value ofdummyrswill be used, otherwise, the existing default dummy build script will be used.
Fixed
- Fix Windows pthreads being added to non-Windows platforms when cross compiling
0.21.1 - 2025-09-24
Fixed
- The default dummy source used by
mkDummySrcnow additionally works for theamdgputarget out of the box removeReferencesToRustToolchainHooknow handles exclusions case insensitivelycleanCargoTomlnow retains targets'harnessattribute if definedcargoTest,cargoDocTest, andcargoNextestwill log a warning ifdoCheck = false;installCargoArtifactsHookgracefully handles (ignores) situations where no cargo artifacts are generated by the derivation
0.21.0 - 2025-07-19
Changed
- Breaking: dropped compatibility for Nix versions below 2.28.3
- Breaking: dropped compatibility for nixpkgs-24.11
- Windows cross builds provides pthreads as it is required for most crates.
registryFromSparsenow passesfetchurlExtraArgsto the initial query for the registry'sconfig.json
0.20.3 - 2025-04-23
Added
mkCrossToolchainEnvis now available for setting up some default cross-compilation environment variables and derivation arguments
Changed
- Vendoring git dependencies now respects Cargo.toml
includesandexcludes mkCargoDerivationnow configures the cross-compilation toolchain by default using the newly addedmkCrossToolchainEnvfunction. To select the utilized cross compiler, thestdenvargument now also accepts a selector function, taking an arbitrarypkgsinstantiation as an argument. This behavior can be turned off by settingdoIncludeCrossToolchainEnv = false;.
0.20.2 - 2025-03-08
Changed
craneUtils(used internally for vendoring git dependencies) now usesimportCargoLockto fetch its own dependencies instead of the (now deprecated)fetchCargoTarballmethod.cleanCargoTomlnow preserves theproc-macroattribute of any defined targets
Fixed
buildTrunkPackageno longer ignoresinstallPhaseandinstallPhaseCommandargs.mkDummySrcnow supports embedded proc-macros.removeReferencesToRustToolchainHooknow handles file names which contain whitespaceremoveReferencesToVendoredSourcesHooknow handles file names which contain whitespace
0.20.1 - 2025-02-08
Added
cargoNextestnow supports passingcargoNextestPartitionsExtraArgsto eachcargo nextestpartition run.- Add self-reference
craneLibto crane lib instance. - Add
removeReferencesToRustToolchainHook, which, by default, removes references to the Rust toolchain from all installed binaries
Changed
buildPackagenow includesremoveReferencesToRustToolchainHookas a native dependency. To disable automatically removing references to the Rust toolchain, setdoNotRemoveReferencesToRustToolchain = true;mkCargoDerivationnow will also append therustcpackage to the derivation'snativeBuildInputs
0.20.0 - 2024-12-21
Changed
- Breaking: dropped compatibility for Nix versions below 2.24.10
- Breaking: dropped compatibility for nixpkgs-24.05
- Breaking (technically):
buildPackage's installation behavior has been split into two steps: binaries are now installed into a temporary directory as a post build hook (to avoid interference from the check phase clobbering resultant binaries with development features enabled) followed by an actual installation (from said directory) during the install phase. If you use a custom build phase withbuildPackageyou may need to ensure the additional post build hook defined ininstallFromCargoBuildLogHookruns (or follow the error messages to resolve any build issues). mkDummySrchas been reworked to match cargo'sautobindetection logic, meaning that only real binary targets defined by the project will be dummified if they exist (no more injectingsrc/bin/crane-dummy-*). This does mean that adding a new bin target definition will invalidate caches and require rebuilding all dependencies once more. (If this is a frequent enough occurrence for your project to cause headaches, please open an issue!)
Fixed
mkDummySrcwill deduplicate discovered and declared binary targets when dummifying sourcescrateNameFromCargoTomlwill ignore store contexts when parsing a Cargo.toml file (avoiding errors likethe string ... is not allowed to refer to a store path).vendorGitDepswill perform a basic URL-decoding of git dependency entries in theCargo.lockfile since lockfiles now encode special characters starting at version 4
Meta
- Dropped support for publishing releases to https://flakestry.dev/
0.19.4 - 2024-11-30
Fixed
removeReferencesToVendoredSourcesnow deduplicates any found references to avoid pathological memory usage before removing them.buildDepsOnlywill calculate fallbackpname/version/cargoVendorDirattributes usingdummySrcif it was specified (rather than attempting to usesrc)
0.19.3 - 2024-11-18
A republish of 0.19.2 which was incorrectly tagged.
0.19.2 - 2024-11-18
Added
- Added a number of fileset helpers to more easily compose source filtering:
fileset.cargoTomlAndLock: forCargo.tomlandCargo.lockfilesfileset.commonCargoSources: for files commonly used by cargo projectsfileset.configToml: forconfig.tomlfilesfileset.rust: for*.rsfilesfileset.toml: for*.tomlfiles
Fixed
buildTrunkPackagewill pass in--release=true(instead of just--release) for trunk versions 0.21 or higher to avoid argument ambiguitiesbuildTrunkPackagewill now correctly honorbuildPhaseCargoCommandif specified (previously the value ofbuildPhaseCommandwas incorrectly being used)removeReferencesToVendoredSourcesHookavoids referencing/dev/fddirectly since it may not be present on certain platforms
0.19.1 - 2024-10-12
Added
cargoDocTestis now available as an alternative tocargoTestwhich runs only doc tests.
Changed
buildDepsOnlynow setsCRANE_BUILD_DEPS_ONLYas an environment variable when it runs. Build hooks can use this as a shortcut to determine whether running inside of abuildDepsOnlyderivation in case they need to tailor their behavior accordingly.
Fixed
- Vendoring dependencies avoids creating malformed TOML configurations in situations where registry name/url definitions cannot be found. When this happens a warning will be printed out during evaluation to highlight the issue.
0.19.0 - 2024-09-25
Added
taploFmtis now available for checking TOML formatting
Changed
- Breaking (technically):
buildPackageno longer addsjqtonativeBuildInputsas doing so can result in rebuilding any*-syscrates which rely onPKG_CONFIG_PATHremaining stable - Breaking:
downloadCargoPackageFromGitnow takeshashinstead ofsha256when specifying an output hash for the download installFromCargoBuildLogHookno longer assumes or requires thatjqis available on$PATHand will instead directly referencepkgs.jqdownloadCargoPackageFromGitwill now setfetchLFS = truewhen fetching git repos with defined output hashes
Fixed
cargoDoccorrectly honorsdocInstallRootwhen specifiedcargoDocfalls back to installing from./target/doceven if$CARGO_BUILD_TARGETis set but./target/$CARGO_BUILD_TARGET/docdoes not exist
Removed
- The deprecated top-level (flake) attribute
libno longer exists. Please usemkLibwith an instance ofpkgsinstead.
0.18.1 - 2024-08-22
Fixed
- Fixed vendoring dependencies from an alternative registry which they themselves have dependencies on crates from other registries.
- Fixed
cargoNextest's positioning ofcargoExtraArgsto form a valid command invocation when specified.
0.18.0 - 2024-07-05
Changed
- Breaking: dropped compatibility for Nix versions below 2.18.2
- Breaking: dropped compatibility for nixpkgs-23.11
- The guidance around using (both)
cleanCargoSourceandpathhas been updated. Namely, it is no longer necessary to call both (e.g.craneLib.cleanCargoSource (craneLib.path ./.)): it is recommended to either usecraneLib.cleanCargoSource ./.directly (if the default source cleaning is desired) orcraneLib.path ./.(if not). overrideToolchainhas been updated to better handle cross-compilation splicing for a customized toolchain. This means thatoverrideToolchainshould now be called with a function which constructs said toolchain for any givenpkgsinstantiation. For example:craneLib.overrideToolchain (p: p.rust-bin.stable.latest.default)
Fixed
- The cross compilation example also hows how to set the
TARGET_CCenvironment variable which may be required by some build scripts to function properly vendorCargoDepsandcrateNameFromCargoTomldo their best to avoid IFD whensrcis the result oflib.cleanSourceWith(and by extensioncleanCargoSource)removeReferencesToVendoredSourceshandles the edge case wherecargoVendorDirdoes not point to a path within the Nix store- It is now possible to use
.overrideScopeto change what instance ofcraneUtilswill be used during vendoring.
0.17.3 - 2024-06-02
Fixed
removeReferencesToVendoredSourcescorrectly signs aarch64-darwin builds (which was accidentally broken in 0.17.2)
0.17.2 - 2024-05-26
Fixed
removeReferencesToVendoredSourceshas been optimized to search for source references only once. For derivations which install many files, this phase can run up to 99% faster than before.cleanCargoTomlnow cleans underscored versions of the same attributes (e.g.lib.proc-macroandlib.proc_macro)
0.17.1 - 2024-05-19
Fixed
downloadCargoPackageanddownloadCargoPackageFromGitno longer run the fixup phase by default, avoiding issues with source directories and files being moved to different locationsdownloadCargoPackagenow unpacks and installs from a fresh directory, avoiding having build environment files (likeenv-vars) appearing in the output
0.17.0 - 2024-05-18
Added
cargoDocnow supportsdocInstallRootto influence which directory will be installed to$out/share(which can be useful when cross-compiling). By default$CARGO_TARGET_DIRand$CARGO_BUILD_TARGET(if set) will be taken into accountcrateNameFromCargoTomlnow supports selecting a derivation name by settingpackage.metadata.crane.nameorworkspace.metadata.crane.namein the rootCargo.tomlvendorCargoDeps,vendorCargoRegistries,vendorGitDeps, andvendorMultipleCargoDepsnow support arbitrary overrides (i.e. patching) at the individual crate/repo level when vendoring sources.
Changed
- Breaking
cargoAuditno longer acceptscargoExtraArgs(since it does not support the regular set ofcargoflags like most cargo-commands do, it does not make much sense to propagate those flags through) buildTrunkPackagenow setsenv.TRUNK_SKIP_VERSION_CHECK = "true";if not specified
Deprecations
- In the future,
crateNameFromCargoTomlwill stop consideringworkspace.package.namein the rootCargo.tomlwhen determining the crate name. This attribute is not recognized by cargo (which will emit its own warnings about it) and should be avoided going forward. - In the future,
crane.lib.${system}will be removed. Please switch to using(crane.mkLib nixpkgs.lib.${system})as an equivalent alternative.
0.16.6 - 2024-05-04
Fixed
- Same as 0.16.5 but with the correct tag deployed to Flakestry/FlakeHub
0.16.5 - 2024-05-04
Fixed
- Workspace inheritance for git dependencies now ignores (removes) all comments
around dependency declarations to work around a mangling bug in
toml_edit(see https://github.com/ipetkov/crane/issues/527 and https://github.com/toml-rs/toml/issues/691)
0.16.4 - 2024-04-07
Added
- Added a warning if an unsupported version of nixpkgs is used
Changed
cargoNextestnow supports settingwithLlvmCovwhich will automatically runcargo llvm-cov nextest. Note thatwithLlvmCov = true;is (currently) only supported whenpartitions = 1;
Fixed
inheritCargoArtifactsHookandinstallCargoArtifactsHooknow correctly handle the case whenCARGO_TARGET_DIRis set to a nested directory- Dependency vendoring now correctly takes unused patch dependencies into account
0.16.3 - 2024-03-19
Changed
- Sources are now fetched crates.io's CDN, following cargo's (new) default behavior.
Fixed
vendorMultipleCargoDepscorrectly listsregistriesas an optional parameter
0.16.2 - 2024-02-21
Changed
cleanCargoTomlnow also strips out[lints]and[workspace.lints]definitions. This means avoiding unnecessarily rebuilding dependencies when the lint definitions change, and it avoids issues with failing to build dummified sources which might have violated a lint marked asdenyorforbid
Fixed
- Fixed an edge case with inheriting workspace dependencies where the workspace
dependency is a string (e.g.
foo = "0.1.2") but the crate definition is a table (e.g.foo = { workspace = true, optional = true })
0.16.1 - 2024-01-28
Changed
buildDepsOnlynow ignores any outputs (besides the defaultout)
Fixed
buildDepsOnlyno longer fails when workspace is configured with#[deny(unused-extern-crates)]vendorCargoDeps(and friends) are now much more friendly to cross-compilation definitions. Specifically, source vendoring will always build dependencies to run on the build machine (and not for the host we're cross compiling to).
0.16.0 - 2024-01-18
Changed
- Breaking: dropped compatibility for Nix versions below 2.18.1
- Breaking: dropped compatibility for nixpkgs-23.05.
buildTrunkPackagehas a new argument,wasm-bindgen-climust be set to avoid mismatching versions between the wasm-bindgen library and CLI tool.
Fixed
- Workspace inheritance of
lintsin git dependencies is now correctly handled
0.15.1 - 2023-11-30
Changed
buildDepsOnlywill now assumecargoTestExtraArgs = "--no-run";if not specified (since there is no point to trying to run tests with the stripped sources). To get the old behavior back, setcargoTestExtraArgs = "";
Fixed
buildTrunkPackage'spreConfigurescript to fail quicker with a more obvious error message if dependencies at not appropriately met
0.15.0 - 2023-11-05
Added
cargoDenyadded for runningcargo-deny.installCargoArtifactsHookwill now pass along the contents of$zstdCompressionExtraArgsas arguments tozstdwhen compressing artifacts. This allows for tailoring compression behavior, for example, by settingzstdCompressionExtraArgs = "-19";on the derivation.
Changed
- The
use-zstdartifact installation mode now uses a chained, incremental approach to avoid redundancy. Old behavior (taking a full snapshot of the cargo artifacts) can be achieved by settingdoCompressAndInstallFullArchive = true. - The default
installCargoArtifactsModehas been changed touse-zstd, meaning cargo artifacts will be compressed to a series of incremental, zstd compressed tarballs across derivations. To get the old behavior back, setinstallCargoArtifactsMode = "use-symlink"to any derivation which produces cargo artifacts. - All dependencies (outside of
nixpkgs) have been dropped from the (main) flake.lock file so they do not pollute downstream projects' lock files.
Fixed
mkDummySrcnow properly handles file cleaning (and file including) when a build is invoked with a--store ...override
0.14.3 - 2023-10-17
Changed
craneUtilswill now be built with therustPlatformprovided by nixpkgs instead of the currently configured toolchain. This should hopefully result in fewer surprises for those testing with really old MSRV toolchains.devShellwill now additionally includeclippyandrustfmtfrom the currently configured toolchain
Fixed
replaceCargoLockHooknow runs as aprePatchhook (rather thanpostUnpack) which correctly replaces theCargo.lockin the source directory rather than the parent directory
0.14.2 - 2023-10-15
Added
replaceCargoLockHookcan now be used to easily replace or insert aCargo.lockfile in the current derivation
Changed
cargoAuditwill pass--ignore yankedby default ifcargoAuditExtraArgsare not specified. This is becausecargo-auditcannot check for yanked crates from inside of the sandbox. To get the old behavior back, setcargoAuditExtraArgs = "";.
Fixed
- Fixed handling of Cargo workspace inheritance for git-dependencies where said crate relies on reading non-TOML metadata (i.e. comments) from its Cargo.toml at build time. (#407)
- Fixed handling of dummy target names to avoid issues with
cargo doc. (#410) - When using
installCargoArtifactsMode = "use-zstd";all files will be marked as user-writable while compressing removeReferencesToVendoredSourcesnow signsaarch64-darwinbinaries. (#418)
0.14.1 - 2023-09-23
Fixed
- Fixed a bug where
buildPackagewould fail to inherit artifacts from dependency crates ifcargoArtifactswas not explicitly specified.
0.14.0 - 2023-09-21
Added
- Added
devShell, a thin wrapper aroundpkgs.mkShellwhich automatically providescargoandrustc. - Added the ability to specify output hashes of git dependencies for fully
offline evaluations. The
outputHashesattribute can now be optionally specified invendorCargoDeps,vendorGitDeps,vendorMultipleCargoDeps, or anything else which delegates to them.
Changed
- Breaking (technically):
buildDepsOnly,buildPackage,cargoBuild,cargoClippy,cargoDoc,cargoLlvmCov, andcargoTest's defaults have been changed such that ifcargoExtraArgshave not been set, a default value of--lockedwill be used. This ensures that a project's committedCargo.lockis exactly what is expected (without implicit changes at build time) but this may end up rejecting builds which were previously passing. To get the old behavior back, setcargoExtraArgs = ""; - Breaking:
cargoDocwill no longer install cargo artifacts by default. SetdoInstallCargoArtifacts = true;to get the old behavior back. cargoDocwill now install generated documentation in$out/share/doc- Fixed a bug when testing proc macro crates with
cargoNexteston macOS. (#376) - Replaced various internal usages of
runCommandLocalwithrunCommandfor more optimal behavior when downloading cached artifacts
0.13.1 - 2023-08-22
Changed
buildTrunkPackagewill now usedart-sassinstead ofnodePackages.sass- Vendoring git dependencies will now always resolve symlinks inside of a crate's directory. This allows for symlinks inside of a crate's directory to possibly refer to files at the root of the git repo itself (via symlink) and have those contents preserved during vendoring.
0.13.0 - 2023-08-07
Added
buildPackagenow supports installingdylibtargets- Added support for sparse registries
Changed
- Breaking: dropped compatibility for Nix versions below 2.13.3
- Breaking: dropped compatibility for nixpkgs-22.05. nixpkgs-23.05 and
- Breaking (technically): if
buildPackageis called without settingcargoArtifacts, the defaultbuildDepsOnlyinvocation will now stop running any installation hooks - Breaking (technically):
buildPackageno longer installs cargo binary dependencies (i.e. when thebindepsfeature is used) by default inheritCargoArtifactsHookwill now symlink dependency.rliband.rmetafiles. This means that derivations which reuse existing cargo artifacts will run faster as fewer files (and bytes!) need to be copied around. To disable this behavior, setdoNotLinkInheritedArtifacts = true;.cargoTarpaulinwill now setdoNotLinkInheritedArtifacts = true;unless otherwise specified- Update
crane-utilsdependencies for successful build in nightly Rust (2023-06-28)
0.12.2 - 2023-06-06
Added
- Added support for the Trunk wasm app build tool
Changed
resolverkey is no longer cleaned from Cargo.toml
Fixed
buildTrunkPackagewill now strip references to store files by defaultbuildTrunkPackagewill now set the rightwasm-optversion
0.12.1 - 2023-04-10
Changed
- Breaking: When setting a default value for
cargoArtifacts,buildPackagewill now ignoreinstallPhaseandinstallPhaseCommandwhen callingbuildPackage. To bring back the old behavior, please specifycargoArtifactsexplicitly
Added
vendorMultipleCargoDepscan now be used to vendor crates from multiple distinctCargo.lockfiles. Notably this allows for building the standard library (via-Z build-stdor equivalent) since both the project's and the Rust toolchain'sCargo.lockfiles can be vendored together
Changed
vendorCargoRegistriesnow accepts aregistriesparameter from the caller. If not specified, it will be computed viacargoConfigs. AlsocargoConfigsis now an optional parameter which will default to[]if not specified.
Fixed
vendorCargoDepscorrectly accepts arguments which have not setsrc, so long as one ofcargoLock,cargoLockContents, orcargoLockParsedis set
0.12.0 - 2023-03-19
Added
- Add a stubbed binary target to each "dummy" crate generated to support
"artifact dependencies" nightly feature
in case a crate is used as
binartifact dependency. - Add
cargoLlvmCovto runcargo llvm-cov - Add
cargoLockParsedoption tovendorCargoDepsto supportCargo.lockfiles parsed as nix attribute sets. craneLib.pathcan now be used as a convenience wrapper on (or drop in replacement of)builtins.pathto ensure reproducible results whenever paths like./.or./..are used directly.
Changed
- Breaking (technically):
mkCargoDerivationwill remove the following attributes before lowering tomkDerivation:cargoLock,cargoLockContentsandcargoLockParsed. If your derivation needs these values to be present they can be explicitly passed through via.overrideAttrsbuildDepsOnlyasdummySrcwill take priority - The API docs have been updated to refer to
craneLib(instead of justlib) to avoid ambiguities withpkgs.lib. - cargo is now invoked with
--releasewhen$CARGO_PROFILE == releaseinstead of passing in--profile releaseto better support tools which do not understand the latter
Fixed
- Fixed support for projects depending on crates utilising per-target workspace dependencies.
0.11.3 - 2023-02-19
Fixed
- Fixed an unintentional cache invalidation whenever
buildDepsOnlywould run on an unfiltered source (likesrc = ./.;).
Changed
- A warning will now be emitted if a derivation's
pnameorversionattributes are not set and the value cannot be loaded from the derivation's rootCargo.toml. To resolve it consider settingpname = "...";orversion = "...";explicitly on the derivation. - A warning will now be emitted if
srcanddummySrcare passed tobuildDepsOnlyasdummySrcwill take priority
0.11.2 - 2023-02-11
Fixed
buildPackageis more tolerant of misbehaving proc macros which write to stdout during the build
0.11.1 - 2023-01-21
Changed
- Documented and made it easier to build a cargo workspace located in a subdirectory of the source root
Fixed
- Previously compiled build scripts now maintain their executable bit when inherited
- Workspace inheritance in git dependencies is now correctly handled
0.11.0 - 2022-12-26
Added
- Documentation is now available at crane.dev
Changed
- Breaking: dropped compatibility for Nix versions below 2.11.0
- Breaking: dropped compatibility for nixpkgs-22.05. nixpkgs-22.11 and nixpkgs-unstable are fully supported
- Zstd compression of cargo artifacts now defaults to using as many cores as
$NIX_BUILD_CORESallows for (or all available cores if it isn't defined) - Dummy sources now attempt to use the same name as their original source (minus the Nix store path and hash) to minimize errors with build scripts which expect their full path to not change between runs
0.10.0 - 2022-12-01
Added
- A new installation mode has been defined which symlinks identical cargo artifacts against previously generated ones. This allows for linear space usage in the Nix store across many chained derivations (as opposed to using a zstd compressed tarball which uses quadratic space across many chained derivations).
mkDummySrcoptionally accepts adummyrsargument which allows for customizing the contents of the dummy Rust files that will be generated.
Changed
- Breaking: all cargo-based derivations will now default to using symlinking
their installed artifacts together instead of using zstd compressed tarballs.
To get the old behavior back, set
installCargoArtifactsMode = "use-zstd";in the derivation.- Note that
buildPackagewill continue to use zstd compressed tarballs while building dependencies (unless either ofcargoArtifactsorinstallCargoArtifactsModeis defined, in which case they will be honored)
- Note that
- Breaking: the format for defining crate registries has been changed: each
registry URL should map to a set containing a
downloadUrlattribute. This set may also definefetchurlExtraArgs(another set) which will be forwarded to thefetchurlinvocations for crates for that registry. - Breaking (technically):
buildDepsOnlywill now only default to runningcargo checkwith the--all-targetsflag only ifdoCheck = true;is set on the derivation (otherwise the flag is omitted). To get the previous behavior back simply setcargoCheckExtraArgs = "--all-targets";. registryFromGitIndexnow uses shallow checkouts for better performanceregistryFromDownloadUrlandregistryFromGitIndexnow allow specifyingfetchurlExtraArgswhich will be forwarded to thefetchurlinvocations for crates for that registry
Fixed
- Unpacking a git repository now ignores duplicate crates to match cargo's behavior
- Sped up stripping references to source files
- Dummy sources now import the
corecrate more robustly (playing more nicely withcargo-hakari) - Building a crate's dependencies automatically works for uefi targets
0.9.0 - 2022-10-29
Changed
- Breaking: all setup hooks have been removed from the
packagesflake output. They can still be accessed via thelibflake output. - Breaking:
cargoBuildnow only runscargo buildin a workspace, tests are no longer run - Breaking:
buildDepsOnlydoes not automatically imply the--all-targetsflag when invokingcargo check. UsecargoCheckExtraArgsto control this buildDepsOnlynow acceptscargoCheckExtraArgsfor passing additional arguments just to thecargo checkinvocation. By default--all-targetswill be usedbuildDepsOnlynow acceptscargoTestExtraArgsfor passing additional arguments just to thecargo testinvocationbuildPackagenow delegates tomkCargoDerivationinstead ofcargoBuild
Fixed
crateNameFromCargoTomlnow takes workspace inheritance into account. If a crate does not specifypackage.versionin its (root) Cargo.toml but does specifyworkspace.package.versionthen the latter will be returned.- Freestanding (
#![no_std]) targets are now supported
0.8.0 - 2022-10-09
Added
cargoTestcan now be used for only running the tests of a workspace
Changed
- Breaking (technically): build hooks now expect helper tools (like
cargo,jq,zstd, etc.) to be present on the path instead of substituting a reference to a (possibly different) executable in the store. mkCargoDerivationnow automatically vendors dependencies ifcargoVendorDiris not definedmkCargoDerivationnow automatically populatespnameandversion(viacrateNameFromCargoToml) if they are not specifiedmkCargoDerivationnow defaults to an emptycheckPhaseCargoCommandif not specifiedcargoAuditnow delegates tomkCargoDerivationinstead ofcargoBuildcargoClippynow delegates tomkCargoDerivationinstead ofcargoBuildcargoDocnow delegates tomkCargoDerivationinstead ofcargoBuildcargoFmtnow delegates tomkCargoDerivationinstead ofcargoBuildcargoNextestnow delegates tomkCargoDerivationinstead ofcargoBuildcargoTarpaulinnow delegates tomkCargoDerivationinstead ofcargoBuild
Fixed
- Installing binaries now uses the same version of cargo as was used to build the package (instead of using whatever version is present in nixpkgs)
Deprecated
- The
packagesflake output has been deprecated. All setup hooks can be accessed via thelibflake output (or via the result of themkLibflake output)
0.7.0 - 2022-09-28
Added
cargoDoccan now be used for building the documentation of a workspacecleanCargoSourcecan now be used to filter sources to only include cargo and Rust files (and avoid rebuilds when irrelevant files change).filterCargoSourcesis the underlying filter implementation and can be composed with other filtersremoveReferencesToVendoredSourcesHookdefines a post-install hook which will remove any references to vendored sources from any installed binaries. Useful for preventing nix from considering the binaries as having a (runtime) dependency on said sources
Changed
- Breaking:
mkCargoDerivationnow includes a defaultconfigurePhasewhich does nothing but run thepreConfigureandpostConfigurehooks. This is done to avoid breaking builds by including puts happen to have setup-hooks which try to claim the configure phase (such ascmake). To get the old behavior back, setconfigurePhase = null;in the derivation. mkCargoDerivation(along with any of its callers likecargoBuild,buildPackage, etc.) now accept astdenvargument which will override the default environment (coming frompkgs.stdenv) for that particular derivationmkDummySrcnow acceptsextraScriptwhich can be used to run a custom script, and therefore customize what the dummy source containsbuildDepsOnlynow acceptsdummySrcas a way to directly pass in the dummy source to be used. Automatically derived viaargs.srcif not specified.
Fixed
cargoAuditproperly keeps anyaudit.tomlfiles when cleaning the sourcebuildPackagenow has more robust checks to ensure that all references to vendored sources are removed after installation (which avoids consumers of the final binaries having to download the sources as well)mkDummySrchow handles build scripts in a manner which ensures cargo runs the real script later (instead of thinking it has not changed)
0.6.0 - 2022-09-07
Added
- Added
cargoNextestfor running tests via cargo-nextest - Added
cargoAuditfor running cargo-audit with a provided advisory database instance.
Changed
- Breaking: the
--workspaceflag is no longer set for all cargo commands by default. The previous behavior can be recovered by settingcargoExtraArgs = "--workspace";in any derivation. - Breaking: the
$CARGO_PROFILEenvironment variable can be used to specify which cargo-profile all invocations use (by defaultreleasewill be used). Technically breaking if the default command was overridden for any derivation; setCARGO_PROFILE = "";to avoid telling cargo to use a release build. - Breaking:
cargoTarpaulinwill use the release profile by default - Breaking:
cargoClippy'scargoClippyExtraArgsnow default to"--all-targets"instead of being specified as the cargo command itself. If you have setcargoClippyExtraArgsto an explicit value and wish to retain the previous behavior you should prepend"--all-targets"to it. - Breaking:
remapSourcePathPrefixHookand thedoRemapSourcePathPrefixoption have been removed, and the behavior ofbuildPackagehas been updated to break false dependencies on the crate sources from the final binaries (which was the old behavior of thedoRemapSourcePathPrefixoption). To disable this behavior, set thedoNotRemoveReferencesToVendorDirenvironment variable to any non-empty string. - All cargo invocations made during the build are automatically logged
- Vendoring git dependencies will throw a descriptive error message if a locked
revision is missing from
Cargo.lockand a hint towards resolution
Fixed
- Breaking:
vendorGitDepswill only include crates referenced by theCargo.lockfile, meaning any extraneous crates which happen to be present in the git repository will be ignored.
0.5.1 - 2022-07-20
Added
- Added
.overrideToolchainas a convenience for using a custom rust toolchain
Fixed
- Fixed an issue where
mkDummySrcwould produce incorrect results for filtered sources: #46
0.5.0 - 2022-06-12
Changed
- Breaking: dropped compatibility for Nix versions below 2.8.1
- Breaking: updated all flake attributes to follow the new
.defaultguidance as per Nix's warnings. Specifically:- Crane's default overlay is now available at
.overlays.default(previously.overlay) - All templates now use
{app,devShells,packages}.defaultas well
- Crane's default overlay is now available at
- Breaking:
lib.fromTOMLandlib.toTOMLhave been removed in favor ofbuiltins.fromTOML - Improved support for consuming
cranewithout using flakes - The
nix-stddependency has been dropped
0.4.1 - 2022-05-29
Fixed
- Dummy source derivations go to greater lengths to only depend on the files
they consume. Specifying the entire flake source as an input (e.g. via
buildPackage { src = self; }) now avoids rebuilding everything from scratch whenever any file is changed. #28
0.4.0 - 2022-05-10
Changed
- Breaking: the previously named
utilsflake input has been renamed toflake-utils buildDepsOnlynow adds--all-targetsto the defaultcargo checkinvocation. This allows caching all artifacts (including from dev-dependencies) such that tools like clippy don't have to generate them every time they run.- Templates now use the newer flake format accepted by Nix 2.8 (e.g.
{packages,overlays,devShells}.default, etc.)
Fixed
- Fixed project and template flakes to avoid superfluous follows declaration for
flake-utils - Fixed quoting of relative paths to allow building with external sources
0.3.3 - 2022-02-24
Fixed
- Use
lib.groupByifbuiltins.groupByisn't available (i.e. if a Nix version earlier than 2.5 is used) - The cross compilation example also hows how to set the
HOST_CCenvironment variable which may be required by some build scripts to function properly
0.3.2 - 2022-02-18
Fixed
- Fixed handling git dependencies whose locked revision is not on the repository's main branch
0.3.1 - 2022-02-17
Added
- Added template and example for cross compiling to other platforms
- Added template and example for building static binaries using musl
Changed
cargoClippyandcargoTarpaulinwill install cargo artifacts by default (or install an emptytargetdirectory if there are none). This allows for more easily chaining derivations if doing so is desired.- This can be disabled by setting
doInstallCargoArtifacts = false;in the derivation
- This can be disabled by setting
Fixed
- Fixed an issue where cross compiling would try to needlessly cross compile rustc and cargo themselves
0.3.0 - 2022-02-11
Added
downloadCargoPackageFromGithas been added to handle downloading and unpacking a cargo workspace from a git repositoryvendorCargoRegistrieshas been added to handle vendoring crates from all registries used in aCargo.lockfilevendorGitDepshas been added to handle vendoring crates from all git sources used in aCargo.lockfile
Changed
vendorCargoDepsnow automatically handles git dependencies by default- Git dependencies will be vendored as another source in the output derivation
- The cargo configuration is done such that the sources are available to use
when it decides, without overriding that crate for the entire workspace
- For example, if your workspace contains a crate only used for testing which has a git dependency of a crate used by other parts of the workspace, then only that crate will use the git dependency. The rest of the workspace will continue to use the crates.io version, just like cargo behaves when used outside of Nix.
0.2.1 - 2022-02-11
Changed
cargoFmtwill install cargo artifacts by default (or install an emptytargetdirectory if there are none). This allows for more easily chaining derivations if doing so is desired.- This can be disabled by setting
doInstallCargoArtifacts = false;in the derivation
- This can be disabled by setting
0.2.0 - 2022-01-30
Added
- Support for alternative cargo registries
Changed
urlForCargoPackagenow takes configured registries into account when downloading crate sources- Breaking:
vendorCargoDepsnow vendors each unique registry as a subdirectory within the derivation's output. Aconfig.tomlfile is also placed at the output root which contains the necessary configurations to point cargo at the vendored sources. configureCargoVendoredDepsHookis now aware of the updatedvendorCargoDepsoutput format, and will use theconfig.tomlfile it generates if it is present. Otherwise it will fall back to the previous behavior (which is treat the entire directory as only vendoring crates.io).- Source vendoring now uses
runCommandLocal(instead ofrunCommand) to reduce network pressure in trying to fetch results which can quickly be built locally - Searching for
Cargo.tomlor.cargo/config.tomlfiles is now done more efficiently
0.1.0 - 2022-01-22
- First release