about summary refs log tree commit diff
path: root/pkgs/by-name/gn/gnucap/package.nix
blob: 2713a2283de6d61c701eac1bee96eac0e17a07ed (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
{ lib
, stdenv
, fetchurl
, readline
, termcap
, gnucap
, callPackage
, writeScript
}:

let
  version = "20240130-dev";
  meta = with lib; {
    description = "Gnu Circuit Analysis Package";
    longDescription = ''
Gnucap is a modern general purpose circuit simulator with several advantages over Spice derivatives.
It performs nonlinear dc and transient analyses, fourier analysis, and ac analysis.
    '';
    homepage = "http://www.gnucap.org/";
    changelog = "https://git.savannah.gnu.org/cgit/gnucap.git/plain/NEWS?h=v${version}";
    license = licenses.gpl3Plus;
    platforms = platforms.all;
    broken = stdenv.hostPlatform.isDarwin; # Relies on LD_LIBRARY_PATH
    maintainers = [ maintainers.raboof ];
    mainProgram = "gnucap";
  };
in
stdenv.mkDerivation rec {
  pname = "gnucap";
  inherit version;

  src = fetchurl {
    url = "https://git.savannah.gnu.org/cgit/gnucap.git/snapshot/gnucap-${version}.tar.gz";
    hash = "sha256-MUCtGw3BxGWgXgUwzklq5T1y9kjBTnFBa0/GK0hhl0E=";
  };

  buildInputs = [
    readline
    termcap
  ];

  doCheck = true;

  inherit meta;
} // {
  plugins = callPackage ./plugins.nix {};
  withPlugins = p:
    let
      selectedPlugins = p gnucap.plugins;
      wrapper = writeScript "gnucap" ''
        export GNUCAP_PLUGPATH=${gnucap}/lib/gnucap
        for plugin in ${builtins.concatStringsSep " " selectedPlugins}; do
          export GNUCAP_PLUGPATH=$plugin/lib/gnucap:$GNUCAP_PLUGPATH
        done
        ${lib.getExe gnucap}
      '';
    in
      stdenv.mkDerivation {
        pname = "gnucap-with-plugins";
        inherit version;

        propagatedBuildInputs = selectedPlugins;

        dontUnpack = true;

        installPhase = ''
          mkdir -p $out/bin
          cp ${wrapper} $out/bin/gnucap
        '';

        inherit meta;
      };
}