Unverified Commit 4d2ad0cf authored by Jörg Thalheim's avatar Jörg Thalheim Committed by GitHub
Browse files

zerotierone: fix build on macOS (#380892)

parents 56f99587 9801b983
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
From b83e6354de099860bcb1ca3876c222c57de89f0c Mon Sep 17 00:00:00 2001
From: Michael Hoang <enzime@users.noreply.github.com>
Date: Mon, 10 Feb 2025 18:03:12 +0700
Subject: [PATCH] rustfsm: remove unsupported `lints.workspace`

This patch will no longer be necessary when
https://github.com/NixOS/nixpkgs/pull/300532 is merged
---
 fsm/Cargo.toml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fsm/Cargo.toml b/fsm/Cargo.toml
index 5e9e1c9..3fda704 100644
--- a/fsm/Cargo.toml
+++ b/fsm/Cargo.toml
@@ -17,5 +17,3 @@ rustfsm_trait = { version = "0.1", path = "rustfsm_trait" }
 [package.metadata.workspaces]
 independent = true
 
-[lints]
-workspace = true
-- 
2.46.0
+0 −3579

File deleted.

Preview size limit exceeded, changes collapsed.

+23 −30
Original line number Diff line number Diff line
@@ -18,45 +18,46 @@

let
  pname = "zerotierone";
  version = "1.14.0";
  version = "1.14.2";

  src = fetchFromGitHub {
    owner = "zerotier";
    repo = "ZeroTierOne";
    rev = version;
    hash = "sha256-YWcqALUB3ZEukL4er2FKcyNdEbuaf//QU5hRbKAfxDA=";
    tag = version;
    hash = "sha256-D+7/ja5uYzH1iNd+Ti3k+dWOf5GvN4U+GuVBA9gxtTc=";
  };

in
stdenv.mkDerivation {
  inherit pname version src;

  cargoDeps = rustPlatform.importCargoLock {
    lockFile = ./Cargo.lock;
    outputHashes = {
      "jwt-0.16.0" = "sha256-P5aJnNlcLe9sBtXZzfqHdRvxNfm6DPBcfcKOVeLZxcM=";
      "rustfsm-0.1.0" = "sha256-q7J9QgN67iuoNhQC8SDVzUkjCNRXGiNCkE8OsQc5+oI=";
    };
  cargoDeps = rustPlatform.fetchCargoVendor {
    inherit src;
    sourceRoot = "source/rustybits";
    hash = "sha256-CSpm4zBWKhcrM/KXGU6/51NSQ6hzpT44D2J+QETBtpQ=";

    # REMOVEME when https://github.com/NixOS/nixpkgs/pull/300532 is merged
    postBuild = ''
      pushd $out/git/730aadcc02767ae630e88f8f8c788a85d6bc81e6
      patch --verbose -p1 <${./0001-rustfsm-remove-unsupported-lints.workspace.patch}
      popd
    '';
  };

  patches = [
    # https://github.com/zerotier/ZeroTierOne/pull/2314
    ./0001-darwin-disable-link-time-optimization.patch
    # https://github.com/zerotier/ZeroTierOne/pull/2435
    (fetchpatch {
      url = "https://github.com/zerotier/ZeroTierOne/commit/f9c6ee0181acb1b77605d9a4e4106ac79aaacca3.patch";
      hash = "sha256-zw7KmaxiCH99Y0wQtOQM4u0ruxiePhvv/birxMQioJU=";
      url = "https://github.com/zerotier/ZeroTierOne/commit/8f56d484b681ea30cd28e19cab34499acfa6e64d.patch";
      hash = "sha256-UplkX2O4o8XKKTlR3ZsSG9E0y5gVhAagyepqwyGEYmA=";
    })
    ./0001-darwin-disable-link-time-optimization.patch
  ];

  postPatch = ''
    cp ${./Cargo.lock} Cargo.lock
    cp ${./Cargo.lock} rustybits/Cargo.lock
    cp rustybits/Cargo.lock Cargo.lock
  '';

  preConfigure = ''
    cmp ./Cargo.lock ./rustybits/Cargo.lock || {
      echo 1>&2 "Please make sure that the derivation's Cargo.lock is identical to ./rustybits/Cargo.lock!"
      exit 1
    }

    patchShebangs ./doc/build.sh
    substituteInPlace ./doc/build.sh \
      --replace '/usr/bin/ronn' '${buildPackages.ronn}/bin/ronn' \
@@ -94,20 +95,12 @@ stdenv.mkDerivation {
  preBuild =
    if stdenv.hostPlatform.isDarwin then
      ''
        makeFlagsArray+=("ARCH_FLAGS=") # disable multi-arch build
        # building multiple architectures at the same time from nixpkgs is not supported
        makeFlagsArray+=("ARCH=${stdenv.hostPlatform.darwinArch}")
        if ! grep -q MACOS_VERSION_MIN=10.13 make-mac.mk; then
          echo "You may need to update MACOSX_DEPLOYMENT_TARGET to match the value in make-mac.mk"
          exit 1
        fi
        (cd rustybits && MACOSX_DEPLOYMENT_TARGET=10.13 cargo build -p zeroidc --release)

        cp \
          ./rustybits/target/${stdenv.hostPlatform.rust.rustcTarget}/release/libzeroidc.a \
          ./rustybits/target

        # zerotier uses the "FORCE" target as a phony target to force rebuilds.
        # We don't want to rebuild libzeroidc.a as we build want to build this library ourself for a single architecture
        touch FORCE
      ''
    else
      ''