diff --git a/checks/cleanCargoTomlTests/default.nix b/checks/cleanCargoTomlTests/default.nix index cb9f5920..2ecb5127 100644 --- a/checks/cleanCargoTomlTests/default.nix +++ b/checks/cleanCargoTomlTests/default.nix @@ -1,5 +1,7 @@ { cleanCargoToml +, lib , linkFarmFromDrvs +, remarshal , runCommand , writeTOML }: @@ -12,9 +14,20 @@ let }; cleanedToml = writeTOML "cleaned.toml" cleaned; expected = path + "/expected.toml"; + + # 23.05 has remarshal 0.14 which sorts keys by default + # starting with version 0.16 ordering is preserved unless + # --sort-keys is specified + sortKeys = lib.optionalString + (lib.strings.versionAtLeast remarshal.version "0.16.0") + "--sort-keys"; in runCommand "compare-${name}" { } '' - diff ${expected} ${cleanedToml} + function reformat { + ${remarshal}/bin/remarshal ${sortKeys} -i "$1" --of toml + } + + diff <(reformat ${expected}) <(reformat ${cleanedToml}) touch $out ''; in diff --git a/checks/mkDummySrcTests/default.nix b/checks/mkDummySrcTests/default.nix index 674036c4..0a71e518 100644 --- a/checks/mkDummySrcTests/default.nix +++ b/checks/mkDummySrcTests/default.nix @@ -1,6 +1,7 @@ { lib , linkFarmFromDrvs , mkDummySrc +, remarshal , runCommand , writeText }: @@ -12,10 +13,26 @@ let cp --recursive ${orig_actual} --no-target-directory $out --no-preserve=mode,ownership find $out -name Cargo.toml | xargs sed -i"" 's!/nix/store/[^-]\+-dummy.rs!cranespecific-dummy.rs!' ''; + + # 23.05 has remarshal 0.14 which sorts keys by default + # starting with version 0.16 ordering is preserved unless + # --sort-keys is specified + sortKeys = lib.optionalString + (lib.strings.versionAtLeast remarshal.version "0.16.0") + "--sort-keys"; in runCommand "compare-${name}" { } '' echo ${expected} ${actual} - diff -r ${expected} ${actual} + cp -r --no-preserve=ownership,mode ${expected} ./expected + cp -r --no-preserve=ownership,mode ${actual} ./actual + + find ./expected ./actual \ + -name Cargo.toml \ + -exec mv '{}' '{}.bak' \; \ + -exec ${remarshal}/bin/remarshal ${sortKeys} --if toml -i '{}.bak' --of toml -o '{}' \; + find ./expected ./actual -name Cargo.toml.bak -delete + + diff -r ./expected ./actual touch $out ''; diff --git a/flake.lock b/flake.lock index 07174f5c..1f1619d6 100644 --- a/flake.lock +++ b/flake.lock @@ -21,11 +21,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1689068808, - "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "lastModified": 1692799911, + "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", "owner": "numtide", "repo": "flake-utils", - "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", "type": "github" }, "original": { @@ -36,11 +36,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1691371061, - "narHash": "sha256-BxPbPVlBIoneaXIBiHd0LVzA+L4nmvFCNBU6TmQAiMM=", + "lastModified": 1693654884, + "narHash": "sha256-EqKKEl+IOS8TSjkt+xn1qGpsjnx5/ag33YNQ1+c7OuM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5068bc8fe943bde3c446326da8d0ca9c93d5a682", + "rev": "e7f35e03abd06a2faef6684d0de813370e13bda8", "type": "github" }, "original": { @@ -68,11 +68,11 @@ ] }, "locked": { - "lastModified": 1691374719, - "narHash": "sha256-HCodqnx1Mi2vN4f3hjRPc7+lSQy18vRn8xWW68GeQOg=", + "lastModified": 1693707092, + "narHash": "sha256-HR1EnynBSPqbt+04/yxxqsG1E3n6uXrOl7SPco/UnYo=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "b520a3889b24aaf909e287d19d406862ced9ffc9", + "rev": "98ccb73e6eefc481da6039ee57ad8818d1ca8d56", "type": "github" }, "original": {