nixpkgs/pkgs/by-name/fe/fedimint/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

97 lines
2.5 KiB
Nix

{ lib
, buildPackages
, clang
, fetchFromGitHub
, libclang
, libiconv
, llvmPackages_12
, openssl
, pkg-config
, protobuf
, rustPlatform
, stdenv
, Security
, SystemConfiguration
}:
let
# Rust rocksdb bindings have C++ compilation/linking errors on Darwin when using newer clang
# Forcing it to clang 12 fixes the issue.
buildRustPackage =
if stdenv.hostPlatform.isDarwin then
rustPlatform.buildRustPackage.override { stdenv = llvmPackages_12.stdenv; }
else
rustPlatform.buildRustPackage;
in
buildRustPackage rec {
pname = "fedimint";
version = "0.4.2";
src = fetchFromGitHub {
owner = "fedimint";
repo = "fedimint";
rev = "v${version}";
hash = "sha256-ih1ZwH8uItplMJU2/XkQseFlYUsf8/TkX8lGyRl7/KU=";
};
cargoHash = "sha256-scfgUFuS/b4EFfPuhl6uFlTZi4gyTqtEso2a5jhrxno=";
nativeBuildInputs = [
protobuf
pkg-config
clang
libclang.lib
];
buildInputs = [
openssl
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
Security
libiconv
Security
SystemConfiguration
];
outputs = [ "out" "fedimintCli" "fedimint" "gateway" "gatewayCli" "devimint" ];
postInstall = ''
mkdir -p $fedimint/bin $fedimintCli/bin $gateway/bin $gatewayCli/bin $devimint/bin
# delete fuzzing targets and other binaries no one cares about
binsToKeep=(fedimint-cli fedimint-dbtool recoverytool fedimintd gatewayd gateway-cli gateway-cln-extension devimint)
keepPattern=$(printf "|%s" "''${binsToKeep[@]}")
keepPattern=''${keepPattern:1}
find "$out/bin" -maxdepth 1 -type f | grep -Ev "(''${keepPattern})" | xargs rm -f
cp -a $releaseDir/fedimint-cli $fedimintCli/bin/
cp -a $releaseDir/fedimint-dbtool $fedimintCli/bin/
cp -a $releaseDir/fedimint-recoverytool $fedimintCli/bin/
cp -a $releaseDir/fedimintd $fedimint/bin/
cp -a $releaseDir/gateway-cli $gatewayCli/bin/
cp -a $releaseDir/gatewayd $gateway/bin/
cp -a $releaseDir/gateway-cln-extension $gateway/bin/
cp -a $releaseDir/devimint $devimint/bin/
'';
PROTOC = "${buildPackages.protobuf}/bin/protoc";
PROTOC_INCLUDE = "${protobuf}/include";
OPENSSL_DIR = openssl.dev;
LIBCLANG_PATH = "${libclang.lib}/lib";
FEDIMINT_BUILD_FORCE_GIT_HASH = "0000000000000000000000000000000000000000";
# currently broken, will require some upstream fixes
doCheck = false;
meta = {
description = "Federated E-Cash Mint";
homepage = "https://github.com/fedimint/fedimint";
license = [ lib.licenses.mit ];
maintainers = with lib.maintainers; [ dpc ];
mainProgram = "fedimint-cli";
};
}