nixpkgs/pkgs/applications/science/chemistry/jmol/default.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

54 lines
1.4 KiB
Nix

{ stdenv
, lib
, fetchurl
, unzip
, makeDesktopItem
, jre
}:
let
desktopItem = makeDesktopItem {
name = "jmol";
exec = "jmol";
desktopName = "JMol";
genericName = "Molecular Modeler";
mimeType = "chemical/x-pdb;chemical/x-mdl-molfile;chemical/x-mol2;chemical/seq-aa-fasta;chemical/seq-na-fasta;chemical/x-xyz;chemical/x-mdl-sdf;";
categories = "Graphics;Education;Science;Chemistry;";
};
in
stdenv.mkDerivation rec {
version = "14.31.18";
pname = "jmol";
src = let
baseVersion = "${lib.versions.major version}.${lib.versions.minor version}";
in fetchurl {
url = "mirror://sourceforge/jmol/Jmol/Version%20${baseVersion}/Jmol%20${version}/Jmol-${version}-binary.tar.gz";
sha256 = "0hkc7c08azbw3k91ygwz6r5y4yw6k8l7h4gcq5p71knd5k1fa5jd";
};
patchPhase = ''
sed -i -e "4s:.*:command=${jre}/bin/java:" -e "10s:.*:jarpath=$out/share/jmol/Jmol.jar:" -e "11,21d" jmol
'';
installPhase = ''
mkdir -p "$out/share/jmol" "$out/bin"
${unzip}/bin/unzip jsmol.zip -d "$out/share/"
cp *.jar jmol.sh "$out/share/jmol"
cp -r ${desktopItem}/share/applications $out/share
cp jmol $out/bin
'';
enableParallelBuilding = true;
meta = with lib; {
description = "A Java 3D viewer for chemical structures";
homepage = "https://sourceforge.net/projects/jmol";
license = licenses.lgpl2;
platforms = platforms.all;
maintainers = with maintainers; [ mounium ] ++ teams.sage.members;
};
}