diff --git a/pkgs/development/tools/rcodesign/default.nix b/pkgs/development/tools/rcodesign/default.nix index a110611ab4a9..b96258cf1672 100644 --- a/pkgs/development/tools/rcodesign/default.nix +++ b/pkgs/development/tools/rcodesign/default.nix @@ -2,26 +2,37 @@ , stdenv , rustPlatform , fetchFromGitHub -, darwin +, apple-sdk_11 +, uutils-coreutils }: rustPlatform.buildRustPackage rec { pname = "rcodesign"; - version = "0.22.0"; + version = "0.27.0"; src = fetchFromGitHub { owner = "indygreg"; repo = "apple-platform-rs"; rev = "apple-codesign/${version}"; - hash = "sha256-ndbDBGtTOfHHUquKrETe4a+hB5Za9samlnXwVGVvWy4="; + hash = "sha256-F6Etl3Zbpmh3A/VeCcSXIy3W1WYFg8WUSJBJV/akCxU="; }; - cargoHash = "sha256-cpQBdxTw/ge4VtzjdL2a2xgSeCT22fMIjuKu5UEedhI="; - - buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ - darwin.apple_sdk_11_0.frameworks.Security + cargoPatches = [ + # Update time to a version that is compatible with Rust 1.80 + ./update-time-rs-in-cargo-lock.patch ]; + patches = [ + # Fix rcodesign’s verbosity level to set the logging level as intended. Needed for cli_tests. + ./fix-verbosity-level.patch + # Disable cli_tests test that requires network access. + ./disable-sign-for-notarization-test.patch + ]; + + cargoHash = "sha256-VrexypkCW58asvzXo3wj/Rgi72tiGuchA31BkEZoYpI="; + + buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ apple-sdk_11 ]; + cargoBuildFlags = [ # Only build the binary we want "--bin" @@ -31,8 +42,19 @@ rustPlatform.buildRustPackage rec { checkFlags = [ # Does network IO "--skip=ticket_lookup::test::lookup_ticket" + # These tests require Xcode to be installed + "--skip=find_all_platform_directories" + "--skip=find_all_sdks" ]; + # Set up uutils-coreutils for cli_tests. Without this, it will be installed with `cargo install`, which will fail + # due to the lack of network access in the build environment. + preCheck = '' + coreutils_dir=''${CARGO_TARGET_DIR:-"$(pwd)/target"}/${stdenv.hostPlatform.rust.cargoShortTarget}/coreutils/bin + install -m 755 -d "$coreutils_dir" + ln -s '${lib.getExe' uutils-coreutils "uutils-coreutils"}' "$coreutils_dir/coreutils" + ''; + meta = with lib; { description = "Cross-platform CLI interface to interact with Apple code signing"; mainProgram = "rcodesign"; diff --git a/pkgs/development/tools/rcodesign/disable-sign-for-notarization-test.patch b/pkgs/development/tools/rcodesign/disable-sign-for-notarization-test.patch new file mode 100644 index 000000000000..ce48e30bbea1 --- /dev/null +++ b/pkgs/development/tools/rcodesign/disable-sign-for-notarization-test.patch @@ -0,0 +1,14 @@ +diff --git a/apple-codesign/tests/cli_tests.rs b/apple-codesign/tests/cli_tests.rs +index 22166712ec..8721a92753 100644 +--- a/apple-codesign/tests/cli_tests.rs ++++ b/apple-codesign/tests/cli_tests.rs +@@ -271,6 +271,9 @@ + + cases.case("tests/cmd/*.trycmd").case("tests/cmd/*.toml"); + ++ // Disable in nixpkgs because it requires network access ++ cases.skip("tests/cmd/sign-for-notarization.trycmd"); ++ + // Help output breaks without notarize feature. + if cfg!(not(feature = "notarize")) { + cases.skip("tests/cmd/encode-app-store-connect-api-key.trycmd"); diff --git a/pkgs/development/tools/rcodesign/fix-verbosity-level.patch b/pkgs/development/tools/rcodesign/fix-verbosity-level.patch new file mode 100644 index 000000000000..5d134bd71165 --- /dev/null +++ b/pkgs/development/tools/rcodesign/fix-verbosity-level.patch @@ -0,0 +1,19 @@ +diff --git a/apple-codesign/src/cli/mod.rs b/apple-codesign/src/cli/mod.rs +index 53e9649271..82d4d061a6 100644 +--- a/apple-codesign/src/cli/mod.rs ++++ b/apple-codesign/src/cli/mod.rs +@@ -2499,9 +2499,11 @@ + _ => LevelFilter::Trace, + }; + +- let mut builder = env_logger::Builder::from_env( +- env_logger::Env::default().default_filter_or(log_level.as_str()), +- ); ++ let mut builder = env_logger::Builder::new(); ++ ++ builder ++ .filter_level(log_level) ++ .parse_default_env(); + + // Disable log context except at higher log levels. + if log_level <= LevelFilter::Info { diff --git a/pkgs/development/tools/rcodesign/update-time-rs-in-cargo-lock.patch b/pkgs/development/tools/rcodesign/update-time-rs-in-cargo-lock.patch new file mode 100644 index 000000000000..892c5c2ae402 --- /dev/null +++ b/pkgs/development/tools/rcodesign/update-time-rs-in-cargo-lock.patch @@ -0,0 +1,47 @@ +diff --git a/Cargo.lock b/Cargo.lock +index 3a5dd6d244..787b048829 100644 +--- a/Cargo.lock ++++ b/Cargo.lock +@@ -2257,6 +2257,12 @@ + ] + + [[package]] ++name = "num-conv" ++version = "0.1.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" ++ ++[[package]] + name = "num-integer" + version = "0.1.45" + source = "registry+https://github.com/rust-lang/crates.io-index" +@@ -3605,12 +3611,13 @@ + + [[package]] + name = "time" +-version = "0.3.31" ++version = "0.3.36" + source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" ++checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" + dependencies = [ + "deranged", + "itoa", ++ "num-conv", + "powerfmt", + "serde", + "time-core", +@@ -3625,10 +3632,11 @@ + + [[package]] + name = "time-macros" +-version = "0.2.16" ++version = "0.2.18" + source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" ++checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" + dependencies = [ ++ "num-conv", + "time-core", + ] + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index de9c1a1be77e..1054a78c1a45 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -18221,7 +18221,7 @@ with pkgs; hammer = callPackage ../development/tools/parsing/hammer { }; - rcodesign = darwin.apple_sdk_11_0.callPackage ../development/tools/rcodesign {}; + rcodesign = callPackage ../development/tools/rcodesign { }; rdocker = callPackage ../development/tools/rdocker { };