From c16cfdbfba043a7276cddfcc8231c266aca1f4ad Mon Sep 17 00:00:00 2001 From: Will Bush Date: Sun, 19 May 2024 21:44:16 -0500 Subject: [PATCH] Fix auto cargo updates I was messing around with `cargo audit` and `cargo outdated` and realized I broke the auto-update of cargo. When I switched from using `cargo update` to `cargo upgrade`, I didn't realize that `cargo upgrade` doesn't update the `Cargo.lock` file. I only noticed because `cargo audit` was reporting a yanked version of libc and running `cargo update` fixed it. I added running `cargo outdated` as a sanity check that things are updating correcty. --- default.nix | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/default.nix b/default.nix index c3911e3..acd2ae5 100644 --- a/default.nix +++ b/default.nix @@ -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 @@ -94,21 +96,40 @@ let echo "" ''; }; + # 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 "
cargo changes" - # 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 "
" ''; };