nixpkgs/pkgs/by-name/gn/gnucap/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

74 lines
1.8 KiB
Nix

{ 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;
};
}