nixpkgs/pkgs/by-name/sk/sketchybar/package.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

89 lines
1.6 KiB
Nix

{
lib,
overrideSDK,
stdenv,
darwin,
fetchFromGitHub,
testers,
nix-update-script,
}:
let
inherit (stdenv.hostPlatform) system;
inherit (darwin.apple_sdk_11_0.frameworks)
AppKit
Carbon
CoreAudio
CoreWLAN
CoreVideo
DisplayServices
IOKit
MediaRemote
SkyLight
;
target =
{
"aarch64-darwin" = "arm64";
"x86_64-darwin" = "x86";
}
.${system} or (throw "Unsupported system: ${system}");
stdenv' = if stdenv.hostPlatform.isDarwin then overrideSDK stdenv "11.0" else stdenv;
in
stdenv'.mkDerivation (finalAttrs: {
pname = "sketchybar";
version = "2.21.0";
src = fetchFromGitHub {
owner = "FelixKratz";
repo = "SketchyBar";
rev = "v${finalAttrs.version}";
hash = "sha256-hTfQQjx6ai83zYFfccsz/KaoZUIj5Dfz4ENe59gS02E=";
};
buildInputs = [
AppKit
Carbon
CoreAudio
CoreWLAN
CoreVideo
DisplayServices
IOKit
MediaRemote
SkyLight
];
makeFlags = [ target ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp ./bin/sketchybar $out/bin/sketchybar
runHook postInstall
'';
passthru = {
tests.version = testers.testVersion {
package = finalAttrs.finalPackage;
version = "sketchybar-v${finalAttrs.version}";
};
updateScript = nix-update-script { };
};
meta = {
description = "Highly customizable macOS status bar replacement";
homepage = "https://github.com/FelixKratz/SketchyBar";
license = lib.licenses.gpl3;
mainProgram = "sketchybar";
maintainers = with lib.maintainers; [
azuwis
khaneliman
];
platforms = lib.platforms.darwin;
};
})