From 536ef350651b3967652d786ece0830ab3d5a5093 Mon Sep 17 00:00:00 2001 From: Steven Sherry Date: Fri, 24 Dec 2021 01:04:49 -0600 Subject: [PATCH 1/3] btop: Add darwin support --- pkgs/tools/system/btop/default.nix | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/system/btop/default.nix b/pkgs/tools/system/btop/default.nix index 9c926381dc47..f51b0362ac9c 100644 --- a/pkgs/tools/system/btop/default.nix +++ b/pkgs/tools/system/btop/default.nix @@ -1,6 +1,9 @@ { lib , stdenv , fetchFromGitHub +, runCommand +, darwin +, gcc11 }: stdenv.mkDerivation rec { @@ -14,6 +17,28 @@ stdenv.mkDerivation rec { sha256 = "sha256-uKR1ogQwEoyxyWBiLnW8BsOsYgTpeIpKrKspq0JwYjY="; }; + nativeBuildInputs = lib.optionals stdenv.isDarwin [ gcc11 ]; + + hardeningDisable = lib.optionals (stdenv.isAarch64 && stdenv.isDarwin) [ "stackprotector" ]; + + ADDFLAGS = with darwin.apple_sdk; + lib.optional stdenv.isDarwin + "-F${frameworks.IOKit}/Library/Frameworks/"; + + buildInputs = with darwin.apple_sdk; + lib.optionals stdenv.isDarwin [ + frameworks.CoreFoundation + frameworks.IOKit + ] ++ lib.optional (stdenv.isDarwin && !stdenv.isAarch64) ( + # Found this explanation for needing to create a header directory for libproc.h alone. + # https://github.com/NixOS/nixpkgs/blob/049e5e93af9bbbe06b4c40fd001a4e138ce1d677/pkgs/development/libraries/webkitgtk/default.nix#L154 + # TL;DR, the other headers in the include path for the macOS SDK is not compatible with the C++ stdlib and causes issues, so we copy + # this to avoid those issues + runCommand "${pname}_headers" { } '' + install -Dm444 "${lib.getDev sdk}"/include/libproc.h "$out"/include/libproc.h + '' + ); + installFlags = [ "PREFIX=$(out)" ]; meta = with lib; { @@ -21,7 +46,7 @@ stdenv.mkDerivation rec { homepage = "https://github.com/aristocratos/btop"; changelog = "https://github.com/aristocratos/btop/blob/v${version}/CHANGELOG.md"; license = licenses.asl20; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.darwin; maintainers = with maintainers; [ rmcgibbo ]; }; } From aa9c18ef075796f9418d0fbc5ab8630b56df39bc Mon Sep 17 00:00:00 2001 From: Steven Sherry Date: Fri, 24 Dec 2021 08:24:15 -0600 Subject: [PATCH 2/3] btop: Address initial pr review comments --- pkgs/tools/system/btop/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/tools/system/btop/default.nix b/pkgs/tools/system/btop/default.nix index f51b0362ac9c..2c1534976dac 100644 --- a/pkgs/tools/system/btop/default.nix +++ b/pkgs/tools/system/btop/default.nix @@ -29,7 +29,7 @@ stdenv.mkDerivation rec { lib.optionals stdenv.isDarwin [ frameworks.CoreFoundation frameworks.IOKit - ] ++ lib.optional (stdenv.isDarwin && !stdenv.isAarch64) ( + ] ++ lib.optional (stdenv.isDarwin && stdenv.isx86_64) ( # Found this explanation for needing to create a header directory for libproc.h alone. # https://github.com/NixOS/nixpkgs/blob/049e5e93af9bbbe06b4c40fd001a4e138ce1d677/pkgs/development/libraries/webkitgtk/default.nix#L154 # TL;DR, the other headers in the include path for the macOS SDK is not compatible with the C++ stdlib and causes issues, so we copy From 0aaf5768e5f664d6bbbe421bccf125e2316b246c Mon Sep 17 00:00:00 2001 From: Steven Sherry Date: Wed, 29 Dec 2021 17:13:02 -0600 Subject: [PATCH 3/3] btop: Remove gcc11 as a nativeBuildInput for darwin since gcc11Stdenv is already set in all-packages.nix --- pkgs/tools/system/btop/default.nix | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkgs/tools/system/btop/default.nix b/pkgs/tools/system/btop/default.nix index 2c1534976dac..70b1a78586cf 100644 --- a/pkgs/tools/system/btop/default.nix +++ b/pkgs/tools/system/btop/default.nix @@ -3,7 +3,6 @@ , fetchFromGitHub , runCommand , darwin -, gcc11 }: stdenv.mkDerivation rec { @@ -17,13 +16,11 @@ stdenv.mkDerivation rec { sha256 = "sha256-uKR1ogQwEoyxyWBiLnW8BsOsYgTpeIpKrKspq0JwYjY="; }; - nativeBuildInputs = lib.optionals stdenv.isDarwin [ gcc11 ]; - hardeningDisable = lib.optionals (stdenv.isAarch64 && stdenv.isDarwin) [ "stackprotector" ]; - ADDFLAGS = with darwin.apple_sdk; + ADDFLAGS = with darwin.apple_sdk.frameworks; lib.optional stdenv.isDarwin - "-F${frameworks.IOKit}/Library/Frameworks/"; + "-F${IOKit}/Library/Frameworks/"; buildInputs = with darwin.apple_sdk; lib.optionals stdenv.isDarwin [