Skip to content

Commit

Permalink
various: switch to using runCommand to improve caching (ipetkov#384)
Browse files Browse the repository at this point in the history
For example, commands which extract a tarball should be cached (i.e
should use `runCommand` not `runCommandLocal`) because it allows builds
to download the unpacked result instead of having to write both to the
store
  • Loading branch information
ipetkov authored Sep 4, 2023
1 parent 6630354 commit 8b4f7a4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* `cargoDoc` will now install generated documentation in `$out/share/doc`
* Fixed a bug when testing proc macro crates with `cargoNextest` on macOS.
([#376](https://github.com/ipetkov/crane/pull/376))
* Replaced various internal usages of `runCommandLocal` with `runCommand` for
more optimal behavior when downloading cached artifacts

## [0.13.1] - 2023-08-22

Expand Down
4 changes: 2 additions & 2 deletions checks/cargoAudit.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ cargoAudit
, fetchFromGitHub
, linkFarmFromDrvs
, runCommandLocal
, runCommand
}:

let
Expand All @@ -17,7 +17,7 @@ let

simpleWithAuditToml = (auditWith "simple-with-audit-toml" ./simple-with-audit-toml);

containsAuditTomlInSrc = runCommandLocal "containsAuditTomlInSrc" { } ''
containsAuditTomlInSrc = runCommand "containsAuditTomlInSrc" { } ''
if [[ -f ${simpleWithAuditToml.src}/.cargo/audit.toml ]]; then
touch $out
else
Expand Down
4 changes: 2 additions & 2 deletions lib/downloadCargoPackage.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ fetchurl
, urlForCargoPackage
, runCommandLocal
, runCommand
}:

{ name
Expand All @@ -16,7 +16,7 @@ let
sha256 = checksum;
});
in
runCommandLocal "cargo-package-${name}-${version}" { } ''
runCommand "cargo-package-${name}-${version}" { } ''
mkdir -p $out
tar -xzf ${tarball} -C $out --strip-components=1
echo '{"files":{}, "package":"${checksum}"}' > $out/.cargo-checksum.json
Expand Down
4 changes: 2 additions & 2 deletions lib/downloadCargoPackageFromGit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
, craneUtils
, jq
, lib
, runCommandLocal
, runCommand
}:

{ git
Expand All @@ -26,7 +26,7 @@ let
];
};
in
runCommandLocal "cargo-git" deps ''
runCommand "cargo-git" deps ''
mkdir -p $out
existing_crates=()
while read -r cargoToml; do
Expand Down
4 changes: 2 additions & 2 deletions lib/mkDummySrc.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ cleanCargoToml
, findCargoFiles
, lib
, runCommandLocal
, runCommand
, writeText
, writeTOML
}:
Expand Down Expand Up @@ -236,7 +236,7 @@ let
then "dummy-src"
else last nameWithoutHash;
in
runCommandLocal sourceName { } ''
runCommand sourceName { } ''
mkdir -p $out
cp --recursive --no-preserve=mode,ownership ${cleanSrc}/. -t $out
${copyCargoLock}
Expand Down

0 comments on commit 8b4f7a4

Please sign in to comment.