Files
nixpkgs/pkgs/development/tools/rubyfmt/default.nix
T
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

85 lines
1.6 KiB
Nix

{ lib
, stdenv
, rustPlatform
, fetchFromGitHub
, autoconf
, automake
, bison
, ruby
, zlib
, readline
, libiconv
, libobjc
, libunwind
, libxcrypt
, libyaml
, rust-jemalloc-sys-unprefixed
, Foundation
, Security
}:
rustPlatform.buildRustPackage rec {
pname = "rubyfmt";
version = "0.10.0";
src = fetchFromGitHub {
owner = "fables-tales";
repo = "rubyfmt";
rev = "v${version}";
hash = "sha256-IIHPU6iwFwQ5cOAtOULpMSjexFtTelSd/LGLuazdmUo=";
fetchSubmodules = true;
};
nativeBuildInputs = [
autoconf
automake
bison
ruby
];
buildInputs = [
zlib
libxcrypt
libyaml
rust-jemalloc-sys-unprefixed
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
readline
libiconv
libobjc
libunwind
Foundation
Security
];
preConfigure = ''
pushd librubyfmt/ruby_checkout
autoreconf --install --force --verbose
./configure
popd
'';
cargoPatches = [
# Avoid checking whether ruby gitsubmodule is up-to-date.
./0002-remove-dependency-on-git.patch
# Avoid failing on unused variable warnings.
./0003-ignore-warnings.patch
];
cargoHash = "sha256-QZ26GmsKyENkzdCGg2peie/aJhEt7KQAF/lwsibonDk=";
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-fdeclspec";
preFixup = ''
mv $out/bin/rubyfmt{-main,}
'';
meta = {
description = "Ruby autoformatter";
homepage = "https://github.com/fables-tales/rubyfmt";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ bobvanderlinden ];
broken = stdenv.hostPlatform.isDarwin;
mainProgram = "rubyfmt";
};
}