From 758ae442227103fa501276e8225609a11c99718e Mon Sep 17 00:00:00 2001 From: Ivan Petkov Date: Fri, 20 Oct 2023 22:28:41 +0000 Subject: [PATCH] installCargoArtifactsHook: change default installation mode to use-zstd (#442) --- CHANGELOG.md | 5 +++++ docs/API.md | 4 +--- lib/buildPackage.nix | 1 - lib/buildTrunkPackage.nix | 1 - lib/setupHooks/installCargoArtifactsHook.sh | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d87e6fd..eb54954 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. approach to avoid redundancy. Old behavior (taking a full snapshot of the cargo artifacts) can be achieved by setting `doCompressAndInstallFullArchive = true`. +* The default `installCargoArtifactsMode` has been changed to `use-zstd`, + meaning cargo artifacts will be compressed to a series of incremental, zstd + compressed tarballs across derivations. To get the old behavior back, set + `installCargoArtifactsMode = "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. diff --git a/docs/API.md b/docs/API.md index 2122eb0..81a362d 100644 --- a/docs/API.md +++ b/docs/API.md @@ -187,7 +187,6 @@ install hooks. Useful for caching incremental cargo builds. - Default value: the result of `buildDepsOnly` after applying the arguments set (with the respective default values). - - `installCargoArtifactsMode` will be set to `"use-zstd"` if not specified. - `installPhase` and `installPhaseCommand` will be removed, and no installation hooks will be run * `cargoBuildCommand`: A cargo invocation to run during the derivation's build @@ -257,7 +256,6 @@ Except where noted below, all derivation attributes are delegated to set (with the respective default values). - `CARGO_BUILD_TARGET` will be set to `"wasm32-unknown-unknown"` if not specified. - `doCheck` will be set to `false` if not specified. - - `installCargoArtifactsMode` will be set to `"use-zstd"` if not specified. - `installPhase` and `installPhaseCommand` will be removed (in favor of their default values provided by `buildDepsOnly`) * `installPhaseCommand`: the command(s) which are expected to install the @@ -1541,7 +1539,7 @@ arguments: `./target`) will be used. 1. the installation mode to apply * If specified, the value of `$installCargoArtifactsMode` will be used, - otherwise, a default value of `"use-symlink" will be used + otherwise, a default value of `"use-zstd" will be used * If set to "use-symlink" then `dedupAndInstallCargoArtifactsDir()` will be used. - If `$cargoArtifacts` is defined and `$cargoArtifacts/target` is a valid diff --git a/lib/buildPackage.nix b/lib/buildPackage.nix index d4fd5fc..51307c9 100644 --- a/lib/buildPackage.nix +++ b/lib/buildPackage.nix @@ -39,7 +39,6 @@ mkCargoDerivation (cleanedArgs // memoizedArgs // { cargoArtifacts = args.cargoArtifacts or ( buildDepsOnly (args // memoizedArgs // { - installCargoArtifactsMode = args.installCargoArtifactsMode or "use-zstd"; # NB: we intentionally don't run any caller-provided hooks here since they might fail # if they require any files that have been omitted by the source dummification. # However, we still _do_ want to run the installation hook with the actual artifacts diff --git a/lib/buildTrunkPackage.nix b/lib/buildTrunkPackage.nix index 837c136..f213a7b 100644 --- a/lib/buildTrunkPackage.nix +++ b/lib/buildTrunkPackage.nix @@ -37,7 +37,6 @@ mkCargoDerivation (args // { cargoArtifacts = args.cargoArtifacts or (buildDepsOnly (args // { CARGO_BUILD_TARGET = args.CARGO_BUILD_TARGET or "wasm32-unknown-unknown"; - installCargoArtifactsMode = args.installCargoArtifactsMode or "use-zstd"; doCheck = args.doCheck or false; })); diff --git a/lib/setupHooks/installCargoArtifactsHook.sh b/lib/setupHooks/installCargoArtifactsHook.sh index f327faa..a60b3da 100644 --- a/lib/setupHooks/installCargoArtifactsHook.sh +++ b/lib/setupHooks/installCargoArtifactsHook.sh @@ -76,7 +76,7 @@ prepareAndInstallCargoArtifactsDir() { # or fall back to defaults if none are provided local dir="${1:-${out}}" local cargoTargetDir="${2:-${CARGO_TARGET_DIR:-target}}" - local mode="${3:-${installCargoArtifactsMode:-use-symlink}}" + local mode="${3:-${installCargoArtifactsMode:-use-zstd}}" local prevCargoArtifacts="${4:-${cargoArtifacts:""}}" mkdir -p "${dir}"