nixpkgs/pkgs/by-name/db/dbqn/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

73 lines
1.7 KiB
Nix

{ lib
, stdenv
, fetchFromGitHub
, jdk
, makeWrapper
, buildNativeImage ? false
}:
stdenv.mkDerivation rec {
pname = "dbqn" + lib.optionalString buildNativeImage "-native";
version = "0.2.2";
src = fetchFromGitHub {
owner = "dzaima";
repo = "BQN";
rev = "v${version}";
hash = "sha256-AUfT7l7zr/pyG63wX8FMej8RUg7tXC1aroCrunjyw/8=";
};
nativeBuildInputs = [
jdk
makeWrapper
];
dontConfigure = true;
postPatch = ''
patchShebangs --build ./build8
'';
buildPhase = ''
runHook preBuild
./build8
'' + lib.optionalString buildNativeImage ''
native-image --report-unsupported-elements-at-runtime \
-H:CLibraryPath=${lib.getLib jdk}/lib -J-Dfile.encoding=UTF-8 \
-jar BQN.jar dbqn
'' + ''
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
'' + (if buildNativeImage then ''
mv dbqn $out/bin
'' else ''
mkdir -p $out/share/dbqn
mv BQN.jar $out/share/dbqn/
makeWrapper "${lib.getBin jdk}/bin/java" "$out/bin/dbqn" \
--add-flags "-jar $out/share/dbqn/BQN.jar"
'') + ''
ln -s $out/bin/dbqn $out/bin/bqn
runHook postInstall
'';
meta = with lib; {
homepage = "https://github.com/dzaima/BQN";
description = "BQN implementation in Java" + lib.optionalString buildNativeImage ", compiled as a native image";
license = licenses.mit;
maintainers = with maintainers; [ AndersonTorres sternenseemann ];
inherit (jdk.meta) platforms;
broken = stdenv.hostPlatform.isDarwin; # never built on Hydra https://hydra.nixos.org/job/nixpkgs/staging-next/dbqn-native.x86_64-darwin
};
}
# TODO: Processing app
# TODO: minimalistic JDK