nixpkgs/pkgs/by-name/bl/bleep/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

76 lines
1.9 KiB
Nix

{
stdenvNoCC,
fetchzip,
autoPatchelfHook,
installShellFiles,
makeWrapper,
lib,
zlib,
}:
let
platform =
{
x86_64-linux = "x86_64-pc-linux";
x86_64-darwin = "x86_64-apple-darwin";
aarch64-darwin = "arm64-apple-darwin";
}
."${stdenvNoCC.system}" or (throw "unsupported system ${stdenvNoCC.hostPlatform.system}");
hash =
{
x86_64-linux = "sha256-dB8reN5rTlY5czFH7BaRya7qBa6czAIH2NkFWZh81ek=";
x86_64-darwin = "sha256-tpUcduCPCbVVaYZZOhWdPlN6SW3LGZPWSO9bDStVDms=";
aarch64-darwin = "sha256-V8QGF3Dpuy9I6CqKsJRHBHRdaLhc4XKZkv/rI7zs+qQ=";
}
."${stdenvNoCC.system}" or (throw "unsupported system ${stdenvNoCC.hostPlatform.system}");
in
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "bleep";
version = "0.0.7";
src = fetchzip {
url = "https://github.com/oyvindberg/bleep/releases/download/v${finalAttrs.version}/bleep-${platform}.tar.gz";
hash = hash;
};
nativeBuildInputs = [
installShellFiles
makeWrapper
] ++ lib.optional stdenvNoCC.hostPlatform.isLinux autoPatchelfHook;
buildInputs = [ zlib ];
installPhase = ''
runHook preInstall
install -Dm755 bleep -t $out/bin/
runHook postInstall
'';
dontAutoPatchelf = true;
postFixup =
lib.optionalString stdenvNoCC.hostPlatform.isLinux ''
autoPatchelf $out
''
+ ''
export PATH=$PATH:$out/bin
installShellCompletion --cmd bleep \
--bash <(bleep install-tab-completions-bash --stdout) \
--zsh <(bleep install-tab-completions-zsh --stdout) \
'';
meta = {
homepage = "https://bleep.build/";
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
license = lib.licenses.mit;
description = "Bleeping fast scala build tool";
mainProgram = "bleep";
platforms = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
maintainers = with lib.maintainers; [ kristianan ];
};
})