about summary refs log tree commit diff
path: root/pkgs/development/libraries/physics/cernlib/default.nix
blob: 13d1cb08124950032e44eba0ca73dbc446e8face (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{
  lib,
  stdenv,
  fetchpatch,
  fetchurl,
  cmake,
  freetype,
  gfortran,
  openssl,
  libnsl,
  motif,
  xorg,
  libxcrypt,
}:

stdenv.mkDerivation rec {
  version = "2024.06.12.0";
  pname = "cernlib";
  year = lib.versions.major version;

  src = fetchurl {
    urls = [
      "https://ftp.riken.jp/cernlib/download/${year}_source/tar/cernlib-cernlib-${version}-free.tar.gz"
      "https://cernlib.web.cern.ch/download/${year}_source/tar/cernlib-cernlib-${version}-free.tar.gz"
    ];
    hash = "sha256-SEFgQjPBkmRoaMD/7yXiXO9DZNrRhqZ01kptSDQur84=";
  };

  patches = [
    (fetchpatch {
      url = "https://github.com/user-attachments/files/16832928/geant321-fix-weak-alias-on-darwin.patch";
      hash = "sha256-YzaUh4rJBszGdp5s/HDQMI5qQhCGrTt9P6XCgZOFn1I=";
    })
  ];

  postPatch = ''
    substituteInPlace CMakeLists.txt \
      --replace-fail "find_program ( SED NAMES gsed" "find_program ( SED NAMES sed"
  '';

  # gfortran warning's on iframework messes with CMake's check_fortran_compiler_flag
  # see also https://github.com/NixOS/nixpkgs/issues/27218
  preConfigure = ''
    export NIX_CFLAGS_COMPILE="$(echo $NIX_CFLAGS_COMPILE | sed 's|-iframework [^ ]*||g')"
  '';

  nativeBuildInputs = [ cmake ];
  buildInputs = with xorg; [
    freetype
    gfortran
    openssl
    libX11
    libXaw
    libXft
    libXt
    libxcrypt
    motif
  ] ++ lib.optional stdenv.isLinux libnsl;

  setupHook = ./setup-hook.sh;

  meta = {
    homepage = "http://cernlib.web.cern.ch";
    description = "Legacy collection of libraries and modules for data analysis in high energy physics";
    platforms = [
      "aarch64-linux"
      "i686-linux"
      "x86_64-linux"
      "x86_64-darwin"
    ];
    maintainers = with lib.maintainers; [ veprbl ];
    license = lib.licenses.gpl2;
  };
}