nixpkgs/pkgs/by-name/re/rerun/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

125 lines
3.0 KiB
Nix

{
lib,
rustPlatform,
fetchpatch,
fetchFromGitHub,
pkg-config,
stdenv,
binaryen,
rustfmt,
lld,
darwin,
freetype,
glib,
gtk3,
libxkbcommon,
openssl,
protobuf,
vulkan-loader,
wayland,
python3Packages,
}:
rustPlatform.buildRustPackage rec {
pname = "rerun";
version = "0.18.2";
src = fetchFromGitHub {
owner = "rerun-io";
repo = "rerun";
rev = version;
sha256 = "sha256-mQjjgRKNFSts34Lphfje9H1BLY9nybCrJ2V09nMzVDM=";
};
cargoHash = "sha256-ZyjRe4M6RabSKhKCLa1ed1fsF6dkUt2a1c8C/1E48+M=";
# the crate uses an old rust version (currently 1.76)
# nixpkgs only works with the latest rust (currently 1.80)
# so we patch this
cargoPatches = [ ./rust-version.patch ];
cargoBuildFlags = [ "--package rerun-cli" ];
cargoTestFlags = [ "--package rerun-cli" ];
buildNoDefaultFeatures = true;
buildFeatures = [ "native_viewer" ];
nativeBuildInputs = [
(lib.getBin binaryen) # wasm-opt
# @SomeoneSerge: Upstream suggests `mold`, but I didn't get it to work
lld
pkg-config
protobuf
rustfmt
];
buildInputs =
[
freetype
glib
gtk3
(lib.getDev openssl)
libxkbcommon
vulkan-loader
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
darwin.apple_sdk.frameworks.AppKit
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.CoreGraphics
darwin.apple_sdk.frameworks.CoreServices
darwin.apple_sdk.frameworks.Foundation
darwin.apple_sdk.frameworks.IOKit
darwin.apple_sdk.frameworks.Metal
darwin.apple_sdk.frameworks.QuartzCore
darwin.apple_sdk.frameworks.Security
]
++ lib.optionals stdenv.hostPlatform.isLinux [ (lib.getLib wayland) ];
addDlopenRunpaths = map (p: "${lib.getLib p}/lib") (
lib.optionals stdenv.hostPlatform.isLinux [
libxkbcommon
vulkan-loader
wayland
]
);
addDlopenRunpathsPhase = ''
elfHasDynamicSection() {
patchelf --print-rpath "$1" >& /dev/null
}
while IFS= read -r -d $'\0' path ; do
elfHasDynamicSection "$path" || continue
for dep in $addDlopenRunpaths ; do
patchelf "$path" --add-rpath "$dep"
done
done < <(
for o in $(getAllOutputNames) ; do
find "''${!o}" -type f -and "(" -executable -or -iname '*.so' ")" -print0
done
)
'';
postPhases = lib.optionals stdenv.hostPlatform.isLinux [ "addDlopenRunpathsPhase" ];
# The path in `build.rs` is wrong for some reason, so we patch it to make the passthru tests work
patches = [ ./tests.patch ];
passthru.tests = {
inherit (python3Packages) rerun-sdk;
};
meta = with lib; {
description = "Visualize streams of multimodal data. Fast, easy to use, and simple to integrate. Built in Rust using egui";
homepage = "https://github.com/rerun-io/rerun";
changelog = "https://github.com/rerun-io/rerun/blob/${src.rev}/CHANGELOG.md";
license = with licenses; [
asl20
mit
];
maintainers = with maintainers; [
SomeoneSerge
robwalt
];
mainProgram = "rerun";
};
}