nixpkgs/pkgs/development/tools/comby/default.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

106 lines
2.6 KiB
Nix

{ ocamlPackages
, fetchFromGitHub
, lib
, zlib
, pkg-config
, cacert
, gmp
, libev
, autoconf
, sqlite
, stdenv
}:
let
mkCombyPackage = { pname, extraBuildInputs ? [ ], extraNativeInputs ? [ ], preBuild ? "" }:
ocamlPackages.buildDunePackage rec {
inherit pname preBuild;
version = "1.8.1";
duneVersion = "3";
minimalOCamlVersion = "4.08.1";
doCheck = true;
src = fetchFromGitHub {
owner = "comby-tools";
repo = "comby";
rev = version;
sha256 = "sha256-yQrfSzJgJm0OWJxhxst2XjZULIVHeEfPMvMIwH7BYDc=";
};
patches = [ ./comby.patch ];
nativeBuildInputs = extraNativeInputs;
buildInputs = [
ocamlPackages.core
ocamlPackages.core_kernel
ocamlPackages.ocaml_pcre
ocamlPackages.mparser
ocamlPackages.mparser-pcre
ocamlPackages.angstrom
ocamlPackages.ppx_deriving
ocamlPackages.ppx_deriving_yojson
ocamlPackages.ppx_sexp_conv
ocamlPackages.ppx_sexp_message
] ++ extraBuildInputs;
nativeCheckInputs = [ cacert ];
meta = {
description = "Tool for searching and changing code structure";
mainProgram = "comby";
license = lib.licenses.asl20;
homepage = "https://comby.dev";
};
};
combyKernel = mkCombyPackage { pname = "comby-kernel"; };
combySemantic = mkCombyPackage { pname = "comby-semantic"; extraBuildInputs = [ ocamlPackages.cohttp-lwt-unix ]; };
in
mkCombyPackage {
pname = "comby";
# tests have to be removed before building otherwise installPhase will fail
# cli tests expect a path to the built binary
preBuild = ''
substituteInPlace test/common/dune \
--replace "test_cli_list" "" \
--replace "test_cli_helper" "" \
--replace "test_cli" ""
rm test/common/{test_cli_list,test_cli_helper,test_cli}.ml
'';
extraBuildInputs = [
zlib
gmp
libev
sqlite
ocamlPackages.shell # This input must appear before `parany` or any other input that propagates `ocamlnet`
ocamlPackages.lwt
ocamlPackages.patience_diff
ocamlPackages.toml
ocamlPackages.cohttp-lwt-unix
ocamlPackages.opium
ocamlPackages.textutils
ocamlPackages.jst-config
ocamlPackages.parany
ocamlPackages.conduit-lwt-unix
ocamlPackages.lwt_react
ocamlPackages.tar-unix
ocamlPackages.tls
ocamlPackages.ppx_jane
ocamlPackages.ppx_expect
ocamlPackages.dune-configurator
combyKernel
combySemantic
] ++ (if !stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64 then
[ ocamlPackages.hack_parallel ]
else
[ ]);
extraNativeInputs = [
autoconf
pkg-config
];
}