Commit 007e8903 authored by Sigmanificient's avatar Sigmanificient Committed by github-actions[bot]
Browse files

fasthenry: modernize

(cherry picked from commit afc5cef2)
parent cbe84849
Loading
Loading
Loading
Loading
+20 −38
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
  lib,
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "fasthenry";
  # later versions are Windows only ports
  # nixpkgs-update: no auto update
@@ -17,60 +17,42 @@ stdenv.mkDerivation rec {
  src = fetchFromGitHub {
    owner = "ediloren";
    repo = "FastHenry2";
    rev = "R${version}";
    sha256 = "017kcri69zhyhii59kxj1ak0gyfn7jf0qp6p2x3nnljia8njdkcc";
    tag = "R${finalAttrs.version}";
    hash = "sha256-jM0mLVJRUmtHF9dcDJw81vkHpgqyz1RihB7+ZGJm8wQ=";
  };

  dontConfigure = true;

  env.NIX_CFLAGS_COMPILE = toString [
    "-fcommon -O -DFOUR"
    (lib.optional stdenv.hostPlatform.isx86_64 "-m64")
    "-Wno-error=implicit-function-declaration"
    "-Wno-error=implicit-int"
    "-Wno-error=return-mismatch"
  ];


  preBuild =
    ''
      makeFlagsArray=(
        CC="gcc"
        RM="rm"
        SHELL="sh"
        "all"
      )
    ''
    + (
      if stdenv.hostPlatform.isx86_64 then
        ''
          makeFlagsArray+=(
            CFLAGS="-fcommon -O -DFOUR -m64"
          );
        ''
      else
        ''
            makeFlagsArray+=(
              CFLAGS="-fcommon -O -DFOUR"
          );
        ''
    );
  makeFlags = [ "all" ]; # need "all" to be explicitely set

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    cp -r bin/* $out/bin/
    mkdir -p $out/share/doc/${pname}-${version}
    cp -r doc/* $out/share/doc/${pname}-${version}
    mkdir -p $out/share/${pname}-${version}/examples
    cp -r examples/* $out/share/${pname}-${version}/examples
    mkdir -p $out/share/fasthenry/doc
    cp -r doc/* $out/share/fasthenry/doc
    mkdir -p $out/share/fasthenry/examples
    cp -r examples/* $out/share/fasthenry/examples

    runHook postInstall
  '';

  meta = with lib; {
  meta = {
    description = "Multipole-accelerated inductance analysis program";
    longDescription = ''
      Fasthenry is an inductance extraction program based on a
      multipole-accelerated algorithm.'';
    homepage = "https://www.fastfieldsolvers.com/fasthenry2.htm";
    license = licenses.lgpl2Only;
    maintainers = with maintainers; [ fbeffa ];
    platforms = intersectLists (platforms.linux) (platforms.x86_64 ++ platforms.x86);
    license = lib.licenses.lgpl2Only;
    maintainers = with lib.maintainers; [ fbeffa ];
    platforms = with lib.platforms; lib.intersectLists (linux) (x86_64 ++ x86);
    mainProgram = "fasthenry";
  };
}
})