Skip to content

Commit

Permalink
Merge pull request #67 from willbush/bugfix/cargo-changes
Browse files Browse the repository at this point in the history
Fix auto cargo updates
  • Loading branch information
philiptaron authored May 24, 2024
2 parents 0964530 + c16cfdb commit 4d52ff6
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ let
env.RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
inputsFrom = [ packages.build ];
nativeBuildInputs = with pkgs; [
cargo-audit
cargo-edit
cargo-outdated
npins
rust-analyzer
treefmtEval.config.build.wrapper
Expand Down Expand Up @@ -94,21 +96,40 @@ let
echo "</details>"
'';
};
# These steps have to be in the same script because order matters.
# `carge upgrade` should happen before `cargo update` and then check
# `cargo outdated` and `cargo audit` after that.
cargo = pkgs.writeShellApplication {
name = "update-cargo";
name = "cargo";
runtimeInputs = with pkgs; [
cargo
cargo-edit
cargo-audit
cargo-edit # provides `cargo upgrade`
cargo-outdated
];
text = ''
echo "<details><summary>cargo changes</summary>"
# Needed because GitHub's rendering of the first body line breaks down otherwise
echo ""
# Note: `cargo upgrade` is a subcommand provided by `cargo-edit`.
echo "### cargo upgrade"
printf "\n\`\`\`\n"
# --incompatible allows jumping to the next major version.
echo '```'
cargo upgrade --incompatible --manifest-path "$1/Cargo.toml" 2>&1
echo '```'
printf "\n\`\`\`\n"
echo "### cargo update"
printf "\n\`\`\`\n"
cargo update --manifest-path "$1/Cargo.toml" 2>&1
printf "\n\`\`\`\n"
echo "### cargo outdated"
printf "\n\`\`\`\n"
cargo outdated --manifest-path "$1/Cargo.toml" 2>&1
printf "\n\`\`\`\n"
echo "### cargo audit"
printf "\n\`\`\`\n"
cargo audit --file "$1/Cargo.lock" 2>&1
printf "\n\`\`\`\n"
echo "</details>"
'';
};
Expand Down

0 comments on commit 4d52ff6

Please sign in to comment.