mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-22 23:17:15 +03:00
Remove doCompressTarget option
* Reducing the parameter surface area for good measure, zstd compression works pretty well and it seems redundant to support multiple ways of copying the target directory around
This commit is contained in:
parent
38006226c1
commit
64914fbc98
@ -60,9 +60,6 @@ in
|
||||
# access. Directory structure should basically follow the output of `cargo vendor`.
|
||||
# This can be inferred automatically if the `src` root has a Cargo.lock file.
|
||||
, cargoVendorDir ? vendorCargoDepsFromArgs args
|
||||
# Controls whether cargo's `target` directory should be compressed when copied
|
||||
# to the output at the end of the derivation.
|
||||
, doCompressTarget ? true
|
||||
# Controls whether cargo's `target` directory should be copied as an output
|
||||
, doCopyTargetToOutput ? true
|
||||
# Controls instructing rustc to remap the path prefix of any sources it
|
||||
@ -79,7 +76,6 @@ let
|
||||
inherit
|
||||
cargoArtifacts
|
||||
cargoVendorDir
|
||||
doCompressTarget
|
||||
doCopyTargetToOutput
|
||||
doRemapSourcePathPrefix;
|
||||
|
||||
|
@ -4,18 +4,12 @@ copyCargoTargetToOutput() {
|
||||
export SOURCE_DATE_EPOCH=1
|
||||
mkdir -p "${target}"
|
||||
|
||||
if [ "1" != "${doCompressTarget-}" ]; then
|
||||
# Copy the cargo `target` directory to the `target` output
|
||||
mv "${CARGO_TARGET_DIR:-target}" "${target}/target"
|
||||
return
|
||||
fi
|
||||
|
||||
# See: https://reproducible-builds.org/docs/archives/
|
||||
tar --sort=name \
|
||||
--mtime="@${SOURCE_DATE_EPOCH}" \
|
||||
--owner=0 --group=0 --numeric-owner \
|
||||
--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
|
||||
-c target | @zstd@ -o "${target}/target.tar.zst"
|
||||
-c "${CARGO_TARGET_DIR:-target}" | @zstd@ -o "${target}/target.tar.zst"
|
||||
}
|
||||
|
||||
if [ "1" = "${doCopyTargetToOutput-}" ]; then
|
||||
|
@ -26,7 +26,6 @@
|
||||
{
|
||||
name = "inheritCargoArtifactsHook";
|
||||
substitutions = {
|
||||
rsync = "${rsync}/bin/rsync";
|
||||
zstd = "${zstd}/bin/zstd";
|
||||
};
|
||||
} ./inheritCargoArtifactsHook.sh;
|
||||
|
@ -1,5 +1,5 @@
|
||||
inheritCargoArtifacts() {
|
||||
echo "Executing inheritCargoArtifacts"
|
||||
echo cargoArtifacts is ${cargoArtifacts}
|
||||
|
||||
local cargoTarget="${CARGO_TARGET_DIR:-target}"
|
||||
mkdir -p "${cargoTarget}"
|
||||
@ -7,16 +7,6 @@ inheritCargoArtifacts() {
|
||||
if [ -f "${cargoArtifacts}/target.tar.zst" ]; then
|
||||
@zstd@ -d "${cargoArtifacts}/target.tar.zst" --stdout | \
|
||||
tar -x -C "${cargoTarget}" --strip-components=1
|
||||
elif [ -d "${cargoArtifacts}/target" ]; then
|
||||
@rsync@ \
|
||||
--recursive \
|
||||
--links \
|
||||
--executability \
|
||||
--chmod=+w \
|
||||
--no-perms \
|
||||
--no-owner \
|
||||
--no-group \
|
||||
"${cargoArtifacts}/target" "${cargoTarget}"
|
||||
else
|
||||
echo "${cargoArtifacts} looks invalid, are you sure it is pointing to a ".target" output?"
|
||||
false
|
||||
|
@ -27,6 +27,18 @@ pkgs.lib.makeScope myLib.newScope (self:
|
||||
"overlapping-targets"
|
||||
]);
|
||||
|
||||
customCargoTargetDirectory = let
|
||||
simple = myLib.buildWithCargo {
|
||||
doCopyTargetToOutput = false;
|
||||
src = ./simple;
|
||||
CARGO_TARGET_DIR = "my-custom-cargo-dir";
|
||||
};
|
||||
in pkgs.runCommand "smoke-simple" { } ''
|
||||
# does it run?
|
||||
${simple}/bin/simple
|
||||
touch $out
|
||||
'';
|
||||
|
||||
smokeSimple = let
|
||||
simple = myLib.buildWithCargo {
|
||||
doCopyTargetToOutput = false;
|
||||
|
Loading…
Reference in New Issue
Block a user