nixpkgs/pkgs/by-name/ds/dssat/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

75 lines
1.9 KiB
Nix

{
stdenv,
lib,
cmake,
glibc,
gfortran,
makeWrapper,
fetchFromGitHub,
fetchpatch,
dos2unix,
dataRepo ? fetchFromGitHub {
owner = "DSSAT";
repo = "dssat-csm-data";
rev = "v4.8.2.8";
hash = "sha256-hbSBKEvdSd1lfbemfp4Lk4/JcGMXGVjm1x7P7lmmuA0=";
},
}:
let
# Temporary patch to fix 80 chars limit on paths
# https://github.com/DSSAT/dssat-csm-os/pull/417/
charLimitPatch = fetchpatch {
url = "https://github.com/DSSAT/dssat-csm-os/pull/417/commits/9215012a297c074f392b5e7eb90b8c20495f13f7.patch";
hash = "sha256-WwJR5lnWtR3aYWZmk8pBC0/qaRqY0UrWHIaYp2ajImE=";
};
in
stdenv.mkDerivation (final: {
pname = "dssat";
version = "4.8.2.12";
src = fetchFromGitHub {
owner = "DSSAT";
repo = "dssat-csm-os";
rev = "refs/tags/v${final.version}";
hash = "sha256-8OaTM7IXFZjlelx5O4O+bVNQj4dIhGzIk2iCfpqI8uA=";
};
# maintainers are on windows and have CRLF endings in their files
# And github returns a patch file in unix format only.
patchPhase = ''
runHook prePatch
cp ${charLimitPatch} ./limit-path.patch
unix2dos ./limit-path.patch
patch --binary -p1 < ./limit-path.patch
runHook postPatch
'';
nativeBuildInputs = [
cmake
dos2unix
gfortran
makeWrapper
];
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ glibc.static ];
cmakeFlags = [ "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}/share/dssat/" ];
postInstall = ''
mkdir -p $out/share/dssat/Data
cp -r $src/Data/* $out/share/dssat/Data/
cp -r ${dataRepo}/* $out/share/dssat/Data/
makeWrapper $out/share/dssat/dscsm048 $out/bin/dscsm048
'';
meta = {
homepage = "https://github.com/DSSAT/dssat-csm-os";
description = "Cropping System Model";
mainProgram = "dscsm048";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ pcboy ];
platforms = lib.platforms.unix;
broken = stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux;
};
})