about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/science
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/applications/science')
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/astrolabe-generator/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/astrolog/default.nix64
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/celestia/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/gildas/aarch64.patch12
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/gildas/clang.patch22
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/gildas/default.nix70
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/gildas/wrapper.patch20
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/gpredict/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/gprojector/default.nix51
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/gravit/default.nix45
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/kstars/default.nix53
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/openspace/assets.patch100
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/openspace/config.patch49
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/openspace/constexpr.patch91
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/openspace/default.nix90
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/openspace/vrpn.patch13
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/phd2/default.nix48
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/siril/default.nix46
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/stellarium/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/xearth/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/xplanet/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/science/biology/EZminc/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/biology/MACS2/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/science/biology/N3/default.nix35
-rw-r--r--nixpkgs/pkgs/applications/science/biology/angsd/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/science/biology/ants/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/biology/aragorn/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/biology/bayescan/default.nix39
-rw-r--r--nixpkgs/pkgs/applications/science/biology/bcftools/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/science/biology/bedops/default.nix51
-rw-r--r--nixpkgs/pkgs/applications/science/biology/bedtools/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/biology/bftools/default.nix41
-rw-r--r--nixpkgs/pkgs/applications/science/biology/blast/default.nix109
-rw-r--r--nixpkgs/pkgs/applications/science/biology/blast/no_slash_bin.patch178
-rw-r--r--nixpkgs/pkgs/applications/science/biology/bowtie/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/science/biology/bowtie2/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/biology/bppsuite/default.nix21
-rw-r--r--nixpkgs/pkgs/applications/science/biology/bwa/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/science/biology/cd-hit/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/science/biology/clustal-omega/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/biology/cmtk/default.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/biology/conglomerate/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/biology/dcm2niix/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/biology/deeptools/default.nix42
-rw-r--r--nixpkgs/pkgs/applications/science/biology/delly/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/biology/diamond/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/science/biology/diamond/diamond-0.8.36-no-warning.patch20
-rw-r--r--nixpkgs/pkgs/applications/science/biology/ecopcr/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/science/biology/eggnog-mapper/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/biology/emboss/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/biology/est-sfs/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/biology/exonerate/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/science/biology/fastp/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/biology/febio-studio/default.nix61
-rw-r--r--nixpkgs/pkgs/applications/science/biology/febio-studio/febio-studio-cmake.patch38
-rw-r--r--nixpkgs/pkgs/applications/science/biology/freebayes/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/biology/genmap/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/biology/genmap/gtest.patch30
-rw-r--r--nixpkgs/pkgs/applications/science/biology/hisat2/default.nix46
-rw-r--r--nixpkgs/pkgs/applications/science/biology/hmmer/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/biology/igv/default.nix35
-rw-r--r--nixpkgs/pkgs/applications/science/biology/inormalize/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/biology/inormalize/lgmask-interp.patch10
-rw-r--r--nixpkgs/pkgs/applications/science/biology/inormalize/nu_correct_norm-interp.patch10
-rw-r--r--nixpkgs/pkgs/applications/science/biology/itsx/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/biology/iv/default.nix43
-rw-r--r--nixpkgs/pkgs/applications/science/biology/kallisto/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/biology/kent/default.nix75
-rw-r--r--nixpkgs/pkgs/applications/science/biology/kssd/default.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/biology/last/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/biology/macse/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/biology/manta/default.nix35
-rw-r--r--nixpkgs/pkgs/applications/science/biology/megahit/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/science/biology/meme-suite/default.nix21
-rw-r--r--nixpkgs/pkgs/applications/science/biology/messer-slim/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/biology/migrate/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/science/biology/minc-tools/default.nix36
-rw-r--r--nixpkgs/pkgs/applications/science/biology/minc-widgets/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/biology/minia/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/biology/minia/no-bundle.patch222
-rw-r--r--nixpkgs/pkgs/applications/science/biology/minimap2/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/biology/mni_autoreg/default.nix35
-rw-r--r--nixpkgs/pkgs/applications/science/biology/mosdepth/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/science/biology/mrbayes/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/biology/mrtrix/default.nix95
-rw-r--r--nixpkgs/pkgs/applications/science/biology/muscle/default.nix35
-rw-r--r--nixpkgs/pkgs/applications/science/biology/muscle/muscle-3.8.31-no-static.patch21
-rw-r--r--nixpkgs/pkgs/applications/science/biology/ncbi-tools/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/biology/neuron/default.nix88
-rw-r--r--nixpkgs/pkgs/applications/science/biology/neuron/neuron-carbon-disable.patch21
-rw-r--r--nixpkgs/pkgs/applications/science/biology/niftyreg/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/science/biology/niftyseg/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/science/biology/obitools/obitools3.nix35
-rw-r--r--nixpkgs/pkgs/applications/science/biology/octopus/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/biology/paml/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/biology/picard-tools/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/biology/platypus/default.nix39
-rw-r--r--nixpkgs/pkgs/applications/science/biology/plink-ng/default.nix39
-rwxr-xr-xnixpkgs/pkgs/applications/science/biology/poretools/default.nix22
-rw-r--r--nixpkgs/pkgs/applications/science/biology/prodigal/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/biology/quast/default.nix58
-rw-r--r--nixpkgs/pkgs/applications/science/biology/raxml/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/biology/repseek/default.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/biology/sambamba/default.nix39
-rw-r--r--nixpkgs/pkgs/applications/science/biology/samblaster/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/biology/samtools/default.nix43
-rw-r--r--nixpkgs/pkgs/applications/science/biology/samtools/samtools-0.1.19-no-curses.patch22
-rw-r--r--nixpkgs/pkgs/applications/science/biology/samtools/samtools_0_1_19.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/biology/seaview/default.nix41
-rw-r--r--nixpkgs/pkgs/applications/science/biology/snpeff/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/biology/somatic-sniper/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/biology/somatic-sniper/somatic-sniper.patch26
-rw-r--r--nixpkgs/pkgs/applications/science/biology/sortmerna/default.nix46
-rw-r--r--nixpkgs/pkgs/applications/science/biology/spades/default.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/biology/stacks/default.nix19
-rw-r--r--nixpkgs/pkgs/applications/science/biology/star/default.nix39
-rw-r--r--nixpkgs/pkgs/applications/science/biology/strelka/default.nix43
-rw-r--r--nixpkgs/pkgs/applications/science/biology/subread/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/biology/sumatools/default.nix68
-rw-r--r--nixpkgs/pkgs/applications/science/biology/svaba/default.nix42
-rw-r--r--nixpkgs/pkgs/applications/science/biology/tebreak/default.nix48
-rwxr-xr-xnixpkgs/pkgs/applications/science/biology/trimal/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/biology/truvari/default.nix52
-rw-r--r--nixpkgs/pkgs/applications/science/biology/varscan/default.nix37
-rwxr-xr-xnixpkgs/pkgs/applications/science/biology/vcftools/default.nix23
-rw-r--r--nixpkgs/pkgs/applications/science/biology/whisper/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/biology/xenomapper/default.nix23
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/avogadro/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/avogadro2/default.nix49
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/chemtool/default.nix51
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/cp2k/default.nix121
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/d-seams/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/dkh/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/element/default.nix22
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/ergoscf/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/ergoscf/math-constants.patch19
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/gwyddion/codegen.patch22
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/gwyddion/default.nix86
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/jmol/default.nix61
-rwxr-xr-xnixpkgs/pkgs/applications/science/chemistry/marvin/LicenseManager.desktop9
-rwxr-xr-xnixpkgs/pkgs/applications/science/chemistry/marvin/MarvinSketch.desktop10
-rwxr-xr-xnixpkgs/pkgs/applications/science/chemistry/marvin/MarvinView.desktop10
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/marvin/default.nix48
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/molden/default.nix43
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/molden/dont_register_file_types.patch29
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/octopus/default.nix75
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/openmolcas/default.nix89
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/openmolcas/openblasPath.patch12
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/pymol/default.nix75
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/quantum-espresso/default.nix53
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/siesta/default.nix75
-rw-r--r--nixpkgs/pkgs/applications/science/computer-architecture/qtrvsim/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/adms/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/alliance/default.nix58
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/appcsxcad/default.nix55
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/archimedes/default.nix18
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/bitscope/common.nix64
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/bitscope/packages.nix146
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/caneda/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/caneda/gcc6.patch13
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/csxcad/default.nix47
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/csxcad/searchPath.patch11
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/diylc/default.nix76
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/dsview/default.nix55
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/dsview/install.patch15
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/dsview/libsigrok4dsl.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/dsview/libsigrokdecode4dsl.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/dsview/qt515.patch13
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/dwfv/default.nix20
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/eagle/eagle.nix80
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/eagle/eagle7.nix97
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/eagle/eagle7_fixer.c134
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/flatcam/default.nix57
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/flatcam/release.patch13
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/fparser/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/fped/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/fritzing/default.nix84
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/gaw/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/geda/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/gerbv/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/gnucap/default.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/gtkwave/default.nix42
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/hal-hardware-analyzer/default.nix52
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/horizon-eda/default.nix75
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/hyp2mat/default.nix53
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/kicad/base.nix176
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/kicad/default.nix239
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/kicad/libraries.nix30
-rwxr-xr-xnixpkgs/pkgs/applications/science/electronics/kicad/update.sh189
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/kicad/versions.nix48
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/lepton-eda/default.nix61
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/librepcb/default.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/magic-vlsi/0001-strip-bin-prefix.patch10
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/magic-vlsi/0002-fix-format-security.patch19
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/magic-vlsi/default.nix60
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/nanovna-saver/default.nix65
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/ngspice/default.nix36
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/openems/default.nix70
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/openhantek6022/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/openroad/default.nix94
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/pcb/default.nix65
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/picoscope/default.nix137
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/picoscope/sources.json69
-rwxr-xr-xnixpkgs/pkgs/applications/science/electronics/picoscope/update.py44
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/pulseview/default.nix39
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/qfsm/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/qfsm/drop-hardcoded-prefix.patch20
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/qfsm/gcc6-fixes.patch20
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/qucs-s/default.nix42
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/qucs/cmakelists.patch34
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/qucs/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/tkgate/1.x.nix42
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/verilator/default.nix42
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/verilog/default.nix70
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/vhd2vl/default.nix52
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/xcircuit/default.nix35
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/xoscope/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/xschem/default.nix46
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/xyce/default.nix182
-rw-r--r--nixpkgs/pkgs/applications/science/geometry/antiprism/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/geometry/drgeo/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/geometry/drgeo/struct.patch68
-rw-r--r--nixpkgs/pkgs/applications/science/geometry/gama/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/science/geometry/tetgen/1.4.nix23
-rw-r--r--nixpkgs/pkgs/applications/science/geometry/tetgen/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/logic/abc/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/logic/abella/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/science/logic/acgtk/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/logic/aiger/default.nix55
-rw-r--r--nixpkgs/pkgs/applications/science/logic/alt-ergo/default.nix49
-rw-r--r--nixpkgs/pkgs/applications/science/logic/anders/default.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/logic/aspino/default.nix51
-rw-r--r--nixpkgs/pkgs/applications/science/logic/avy/default.nix50
-rw-r--r--nixpkgs/pkgs/applications/science/logic/avy/glucose-fenv.patch65
-rw-r--r--nixpkgs/pkgs/applications/science/logic/avy/minisat-fenv.patch65
-rw-r--r--nixpkgs/pkgs/applications/science/logic/beluga/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/logic/bitwuzla/default.nix67
-rw-r--r--nixpkgs/pkgs/applications/science/logic/boolector/cmake-gtest.patch16
-rw-r--r--nixpkgs/pkgs/applications/science/logic/boolector/default.nix70
-rw-r--r--nixpkgs/pkgs/applications/science/logic/btor2tools/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/logic/cadical/default.nix48
-rw-r--r--nixpkgs/pkgs/applications/science/logic/cedille/Fix-to-string.agda-to-compile-with-Agda-2.6.1.patch31
-rw-r--r--nixpkgs/pkgs/applications/science/logic/cedille/default.nix61
-rw-r--r--nixpkgs/pkgs/applications/science/logic/celf/default.nix36
-rw-r--r--nixpkgs/pkgs/applications/science/logic/clprover/clprover.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/logic/coq/default.nix212
-rw-r--r--nixpkgs/pkgs/applications/science/logic/cryptominisat/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/logic/cryptoverif/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/logic/cubicle/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/science/logic/cvc3/cvc3-2.4.1-gccv6-fix.patch76
-rw-r--r--nixpkgs/pkgs/applications/science/logic/cvc3/default.nix39
-rw-r--r--nixpkgs/pkgs/applications/science/logic/cvc4/default.nix45
-rw-r--r--nixpkgs/pkgs/applications/science/logic/cvc4/minisat-fenv.patch65
-rw-r--r--nixpkgs/pkgs/applications/science/logic/drat-trim/default.nix45
-rw-r--r--nixpkgs/pkgs/applications/science/logic/ekrhyper/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/logic/elan/0001-dynamically-patchelf-binaries.patch35
-rw-r--r--nixpkgs/pkgs/applications/science/logic/elan/default.nix65
-rw-r--r--nixpkgs/pkgs/applications/science/logic/eprover/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/logic/fast-downward/default.nix60
-rw-r--r--nixpkgs/pkgs/applications/science/logic/formula/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/logic/formula/nuget.nix77
-rw-r--r--nixpkgs/pkgs/applications/science/logic/gappa/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/science/logic/glucose/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/logic/glucose/syrup.nix24
-rw-r--r--nixpkgs/pkgs/applications/science/logic/hol/default.nix87
-rw-r--r--nixpkgs/pkgs/applications/science/logic/hol_light/default.nix58
-rw-r--r--nixpkgs/pkgs/applications/science/logic/iprover/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/logic/isabelle/default.nix155
-rw-r--r--nixpkgs/pkgs/applications/science/logic/jonprl/default.nix35
-rw-r--r--nixpkgs/pkgs/applications/science/logic/key/default.nix121
-rw-r--r--nixpkgs/pkgs/applications/science/logic/kissat/default.nix54
-rw-r--r--nixpkgs/pkgs/applications/science/logic/kissat/writable-passwd-is-ok.patch13
-rw-r--r--nixpkgs/pkgs/applications/science/logic/klee/default.nix110
-rw-r--r--nixpkgs/pkgs/applications/science/logic/lci/default.nix16
-rw-r--r--nixpkgs/pkgs/applications/science/logic/lean/default.nix50
-rw-r--r--nixpkgs/pkgs/applications/science/logic/lean2/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/logic/leo2/default.nix49
-rw-r--r--nixpkgs/pkgs/applications/science/logic/leo3/binary.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/logic/lingeling/default.nix48
-rw-r--r--nixpkgs/pkgs/applications/science/logic/logisim-evolution/default.nix49
-rw-r--r--nixpkgs/pkgs/applications/science/logic/logisim/default.nix50
-rw-r--r--nixpkgs/pkgs/applications/science/logic/ltl2ba/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/logic/mcrl2/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/logic/mcy/default.nix51
-rw-r--r--nixpkgs/pkgs/applications/science/logic/metis-prover/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/logic/minisat/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/science/logic/monosat/default.nix89
-rw-r--r--nixpkgs/pkgs/applications/science/logic/open-wbo/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/logic/opensmt/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/science/logic/ott/default.nix45
-rw-r--r--nixpkgs/pkgs/applications/science/logic/otter/default.nix53
-rw-r--r--nixpkgs/pkgs/applications/science/logic/petrinizer/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/logic/picosat/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/science/logic/poly/default.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/logic/potassco/clingcon.nix36
-rw-r--r--nixpkgs/pkgs/applications/science/logic/potassco/clingo.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/logic/prooftree/default.nix43
-rw-r--r--nixpkgs/pkgs/applications/science/logic/prover9/default.nix46
-rw-r--r--nixpkgs/pkgs/applications/science/logic/proverif/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/logic/redprl/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/logic/sad/default.nix41
-rw-r--r--nixpkgs/pkgs/applications/science/logic/sad/monoid.patch51
-rw-r--r--nixpkgs/pkgs/applications/science/logic/sad/patch.patch200
-rw-r--r--nixpkgs/pkgs/applications/science/logic/satallax/default.nix70
-rw-r--r--nixpkgs/pkgs/applications/science/logic/satallax/fix-declaration-gcc9.patch21
-rw-r--r--nixpkgs/pkgs/applications/science/logic/saw-tools/default.nix58
-rw-r--r--nixpkgs/pkgs/applications/science/logic/spass/default.nix42
-rw-r--r--nixpkgs/pkgs/applications/science/logic/statverif/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/logic/stp/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/logic/symbiyosys/default.nix61
-rw-r--r--nixpkgs/pkgs/applications/science/logic/tamarin-prover/default.nix97
-rw-r--r--nixpkgs/pkgs/applications/science/logic/tlaplus/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/logic/tlaplus/tlaps.nix58
-rw-r--r--nixpkgs/pkgs/applications/science/logic/tlaplus/toolbox.nix100
-rw-r--r--nixpkgs/pkgs/applications/science/logic/tptp/default.nix49
-rw-r--r--nixpkgs/pkgs/applications/science/logic/twelf/default.nix51
-rw-r--r--nixpkgs/pkgs/applications/science/logic/vampire/default.nix56
-rw-r--r--nixpkgs/pkgs/applications/science/logic/verifast/default.nix50
-rw-r--r--nixpkgs/pkgs/applications/science/logic/verit/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/logic/why3/default.nix46
-rw-r--r--nixpkgs/pkgs/applications/science/logic/why3/with-provers.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/logic/workcraft/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/logic/yices/default.nix39
-rw-r--r--nixpkgs/pkgs/applications/science/logic/yices/linux-no-ldconfig.patch13
-rw-r--r--nixpkgs/pkgs/applications/science/logic/z3/4.4.0.nix41
-rw-r--r--nixpkgs/pkgs/applications/science/logic/z3/default.nix95
-rw-r--r--nixpkgs/pkgs/applications/science/logic/z3/tptp.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/machine-learning/fasttext/default.nix23
-rw-r--r--nixpkgs/pkgs/applications/science/machine-learning/finalfrontier/default.nix51
-rw-r--r--nixpkgs/pkgs/applications/science/machine-learning/finalfusion-utils/default.nix54
-rw-r--r--nixpkgs/pkgs/applications/science/machine-learning/labelimg/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/machine-learning/nengo-gui/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/machine-learning/sc2-headless/default.nix61
-rw-r--r--nixpkgs/pkgs/applications/science/machine-learning/sc2-headless/maps.nix63
-rw-r--r--nixpkgs/pkgs/applications/science/machine-learning/shogun/default.nix192
-rw-r--r--nixpkgs/pkgs/applications/science/machine-learning/shogun/eigen-3.4.patch74
-rw-r--r--nixpkgs/pkgs/applications/science/machine-learning/shogun/svmlight-scrubber.patch76
-rw-r--r--nixpkgs/pkgs/applications/science/machine-learning/starspace/default.nix37
-rwxr-xr-xnixpkgs/pkgs/applications/science/machine-learning/streamlit/default.nix89
-rw-r--r--nixpkgs/pkgs/applications/science/machine-learning/vowpal-wabbit/default.nix53
-rw-r--r--nixpkgs/pkgs/applications/science/math/4ti2/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/science/math/LiE/default.nix47
-rw-r--r--nixpkgs/pkgs/applications/science/math/R/default.nix132
-rw-r--r--nixpkgs/pkgs/applications/science/math/R/no-usr-local-search-paths.patch24
-rw-r--r--nixpkgs/pkgs/applications/science/math/R/setup-hook.sh7
-rw-r--r--nixpkgs/pkgs/applications/science/math/almonds/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/math/bcal/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/math/bliss/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/math/caffe/darwin.patch47
-rw-r--r--nixpkgs/pkgs/applications/science/math/caffe/default.nix144
-rw-r--r--nixpkgs/pkgs/applications/science/math/caffe/python.patch70
-rw-r--r--nixpkgs/pkgs/applications/science/math/calc/default.nix51
-rw-r--r--nixpkgs/pkgs/applications/science/math/calculix/calculix.patch22
-rw-r--r--nixpkgs/pkgs/applications/science/math/calculix/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/math/cbc/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/math/cemu/default.nix57
-rw-r--r--nixpkgs/pkgs/applications/science/math/clp/default.nix22
-rw-r--r--nixpkgs/pkgs/applications/science/math/cntk/default.nix127
-rw-r--r--nixpkgs/pkgs/applications/science/math/colpack/default.nix43
-rw-r--r--nixpkgs/pkgs/applications/science/math/cplex/default.nix87
-rw-r--r--nixpkgs/pkgs/applications/science/math/csdp/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/math/dap/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/math/ecm/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/math/engauge-digitizer/default.nix60
-rw-r--r--nixpkgs/pkgs/applications/science/math/eukleides/default.nix67
-rw-r--r--nixpkgs/pkgs/applications/science/math/eukleides/gs-allowpstransparency.patch10
-rw-r--r--nixpkgs/pkgs/applications/science/math/eukleides/use-CC.patch11
-rw-r--r--nixpkgs/pkgs/applications/science/math/form/default.nix22
-rw-r--r--nixpkgs/pkgs/applications/science/math/fricas/default.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/math/gap/default.nix159
-rw-r--r--nixpkgs/pkgs/applications/science/math/geogebra/default.nix92
-rw-r--r--nixpkgs/pkgs/applications/science/math/geogebra/geogebra6.nix73
-rw-r--r--nixpkgs/pkgs/applications/science/math/getdp/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/math/gfan/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/math/gfan/gfan-0.6.2-cddlib-prefix.patch55
-rw-r--r--nixpkgs/pkgs/applications/science/math/giac/default.nix120
-rw-r--r--nixpkgs/pkgs/applications/science/math/ginac/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/math/glsurf/default.nix67
-rw-r--r--nixpkgs/pkgs/applications/science/math/gmsh/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/math/gretl/default.nix43
-rw-r--r--nixpkgs/pkgs/applications/science/math/gurobi/default.nix53
-rw-r--r--nixpkgs/pkgs/applications/science/math/hmetis/default.nix42
-rw-r--r--nixpkgs/pkgs/applications/science/math/jags/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/science/math/lp_solve/default.nix52
-rw-r--r--nixpkgs/pkgs/applications/science/math/lrcalc/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/math/mathematica/10.nix136
-rw-r--r--nixpkgs/pkgs/applications/science/math/mathematica/11.nix150
-rw-r--r--nixpkgs/pkgs/applications/science/math/mathematica/9.nix123
-rw-r--r--nixpkgs/pkgs/applications/science/math/mathematica/default.nix178
-rw-r--r--nixpkgs/pkgs/applications/science/math/mathematica/l10ns.nix106
-rw-r--r--nixpkgs/pkgs/applications/science/math/maxima/default.nix124
-rw-r--r--nixpkgs/pkgs/applications/science/math/msieve/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/math/mxnet/default.nix70
-rw-r--r--nixpkgs/pkgs/applications/science/math/nasc/default.nix88
-rw-r--r--nixpkgs/pkgs/applications/science/math/nauty/default.nix43
-rw-r--r--nixpkgs/pkgs/applications/science/math/nota/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/math/numworks-epsilon/0001-ion-linux-makerules.patch12
-rw-r--r--nixpkgs/pkgs/applications/science/math/numworks-epsilon/default.nix63
-rw-r--r--nixpkgs/pkgs/applications/science/math/palp/default.nix91
-rw-r--r--nixpkgs/pkgs/applications/science/math/pari/default.nix86
-rw-r--r--nixpkgs/pkgs/applications/science/math/pari/gp2c.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/math/pcalc/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/math/perseus/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/math/polymake/default.nix51
-rw-r--r--nixpkgs/pkgs/applications/science/math/programmer-calculator/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/math/pspp/default.nix53
-rw-r--r--nixpkgs/pkgs/applications/science/math/pynac/default.nix60
-rw-r--r--nixpkgs/pkgs/applications/science/math/qalculate-gtk/default.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/math/ratpoints/default.nix35
-rw-r--r--nixpkgs/pkgs/applications/science/math/ries/default.nix22
-rw-r--r--nixpkgs/pkgs/applications/science/math/ripser/default.nix67
-rw-r--r--nixpkgs/pkgs/applications/science/math/rofi-calc/0001-Patch-plugindir-to-output.patch25
-rw-r--r--nixpkgs/pkgs/applications/science/math/rofi-calc/default.nix54
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/README.md78
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/default.nix172
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/dist-tests.nix17
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/env-locations.nix48
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/Only-test-external-software-when-all-of-sage-is.patch46
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/configurationpy-error-verbose.patch19
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/do-not-test-find-library.patch87
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/fix-ecl-race.patch19
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/linbox-1.7-upgrade.patch58
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/no-cython-sources-in-tracebacks-on-ipython8.patch52
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/sphinx-docbuild-subprocesses.patch58
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/sympow-cache.patch21
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/tachyon-renamed-focallength.patch81
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/python-modules/sage-setup.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/sage-env.nix192
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/sage-src.nix191
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/sage-tests.nix61
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/sage-with-env.nix139
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/sage.nix70
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/sagedoc.nix88
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/sagelib.nix204
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/threejs-sage.nix19
-rw-r--r--nixpkgs/pkgs/applications/science/math/scilab-bin/default.nix102
-rw-r--r--nixpkgs/pkgs/applications/science/math/scilab/default.nix67
-rw-r--r--nixpkgs/pkgs/applications/science/math/scotch/default.nix36
-rw-r--r--nixpkgs/pkgs/applications/science/math/singular/default.nix172
-rw-r--r--nixpkgs/pkgs/applications/science/math/speedcrunch/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/math/symmetrica/default.nix36
-rw-r--r--nixpkgs/pkgs/applications/science/math/weka/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/math/wxmaxima/default.nix47
-rw-r--r--nixpkgs/pkgs/applications/science/math/yacas/default.nix86
-rw-r--r--nixpkgs/pkgs/applications/science/math/yacas/fix-test-script.patch26
-rw-r--r--nixpkgs/pkgs/applications/science/math/yacas/jsoncpp-fix-include.patch63
-rw-r--r--nixpkgs/pkgs/applications/science/math/zegrapher/default.nix36
-rw-r--r--nixpkgs/pkgs/applications/science/medicine/aliza/default.nix59
-rw-r--r--nixpkgs/pkgs/applications/science/medicine/dcmtk/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/medicine/xmedcon/default.nix36
-rw-r--r--nixpkgs/pkgs/applications/science/misc/bada-bib/default.nix78
-rw-r--r--nixpkgs/pkgs/applications/science/misc/boinc/default.nix51
-rw-r--r--nixpkgs/pkgs/applications/science/misc/colmap/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/misc/convertall/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/misc/cwltool/default.nix76
-rw-r--r--nixpkgs/pkgs/applications/science/misc/cytoscape/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/science/misc/cytoscape/gen_vmoptions_to_homedir.patch19
-rw-r--r--nixpkgs/pkgs/applications/science/misc/fityk/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/misc/foldingathome/client.nix59
-rw-r--r--nixpkgs/pkgs/applications/science/misc/foldingathome/control.nix58
-rw-r--r--nixpkgs/pkgs/applications/science/misc/foldingathome/viewer.nix55
-rw-r--r--nixpkgs/pkgs/applications/science/misc/gephi/default.nix65
-rw-r--r--nixpkgs/pkgs/applications/science/misc/golly/beta.nix50
-rw-r--r--nixpkgs/pkgs/applications/science/misc/golly/default.nix54
-rw-r--r--nixpkgs/pkgs/applications/science/misc/gplates/default.nix71
-rw-r--r--nixpkgs/pkgs/applications/science/misc/graphia/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/misc/megam/default.nix47
-rw-r--r--nixpkgs/pkgs/applications/science/misc/megam/ocaml-3.12.patch12
-rw-r--r--nixpkgs/pkgs/applications/science/misc/megam/ocaml-includes.patch21
-rw-r--r--nixpkgs/pkgs/applications/science/misc/netlogo/default.nix58
-rw-r--r--nixpkgs/pkgs/applications/science/misc/nextinspace/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/combined/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/default.nix17
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/mkderivation/default.nix101
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/mkderivation/src-main.nix7
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/omcompiler/default.nix63
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/omedit/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/omlibrary/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/omlibrary/fakegit.nix49
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/omlibrary/src-libs.nix81
-rwxr-xr-xnixpkgs/pkgs/applications/science/misc/openmodelica/omlibrary/update-src-libs.sh39
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/omparser/Makefile.in.patch22
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/omparser/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/omplot/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/omshell/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/omsimulator/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmvg/default.nix49
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmvs/default.nix77
-rw-r--r--nixpkgs/pkgs/applications/science/misc/rink/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/misc/root/5.nix143
-rw-r--r--nixpkgs/pkgs/applications/science/misc/root/default.nix192
-rw-r--r--nixpkgs/pkgs/applications/science/misc/root/disable_libc_dicts_root5.patch27
-rw-r--r--nixpkgs/pkgs/applications/science/misc/root/purify_include_paths_root5.patch204
-rw-r--r--nixpkgs/pkgs/applications/science/misc/root/setup-hook.sh13
-rw-r--r--nixpkgs/pkgs/applications/science/misc/root/sw_vers.patch87
-rw-r--r--nixpkgs/pkgs/applications/science/misc/root/sw_vers_root5.patch104
-rw-r--r--nixpkgs/pkgs/applications/science/misc/sasview/default.nix62
-rw-r--r--nixpkgs/pkgs/applications/science/misc/sasview/xhtml2pdf.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/misc/simgrid/default.nix120
-rw-r--r--nixpkgs/pkgs/applications/science/misc/snakemake/default.nix71
-rw-r--r--nixpkgs/pkgs/applications/science/misc/toil/default.nix46
-rw-r--r--nixpkgs/pkgs/applications/science/misc/tulip/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/misc/vite/default.nix46
-rw-r--r--nixpkgs/pkgs/applications/science/molecular-dynamics/dl-poly-classic/default.nix39
-rw-r--r--nixpkgs/pkgs/applications/science/molecular-dynamics/gromacs/default.nix92
-rw-r--r--nixpkgs/pkgs/applications/science/molecular-dynamics/lammps/default.nix67
-rw-r--r--nixpkgs/pkgs/applications/science/molecular-dynamics/viennarna/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/networking/sumo/default.nix68
-rw-r--r--nixpkgs/pkgs/applications/science/physics/MCFM/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/physics/elmerfem/default.nix43
-rw-r--r--nixpkgs/pkgs/applications/science/physics/professor/default.nix41
-rw-r--r--nixpkgs/pkgs/applications/science/physics/quantomatic/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/physics/sacrifice/compat.patch12
-rw-r--r--nixpkgs/pkgs/applications/science/physics/sacrifice/default.nix48
-rw-r--r--nixpkgs/pkgs/applications/science/physics/sacrifice/pythia83xx.patch55
-rw-r--r--nixpkgs/pkgs/applications/science/physics/sherpa/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/science/physics/shtns/default.nix22
-rw-r--r--nixpkgs/pkgs/applications/science/physics/xfitter/default.nix58
-rw-r--r--nixpkgs/pkgs/applications/science/physics/xfitter/undefined_behavior.patch454
-rw-r--r--nixpkgs/pkgs/applications/science/physics/xflr5/default.nix21
-rw-r--r--nixpkgs/pkgs/applications/science/programming/fdr/default.nix69
-rw-r--r--nixpkgs/pkgs/applications/science/programming/groove/default.nix54
-rw-r--r--nixpkgs/pkgs/applications/science/programming/plm/default.nix39
-rw-r--r--nixpkgs/pkgs/applications/science/robotics/apmplanner2/default.nix43
-rw-r--r--nixpkgs/pkgs/applications/science/robotics/betaflight-configurator/default.nix49
-rw-r--r--nixpkgs/pkgs/applications/science/robotics/emuflight-configurator/default.nix50
-rw-r--r--nixpkgs/pkgs/applications/science/robotics/inav-configurator/default.nix57
-rw-r--r--nixpkgs/pkgs/applications/science/robotics/mavproxy/default.nix36
-rw-r--r--nixpkgs/pkgs/applications/science/robotics/mission-planner/default.nix59
-rw-r--r--nixpkgs/pkgs/applications/science/robotics/qgroundcontrol/default.nix78
-rw-r--r--nixpkgs/pkgs/applications/science/robotics/sumorobot-manager/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/science/robotics/yarp/default.nix36
533 files changed, 27632 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/science/astronomy/astrolabe-generator/default.nix b/nixpkgs/pkgs/applications/science/astronomy/astrolabe-generator/default.nix
new file mode 100644
index 000000000000..3802f2bada86
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/astrolabe-generator/default.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchurl, jre, makeWrapper, unzip }:
+
+stdenv.mkDerivation rec {
+  pname = "astrolabe-generator";
+  version = "3.3";
+
+  src = fetchurl {
+    url = "https://github.com/wymarc/astrolabe-generator/releases/download/v${version}/AstrolabeGenerator-${version}.zip";
+    sha256 = "141gfmrqa1mf2qas87qig4phym9fg9gbrcfl2idzd5gi91824dn9";
+  };
+
+  buildInputs = [ jre ];
+  nativeBuildInputs = [ makeWrapper unzip ];
+  sourceRoot = ".";
+
+  installPhase = ''
+    mkdir -p $out/{bin,share/java}
+    cp AstrolabeGenerator-${version}.jar $out/share/java
+
+    makeWrapper ${jre}/bin/java $out/bin/AstrolabeGenerator \
+      --add-flags "-jar $out/share/java/AstrolabeGenerator-${version}.jar"
+  '';
+
+  meta = with lib;{
+    homepage = "https://www.astrolabeproject.com";
+    description = "A Java-based tool for generating EPS files for constructing astrolabes and related tools";
+    license = licenses.gpl3;
+    maintainers = [ ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/astronomy/astrolog/default.nix b/nixpkgs/pkgs/applications/science/astronomy/astrolog/default.nix
new file mode 100644
index 000000000000..26d0639ae67f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/astrolog/default.nix
@@ -0,0 +1,64 @@
+{ lib, stdenv, fetchzip, fetchurl, xorg
+, withBigAtlas ? true
+, withEphemeris ? true
+, withMoonsEphemeris ? true
+}:
+stdenv.mkDerivation rec {
+  pname = "astrolog";
+  version = "7.30";
+
+  src = fetchzip {
+    url = "http://www.astrolog.org/ftp/ast73src.zip";
+    sha256 = "0nry4gxwy5aa99zzr8dlb6babpachsc3jjyk0vw82c7x3clbhl7l";
+    stripRoot = false;
+  };
+
+  patchPhase = ''
+    sed -i "s:~/astrolog:$out/astrolog:g" astrolog.h
+    substituteInPlace Makefile --replace cc "$CC" --replace strip "$STRIP"
+  '';
+
+  buildInputs = [ xorg.libX11 ];
+  NIX_CFLAGS_COMPILE = "-Wno-format-security";
+
+  installPhase =
+  let
+    ephemeris = fetchzip {
+      url = "http://astrolog.org/ftp/ephem/astephem.zip";
+      sha256 = "1mwvpvfk3lxjcc79zvwl4ypqzgqzipnc01cjldxrmx56xkc35zn7";
+      stripRoot = false;
+    };
+    moonsEphemeris = fetchzip {
+      url = "https://www.astrolog.org/ftp/ephem/moons/sepm.zip";
+      sha256 = "0labcidm8mrwvww93nwpp5738m9ff9q48cqzbgd18xny1jf6f8xd";
+      stripRoot = false;
+    };
+    atlas = fetchurl {
+      url = "http://astrolog.org/ftp/atlas/atlasbig.as";
+      sha256 = "001bmqyldsbk4bdliqfl4a9ydrh1ff13wccvfniwaxlmvkridx2q";
+    };
+  in ''
+    mkdir -p $out/bin $out/astrolog
+    cp *.as $out/astrolog
+    install astrolog $out/bin
+    ${lib.optionalString withBigAtlas "cp ${atlas} $out/astrolog/atlas.as"}
+    ${lib.optionalString withEphemeris ''
+      sed -i "/-Yi1/s#\".*\"#\"$out/ephemeris\"#" $out/astrolog/astrolog.as
+      mkdir -p $out/ephemeris
+      cp -r ${ephemeris}/*.se1 $out/ephemeris
+    ''}
+    ${lib.optionalString withMoonsEphemeris ''
+      sed -i "/-Yi1/s#\".*\"#\"$out/ephemeris\"#" $out/astrolog/astrolog.as
+      mkdir -p $out/ephemeris
+      cp -r ${moonsEphemeris}/*.se1 $out/ephemeris
+    ''}
+  '';
+
+  meta = with lib; {
+    maintainers = [ maintainers.kmein ];
+    homepage = "https://astrolog.org/astrolog.htm";
+    description = "Freeware astrology program";
+    platforms = platforms.linux;
+    license = licenses.gpl2Plus;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/astronomy/celestia/default.nix b/nixpkgs/pkgs/applications/science/astronomy/celestia/default.nix
new file mode 100644
index 000000000000..3f21987661cf
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/celestia/default.nix
@@ -0,0 +1,37 @@
+{ lib, stdenv, fetchFromGitHub, pkg-config, freeglut, gtk2, gtkglext
+, libjpeg_turbo, libtheora, libXmu, lua, libGLU, libGL, perl, autoreconfHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "celestia";
+  version = "1.6.2.2";
+
+  src = fetchFromGitHub {
+    owner = "CelestiaProject";
+    repo = "Celestia";
+    rev = version;
+    sha256 = "1s9fgxh6i3x1sy75y5wcidi2mjrf5xj71dd4n6rg0hkps441sgsp";
+  };
+
+  nativeBuildInputs = [ pkg-config autoreconfHook ];
+  buildInputs = [
+    freeglut gtk2 gtkglext lua perl
+    libjpeg_turbo libtheora libXmu libGLU libGL
+  ];
+
+  configureFlags = [
+    "--with-gtk"
+    "--with-lua=${lua}"
+  ];
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    homepage = "https://celestia.space/";
+    description = "Real-time 3D simulation of space";
+    changelog = "https://github.com/CelestiaProject/Celestia/releases/tag/${version}";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ hjones2199 ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/astronomy/gildas/aarch64.patch b/nixpkgs/pkgs/applications/science/astronomy/gildas/aarch64.patch
new file mode 100644
index 000000000000..40696a03dec7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/gildas/aarch64.patch
@@ -0,0 +1,12 @@
+diff -ruN gildas-src-jul18a/admin/define-system.sh gildas-src-jul18a.aarch64/admin/define-system.sh
+--- gildas-src-jul18a/admin/define-system.sh	2018-06-12 15:22:32.000000000 +0200
++++ gildas-src-jul18a.aarch64/admin/define-system.sh	2018-07-21 13:05:52.000000000 +0200
+@@ -174,7 +174,7 @@
+     DEFAULT_CONFIG=          # Default config is empty
+     case `uname` in
+         Linux)
+-            if [ `uname -m | grep -c "x86_64"` -ne 0 ]; then
++            if [ `uname -m | grep -c "64"` -ne 0 ]; then
+         	GAG_MACHINE=x86_64
+             else
+         	GAG_MACHINE=pc
diff --git a/nixpkgs/pkgs/applications/science/astronomy/gildas/clang.patch b/nixpkgs/pkgs/applications/science/astronomy/gildas/clang.patch
new file mode 100644
index 000000000000..4d6654a99aee
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/gildas/clang.patch
@@ -0,0 +1,22 @@
+diff -ruN gildas-src-jun18a/admin/define-system.sh gildas-src-jun18a.clang/admin/define-system.sh
+--- gildas-src-jun18a/admin/define-system.sh	2018-03-12 11:07:57.000000000 +0100
++++ gildas-src-jun18a.clang/admin/define-system.sh	2018-06-12 14:56:14.000000000 +0200
+@@ -218,13 +218,13 @@
+         	else
+         	    GAG_MACHINE=pc
+         	fi
+-                if which gcc > /dev/null 2>&1; then
+-                    DEFAULT_CCOMPILER=gcc
++                if which clang > /dev/null 2>&1; then
++                    DEFAULT_CCOMPILER=clang
+                 fi
+-                if which g++ > /dev/null 2>&1; then
+-                    DEFAULT_CXXCOMPILER=g++
+-                elif which clang++ > /dev/null 2>&1; then
++                if which clang++ > /dev/null 2>&1; then
+                     DEFAULT_CXXCOMPILER=clang++
++                elif which g++ > /dev/null 2>&1; then
++                    DEFAULT_CXXCOMPILER=g++
+                 fi
+         	if which ifort > /dev/null 2>&1; then
+         	    DEFAULT_FCOMPILER=ifort
diff --git a/nixpkgs/pkgs/applications/science/astronomy/gildas/default.nix b/nixpkgs/pkgs/applications/science/astronomy/gildas/default.nix
new file mode 100644
index 000000000000..beb3bd92ea5e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/gildas/default.nix
@@ -0,0 +1,70 @@
+{ lib, stdenv, fetchurl, gtk2-x11 , pkg-config , python3 , gfortran , lesstif
+, cfitsio , getopt , perl , groff , which, darwin, ncurses
+}:
+
+let
+  python3Env = python3.withPackages(ps: with ps; [ numpy ]);
+in
+
+stdenv.mkDerivation rec {
+  srcVersion = "nov21a";
+  version = "20211101_a";
+  pname = "gildas";
+
+  src = fetchurl {
+    # For each new release, the upstream developers of Gildas move the
+    # source code of the previous release to a different directory
+    urls = [ "http://www.iram.fr/~gildas/dist/gildas-src-${srcVersion}.tar.xz"
+      "http://www.iram.fr/~gildas/dist/archive/gildas/gildas-src-${srcVersion}.tar.xz" ];
+    sha256 = "0fb6iqwh4hm7v7sib7sx98vxdavn3d6q2gq6y6vxg2z29g31f8g2";
+  };
+
+  nativeBuildInputs = [ pkg-config groff perl getopt gfortran which ];
+
+  buildInputs = [ gtk2-x11 lesstif cfitsio python3Env ncurses ]
+    ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ CoreFoundation ]);
+
+  patches = [ ./wrapper.patch ./clang.patch ./aarch64.patch ];
+
+  NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-unused-command-line-argument";
+
+  NIX_LDFLAGS = lib.optionalString stdenv.isDarwin (with darwin.apple_sdk.frameworks; "-F${CoreFoundation}/Library/Frameworks");
+
+  configurePhase=''
+    substituteInPlace admin/wrapper.sh --replace '%%OUT%%' $out
+    substituteInPlace admin/wrapper.sh --replace '%%PYTHONHOME%%' ${python3Env}
+    substituteInPlace utilities/main/gag-makedepend.pl --replace '/usr/bin/perl' ${perl}/bin/perl
+    source admin/gildas-env.sh -c gfortran -o openmp
+    echo "gag_doc:        $out/share/doc/" >> kernel/etc/gag.dico.lcl
+  '';
+
+  postInstall=''
+    mkdir -p $out/bin
+    cp -a ../gildas-exe-${srcVersion}/* $out
+    mv $out/$GAG_EXEC_SYSTEM $out/libexec
+    cp admin/wrapper.sh $out/bin/gildas-wrapper.sh
+    chmod 755 $out/bin/gildas-wrapper.sh
+    for i in $out/libexec/bin/* ; do
+      ln -s $out/bin/gildas-wrapper.sh $out/bin/$(basename "$i")
+    done
+  '';
+
+  meta = {
+    description = "Radioastronomy data analysis software";
+    longDescription = ''
+      GILDAS is a collection of state-of-the-art software
+      oriented toward (sub-)millimeter radioastronomical
+      applications (either single-dish or interferometer).
+      It is daily used to reduce all data acquired with the
+      IRAM 30M telescope and Plateau de Bure Interferometer
+      PDBI (except VLBI observations). GILDAS is easily
+      extensible. GILDAS is written in Fortran-90, with a
+      few parts in C/C++ (mainly keyboard interaction,
+      plotting, widgets).'';
+    homepage = "http://www.iram.fr/IRAMFR/GILDAS/gildas.html";
+    license = lib.licenses.free;
+    maintainers = [ lib.maintainers.bzizou lib.maintainers.smaret ];
+    platforms = lib.platforms.all;
+  };
+
+}
diff --git a/nixpkgs/pkgs/applications/science/astronomy/gildas/wrapper.patch b/nixpkgs/pkgs/applications/science/astronomy/gildas/wrapper.patch
new file mode 100644
index 000000000000..3843937bf1bc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/gildas/wrapper.patch
@@ -0,0 +1,20 @@
+diff --new-file -r -u gildas-src-feb17d.orig/admin/wrapper.sh gildas-src-feb17d/admin/wrapper.sh
+--- gildas-src-feb17d.orig/admin/wrapper.sh	1970-01-01 01:00:00.000000000 +0100
++++ gildas-src-feb17d/admin/wrapper.sh	2017-05-18 21:00:01.660778782 +0200
+@@ -0,0 +1,16 @@
++#!/bin/sh -e
++
++export GAG_ROOT_DIR="%%OUT%%"
++export GAG_PATH="${GAG_ROOT_DIR}/etc"
++export GAG_EXEC_SYSTEM="libexec"
++export GAG_GAG="${HOME}/.gag"
++export PYTHONHOME="%%PYTHONHOME%%"
++if [ -z "\$PYTHONPATH" ]; then
++  PYTHONPATH="${GAG_ROOT_DIR}/${GAG_EXEC_SYSTEM}/python"
++else
++  PYTHONPATH="${GAG_ROOT_DIR}/${GAG_EXEC_SYSTEM}/python:${PYTHONPATH}"
++fi
++export PYTHONPATH
++export LD_LIBRARY_PATH=${GAG_ROOT_DIR}/${GAG_EXEC_SYSTEM}/lib/
++me=`basename $0`
++exec ${GAG_ROOT_DIR}/${GAG_EXEC_SYSTEM}/bin/${me} ${*}
diff --git a/nixpkgs/pkgs/applications/science/astronomy/gpredict/default.nix b/nixpkgs/pkgs/applications/science/astronomy/gpredict/default.nix
new file mode 100644
index 000000000000..3f82ff7b52a8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/gpredict/default.nix
@@ -0,0 +1,34 @@
+{ lib, stdenv, fetchurl, pkg-config, intltool
+, gtk3, glib, curl, goocanvas2, gpsd
+, hamlib, wrapGAppsHook
+}:
+
+let
+  version = "2.2.1";
+in stdenv.mkDerivation {
+  pname = "gpredict";
+  inherit version;
+
+  src = fetchurl {
+    url = "https://github.com/csete/gpredict/releases/download/v${version}/gpredict-${version}.tar.bz2";
+    sha256 = "0hwf97kng1zy8rxyglw04x89p0bg07zq30hgghm20yxiw2xc8ng7";
+  };
+
+  nativeBuildInputs = [ pkg-config intltool wrapGAppsHook ];
+  buildInputs = [ curl glib gtk3 goocanvas2 gpsd hamlib ];
+
+  meta = with lib; {
+    description = "Real time satellite tracking and orbit prediction";
+    longDescription = ''
+      Gpredict is a real time satellite tracking and orbit prediction program
+      written using the GTK widgets. Gpredict is targetted mainly towards ham radio
+      operators but others interested in satellite tracking may find it useful as
+      well. Gpredict uses the SGP4/SDP4 algorithms, which are compatible with the
+      NORAD Keplerian elements.
+    '';
+    license = licenses.gpl2Only;
+    platforms = platforms.linux;
+    homepage = "http://gpredict.oz9aec.net/";
+    maintainers = [ maintainers.markuskowa maintainers.cmcdragonkai ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/astronomy/gprojector/default.nix b/nixpkgs/pkgs/applications/science/astronomy/gprojector/default.nix
new file mode 100644
index 000000000000..26e8fe11a32b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/gprojector/default.nix
@@ -0,0 +1,51 @@
+{ stdenvNoCC
+, lib
+, fetchzip
+, jre
+, makeDesktopItem
+, copyDesktopItems
+, makeWrapper
+, extraJavaArgs ? "-Xms512M -Xmx2000M"
+}:
+
+stdenvNoCC.mkDerivation rec {
+  pname = "gprojector";
+  version = "3.0.2";
+
+  src = fetchzip {
+    url = "https://www.giss.nasa.gov/tools/gprojector/download/G.ProjectorJ-${version}.tgz";
+    sha256 = "sha256-IvGZOYt2d8aWtlAJJzVrwkqOOhaUHUmEDlMeD/0NdwU=";
+  };
+
+  desktopItems = [ (makeDesktopItem {
+    name = "gprojector";
+    exec = "gprojector";
+    desktopName = "G.Projector";
+    comment = meta.description;
+    categories = [ "Science" ];
+    startupWMClass = "gov-nasa-giss-projector-GProjector";
+  }) ];
+
+  buildInputs = [ jre ];
+  nativeBuildInputs = [ makeWrapper copyDesktopItems ];
+
+  dontConfigure = true;
+  dontBuild = true;
+  dontFixup = true;
+
+  installPhase = ''
+    runHook preInstall
+    mkdir -p $out/share
+    cp -r $src/jars $out/share/java
+    makeWrapper ${jre}/bin/java $out/bin/gprojector --add-flags "-jar $out/share/java/G.Projector.jar" --add-flags "${extraJavaArgs}"
+    runHook postInstall
+  '';
+
+  meta = {
+    description = "G.Projector transforms an input map image into any of about 200 global and regional map projections";
+    homepage = "https://www.giss.nasa.gov/tools/gprojector/";
+    maintainers = with lib.maintainers; [ alyaeanyx ];
+    license = lib.licenses.unfree;
+    inherit (jre.meta) platforms;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/astronomy/gravit/default.nix b/nixpkgs/pkgs/applications/science/astronomy/gravit/default.nix
new file mode 100644
index 000000000000..fb5cce02bdb4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/gravit/default.nix
@@ -0,0 +1,45 @@
+{ lib, stdenv, fetchFromGitHub, SDL, SDL_ttf, SDL_image, libSM, libICE, libGLU, libGL, libpng, lua5, autoconf, automake }:
+
+stdenv.mkDerivation rec {
+  pname = "gravit";
+  version = "0.5.1";
+
+  src = fetchFromGitHub {
+    owner = "gak";
+    repo = pname;
+    rev = version;
+    hash = "sha256-JuqnLLD5+Ec8kQI0SK98V1O6TTbGM6+yKn5KCHe85eM=";
+  };
+
+  buildInputs = [ libGLU libGL SDL SDL_ttf SDL_image lua5 libpng libSM libICE ];
+
+  nativeBuildInputs = [ autoconf automake ];
+
+  preConfigure = ''
+    ./autogen.sh
+
+    # Build fails on Linux with windres.
+    export ac_cv_prog_WINDRES=
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = {
+    homepage = "https://github.com/gak/gravit";
+    description = "Beautiful OpenGL-based gravity simulator";
+    license = lib.licenses.gpl2Plus;
+
+    longDescription = ''
+      Gravit is a gravity simulator which runs under Linux, Windows and
+      macOS. It uses Newtonian physics using the Barnes-Hut N-body
+      algorithm. Although the main goal of Gravit is to be as accurate
+      as possible, it also creates beautiful looking gravity patterns.
+      It records the history of each particle so it can animate and
+      display a path of its travels. At any stage you can rotate your
+      view in 3D and zoom in and out.
+    '';
+
+    platforms = lib.platforms.mesaPlatforms;
+    hydraPlatforms = lib.platforms.linux; # darwin times out
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/astronomy/kstars/default.nix b/nixpkgs/pkgs/applications/science/astronomy/kstars/default.nix
new file mode 100644
index 000000000000..3cd98f1acadc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/kstars/default.nix
@@ -0,0 +1,53 @@
+{
+  lib, mkDerivation, extra-cmake-modules, fetchurl,
+
+  kconfig, kdoctools, kguiaddons, ki18n, kinit, kiconthemes, kio,
+  knewstuff, kplotting, kwidgetsaddons, kxmlgui, knotifyconfig,
+
+
+  qtx11extras, qtwebsockets, qtkeychain, libsecret,
+
+  eigen, zlib,
+
+  cfitsio, indi-full, xplanet, libnova, libraw, gsl, wcslib, stellarsolver
+}:
+
+mkDerivation rec {
+  pname = "kstars";
+  version = "3.5.7";
+
+  src = fetchurl {
+    url = "mirror://kde/stable/kstars/kstars-${version}.tar.xz";
+    sha256 = "sha256-qo8SLum46BM0QzGR6rJ2w2ERK53Lm8+N+ghR6HoQDQY=";
+  };
+
+  nativeBuildInputs = [ extra-cmake-modules kdoctools ];
+  buildInputs = [
+    kconfig kdoctools kguiaddons ki18n kinit kiconthemes kio
+    knewstuff kplotting kwidgetsaddons kxmlgui knotifyconfig
+
+    qtx11extras qtwebsockets qtkeychain libsecret
+
+    eigen zlib
+
+    cfitsio indi-full xplanet libnova libraw gsl wcslib stellarsolver
+  ];
+
+  cmakeFlags = [
+    "-DINDI_PREFIX=${indi-full}"
+    "-DXPLANET_PREFIX=${xplanet}"
+  ];
+
+  meta = with lib; {
+    description = "Virtual planetarium astronomy software";
+    homepage = "https://kde.org/applications/education/org.kde.kstars";
+    longDescription = ''
+      It provides an accurate graphical simulation of the night sky, from any location on Earth, at any date and time.
+      The display includes up to 100 million stars, 13.000 deep-sky objects, all 8 planets, the Sun and Moon, and thousands of comets, asteroids, supernovae, and satellites.
+      For students and teachers, it supports adjustable simulation speeds in order to view phenomena that happen over long timescales, the KStars Astrocalculator to predict conjunctions, and many common astronomical calculations.
+    '';
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ timput hjones2199 ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/astronomy/openspace/assets.patch b/nixpkgs/pkgs/applications/science/astronomy/openspace/assets.patch
new file mode 100644
index 000000000000..38c17ad4593a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/openspace/assets.patch
@@ -0,0 +1,100 @@
+diff --git a/data/assets/scene/solarsystem/planets/jupiter/jup310.asset b/data/assets/scene/solarsystem/planets/jupiter/jup310.asset
+index c15f6d9..1f8ddaf 100755
+--- a/data/assets/scene/solarsystem/planets/jupiter/jup310.asset
++++ b/data/assets/scene/solarsystem/planets/jupiter/jup310.asset
+@@ -1,8 +1,8 @@
+-local Kernels = asset.syncedResource({
+-    Name = "Jupiter Spice Kernels (jup310)",
+-    Type = "TorrentSynchronization",
+-    Identifier = "jup310",
+-    Magnet = "magnet:?xt=urn:btih:E8B7D7E136DE1C6249158B254BFC8B9ECE2A0539&dn=jup310.bsp&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.publicbt.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.ccc.de%3a80%2fannounce"
+-})
++-- local Kernels = asset.syncedResource({
++--     Name = "Jupiter Spice Kernels (jup310)",
++--     Type = "TorrentSynchronization",
++--     Identifier = "jup310",
++--     Magnet = "magnet:?xt=urn:btih:E8B7D7E136DE1C6249158B254BFC8B9ECE2A0539&dn=jup310.bsp&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.publicbt.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.ccc.de%3a80%2fannounce"
++-- })
+ 
+-asset.export("Kernels", Kernels .. '/jup310.bsp')
++-- asset.export("Kernels", Kernels .. '/jup310.bsp')
+diff --git a/data/assets/scene/solarsystem/planets/mars/mar097.asset b/data/assets/scene/solarsystem/planets/mars/mar097.asset
+index e77d67d..8d738a6 100755
+--- a/data/assets/scene/solarsystem/planets/mars/mar097.asset
++++ b/data/assets/scene/solarsystem/planets/mars/mar097.asset
+@@ -1,8 +1,8 @@
+-local Kernels = asset.syncedResource({
+-    Name = "Mars Spice Kernels",
+-    Type = "TorrentSynchronization",
+-    Identifier = "mat097",
+-    Magnet = "magnet:?xt=urn:btih:308F326B9AF864294D73042FBBED33B17291E27E&dn=mar097.bsp&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.publicbt.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.ccc.de%3a80%2fannounce"
+-})
++-- local Kernels = asset.syncedResource({
++--     Name = "Mars Spice Kernels",
++--     Type = "TorrentSynchronization",
++--     Identifier = "mat097",
++--     Magnet = "magnet:?xt=urn:btih:308F326B9AF864294D73042FBBED33B17291E27E&dn=mar097.bsp&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.publicbt.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.ccc.de%3a80%2fannounce"
++-- })
+ 
+-asset.export("Kernels", Kernels .. '/mar097.bsp')
++-- asset.export("Kernels", Kernels .. '/mar097.bsp')
+diff --git a/data/assets/scene/solarsystem/planets/neptune/nep081.asset b/data/assets/scene/solarsystem/planets/neptune/nep081.asset
+index e9c49ce..cfb5fac 100755
+--- a/data/assets/scene/solarsystem/planets/neptune/nep081.asset
++++ b/data/assets/scene/solarsystem/planets/neptune/nep081.asset
+@@ -1,8 +1,8 @@
+-local Kernels = asset.syncedResource({
+-    Name = "Neptune Spice Kernels (nep081)",
+-    Type = "TorrentSynchronization",
+-    Identifier = "nep081",
+-    Magnet = "magnet:?xt=urn:btih:A6079CF8D4BF3B6BB38F4F9F633CB7724FF91693&dn=nep081.bsp&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.publicbt.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.ccc.de%3a80%2fannounce"
+-})
++-- local Kernels = asset.syncedResource({
++--     Name = "Neptune Spice Kernels (nep081)",
++--     Type = "TorrentSynchronization",
++--     Identifier = "nep081",
++--     Magnet = "magnet:?xt=urn:btih:A6079CF8D4BF3B6BB38F4F9F633CB7724FF91693&dn=nep081.bsp&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.publicbt.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.ccc.de%3a80%2fannounce"
++-- })
+ 
+-asset.export("Kernels", Kernels .. '/nep081.bsp')
++-- asset.export("Kernels", Kernels .. '/nep081.bsp')
+diff --git a/data/assets/scene/solarsystem/planets/saturn/sat375.asset b/data/assets/scene/solarsystem/planets/saturn/sat375.asset
+index a55f2ed..f904b3c 100755
+--- a/data/assets/scene/solarsystem/planets/saturn/sat375.asset
++++ b/data/assets/scene/solarsystem/planets/saturn/sat375.asset
+@@ -1,8 +1,8 @@
+-local Kernels = asset.syncedResource({
+-    Name = "Saturn Spice Kernels (sat375)",
+-    Type = "TorrentSynchronization",
+-    Identifier = "sat375",
+-    Magnet = "magnet:?xt=urn:btih:79083d2069df389e65d7688bb326c7aaf1953845&dn=sat375.bsp"
+-})
++-- local Kernels = asset.syncedResource({
++--     Name = "Saturn Spice Kernels (sat375)",
++--     Type = "TorrentSynchronization",
++--     Identifier = "sat375",
++--     Magnet = "magnet:?xt=urn:btih:79083d2069df389e65d7688bb326c7aaf1953845&dn=sat375.bsp"
++-- })
+ 
+-asset.export("Kernels", Kernels .. '/sat375.bsp')
++-- asset.export("Kernels", Kernels .. '/sat375.bsp')
+diff --git a/data/assets/scene/solarsystem/planets/uranus/ura111.asset b/data/assets/scene/solarsystem/planets/uranus/ura111.asset
+index 665d059..8f95f34 100755
+--- a/data/assets/scene/solarsystem/planets/uranus/ura111.asset
++++ b/data/assets/scene/solarsystem/planets/uranus/ura111.asset
+@@ -1,8 +1,8 @@
+-local Kernels = asset.syncedResource({
+-    Name = "Uranus Spice Kernels (ura111)",
+-    Type = "TorrentSynchronization",
+-    Identifier = "ura111",
+-    Magnet = "magnet:?xt=urn:btih:26C4903D1A12AE439480F31B45BAEB5781D2B305&dn=ura111.bsp&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.publicbt.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.ccc.de%3a80%2fannounce"
+-})
++-- local Kernels = asset.syncedResource({
++--     Name = "Uranus Spice Kernels (ura111)",
++--     Type = "TorrentSynchronization",
++--     Identifier = "ura111",
++--     Magnet = "magnet:?xt=urn:btih:26C4903D1A12AE439480F31B45BAEB5781D2B305&dn=ura111.bsp&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.publicbt.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.ccc.de%3a80%2fannounce"
++-- })
+ 
+-asset.export("Kernels", Kernels .. '/ura111.bsp')
++-- asset.export("Kernels", Kernels .. '/ura111.bsp')
diff --git a/nixpkgs/pkgs/applications/science/astronomy/openspace/config.patch b/nixpkgs/pkgs/applications/science/astronomy/openspace/config.patch
new file mode 100644
index 000000000000..826edea09071
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/openspace/config.patch
@@ -0,0 +1,49 @@
+diff --git a/openspace.cfg b/openspace.cfg
+index c86830b..e7f89d9 100755
+--- a/openspace.cfg
++++ b/openspace.cfg
+@@ -2,18 +2,21 @@
+ -- require('scripts/configuration_helper.lua')
+ -- which defines helper functions useful to customize the configuration
+ 
++userdir = os.getenv("HOME") .. "/.openspace/"
++os.execute("mkdir -p " .. userdir)
++
+ return {
+     -- Determines which SGCT configuration file is loaded, that is, if there rendering
+     -- occurs in a single window, a fisheye projection, or a dome cluster system
+ 
+     -- A regular 1280x720 window
+-    SGCTConfig = sgct.config.single{},
++    -- SGCTConfig = sgct.config.single{},
+ 
+     -- A regular 1920x1080 window
+     -- SGCTConfig = sgct.config.single{1920, 1080},
+     
+     -- A windowed 1920x1080 fullscreen
+-    -- SGCTConfig = sgct.config.single{1920, 1080, border=false, windowPos={0,0}, shared=true, name="WV_OBS_SPOUT1"},
++    SGCTConfig = sgct.config.single{1920, 1080, border=false, windowPos={0,0}, shared=true, name="WV_OBS_SPOUT1"},
+ 
+     -- A 1k fisheye rendering
+     -- SGCTConfig = sgct.config.fisheye{1024, 1024},
+@@ -53,15 +56,15 @@ return {
+         TASKS = "${DATA}/tasks",
+         WEB = "${DATA}/web",
+ 
+-        CACHE = "${BASE}/cache",
++        CACHE  = userdir .. "cache",
+         CONFIG = "${BASE}/config",
+-        DOCUMENTATION = "${BASE}/documentation",
+-        LOGS = "${BASE}/logs",
++        DOCUMENTATION = userdir .. "documentation",
++        LOGS    = userdir .. "logs",
+         MODULES = "${BASE}/modules",
+         SCRIPTS = "${BASE}/scripts",
+         SHADERS = "${BASE}/shaders",
+-        SYNC = "${BASE}/sync",
+-        TESTDIR = "${BASE}/tests"
++        SYNC    = userdir .. "sync",
++        TESTDIR = userdir .. "tests"
+     },
+     Fonts = {
+         Mono = "${FONTS}/Bitstream-Vera-Sans-Mono/VeraMono.ttf",
diff --git a/nixpkgs/pkgs/applications/science/astronomy/openspace/constexpr.patch b/nixpkgs/pkgs/applications/science/astronomy/openspace/constexpr.patch
new file mode 100644
index 000000000000..d9fc91d7c277
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/openspace/constexpr.patch
@@ -0,0 +1,91 @@
+diff --git a/include/openspace/util/distanceconversion.h b/include/openspace/util/distanceconversion.h
+index 80a3a96..7059752 100755
+--- a/include/openspace/util/distanceconversion.h
++++ b/include/openspace/util/distanceconversion.h
+@@ -159,24 +159,34 @@ constexpr const char* nameForDistanceUnit(DistanceUnit unit, bool pluralForm = f
+ }
+ 
+ constexpr DistanceUnit distanceUnitFromString(const char* unitName) {
++    int result = -1;
++  
+     int i = 0;
+     for (const char* val : DistanceUnitNamesSingular) {
+         if (ghoul::equal(unitName, val)) {
+-            return static_cast<DistanceUnit>(i);
++            result = i;
++            break;
+         }
+         ++i;
+     }
+ 
+-    i = 0;
+-    for (const char* val : DistanceUnitNamesPlural) {
+-        if (ghoul::equal(unitName, val)) {
+-            return static_cast<DistanceUnit>(i);
++    if (result == -1) {
++        i = 0;
++        for (const char* val : DistanceUnitNamesPlural) {
++            if (ghoul::equal(unitName, val)) {
++                result = i;
++                break;
++            }
++            ++i;
+         }
+-        ++i;
+     }
+ 
+-    ghoul_assert(false, "Unit name is not a valid name");
+-    throw ghoul::MissingCaseException();
++    if (result != -1)
++        return static_cast<DistanceUnit>(result);
++    else {
++        ghoul_assert(false, "Unit name is not a valid name");
++        throw ghoul::MissingCaseException();
++    }
+ }
+ 
+ 
+diff --git a/include/openspace/util/timeconversion.h b/include/openspace/util/timeconversion.h
+index a36c92a..699bca9 100755
+--- a/include/openspace/util/timeconversion.h
++++ b/include/openspace/util/timeconversion.h
+@@ -142,23 +142,32 @@ constexpr const char* nameForTimeUnit(TimeUnit unit, bool pluralForm = false) {
+ }
+ 
+ constexpr TimeUnit timeUnitFromString(const char* unitName) {
++    int result = -1;
++    
+     int i = 0;
+     for (const char* val : TimeUnitNamesSingular) {
+         if (ghoul::equal(unitName, val)) {
+-            return static_cast<TimeUnit>(i);
++            result = i;
++            break;
+         }
+         ++i;
+     }
+ 
+-    i = 0;
+-    for (const char* val : TimeUnitNamesPlural) {
+-        if (ghoul::equal(unitName, val)) {
+-            return static_cast<TimeUnit>(i);
++    if (result == -1) {
++        i = 0;
++        for (const char* val : TimeUnitNamesPlural) {
++            if (ghoul::equal(unitName, val)) {
++                result = i;
++                break;
++            }
++            ++i;
+         }
+-        ++i;
+     }
+ 
+-    throw ghoul::MissingCaseException();
++    if (result != -1)
++        return static_cast<TimeUnit>(result);
++    else
++        throw ghoul::MissingCaseException();
+ }
+ 
+ std::pair<double, std::string> simplifyTime(double seconds,
diff --git a/nixpkgs/pkgs/applications/science/astronomy/openspace/default.nix b/nixpkgs/pkgs/applications/science/astronomy/openspace/default.nix
new file mode 100644
index 000000000000..17c721ac8693
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/openspace/default.nix
@@ -0,0 +1,90 @@
+{ lib, stdenv, fetchFromGitHub, fetchurl, makeWrapper, cmake
+, curl, boost, gdal, glew, soil
+, libX11, libXi, libXxf86vm, libXcursor, libXrandr, libXinerama }:
+
+stdenv.mkDerivation rec {
+  version = "0.11.1";
+  pname = "openspace";
+
+  src = fetchFromGitHub {
+    owner  = "OpenSpace";
+    repo   = "OpenSpace";
+    rev    = "a65eea61a1b8807ce3d69e9925e75f8e3dfb085d";
+    sha256 = "0msqixf30r0d41xmfmzkdfw6w9jkx2ph5clq8xiwrg1jc3z9q7nv";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [ cmake makeWrapper ];
+  buildInputs = [
+    curl boost gdal glew soil
+    libX11 libXi libXxf86vm libXcursor libXrandr libXinerama
+  ];
+
+  glmPlatformH = fetchurl {
+    url    = "https://raw.githubusercontent.com/g-truc/glm/dd48b56e44d699a022c69155c8672caacafd9e8a/glm/simd/platform.h";
+    sha256 = "0y91hlbgn5va7ijg5mz823gqkq9hqxl00lwmdwnf8q2g086rplzw";
+  };
+
+  # See <https://github.com/g-truc/glm/issues/726>
+  prePatch = ''
+    cp ${glmPlatformH} ext/sgct/include/glm/simd/platform.h
+    cp ${glmPlatformH} ext/ghoul/ext/glm/glm/simd/platform.h
+  '';
+
+  patches = [
+    # See <https://github.com/opensgct/sgct/issues/13>
+    ./vrpn.patch
+
+    ./constexpr.patch
+    ./config.patch
+
+    # WARNING: This patch disables some slow torrents in a very dirty way.
+    ./assets.patch
+  ];
+
+  bundle = "$out/usr/share/openspace";
+
+  preConfigure = ''
+    cmakeFlagsArray=(
+      $cmakeFlagsArray
+      "-DCMAKE_BUILD_TYPE="
+      "-DCMAKE_INSTALL_PREFIX=${bundle}"
+    )
+  '';
+
+  preInstall = ''
+    mkdir -p $out/bin
+    mkdir -p ${bundle}
+  '';
+
+  postInstall = ''
+    cp ext/spice/libSpice.so       ${bundle}/lib
+    cp ext/ghoul/ext/lua/libLua.so ${bundle}/lib
+  '';
+
+  postFixup = ''
+    for bin in ${bundle}/bin/*
+    do
+      rpath=$(patchelf --print-rpath $bin)
+      patchelf --set-rpath $rpath:${bundle}/lib $bin
+
+      name=$(basename $bin)
+      makeWrapper $bin $out/bin/$name --run "cd ${bundle}"
+    done
+  '';
+
+  meta = {
+    description     = "Open-source astrovisualization project";
+    longDescription = ''
+      OpenSpace is open source interactive data visualization software
+      designed to visualize the entire known universe and portray our
+      ongoing efforts to investigate the cosmos.
+
+      WARNING: This build is not very usable for now.
+    '';
+    homepage  = "https://www.openspaceproject.com/";
+    license   = lib.licenses.mit;
+    platforms = lib.platforms.linux;
+    broken = true; # fails to build
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/astronomy/openspace/vrpn.patch b/nixpkgs/pkgs/applications/science/astronomy/openspace/vrpn.patch
new file mode 100644
index 000000000000..9386d0257b7f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/openspace/vrpn.patch
@@ -0,0 +1,13 @@
+diff --git a/ext/sgct/src/deps/vrpn/vrpn_Connection.C b/ext/sgct/src/deps/vrpn/vrpn_Connection.C
+index d6ffdc5..f90a2b2 100755
+--- a/ext/sgct/src/deps/vrpn/vrpn_Connection.C
++++ b/ext/sgct/src/deps/vrpn/vrpn_Connection.C
+@@ -2489,7 +2489,7 @@ static int vrpn_start_server(const char *machine, char *server_name, char *args,
+ #if defined(sparc) || defined(FreeBSD) || defined(_AIX) || defined(__ANDROID__)
+             int status; // doesn't exist on sparc_solaris or FreeBSD
+ #else
+-            union wait status;
++            int status;
+ #endif
+ 
+             /* Check to see if they called back yet. */
diff --git a/nixpkgs/pkgs/applications/science/astronomy/phd2/default.nix b/nixpkgs/pkgs/applications/science/astronomy/phd2/default.nix
new file mode 100644
index 000000000000..543e6820a763
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/phd2/default.nix
@@ -0,0 +1,48 @@
+{ lib, stdenv, fetchFromGitHub, pkg-config, cmake, gtk3, wxGTK30-gtk3
+, curl, gettext, glib, indi-full, libnova, wrapGAppsHook }:
+
+stdenv.mkDerivation rec {
+  pname = "phd2";
+  version = "2.6.10";
+
+  src = fetchFromGitHub {
+    owner = "OpenPHDGuiding";
+    repo = "phd2";
+    rev = "v${version}";
+    sha256 = "sha256-2ZiPjhlguWXFcC53xG1aqAode7twtoHWszFUMQkK5xU=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    pkg-config
+    wrapGAppsHook
+  ];
+
+  buildInputs = [
+    gtk3
+    wxGTK30-gtk3
+    curl
+    gettext
+    glib
+    indi-full
+    libnova
+  ];
+
+  cmakeFlags = [
+    "-DOPENSOURCE_ONLY=1"
+  ];
+
+  # Fix broken wrapped name scheme by moving wrapped binary to where wrapper expects it
+  postFixup = ''
+    mv $out/bin/.phd2.bin-wrapped $out/bin/.phd2-wrapped.bin
+  '';
+
+  meta = with lib; {
+    homepage = "https://openphdguiding.org/";
+    description = "Telescope auto-guidance application";
+    changelog = "https://github.com/OpenPHDGuiding/phd2/releases/tag/v${version}";
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ hjones2199 ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/astronomy/siril/default.nix b/nixpkgs/pkgs/applications/science/astronomy/siril/default.nix
new file mode 100644
index 000000000000..b50cb4b71d0d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/siril/default.nix
@@ -0,0 +1,46 @@
+{ lib, stdenv, fetchFromGitLab, pkg-config, meson, ninja
+, git, criterion, gtk3, libconfig, gnuplot, opencv, json-glib
+, fftwFloat, cfitsio, gsl, exiv2, librtprocess, wcslib, ffmpeg
+, libraw, libtiff, libpng, libjpeg, libheif, ffms, wrapGAppsHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "siril";
+  version = "0.99.10.1";
+
+  src = fetchFromGitLab {
+    owner = "free-astro";
+    repo = pname;
+    rev = version;
+    sha256 = "sha256-gqV+pJNaU+GnYiUo/imofgNdeM+AtDg/pSH7aoqhkYA=";
+  };
+
+  nativeBuildInputs = [
+    meson ninja pkg-config git criterion wrapGAppsHook
+  ];
+
+  buildInputs = [
+    gtk3 cfitsio gsl exiv2 gnuplot opencv fftwFloat librtprocess wcslib
+    libconfig libraw libtiff libpng libjpeg libheif ffms ffmpeg json-glib
+  ];
+
+  # Necessary because project uses default build dir for flatpaks/snaps
+  dontUseMesonConfigure = true;
+
+  configureScript = ''
+    ${meson}/bin/meson --buildtype release nixbld .
+  '';
+
+  postConfigure = ''
+    cd nixbld
+  '';
+
+  meta = with lib; {
+    homepage = "https://www.siril.org/";
+    description = "Astrophotographic image processing tool";
+    license = licenses.gpl3Plus;
+    changelog = "https://gitlab.com/free-astro/siril/-/blob/HEAD/ChangeLog";
+    maintainers = with maintainers; [ hjones2199 ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/astronomy/stellarium/default.nix b/nixpkgs/pkgs/applications/science/astronomy/stellarium/default.nix
new file mode 100644
index 000000000000..0963b4c17e02
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/stellarium/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, lib, mkDerivation, fetchFromGitHub
+, cmake, freetype, libpng, libGLU, libGL, openssl, perl, libiconv
+, qtscript, qtserialport, qttools
+, qtmultimedia, qtlocation, qtbase, wrapQtAppsHook
+}:
+
+mkDerivation rec {
+  pname = "stellarium";
+  version = "0.21.3";
+
+  src = fetchFromGitHub {
+    owner = "Stellarium";
+    repo = "stellarium";
+    rev = "v${version}";
+    sha256 = "sha256-TQMLy5ziBF7YqPDzPwgjY5FHxxMUe7MXo/TGxQ1nGcg=";
+  };
+
+  nativeBuildInputs = [ cmake perl wrapQtAppsHook ];
+
+  buildInputs = [
+    freetype libpng libGLU libGL openssl libiconv qtscript qtserialport qttools
+    qtmultimedia qtlocation qtbase
+  ];
+
+  preConfigure = lib.optionalString stdenv.isDarwin ''
+    substituteInPlace CMakeLists.txt \
+      --replace 'SET(CMAKE_INSTALL_PREFIX "''${PROJECT_BINARY_DIR}/Stellarium.app/Contents")' \
+                'SET(CMAKE_INSTALL_PREFIX "${placeholder "out"}/Stellarium.app/Contents")'
+  '';
+
+  meta = with lib; {
+    description = "Free open-source planetarium";
+    homepage = "http://stellarium.org/";
+    license = licenses.gpl2;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ ma27 ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/astronomy/xearth/default.nix b/nixpkgs/pkgs/applications/science/astronomy/xearth/default.nix
new file mode 100644
index 000000000000..bd92ae01ebb1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/xearth/default.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchurl, imake, gccmakedep, libXt, libXext }:
+
+stdenv.mkDerivation rec {
+  pname = "xearth";
+  version = "1.1";
+
+  src = fetchurl {
+    url = "http://xearth.org/${pname}-${version}.tar.gz";
+    sha256 = "bcb1407cc35b3f6dd3606b2c6072273b6a912cbd9ed1ae22fb2d26694541309c";
+  };
+
+  nativeBuildInputs = [ imake gccmakedep ];
+  buildInputs = [ libXt libXext ];
+
+  installFlags = [ "DESTDIR=$(out)/" "BINDIR=bin" "MANDIR=man/man1"];
+  installTargets = [ "install" "install.man" ];
+
+  meta = with lib; {
+    description = "sets the X root window to an image of the Earth";
+    homepage = "http://xplanet.org";
+    longDescription =
+      '' Xearth  sets  the X root window to an image of the Earth, as seen from your favorite vantage point in space,
+         correctly shaded for the current position of the Sun.
+         By default, xearth updates the displayed image every  five  minutes.
+      '';
+    maintainers = [ maintainers.mafo ];
+    license = "xearth";
+    platforms=platforms.unix;
+  };
+
+}
diff --git a/nixpkgs/pkgs/applications/science/astronomy/xplanet/default.nix b/nixpkgs/pkgs/applications/science/astronomy/xplanet/default.nix
new file mode 100644
index 000000000000..8c0cb2be32b9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/xplanet/default.nix
@@ -0,0 +1,38 @@
+{lib, stdenv, fetchurl, fetchpatch, pkg-config, freetype, pango, libpng, libtiff
+, giflib, libjpeg, netpbm}:
+
+stdenv.mkDerivation rec {
+  pname = "xplanet";
+  version = "1.3.1";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/xplanet/${pname}-${version}.tar.gz";
+    sha256 = "1rzc1alph03j67lrr66499zl0wqndiipmj99nqgvh9xzm1qdb023";
+  };
+
+  nativeBuildInputs = [ pkg-config ];
+  buildInputs = [ freetype pango libpng libtiff giflib libjpeg netpbm ];
+
+  patches = [
+    (fetchpatch {
+      name = "giflib6.patch";
+      url = "https://raw.githubusercontent.com/archlinux/svntogit-community/ce6f25eb369dc011161613894f01fd0a6ae85a09/trunk/giflib6.patch";
+      sha256 = "173l0xkqq0v2bpaff7hhwc7y2aw5cclqw8988k1nalhyfbrjb8bl";
+    })
+    (fetchpatch {
+      name = "xplanet-c++11.patch";
+      url = "https://raw.githubusercontent.com/archlinux/svntogit-community/ce6f25eb369dc011161613894f01fd0a6ae85a09/trunk/xplanet-c++11.patch";
+      sha256 = "0vldai78ixw49bxch774pps6pq4sp0p33qvkvxywcz7p8kzpg8q2";
+    })
+  ];
+
+  NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=c++11-narrowing";
+
+  meta = with lib; {
+    description = "Renders an image of the earth or other planets into the X root window";
+    homepage = "http://xplanet.sourceforge.net";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ lassulus sander ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/EZminc/default.nix b/nixpkgs/pkgs/applications/science/biology/EZminc/default.nix
new file mode 100644
index 000000000000..a2ba038c0599
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/EZminc/default.nix
@@ -0,0 +1,29 @@
+{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, libminc, bicpl, itk4, fftwFloat, gsl }:
+
+stdenv.mkDerivation rec {
+  pname = "EZminc";
+  version = "unstable-2019-03-12";
+
+  src = fetchFromGitHub {
+    owner  = "BIC-MNI";
+    repo   = pname;
+    rev    = "5e3333ee356f914d34d66d33ea8df809c7f7fa51";
+    sha256 = "0wy8cppf5xpgfqvgb3mqs1cjh81n6qzkk6zxv29wvng8nar9wsy4";
+  };
+
+  nativeBuildInputs = [ cmake pkg-config ];
+  buildInputs = [ itk4 libminc bicpl fftwFloat gsl ];
+
+  cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/cmake"
+                 "-DEZMINC_BUILD_TOOLS=TRUE"
+                 "-DEZMINC_BUILD_MRFSEG=TRUE"
+                 "-DEZMINC_BUILD_DD=TRUE" ];
+
+  meta = with lib; {
+    homepage = "https://github.com/BIC-MNI/${pname}";
+    description = "Collection of Perl and shell scripts for processing MINC files";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license = licenses.free;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/MACS2/default.nix b/nixpkgs/pkgs/applications/science/biology/MACS2/default.nix
new file mode 100644
index 000000000000..cc398608ce52
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/MACS2/default.nix
@@ -0,0 +1,25 @@
+{ lib, python3, fetchurl }:
+
+python3.pkgs.buildPythonPackage rec {
+  pname = "MACS2";
+  version = "2.2.7.1";
+
+  src = python3.pkgs.fetchPypi {
+    inherit pname version;
+    sha256 = "1rcxj943kgzs746f5jrb72x1cp4v50rk3qmad0m99a02vndscb5d";
+  };
+
+  propagatedBuildInputs = with python3.pkgs; [ numpy ];
+
+  # To prevent ERROR: diffpeak_cmd (unittest.loader._FailedTest) for obsolete
+  # function (ImportError: Failed to import test module: diffpeak_cmd)
+  doCheck = false;
+  pythonImportsCheck = [ "MACS2" ];
+
+  meta = with lib; {
+    description = "Model-based Analysis for ChIP-Seq";
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ gschwartz ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/N3/default.nix b/nixpkgs/pkgs/applications/science/biology/N3/default.nix
new file mode 100644
index 000000000000..2f4aa4ce3927
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/N3/default.nix
@@ -0,0 +1,35 @@
+{ lib, stdenv, fetchFromGitHub, cmake, makeWrapper,
+  perlPackages,
+  libminc, EBTKS }:
+
+stdenv.mkDerivation rec {
+  pname = "N3";
+  version = "unstable-2018-08-09";
+
+  src = fetchFromGitHub {
+    owner  = "BIC-MNI";
+    repo   = pname;
+    rev    = "010fc2ac58ce1d67b8e6a863fac0809d3203cb9b";
+    sha256 = "06hci7gzhy8p34ggvx7gah2k9yxpwhgmq1cgw8pcd1r82g4rg6kd";
+  };
+
+  nativeBuildInputs = [ cmake makeWrapper ];
+  buildInputs = [ libminc EBTKS ];
+  propagatedBuildInputs = with perlPackages; [ perl MNI-Perllib GetoptTabular ];
+
+  cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/cmake" "-DEBTKS_DIR=${EBTKS}/lib/" ];
+
+  postFixup = ''
+    for p in $out/bin/*; do
+      wrapProgram $p --prefix PERL5LIB : $PERL5LIB
+    done
+  '';
+
+  meta = with lib; {
+    homepage = "https://github.com/BIC-MNI/N3";
+    description = "MRI non-uniformity correction for MINC files";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license   = licenses.free;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/angsd/default.nix b/nixpkgs/pkgs/applications/science/biology/angsd/default.nix
new file mode 100644
index 000000000000..02e00cd19ad6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/angsd/default.nix
@@ -0,0 +1,25 @@
+{ lib, stdenv, fetchFromGitHub, htslib, zlib, bzip2, xz, curl, openssl }:
+
+stdenv.mkDerivation rec {
+  pname = "angsd";
+  version = "0.937";
+
+  src = fetchFromGitHub {
+    owner = "ANGSD";
+    repo = "angsd";
+    sha256 = "1020gh066dprqhfi90ywqzqqnq7awn49wrkkjnizmmab52v00kxs";
+    rev = "${version}";
+  };
+
+  buildInputs = [ htslib zlib bzip2 xz curl openssl ];
+
+  makeFlags = [ "HTSSRC=systemwide" "prefix=$(out)" ];
+
+  meta = with lib; {
+    description = "Program for analysing NGS data";
+    homepage = "http://www.popgen.dk/angsd";
+    maintainers = [ maintainers.bzizou ];
+    license = licenses.gpl2;
+  };
+}
+
diff --git a/nixpkgs/pkgs/applications/science/biology/ants/default.nix b/nixpkgs/pkgs/applications/science/biology/ants/default.nix
new file mode 100644
index 000000000000..ac332f271662
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/ants/default.nix
@@ -0,0 +1,40 @@
+{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, makeWrapper, itk4, vtk_7, Cocoa }:
+
+stdenv.mkDerivation rec {
+  pname    = "ANTs";
+  version = "2.2.0";
+
+  src = fetchFromGitHub {
+    owner  = "ANTsX";
+    repo   = "ANTs";
+    rev    = "37ad4e20be3a5ecd26c2e4e41b49e778a0246c3d";
+    sha256 = "1hrdwv3m9xh3yf7l0rm2ggxc2xzckfb8srs88g485ibfszx7i03q";
+  };
+
+  patches = [
+    # Fix build with gcc8
+    (fetchpatch {
+      url = "https://github.com/ANTsX/ANTs/commit/89af9b2694715bf8204993e032fa132f80cf37bd.patch";
+      sha256 = "1glkrwa1jmxxbmzihycxr576azjqby31jwpj165qc54c91pn0ams";
+    })
+  ];
+
+  nativeBuildInputs = [ cmake makeWrapper ];
+  buildInputs = [ itk4 vtk_7 ] ++ lib.optionals stdenv.isDarwin [ Cocoa ];
+
+  cmakeFlags = [ "-DANTS_SUPERBUILD=FALSE" "-DUSE_VTK=TRUE" ];
+
+  postInstall = ''
+    for file in $out/bin/*; do
+      wrapProgram $file --set ANTSPATH "$out/bin"
+    done
+  '';
+
+  meta = with lib; {
+    homepage = "https://github.com/ANTsX/ANTs";
+    description = "Advanced normalization toolkit for medical image registration and other processing";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license = licenses.bsd3;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/aragorn/default.nix b/nixpkgs/pkgs/applications/science/biology/aragorn/default.nix
new file mode 100644
index 000000000000..fa0c10b00c20
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/aragorn/default.nix
@@ -0,0 +1,28 @@
+{ lib, stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  version = "1.2.38";
+  pname = "aragorn";
+
+  src = fetchurl {
+    url = "http://mbio-serv2.mbioekol.lu.se/ARAGORN/Downloads/${pname}${version}.tgz";
+    sha256 = "09i1rg716smlbnixfm7q1ml2mfpaa2fpn3hwjg625ysmfwwy712b";
+  };
+
+  buildPhase = ''
+    $CC -O3 -ffast-math -finline-functions -o aragorn aragorn${version}.c
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin && cp aragorn $out/bin
+    mkdir -p $out/man/1 && cp aragorn.1 $out/man/1
+  '';
+
+  meta = with lib; {
+    description = "Detects tRNA, mtRNA, and tmRNA genes in nucleotide sequences";
+    homepage = "http://mbio-serv2.mbioekol.lu.se/ARAGORN/";
+    license = licenses.gpl2;
+    maintainers = [ maintainers.bzizou ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/bayescan/default.nix b/nixpkgs/pkgs/applications/science/biology/bayescan/default.nix
new file mode 100644
index 000000000000..043ee3ca52de
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/bayescan/default.nix
@@ -0,0 +1,39 @@
+{ lib, stdenv, fetchurl, unzip, llvmPackages }:
+
+stdenv.mkDerivation rec {
+  pname = "bayescan";
+  version = "2.1";
+
+  src = fetchurl {
+    url = "http://cmpg.unibe.ch/software/BayeScan/files/BayeScan${version}.zip";
+    sha256 = "0ismima8j8z0zj9yc267rpf7z90w57b2pbqzjnayhc3ab8mcbfy6";
+  };
+
+  nativeBuildInputs = [ unzip ];
+  buildInputs = lib.optional stdenv.cc.isClang llvmPackages.openmp;
+
+  # Disable FORTIFY_SOURCE or the binary fails with "buffer overflow"
+  hardeningDisable = [ "fortify" ];
+
+  sourceRoot = "BayeScan${version}/source";
+
+  postPatch = ''
+    substituteInPlace Makefile --replace "-static" "" \
+                               --replace "g++" "c++"
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mkdir -p $out/share/doc/bayescan
+    cp bayescan_${version} $out/bin
+    cp -r ../*pdf ../input_examples ../"R functions" $out/share/doc/bayescan
+  '';
+
+  meta = with lib; {
+    description = "Detecting natural selection from population-based genetic data";
+    homepage = "http://cmpg.unibe.ch/software/BayeScan";
+    license = licenses.gpl3;
+    maintainers = [ maintainers.bzizou ];
+    platforms = lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/bcftools/default.nix b/nixpkgs/pkgs/applications/science/biology/bcftools/default.nix
new file mode 100644
index 000000000000..c04d6af080e3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/bcftools/default.nix
@@ -0,0 +1,44 @@
+{ lib, stdenv, fetchurl, htslib, zlib, bzip2, xz, curl, perl, python3, bash }:
+
+stdenv.mkDerivation rec {
+  pname = "bcftools";
+  version = "1.15";
+
+  src = fetchurl {
+    url = "https://github.com/samtools/bcftools/releases/download/${version}/${pname}-${version}.tar.bz2";
+    sha256 = "sha256-GIXMtFCobpegCqkF1zgcqeB72JZ8BXBaYdAAfS4iKW4=";
+  };
+
+  nativeBuildInputs = [
+    perl
+    python3
+  ];
+
+  buildInputs = [ htslib zlib bzip2 xz curl ];
+
+  strictDeps = true;
+
+  makeFlags = [
+    "HSTDIR=${htslib}"
+    "prefix=$(out)"
+    "CC=${stdenv.cc.targetPrefix}cc"
+  ];
+
+  preCheck = ''
+    patchShebangs misc/
+    patchShebangs test/
+    sed -ie 's|/bin/bash|${bash}/bin/bash|' test/test.pl
+  '';
+
+  enableParallelBuilding = true;
+
+  doCheck = true;
+
+  meta = with lib; {
+    description = "Tools for manipulating BCF2/VCF/gVCF format, SNP and short indel sequence variants";
+    license = licenses.mit;
+    homepage = "http://www.htslib.org/";
+    platforms = platforms.unix;
+    maintainers = [ maintainers.mimame ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/bedops/default.nix b/nixpkgs/pkgs/applications/science/biology/bedops/default.nix
new file mode 100644
index 000000000000..e7379ee382a4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/bedops/default.nix
@@ -0,0 +1,51 @@
+{ lib, stdenv, fetchFromGitHub, zlib, bzip2, jansson, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  pname = "bedops";
+  version = "2.4.40";
+
+  src = fetchFromGitHub {
+    owner = "bedops";
+    repo = "bedops";
+    rev = "v${version}";
+    sha256 = "sha256-rJVl3KbzGblyQZ7FtJXeEv/wjQJmzYGNjzhvkoMoBWY=";
+  };
+
+  buildInputs = [ zlib bzip2 jansson ];
+  nativeBuildInputs = [ makeWrapper ];
+
+  preConfigure = ''
+    # We use nixpkgs versions of these libraries
+    rm -r third-party
+    sed -i '/^LIBS/d' system.mk/*
+    sed -i 's|^LIBRARIES.*$|LIBRARIES = -lbz2 -lz -ljansson|' */*/*/*/Makefile
+    substituteInPlace applications/bed/starch/src/Makefile --replace '$(LIBRARIES)' ""
+
+    # Function name is different in nixpkgs provided libraries
+    for f in interfaces/src/data/starch/starchFileHelpers.c applications/bed/starch/src/starchcat.c ; do
+      substituteInPlace $f --replace deflateInit2cpp deflateInit2
+    done
+
+    # Don't force static
+    for f in */*/*/*/Makefile ; do
+      substituteInPlace $f --replace '-static' ""
+    done
+  '';
+
+  makeFlags = [ "BINDIR=$(out)/bin" ];
+
+  postFixup = ''
+    for f in $out/bin/* ; do
+      wrapProgram $f --prefix PATH : "$out/bin"
+    done
+  '';
+
+  meta = with lib; {
+    description = "Suite of tools for addressing questions arising in genomics studies";
+    homepage = "https://github.com/bedops/bedops";
+    license = licenses.gpl2Only;
+    maintainers = with maintainers; [ jbedo ];
+    platforms = platforms.x86_64;
+    broken = stdenv.isDarwin;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/bedtools/default.nix b/nixpkgs/pkgs/applications/science/biology/bedtools/default.nix
new file mode 100644
index 000000000000..aac36d2af310
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/bedtools/default.nix
@@ -0,0 +1,34 @@
+{lib, stdenv, fetchFromGitHub, zlib, python3, bzip2, xz}:
+
+stdenv.mkDerivation rec {
+  pname = "bedtools";
+  version = "2.30.0";
+
+  src = fetchFromGitHub {
+    owner = "arq5x";
+    repo = "bedtools2";
+    rev = "v${version}";
+    sha256 = "sha256-NqKldF7ePJn3pT+AkESIQghBKSFFOEBBsTaKEbU+oaQ=";
+  };
+
+  strictDeps = true;
+
+  nativeBuildInputs = [
+    python3
+  ];
+
+  buildInputs = [ zlib bzip2 xz ];
+
+  cxx = if stdenv.cc.isClang then "clang++" else "g++";
+  cc = if stdenv.cc.isClang then "clang" else "gcc";
+  buildPhase = "make prefix=$out SHELL=${stdenv.shell} CXX=${cxx} CC=${cc} -j $NIX_BUILD_CORES";
+  installPhase = "make prefix=$out SHELL=${stdenv.shell} CXX=${cxx} CC=${cc} install";
+
+  meta = with lib; {
+    description = "A powerful toolset for genome arithmetic";
+    license = licenses.gpl2;
+    homepage = "https://bedtools.readthedocs.io/en/latest/";
+    maintainers = with maintainers; [ jbedo ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/bftools/default.nix b/nixpkgs/pkgs/applications/science/biology/bftools/default.nix
new file mode 100644
index 000000000000..89ebdcee65b9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/bftools/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, lib, makeWrapper, fetchzip, jre }:
+
+stdenv.mkDerivation rec {
+  pname = "bftools";
+  version = "6.3.0";
+
+  src = fetchzip {
+    url = "http://downloads.openmicroscopy.org/bio-formats/${version}/artifacts/bftools.zip";
+    sha256 = "02nvvmpfglpah1ihd08aw65g1794w588c988cdar1hfl4s80qwhb";
+  };
+
+  installPhase = ''
+    find . -maxdepth 1 -perm -111 -type f -not -name "*.sh" \
+      -exec install -vD {} "$out"/bin/{} \;
+
+    mkdir $out/libexec
+    mkdir -p $out/share/java
+
+    cp ./*.sh $out/libexec
+    cp ./*.jar $out/share/java
+
+    for file in $out/bin/*; do
+      substituteInPlace $file --replace "\$BF_DIR" $out/libexec
+    done
+    substituteInPlace $out/libexec/bf.sh --replace "\$BF_JAR_DIR" $out/share/java
+  '';
+
+  postFixup = ''
+    wrapProgram $out/libexec/bf.sh --prefix PATH : "${lib.makeBinPath [ jre ]}"
+  '';
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  meta = with lib; {
+    description = "A bundle of scripts for using Bio-Formats on the command line with bioformats_package.jar already included";
+    license = licenses.gpl2;
+    platforms = platforms.all;
+    homepage = "https://www.openmicroscopy.org/bio-formats/";
+    maintainers = [ maintainers.tbenst ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/blast/default.nix b/nixpkgs/pkgs/applications/science/biology/blast/default.nix
new file mode 100644
index 000000000000..15e1b3eb9891
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/blast/default.nix
@@ -0,0 +1,109 @@
+{ lib, stdenv, buildPackages, fetchurl, zlib, bzip2, perl, cpio, gawk, coreutils, ApplicationServices }:
+
+stdenv.mkDerivation rec {
+  pname = "blast";
+  version = "2.12.0";
+
+  src = fetchurl {
+    url = "https://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/${version}/ncbi-blast-${version}+-src.tar.gz";
+    sha256 = "122bf45cyj3s3zv2lw1y1rhz7g22v0va560ai30xdjl8sk4wk8zx";
+  };
+
+  sourceRoot = "ncbi-blast-${version}+-src/c++";
+
+  configureFlags = [
+    # With flat Makefile we can use all_projects in order not to build extra.
+    # These extra cause clang to hang on Darwin.
+    "--with-flat-makefile"
+    "--without-makefile-auto-update"
+    "--with-dll"  # build dynamic libraries (static are default)
+    ];
+
+  makeFlags = [ "all_projects=app/" ];
+
+  preConfigure = ''
+    export NCBICXX_RECONF_POLICY=warn
+    export PWD=$(pwd)
+    export HOME=$PWD
+
+    # The configure scripts wants to set AR="ar cr" unless it is already set in
+    # the environment. Because stdenv sets AR="ar", the result is a bad call to
+    # the assembler later in the process. Thus, we need to unset AR
+    unset AR
+
+    for awks in scripts/common/impl/is_log_interesting.awk \
+        scripts/common/impl/report_duplicates.awk; do
+
+        substituteInPlace $awks \
+              --replace /usr/bin/awk ${gawk}/bin/awk
+    done
+
+    for mk in src/build-system/Makefile.meta.in \
+        src/build-system/helpers/run_with_lock.c ; do
+
+        substituteInPlace $mk \
+        --replace /bin/rm ${coreutils}/bin/rm
+    done
+
+    for mk in src/build-system/Makefile.meta.gmake=no \
+        src/build-system/Makefile.meta_l \
+        src/build-system/Makefile.meta_r \
+        src/build-system/Makefile.requirements \
+        src/build-system/Makefile.rules_with_autodep.in; do
+
+        substituteInPlace $mk \
+            --replace /bin/echo ${coreutils}/bin/echo
+    done
+    for mk in src/build-system/Makefile.meta_p \
+        src/build-system/Makefile.rules_with_autodep.in \
+        src/build-system/Makefile.protobuf.in ; do
+
+        substituteInPlace $mk \
+            --replace /bin/mv ${coreutils}/bin/mv
+    done
+
+
+    substituteInPlace src/build-system/configure \
+        --replace /bin/pwd ${coreutils}/bin/pwd \
+        --replace /bin/ln ${coreutils}/bin/ln
+
+    substituteInPlace src/build-system/configure.ac \
+        --replace /bin/pwd ${coreutils}/bin/pwd \
+        --replace /bin/ln ${coreutils}/bin/ln
+
+    substituteInPlace src/build-system/Makefile.meta_l \
+        --replace /bin/date ${coreutils}/bin/date
+  '';
+
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
+  nativeBuildInputs = [ perl ];
+
+  # perl is necessary in buildInputs so that installed perl scripts get patched
+  # correctly
+  buildInputs = [ coreutils perl gawk zlib bzip2 cpio ]
+    ++ lib.optionals stdenv.isDarwin [ ApplicationServices ];
+  hardeningDisable = [ "format" ];
+
+  postInstall = ''
+    substituteInPlace $out/bin/get_species_taxids.sh \
+        --replace /bin/rm ${coreutils}/bin/rm
+  '';
+  patches = [ ./no_slash_bin.patch ];
+
+  enableParallelBuilding = true;
+
+  # Many tests require either network access or locally available databases
+  doCheck = false;
+
+  meta = with lib; {
+    description = ''Basic Local Alignment Search Tool (BLAST) finds regions of
+    similarity between biological sequences'';
+    homepage = "https://blast.ncbi.nlm.nih.gov/Blast.cgi";
+    license = licenses.publicDomain;
+
+    # Version 2.10.0 fails on Darwin
+    # See https://github.com/NixOS/nixpkgs/pull/61430
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ luispedro ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/blast/no_slash_bin.patch b/nixpkgs/pkgs/applications/science/biology/blast/no_slash_bin.patch
new file mode 100644
index 000000000000..851e37fa905d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/blast/no_slash_bin.patch
@@ -0,0 +1,178 @@
+diff -u --recursive ncbi-blast-2.9.0+-src/scripts/common/impl/collect_outside_libs.sh ncbi-blast-2.9.0+-src.patched/scripts/common/impl/collect_outside_libs.sh
+--- ncbi-blast-2.9.0+-src/scripts/common/impl/collect_outside_libs.sh	2014-08-01 22:01:17.000000000 +0800
++++ ncbi-blast-2.9.0+-src.patched/scripts/common/impl/collect_outside_libs.sh	2019-05-15 12:40:44.145239480 +0800
+@@ -1,8 +1,5 @@
+ #!/bin/sh
+ set -e
+-PATH=/bin:/usr/bin
+-export PATH
+-unset CDPATH
+ 
+ base=$1
+ search=`echo ${2-$LD_LIBRARY_PATH} | tr : ' '`
+diff -u --recursive ncbi-blast-2.9.0+-src/scripts/common/impl/create_flat_tuneups.sh ncbi-blast-2.9.0+-src.patched/scripts/common/impl/create_flat_tuneups.sh
+--- ncbi-blast-2.9.0+-src/scripts/common/impl/create_flat_tuneups.sh	2011-08-17 02:55:10.000000000 +0800
++++ ncbi-blast-2.9.0+-src.patched/scripts/common/impl/create_flat_tuneups.sh	2019-05-15 12:40:48.449276574 +0800
+@@ -1,9 +1,6 @@
+ #!/bin/sh
+ id='$Id: create_flat_tuneups.sh 331412 2011-08-16 18:55:10Z ucko $'
+ 
+-PATH=/bin:/usr/bin
+-export PATH
+-
+ exec > auto_flat_tuneups.mk
+ 
+ cat <<EOF
+diff -u --recursive ncbi-blast-2.9.0+-src/scripts/common/impl/get_lock.sh ncbi-blast-2.9.0+-src.patched/scripts/common/impl/get_lock.sh
+--- ncbi-blast-2.9.0+-src/scripts/common/impl/get_lock.sh	2011-08-20 04:12:28.000000000 +0800
++++ ncbi-blast-2.9.0+-src.patched/scripts/common/impl/get_lock.sh	2019-05-15 12:40:52.901315000 +0800
+@@ -1,7 +1,5 @@
+ #!/bin/sh
+ 
+-PATH=/bin:/usr/bin
+-export PATH
+ 
+ dir=$1.lock
+ 
+diff -u --recursive ncbi-blast-2.9.0+-src/scripts/common/impl/if_diff.sh ncbi-blast-2.9.0+-src.patched/scripts/common/impl/if_diff.sh
+--- ncbi-blast-2.9.0+-src/scripts/common/impl/if_diff.sh	2014-07-30 22:06:45.000000000 +0800
++++ ncbi-blast-2.9.0+-src.patched/scripts/common/impl/if_diff.sh	2019-05-15 12:42:57.298410841 +0800
+@@ -4,9 +4,6 @@
+ # Author:  Denis Vakatov (vakatov@ncbi.nlm.nih.gov)
+ #################################
+ 
+-orig_PATH=$PATH
+-PATH=/bin:/usr/bin
+-
+ script_name=`basename $0`
+ script_args="$*"
+ 
+@@ -16,7 +13,7 @@
+ base_action=`basename "$action"`
+ case "$base_action" in
+   cp | cp\ * | ln | ln\ * )
+-      action=/bin/$base_action
++      action=$base_action
+       rm="rm -f"
+       ;;
+   * )
+@@ -58,10 +55,8 @@
+   shift
+   cmd="$* $dest_file"
+   test "$quiet" = yes || echo "$cmd"
+-  PATH=$orig_PATH
+   "$@" "$dest"
+   status=$?
+-  PATH=/bin:/usr/bin
+   return $status
+ }
+ 
+@@ -74,7 +69,7 @@
+   case "$base_action" in
+     ln | ln\ -f )
+       test "$quiet" = yes || echo "failed; trying \"cp -p ...\" instead"
+-      cmd="/bin/cp -p $src_file $dest_file"
++      cmd="cp -p $src_file $dest_file"
+       ExecHelper "$dest_file" /bin/cp -p "$src_file"  ||
+       Usage "\"$cmd\" failed"
+       ;;
+diff -u --recursive ncbi-blast-2.9.0+-src/scripts/common/impl/make_lock_map.sh ncbi-blast-2.9.0+-src.patched/scripts/common/impl/make_lock_map.sh
+--- ncbi-blast-2.9.0+-src/scripts/common/impl/make_lock_map.sh	2011-11-17 04:43:52.000000000 +0800
++++ ncbi-blast-2.9.0+-src.patched/scripts/common/impl/make_lock_map.sh	2019-05-15 12:40:56.769348434 +0800
+@@ -1,8 +1,6 @@
+ #!/bin/sh
+ # $Id: make_lock_map.sh 344587 2011-11-16 20:43:52Z ucko $
+ 
+-PATH=/bin:/usr/bin
+-export PATH
+ 
+ act=false
+ cache_dir='.#SRC-cache'
+diff -u --recursive ncbi-blast-2.9.0+-src/scripts/common/impl/run_with_lock.sh ncbi-blast-2.9.0+-src.patched/scripts/common/impl/run_with_lock.sh
+--- ncbi-blast-2.9.0+-src/scripts/common/impl/run_with_lock.sh	2015-10-29 22:36:05.000000000 +0800
++++ ncbi-blast-2.9.0+-src.patched/scripts/common/impl/run_with_lock.sh	2019-05-15 12:41:53.401842849 +0800
+@@ -1,10 +1,6 @@
+ #!/bin/sh
+ # $Id: run_with_lock.sh 483249 2015-10-29 14:36:05Z ucko $
+ 
+-orig_PATH=$PATH
+-PATH=/bin:/usr/bin
+-export PATH
+-
+ base=
+ logfile=
+ map=
+@@ -23,7 +19,7 @@
+ : ${base:=`basename "$1"`}
+ 
+ clean_up () {
+-    /bin/rm -rf "$base.lock"
++    rm -rf "$base.lock"
+ }
+ 
+ case $0 in
+@@ -45,7 +41,7 @@
+     trap "clean_up; exit $error_status" 1 2 15
+     if [ -n "$logfile" ]; then
+         status_file=$base.lock/status
+-        (PATH=$orig_PATH; export PATH; "$@"; echo $? > "$status_file") 2>&1 \
++        ("$@"; echo $? > "$status_file") 2>&1 \
+             | tee "$logfile.new"
+         # Emulate egrep -q to avoid having to move from under scripts.
+         if [ ! -f "$logfile" ]  \
+@@ -58,8 +54,6 @@
+             status=1
+         fi
+     else
+-        PATH=$orig_PATH
+-        export PATH
+         "$@"
+         status=$?
+     fi
+diff -u --recursive ncbi-blast-2.9.0+-src/scripts/common/impl/strip_for_install.sh ncbi-blast-2.9.0+-src.patched/scripts/common/impl/strip_for_install.sh
+--- ncbi-blast-2.9.0+-src/scripts/common/impl/strip_for_install.sh	2013-09-24 03:06:51.000000000 +0800
++++ ncbi-blast-2.9.0+-src.patched/scripts/common/impl/strip_for_install.sh	2019-05-15 12:40:13.272975092 +0800
+@@ -1,8 +1,5 @@
+ #!/bin/sh
+ 
+-PATH=/bin:/usr/bin:/usr/ccs/bin
+-export PATH
+-
+ case "$1" in
+     --dirs )
+         shift
+--- ncbi-blast-2.9.0+-src/scripts/common/impl/update_configurable.sh	2017-07-13 22:53:24.000000000 +0800
++++ ncbi-blast-2.9.0+-src.patched/scripts/common/impl/update_configurable.sh	2019-05-15 15:03:35.861276083 +0800
+@@ -1,6 +1,4 @@
+ #!/bin/sh
+-PATH=/bin:/usr/bin
+-export PATH
+ 
+ script_name=`basename $0`
+ script_dir=`dirname $0`
+--- ncbi-blast-2.9.0+-src/src/build-system/Makefile.mk.in	2019-01-04 01:38:37.000000000 +0800
++++ ncbi-blast-2.9.0+-src.patched/src/build-system/Makefile.mk.in	2019-05-15 15:14:41.749416495 +0800
+@@ -50,12 +50,12 @@
+ 
+ ### Auxiliary commands, filters
+ 
+-RM       = /bin/rm -f
+-RMDIR    = /bin/rm -rf
+-COPY     = /bin/cp -p
++RM       = rm -f
++RMDIR    = rm -rf
++COPY     = cp -p
+ BINCOPY  = @BINCOPY@
+ TOUCH    = @TOUCH@
+-MKDIR    = /bin/mkdir
++MKDIR    = mkdir
+ BINTOUCH = $(TOUCH)
+ LN_S     = @LN_S@
+ GREP     = @GREP@
+--- ncbi-blast-2.9.0+-src/src/build-system/configure	2019-03-05 00:49:08.000000000 +0800
++++ ncbi-blast-2.9.0+-src.patched/src/build-system/configure	2019-05-15 16:55:40.711795042 +0800
+@@ -10417,4 +10417,0 @@
+-case "$LN_S" in
+-    /*) ;;
+-    * ) LN_S=/bin/$LN_S ;;
+-esac
diff --git a/nixpkgs/pkgs/applications/science/biology/bowtie/default.nix b/nixpkgs/pkgs/applications/science/biology/bowtie/default.nix
new file mode 100644
index 000000000000..81cdaecf2c1c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/bowtie/default.nix
@@ -0,0 +1,25 @@
+{ lib, stdenv, fetchFromGitHub, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "bowtie";
+  version = "1.3.1";
+
+  src = fetchFromGitHub {
+    owner = "BenLangmead";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "sha256-mWItmrTMPst/NnzSpxxTHcBztDqHPCza9yOsZPwp7G4=";
+  };
+
+  buildInputs = [ zlib ];
+
+  installFlags = [ "prefix=$(out)" ];
+
+  meta = with lib; {
+    description = "An ultrafast memory-efficient short read aligner";
+    license = licenses.artistic2;
+    homepage = "http://bowtie-bio.sourceforge.net";
+    maintainers = with maintainers; [ prusnak ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/bowtie2/default.nix b/nixpkgs/pkgs/applications/science/biology/bowtie2/default.nix
new file mode 100644
index 000000000000..1702079e017f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/bowtie2/default.nix
@@ -0,0 +1,26 @@
+{ lib, stdenv, fetchFromGitHub, cmake, tbb, zlib, python3, perl }:
+
+stdenv.mkDerivation rec {
+  pname = "bowtie2";
+  version = "2.4.5";
+
+  src = fetchFromGitHub {
+    owner = "BenLangmead";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "sha256-xCsTkQXrZS+Njn0YfidhPln+OwVfTXOqbtB0dCfTP2U=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  buildInputs = [ tbb zlib python3 perl ];
+
+  meta = with lib; {
+    description = "An ultrafast and memory-efficient tool for aligning sequencing reads to long reference sequences";
+    license = licenses.gpl3;
+    homepage = "http://bowtie-bio.sf.net/bowtie2";
+    maintainers = with maintainers; [ rybern ];
+    platforms = platforms.all;
+    broken = stdenv.isAarch64; # only x86 is supported
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/bppsuite/default.nix b/nixpkgs/pkgs/applications/science/biology/bppsuite/default.nix
new file mode 100644
index 000000000000..564a38708bcd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/bppsuite/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, fetchFromGitHub, cmake, bpp-core, bpp-seq, bpp-phyl, bpp-popgen }:
+
+stdenv.mkDerivation rec {
+  pname = "bppsuite";
+
+  inherit (bpp-core) version;
+
+  src = fetchFromGitHub {
+    owner = "BioPP";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "1wdwcgczqbc3m116vakvi0129wm3acln3cfc7ivqnalwvi6lrpds";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ bpp-core bpp-seq bpp-phyl bpp-popgen ];
+
+  meta = bpp-core.meta // {
+    changelog = "https://github.com/BioPP/bppsuite/blob/master/ChangeLog";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/bwa/default.nix b/nixpkgs/pkgs/applications/science/biology/bwa/default.nix
new file mode 100644
index 000000000000..a2a11b1d4517
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/bwa/default.nix
@@ -0,0 +1,38 @@
+{ lib, stdenv, fetchurl, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "bwa";
+  version = "0.7.17";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/bio-bwa/${pname}-${version}.tar.bz2";
+    sha256 = "1zfhv2zg9v1icdlq4p9ssc8k01mca5d1bd87w71py2swfi74s6yy";
+  };
+
+  buildInputs = [ zlib ];
+
+  # Avoid hardcoding gcc to allow environments with a different
+  # C compiler to build
+  preConfigure = ''
+    sed -i '/^CC/d' Makefile
+  '';
+
+  # it's unclear which headers are intended to be part of the public interface
+  # so we may find ourselves having to add more here over time
+  installPhase = ''
+    install -vD -t $out/bin bwa
+    install -vD -t $out/lib libbwa.a
+    install -vD -t $out/include bntseq.h
+    install -vD -t $out/include bwa.h
+    install -vD -t $out/include bwamem.h
+    install -vD -t $out/include bwt.h
+  '';
+
+  meta = with lib; {
+    description = "A software package for mapping low-divergent sequences against a large reference genome, such as the human genome";
+    license     = licenses.gpl3;
+    homepage    = "http://bio-bwa.sourceforge.net/";
+    maintainers = with maintainers; [ luispedro ];
+    platforms = platforms.x86_64;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/cd-hit/default.nix b/nixpkgs/pkgs/applications/science/biology/cd-hit/default.nix
new file mode 100644
index 000000000000..474c0f292af4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/cd-hit/default.nix
@@ -0,0 +1,38 @@
+{ lib, stdenv, fetchFromGitHub, makeWrapper, zlib, perl, perlPackages, openmp }:
+
+stdenv.mkDerivation rec {
+  version = "4.8.1";
+  pname = "cd-hit";
+
+  src = fetchFromGitHub {
+    owner = "weizhongli";
+    repo = "cdhit";
+    rev = "V${version}";
+    sha256 = "032nva6iiwmw59gjipm1mv0xlcckhxsf45mc2qbnv19lbis0q22i";
+  };
+
+  propagatedBuildInputs = [ perl perlPackages.TextNSP perlPackages.ImageMagick ];
+
+  nativeBuildInputs = [ zlib makeWrapper ];
+  buildInputs = lib.optional stdenv.cc.isClang openmp;
+
+  makeFlags = [
+    "CC=${stdenv.cc.targetPrefix}c++" # remove once https://github.com/weizhongli/cdhit/pull/114 is merged
+    "PREFIX=$(out)/bin"
+  ];
+
+  preInstall = "mkdir -p $out/bin";
+
+  postFixup = ''
+    wrapProgram $out/bin/FET.pl --prefix PERL5LIB : $PERL5LIB
+    wrapProgram $out/bin/plot_2d.pl --prefix PERL5LIB : $PERL5LIB
+    wrapProgram $out/bin/clstr_list_sort.pl --prefix PERL5LIB : $PERL5LIB
+  '';
+  meta = with lib; {
+    description = "Clustering and comparing protein or nucleotide sequences";
+    homepage = "http://weizhongli-lab.org/cd-hit/";
+    license = licenses.gpl2;
+    maintainers = [ maintainers.bzizou ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/clustal-omega/default.nix b/nixpkgs/pkgs/applications/science/biology/clustal-omega/default.nix
new file mode 100644
index 000000000000..6377e1fce855
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/clustal-omega/default.nix
@@ -0,0 +1,32 @@
+{ lib, stdenv, fetchurl, argtable }:
+
+stdenv.mkDerivation rec {
+  version = "1.2.4";
+  pname = "clustal-omega";
+
+  src = fetchurl {
+    url = "http://www.clustal.org/omega/${pname}-${version}.tar.gz";
+    sha256 = "1vm30mzncwdv881vrcwg11vzvrsmwy4wg80j5i0lcfk6dlld50w6";
+  };
+
+  buildInputs = [ argtable ];
+
+  preConfigure = ''
+    for f in configure \
+             src/clustal-omega-config.h \
+             src/clustal-omega-config.h \
+             src/config.h.in \
+             src/mymain.c
+    do
+      sed -i -re 's/argtable2/argtable3/g' $f
+    done
+  '';
+
+  meta = with lib; {
+    description = "General purpose multiple sequence alignment program for protein and DNA/RNA";
+    homepage = "http://www.clustal.org/omega/";
+    license = licenses.gpl2;
+    maintainers = [ maintainers.bzizou ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/cmtk/default.nix b/nixpkgs/pkgs/applications/science/biology/cmtk/default.nix
new file mode 100644
index 000000000000..b6286d11c8cb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/cmtk/default.nix
@@ -0,0 +1,27 @@
+{ lib, stdenv, fetchurl, cmake }:
+
+stdenv.mkDerivation rec {
+  pname = "cmtk";
+  version = "3.3.1";
+
+  src = fetchurl {
+    name = "cmtk-source.tar.gz";
+    url = "https://www.nitrc.org/frs/download.php/8198/CMTK-${version}-Source.tar.gz//?i_agree=1&download_now=1";
+    sha256 = "1nmsga9m7vcc4y4a6zl53ra3mwlgjwdgsq1j291awkn7zr1az6qs";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=c++11-narrowing";
+
+  meta = with lib; {
+    description = "Computational Morphometry Toolkit ";
+    longDescription = ''A software toolkit for computational morphometry of
+      biomedical images, CMTK comprises a set of command line tools and a
+      back-end general-purpose library for processing and I/O'';
+    maintainers = with maintainers; [ tbenst ];
+    platforms = platforms.all;
+    license = licenses.gpl3;
+    homepage = "https://www.nitrc.org/projects/cmtk/";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/conglomerate/default.nix b/nixpkgs/pkgs/applications/science/biology/conglomerate/default.nix
new file mode 100644
index 000000000000..fe1c1f5511d1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/conglomerate/default.nix
@@ -0,0 +1,37 @@
+{ lib, stdenv, fetchFromGitHub, cmake, coreutils, perlPackages, bicpl, libminc, zlib, minc_tools,
+  makeWrapper }:
+
+stdenv.mkDerivation rec {
+  pname = "conglomerate";
+  version = "unstable-2017-09-10";
+
+  src = fetchFromGitHub {
+    owner  = "BIC-MNI";
+    repo   = pname;
+    rev    = "7343238bc6215942c7ecc885a224f24433a291b0";
+    sha256 = "1mlqgmy3jc13bv7d01rjwldxq0p4ayqic85xcl222hhifi3w2prr";
+  };
+
+  nativeBuildInputs = [ cmake makeWrapper ];
+  buildInputs = [ libminc zlib bicpl ];
+  propagatedBuildInputs = [ coreutils minc_tools ] ++ (with perlPackages; [ perl GetoptTabular MNI-Perllib ]);
+
+  cmakeFlags = [
+    "-DLIBMINC_DIR=${libminc}/lib/cmake"
+    "-DBICPL_DIR=${bicpl}/lib"
+  ];
+
+  postFixup = ''
+    for p in $out/bin/*; do
+      wrapProgram $p --prefix PERL5LIB : $PERL5LIB --set PATH "${lib.makeBinPath [ coreutils minc_tools ]}";
+    done
+  '';
+
+  meta = with lib; {
+    homepage = "https://github.com/BIC-MNI/conglomerate";
+    description = "More command-line utilities for working with MINC files";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license   = licenses.free;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/dcm2niix/default.nix b/nixpkgs/pkgs/applications/science/biology/dcm2niix/default.nix
new file mode 100644
index 000000000000..36dddad5db5a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/dcm2niix/default.nix
@@ -0,0 +1,33 @@
+{ lib, stdenv
+, fetchFromGitHub
+, cmake
+, libyamlcpp
+, git
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.0.20211006";
+  pname = "dcm2niix";
+
+  src = fetchFromGitHub {
+    owner = "rordenlab";
+    repo = "dcm2niix";
+    rev = "v${version}";
+    sha256 = "sha256-fQAVOzynMdSLDfhcYWcaXkFW/mnv4zySGLVJNE7ql/c=";
+  };
+
+  nativeBuildInputs = [ cmake git ];
+  buildInputs = [ libyamlcpp ];
+
+  meta = with lib; {
+    description = "DICOM to NIfTI converter";
+    longDescription = ''
+      dcm2niix is a designed to convert neuroimaging data from the
+      DICOM format to the NIfTI format.
+    '';
+    homepage = "https://www.nitrc.org/projects/dcm2nii";
+    license = licenses.bsd3;
+    maintainers = [ maintainers.ashgillman ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/deeptools/default.nix b/nixpkgs/pkgs/applications/science/biology/deeptools/default.nix
new file mode 100644
index 000000000000..1739a4c999a4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/deeptools/default.nix
@@ -0,0 +1,42 @@
+{ lib, python, fetchFromGitHub }:
+with python.pkgs;
+buildPythonApplication rec {
+  pname = "deepTools";
+  version = "3.5.1";
+
+  src = fetchFromGitHub {
+    owner = "deeptools";
+    repo = "deepTools";
+    rev = version;
+    sha256 = "07v8vb2x4b0mgw0mvcj91vj1fqbcwizwsniysl2cvmv93gad8gbp";
+  };
+
+  propagatedBuildInputs = [
+    numpy
+    numpydoc
+    scipy
+    py2bit
+    pybigwig
+    pysam
+    matplotlib
+    plotly
+    deeptoolsintervals
+  ];
+
+  checkInputs = [ nose ];
+
+  meta = with lib; {
+    homepage = "https://deeptools.readthedocs.io/en/develop";
+    description = "Tools for exploring deep DNA sequencing data";
+    longDescription = ''
+      deepTools contains useful modules to process the mapped reads data for multiple
+      quality checks, creating normalized coverage files in standard bedGraph and bigWig
+      file formats, that allow comparison between different files (for example, treatment and control).
+      Finally, using such normalized and standardized files, deepTools can create many
+      publication-ready visualizations to identify enrichments and for functional
+      annotations of the genome.
+    '';
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ scalavision ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/delly/default.nix b/nixpkgs/pkgs/applications/science/biology/delly/default.nix
new file mode 100644
index 000000000000..f2e0d3a50c24
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/delly/default.nix
@@ -0,0 +1,40 @@
+{ lib, stdenv, fetchpatch, fetchFromGitHub, htslib, zlib, bzip2, xz, ncurses, boost }:
+
+stdenv.mkDerivation rec {
+  pname = "delly";
+  version = "0.9.1";
+
+  src = fetchFromGitHub {
+      owner = "dellytools";
+      repo = pname;
+      rev = "v${version}";
+      sha256 = "sha256-p1pryP+ktGt8OHFiASJQ3T+K94cNBG9fLxsJ2n/T+DA=";
+  };
+
+  buildInputs = [ zlib htslib bzip2 xz ncurses boost ];
+
+  EBROOTHTSLIB = htslib;
+
+  installPhase = ''
+    runHook preInstall
+
+    install -Dm555 src/delly $out/bin/delly
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Structural variant caller for mapped DNA sequenced data";
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ scalavision ];
+    platforms = platforms.linux;
+    longDescription = ''
+      Delly is an integrated structural variant (SV) prediction method
+      that can discover, genotype and visualize deletions, tandem duplications,
+      inversions and translocations at single-nucleotide resolution in
+      short-read massively parallel sequencing data. It uses paired-ends,
+      split-reads and read-depth to sensitively and accurately delineate
+      genomic rearrangements throughout the genome.
+    '';
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/diamond/default.nix b/nixpkgs/pkgs/applications/science/biology/diamond/default.nix
new file mode 100644
index 000000000000..1221684f15c6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/diamond/default.nix
@@ -0,0 +1,44 @@
+{ lib, stdenv, fetchFromGitHub, cmake, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "diamond";
+  version = "0.8.36";
+
+  src = fetchFromGitHub {
+    owner = "bbuchfink";
+    repo = "diamond";
+    rev = "v${version}";
+    sha256 = "sha256-7uqOQOzkYN0RNwKBGUZ/Ny5NVZMoGByOk+GUvjdBzck=";
+  };
+
+  patches = [
+    ./diamond-0.8.36-no-warning.patch
+  ];
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ zlib ];
+
+  meta = with lib; {
+    description = "Accelerated BLAST compatible local sequence aligner";
+    longDescription = ''
+      A sequence aligner for protein and translated DNA
+      searches and functions as a drop-in replacement for the NCBI BLAST
+      software tools. It is suitable for protein-protein search as well as
+      DNA-protein search on short reads and longer sequences including contigs
+      and assemblies, providing a speedup of BLAST ranging up to x20,000.
+
+      DIAMOND is developed by Benjamin Buchfink. Feel free to contact him for support (Email Twitter).
+
+      If you use DIAMOND in published research, please cite
+      B. Buchfink, Xie C., D. Huson,
+      "Fast and sensitive protein alignment using DIAMOND",
+      Nature Methods 12, 59-60 (2015).
+    '';
+    homepage = "https://github.com/bbuchfink/diamond";
+    license = {
+      fullName = "University of Tuebingen, Benjamin Buchfink";
+      url = "https://raw.githubusercontent.com/bbuchfink/diamond/master/src/COPYING";
+    };
+    maintainers = [ maintainers.metabar ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/diamond/diamond-0.8.36-no-warning.patch b/nixpkgs/pkgs/applications/science/biology/diamond/diamond-0.8.36-no-warning.patch
new file mode 100644
index 000000000000..a16d475c5564
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/diamond/diamond-0.8.36-no-warning.patch
@@ -0,0 +1,20 @@
+diff -u -r diamond-0.8.36/src/dp/scalar_traceback.h diamond-0.8.36-patched/src/dp/scalar_traceback.h
+--- diamond-0.8.36/src/dp/scalar_traceback.h	2017-02-06 16:32:05.000000000 +0100
++++ diamond-0.8.36-patched/src/dp/scalar_traceback.h	2017-02-23 15:13:24.000000000 +0100
+@@ -19,6 +19,7 @@
+ #ifndef SCALAR_TRACEBACK_H_
+ #define SCALAR_TRACEBACK_H_
+ 
++#include <cmath>
+ #include <exception>
+ #include "../basic/score_matrix.h"
+ 
+@@ -31,7 +32,7 @@
+ template<>
+ inline bool almost_equal<float>(float x, float y)
+ {
+-	return abs(x - y) < 0.001f;
++	return std::abs(x - y) < 0.001f;
+ }
+ 
+ template<typename _score>
diff --git a/nixpkgs/pkgs/applications/science/biology/ecopcr/default.nix b/nixpkgs/pkgs/applications/science/biology/ecopcr/default.nix
new file mode 100644
index 000000000000..4ed11857a30e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/ecopcr/default.nix
@@ -0,0 +1,38 @@
+{ lib, stdenv, fetchurl, gcc, zlib, python27 }:
+
+stdenv.mkDerivation rec {
+  pname = "ecopcr";
+  version = "0.8.0";
+
+  src = fetchurl {
+    url = "https://git.metabarcoding.org/obitools/ecopcr/uploads/6f37991b325c8c171df7e79e6ae8d080/ecopcr-${version}.tar.gz";
+    sha256 = "10c58hj25z78jh0g3zcbx4890yd2qrvaaanyx8mn9p49mmyf5pk6";
+  };
+
+  sourceRoot = "ecoPCR/src";
+
+  buildInputs = [ gcc python27 zlib ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp -v ecoPCR $out/bin
+    cp -v ecogrep $out/bin
+    cp -v ecofind $out/bin
+    cp -v ../tools/ecoPCRFormat.py $out/bin/ecoPCRFormat
+    chmod a+x $out/bin/ecoPCRFormat
+  '';
+
+  meta = with lib; {
+    description = "Electronic PCR software tool";
+    longDescription = ''
+      ecoPCR is an electronic PCR software developed by the LECA. It
+      helps you estimate Barcode primers quality. In conjunction with
+      OBITools, you can postprocess ecoPCR output to compute barcode
+      coverage and barcode specificity. New barcode primers can be
+      developed using the ecoPrimers software.
+    '';
+    homepage = "https://git.metabarcoding.org/obitools/ecopcr/wikis/home";
+    license = licenses.cecill20;
+    maintainers = [ maintainers.metabar ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/eggnog-mapper/default.nix b/nixpkgs/pkgs/applications/science/biology/eggnog-mapper/default.nix
new file mode 100644
index 000000000000..b42fed8da281
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/eggnog-mapper/default.nix
@@ -0,0 +1,40 @@
+{ lib, fetchFromGitHub, fetchpatch, makeWrapper, python27Packages, wget, diamond, hmmer }:
+
+python27Packages.buildPythonApplication rec {
+  pname = "eggnog-mapper";
+  version = "1.0.3";
+
+  src = fetchFromGitHub {
+    owner = "eggnogdb";
+    repo = "eggnog-mapper";
+    rev = version;
+    sha256 = "1aaaflppy84bhkh2hb5gnzm4xgrz0rz0cgfpadr9w8cva8p0sqdv";
+  };
+
+  patches = (fetchpatch {
+    url = "https://github.com/eggnogdb/eggnog-mapper/commit/6972f601ade85b65090efca747d2302acb58507f.patch";
+    sha256 = "0abnmn0bh11jihf5d3cggiild1ykawzv5f5fhb4cyyi8fvy4hcxf";
+  });
+
+  nativeBuildInputs = [ makeWrapper ];
+  propagatedBuildInputs = [ python27Packages.biopython wget diamond hmmer ];
+
+  # make emapper find diamond & hmmer
+  makeWrapperArgs = [
+    ''--prefix PATH ':' "${diamond}/bin"''
+    ''--prefix PATH ':' "${hmmer}/bin"''
+    ];
+
+  # Tests rely on some of the databases being available, which is not bundled
+  # with this package as (1) in total, they represent >100GB of data, and (2)
+  # the user can download only those that interest them.
+  doCheck = false;
+
+  meta = with lib; {
+    description = "Fast genome-wide functional annotation through orthology assignment";
+    license = licenses.gpl2;
+    homepage = "https://github.com/eggnogdb/eggnog-mapper/wiki";
+    maintainers = with maintainers; [ luispedro ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/emboss/default.nix b/nixpkgs/pkgs/applications/science/biology/emboss/default.nix
new file mode 100644
index 000000000000..29669d027303
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/emboss/default.nix
@@ -0,0 +1,30 @@
+{ lib, stdenv, fetchurl, readline, perl, libharu, libX11, libpng, libXt, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "emboss";
+  version = "6.6.0";
+
+  src = fetchurl {
+    url = "ftp://emboss.open-bio.org/pub/EMBOSS/EMBOSS-${version}.tar.gz";
+    sha256 = "7184a763d39ad96bb598bfd531628a34aa53e474db9e7cac4416c2a40ab10c6e";
+  };
+
+  buildInputs = [ readline perl libharu libpng libX11 libXt zlib ];
+
+  configureFlags = [ "--with-hpdf=${libharu}" "--with-pngdriver=${zlib}" ];
+
+  postConfigure = ''
+    sed -i 's@$(bindir)/embossupdate@true@' Makefile
+  '';
+
+  meta = {
+    description = "The European Molecular Biology Open Software Suite";
+    longDescription = ''EMBOSS is a free Open Source software analysis package
+    specially developed for the needs of the molecular biology (e.g. EMBnet)
+    user community, including libraries. The software automatically copes with
+    data in a variety of formats and even allows transparent retrieval of
+    sequence data from the web.'';
+    license = lib.licenses.gpl2;
+    homepage = "http://emboss.sourceforge.net/";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/est-sfs/default.nix b/nixpkgs/pkgs/applications/science/biology/est-sfs/default.nix
new file mode 100644
index 000000000000..fe4a3e49930c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/est-sfs/default.nix
@@ -0,0 +1,32 @@
+{ lib, stdenv, fetchurl, gsl }:
+
+stdenv.mkDerivation rec {
+  pname = "est-sfs";
+  version = "2.03";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/est-usfs/${pname}-release-${version}.tar.gz";
+    sha256 = "1hvamrgagz0xi89w8qafyd9mjrdpyika8zm22drddnjkp4sdj65n";
+  };
+
+  buildInputs = [ gsl ];
+
+  makeFlags = [
+    "CC=${stdenv.cc.targetPrefix}cc"
+  ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mkdir -p $out/share/doc/${pname}
+    cp est-sfs $out/bin
+    cp est-sfs-documentation.pdf $out/share/doc/${pname}
+  '';
+
+  meta = with lib; {
+    homepage = "https://sourceforge.net/projects/est-usfs";
+    description = "Estimate the unfolded site frequency spectrum and ancestral states";
+    license = licenses.gpl3;
+    maintainers = [ maintainers.bzizou ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/exonerate/default.nix b/nixpkgs/pkgs/applications/science/biology/exonerate/default.nix
new file mode 100644
index 000000000000..f7b6bf6c14ce
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/exonerate/default.nix
@@ -0,0 +1,25 @@
+{ lib, stdenv, fetchurl, glib, pkg-config }:
+
+stdenv.mkDerivation rec {
+  version = "2.4.0";
+  pname = "exonerate";
+
+  src = fetchurl {
+    url = "http://ftp.ebi.ac.uk/pub/software/vertebrategenomics/exonerate/${pname}-${version}.tar.gz";
+    sha256 = "0hj0m9xygiqsdxvbg79wq579kbrx1mdrabi2bzqz2zn9qwfjcjgq";
+  };
+
+  doCheck = true;
+
+  buildInputs = [ glib ];
+
+  nativeBuildInputs = [ pkg-config ];
+
+  meta = with lib; {
+    description = "Generic tool for sequence alignment";
+    homepage = "https://www.ebi.ac.uk/about/vertebrate-genomics/software/exonerate";
+    license = licenses.gpl3;
+    maintainers = [ maintainers.bzizou ];
+    platforms = platforms.unix ;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/fastp/default.nix b/nixpkgs/pkgs/applications/science/biology/fastp/default.nix
new file mode 100644
index 000000000000..4dace9e63b42
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/fastp/default.nix
@@ -0,0 +1,33 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, zlib
+, libdeflate
+, isa-l
+}:
+
+stdenv.mkDerivation rec {
+  pname = "fastp";
+  version = "0.23.2";
+
+  src = fetchFromGitHub {
+    owner = "OpenGene";
+    repo = "fastp";
+    rev = "v${version}";
+    sha256 = "sha256-W1mXTfxD7/gHJhao6qqbNcyM3t2cfrUYiBYPJi/O1RI=";
+  };
+
+  buildInputs = [ zlib libdeflate isa-l ];
+
+  installPhase = ''
+    install -D fastp $out/bin/fastp
+  '';
+
+  meta = with lib; {
+    description = "Ultra-fast all-in-one FASTQ preprocessor";
+    license = licenses.mit;
+    homepage = "https://github.com/OpenGene/fastp";
+    maintainers = with maintainers; [ jbedo ];
+    platforms = platforms.x86_64;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/febio-studio/default.nix b/nixpkgs/pkgs/applications/science/biology/febio-studio/default.nix
new file mode 100644
index 000000000000..e334637f243c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/febio-studio/default.nix
@@ -0,0 +1,61 @@
+{ lib, stdenv, fetchFromGitHub, cmake, zlib, libglvnd, libGLU, wrapQtAppsHook
+, sshSupport ? true, openssl, libssh
+, tetgenSupport ? true, tetgen
+, ffmpegSupport ? true, ffmpeg
+, dicomSupport  ? false, dcmtk
+, withModelRepo ? true
+, withCadFeatures ? false
+}:
+
+stdenv.mkDerivation rec {
+  pname = "febio-studio";
+  version = "1.6.1";
+
+  src = fetchFromGitHub {
+    owner = "febiosoftware";
+    repo = "FEBioStudio";
+    rev = "v${version}";
+    sha256 = "0r6pg49i0q9idp7pjymj7mlxd63qjvmfvg0l7fmx87y1yd2hfw4h";
+  };
+
+  patches = [
+    ./febio-studio-cmake.patch # Fix Errors that appear with certain Cmake flags
+  ];
+
+  cmakeFlags = [
+    "-DQt_Ver=5"
+    "-DNOT_FIRST=On"
+    "-DOpenGL_GL_PREFERENCE=GLVND"
+  ]
+    ++ lib.optional sshSupport "-DUSE_SSH=On"
+    ++ lib.optional tetgenSupport "-DUSE_TETGEN=On"
+    ++ lib.optional ffmpegSupport "-DUSE_FFMPEG=On"
+    ++ lib.optional dicomSupport "-DUSE_DICOM=On"
+    ++ lib.optional withModelRepo "-DMODEL_REPO=On"
+    ++ lib.optional withCadFeatures "-DCAD_FEATURES=On"
+  ;
+
+
+  installPhase = ''
+    runHook preInstall
+    mkdir -p $out/
+    cp -R bin $out/
+    runHook postInstall
+  '';
+
+  nativeBuildInputs = [ cmake wrapQtAppsHook ];
+  buildInputs = [ zlib libglvnd libGLU openssl libssh ]
+    ++ lib.optional sshSupport openssl
+    ++ lib.optional tetgenSupport tetgen
+    ++ lib.optional ffmpegSupport ffmpeg
+    ++ lib.optional dicomSupport dcmtk
+  ;
+
+  meta = with lib; {
+    description = "FEBio Suite Solver";
+    license = with licenses; [ mit ];
+    homepage = "https://febio.org/";
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ Scriptkiddi ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/febio-studio/febio-studio-cmake.patch b/nixpkgs/pkgs/applications/science/biology/febio-studio/febio-studio-cmake.patch
new file mode 100644
index 000000000000..e694f6c3b89f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/febio-studio/febio-studio-cmake.patch
@@ -0,0 +1,38 @@
+diff --git a/FEBioStudio/RepositoryPanel.cpp b/FEBioStudio/RepositoryPanel.cpp
+index 382db303..314cdc68 100644
+--- a/FEBioStudio/RepositoryPanel.cpp
++++ b/FEBioStudio/RepositoryPanel.cpp
+@@ -1364,10 +1364,10 @@ void CRepositoryPanel::loadingPageProgress(qint64 bytesSent, qint64 bytesTotal)
+ 

+ #else

+ 

+-CRepositoryPanel::CRepositoryPanel(CMainWindow* pwnd, QWidget* parent){}

++CRepositoryPanel::CRepositoryPanel(CMainWindow* pwnd, QDockWidget* parent){}

+ CRepositoryPanel::~CRepositoryPanel(){}

+ void CRepositoryPanel::OpenLink(const QString& link) {}

+-// void CRepositoryPanel::Raise() {}

++void CRepositoryPanel::Raise() {}

+ void CRepositoryPanel::SetModelList(){}

+ void CRepositoryPanel::ShowMessage(QString message) {}

+ void CRepositoryPanel::ShowWelcomeMessage(QByteArray messages) {}

+@@ -1396,6 +1396,7 @@ void CRepositoryPanel::on_actionSearch_triggered() {}
+ void CRepositoryPanel::on_actionClearSearch_triggered() {}

+ void CRepositoryPanel::on_actionDeleteRemote_triggered() {}

+ void CRepositoryPanel::on_actionModify_triggered() {}

++void CRepositoryPanel::on_actionCopyPermalink_triggered() {}

+ void CRepositoryPanel::on_treeWidget_itemSelectionChanged() {}

+ void CRepositoryPanel::on_treeWidget_customContextMenuRequested(const QPoint &pos) {}

+ void CRepositoryPanel::DownloadItem(CustomTreeWidgetItem *item) {}

+diff --git a/FEBioStudio/WzdUpload.cpp b/FEBioStudio/WzdUpload.cpp
+index 5ce74346..20062e06 100644
+--- a/FEBioStudio/WzdUpload.cpp
++++ b/FEBioStudio/WzdUpload.cpp
+@@ -1183,7 +1183,7 @@ void CWzdUpload::on_saveJson_triggered()
+ 		getProjectJson(&projectInfo);
+ 
+ 		QFile file(filedlg.selectedFiles()[0]);
+-		file.open(QIODeviceBase::WriteOnly);
++		file.open(QIODevice::WriteOnly);
+ 		file.write(projectInfo);
+ 		file.close();
+ 	}
diff --git a/nixpkgs/pkgs/applications/science/biology/freebayes/default.nix b/nixpkgs/pkgs/applications/science/biology/freebayes/default.nix
new file mode 100644
index 000000000000..8646b8ca54a8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/freebayes/default.nix
@@ -0,0 +1,29 @@
+{ lib, stdenv, fetchFromGitHub, zlib, bzip2, xz }:
+
+stdenv.mkDerivation rec {
+  pname = "freebayes";
+  version = "1.3.1";
+
+  src = fetchFromGitHub {
+    name = "freebayes-${version}-src";
+    owner  = "ekg";
+    repo   = "freebayes";
+    rev    = "v${version}";
+    sha256 = "035nriknjqq8gvil81vvsmvqwi35v80q8h1cw24vd1gdyn1x7bys";
+    fetchSubmodules = true;
+  };
+
+  buildInputs = [ zlib bzip2 xz ];
+
+  installPhase = ''
+    install -vD bin/freebayes bin/bamleftalign scripts/* -t $out/bin
+  '';
+
+  meta = with lib; {
+    description = "Bayesian haplotype-based polymorphism discovery and genotyping";
+    license     = licenses.mit;
+    homepage    = "https://github.com/ekg/freebayes";
+    maintainers = with maintainers; [ jdagilliland ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/genmap/default.nix b/nixpkgs/pkgs/applications/science/biology/genmap/default.nix
new file mode 100644
index 000000000000..c2d1b8da7af1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/genmap/default.nix
@@ -0,0 +1,40 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, cmake
+, gtest
+, which
+}:
+
+stdenv.mkDerivation rec {
+  pname = "genmap";
+  version = "1.3.0";
+
+  src = fetchFromGitHub {
+    owner = "cpockrandt";
+    repo = "genmap";
+    rev = "genmap-v${version}";
+    fetchSubmodules = true;
+    sha256 = "sha256-7sIKBRMNzyCrZ/c2nXkknb6a5YsXe6DRE2IFhp6AviY=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  doCheck = true;
+  patches = [ ./gtest.patch ];
+  checkInputs = [ gtest which ];
+  preCheck = "make genmap_algo_test";
+
+  # disable benchmarks
+  preConfigure = ''
+    echo > benchmarks/CMakeLists.txt
+  '';
+
+  meta = {
+    description = "Ultra-fast computation of genome mappability";
+    license = lib.licenses.bsd3;
+    homepage = "https://github.com/cpockrandt/genmap";
+    maintainers = with lib.maintainers; [ jbedo ];
+    platforms = lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/genmap/gtest.patch b/nixpkgs/pkgs/applications/science/biology/genmap/gtest.patch
new file mode 100644
index 000000000000..f01d0e115eb5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/genmap/gtest.patch
@@ -0,0 +1,30 @@
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index 67ec8f9..ed0b2e0 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -2,23 +2,14 @@
+ #  GenMap tests
+ # ===========================================================================
+ 
+-include (ExternalProject)
+-ExternalProject_Add (googletest
+-                     PREFIX "${CMAKE_CURRENT_BINARY_DIR}/googletest"
+-                     GIT_REPOSITORY "https://github.com/google/googletest.git"
+-                     INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}"
+-                     CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}"
+-                     GIT_TAG release-1.10.0
+-                     UPDATE_DISCONNECTED YES)
+ 
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # TODO: --coverage
+ add_executable (genmap_algo_test tests.cpp)
+-add_dependencies (genmap_algo_test googletest)
+ 
+ include_directories (${CMAKE_CURRENT_BINARY_DIR}/include)
+ target_link_libraries (genmap_algo_test ${SEQAN_LIBRARIES})
+-target_link_libraries (genmap_algo_test ${CMAKE_CURRENT_BINARY_DIR}/lib/libgtest.a)
+-target_link_libraries (genmap_algo_test ${CMAKE_CURRENT_BINARY_DIR}/lib/libgtest_main.a)
++target_link_libraries (genmap_algo_test -lgtest)
++target_link_libraries (genmap_algo_test -lgtest_main)
+ target_link_libraries (genmap_algo_test pthread)
+ 
+ add_test(NAME algo_test COMMAND genmap_algo_test)
diff --git a/nixpkgs/pkgs/applications/science/biology/hisat2/default.nix b/nixpkgs/pkgs/applications/science/biology/hisat2/default.nix
new file mode 100644
index 000000000000..67c39031b773
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/hisat2/default.nix
@@ -0,0 +1,46 @@
+{lib, stdenv, fetchFromGitHub, unzip, which, python3, perl}:
+
+stdenv.mkDerivation rec {
+  pname = "hisat2";
+  version = "2.2.1";
+
+  src = fetchFromGitHub {
+    owner = "DaehwanKimLab";
+    repo = "hisat2";
+    rev = "v${version}";
+    sha256 = "0lmzdhzjkvxw7n5w40pbv5fgzd4cz0f9pxczswn3d4cr0k10k754";
+  };
+
+  nativeBuildInputs = [ unzip which ];
+  buildInputs = [ python3 perl ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp hisat2 \
+       hisat2-inspect-l \
+       hisat2-build-s \
+       hisat2-align-l \
+       hisat2-inspect \
+       hisat2-align-s \
+       hisat2-inspect-s \
+       hisat2-build-l \
+       hisat2-build \
+       extract_exons.py \
+       extract_splice_sites.py \
+       hisat2_extract_exons.py \
+       hisat2_extract_snps_haplotypes_UCSC.py \
+       hisat2_extract_snps_haplotypes_VCF.py \
+       hisat2_extract_splice_sites.py \
+       hisat2_simulate_reads.py \
+       $out/bin
+  '';
+
+  meta = with lib; {
+    description = "Graph based aligner";
+    license = licenses.gpl3Plus;
+    homepage = "https://daehwankimlab.github.io/hisat2/";
+    maintainers = with maintainers; [ jbedo ];
+    platforms = [ "x86_64-linux" "i686-linux" ];
+  };
+
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/hmmer/default.nix b/nixpkgs/pkgs/applications/science/biology/hmmer/default.nix
new file mode 100644
index 000000000000..2a4df9d21dba
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/hmmer/default.nix
@@ -0,0 +1,26 @@
+{ lib, stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  version = "3.3.2";
+  pname = "hmmer";
+
+  src = fetchurl {
+    url = "http://eddylab.org/software/hmmer/${pname}-${version}.tar.gz";
+    sha256 = "0s9wf6n0qanbx8qs6igfl3vyjikwbrvh4d9d6mv54yp3xysykzlj";
+  };
+
+  meta = with lib; {
+    description = "Biosequence analysis using profile hidden Markov models";
+    longDescription = ''
+      HMMER is used for searching sequence databases for sequence homologs, and for making sequence alignments. It implements methods using probabilistic models called profile hidden Markov models (profile HMMs).
+      HMMER is often used together with a profile database, such as Pfam or many of the databases that participate in Interpro. But HMMER can also work with query sequences, not just profiles, just like BLAST. For example, you can search a protein query sequence against a database with phmmer, or do an iterative search with jackhmmer.
+      HMMER is designed to detect remote homologs as sensitively as possible, relying on the strength of its underlying probability models. In the past, this strength came at significant computational expense, but as of the new HMMER3 project, HMMER is now essentially as fast as BLAST.
+      HMMER can be downloaded and installed as a command line tool on your own hardware, and now it is also more widely accessible to the scientific community via new search servers at the European Bioinformatics Institute.
+    '';
+    homepage = "http://hmmer.org/";
+    license = licenses.gpl3;
+    maintainers = [ maintainers.iimog ];
+    # at least SSE is *required*
+    platforms = platforms.x86_64;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/igv/default.nix b/nixpkgs/pkgs/applications/science/biology/igv/default.nix
new file mode 100644
index 000000000000..ff05ef4b8df6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/igv/default.nix
@@ -0,0 +1,35 @@
+{ lib, stdenv, fetchzip, jdk11 }:
+
+stdenv.mkDerivation rec {
+  pname = "igv";
+  version = "2.8.13";
+  src = fetchzip {
+    url = "https://data.broadinstitute.org/igv/projects/downloads/2.8/IGV_${version}.zip";
+    sha256 = "0sab478jq96iw3fv0560hrrj8qbh40r8m4ncypdb7991j9haxl09";
+  };
+
+  installPhase = ''
+    mkdir -pv $out/{share,bin}
+    cp -Rv * $out/share/
+
+    sed -i "s#prefix=.*#prefix=$out/share#g" $out/share/igv.sh
+    sed -i 's#java#${jdk11}/bin/java#g' $out/share/igv.sh
+
+    sed -i "s#prefix=.*#prefix=$out/share#g" $out/share/igvtools
+    sed -i 's#java#${jdk11}/bin/java#g' $out/share/igvtools
+
+    ln -s $out/share/igv.sh $out/bin/igv
+    ln -s $out/share/igvtools $out/bin/igvtools
+
+    chmod +x $out/bin/igv
+    chmod +x $out/bin/igvtools
+  '';
+
+  meta = with lib; {
+    homepage = "https://www.broadinstitute.org/igv/";
+    description = "A visualization tool for interactive exploration of genomic datasets";
+    license = licenses.mit;
+    platforms = platforms.unix;
+    maintainers = [ maintainers.mimame ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/inormalize/default.nix b/nixpkgs/pkgs/applications/science/biology/inormalize/default.nix
new file mode 100644
index 000000000000..8ea115c6b25d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/inormalize/default.nix
@@ -0,0 +1,37 @@
+{ lib, stdenv, fetchFromGitHub, cmake, makeWrapper,
+  perlPackages,
+  libminc, EBTKS }:
+
+stdenv.mkDerivation rec {
+  pname = "inormalize";
+  name  = "${pname}-2014-10-21";
+
+  src = fetchFromGitHub {
+    owner  = "BIC-MNI";
+    repo   = pname;
+    rev    = "79cea9cdfe7b99abfd40afda89ab2253b596ad2f";
+    sha256 = "1ahqv5q0ljvji99a5q8azjkdf6bgp6nr8lwivkqwqs3jm0k5clq7";
+  };
+
+  patches = [ ./lgmask-interp.patch ./nu_correct_norm-interp.patch ];
+
+  nativeBuildInputs = [ cmake makeWrapper ];
+  buildInputs = [ libminc EBTKS ];
+  propagatedBuildInputs = with perlPackages; [ perl GetoptTabular MNI-Perllib ];
+
+  cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/cmake" "-DEBTKS_DIR=${EBTKS}/lib/" ];
+
+  postFixup = ''
+    for p in $out/bin/*; do
+      wrapProgram $p --prefix PERL5LIB : $PERL5LIB
+    done
+  '';
+
+  meta = with lib; {
+    homepage = "https://github.com/BIC-MNI/${pname}";
+    description = "Program to normalize intensity of MINC files";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license   = licenses.free;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/inormalize/lgmask-interp.patch b/nixpkgs/pkgs/applications/science/biology/inormalize/lgmask-interp.patch
new file mode 100644
index 000000000000..953bce9a1848
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/inormalize/lgmask-interp.patch
@@ -0,0 +1,10 @@
+diff --git a/lgmask.in b/lgmask.in
+index 17dbe4d..2195d91 100644
+--- a/lgmask.in
++++ b/lgmask.in
+@@ -1,4 +1,4 @@
+-#! @PERL@
++#! /usr/bin/env perl
+ 
+ #---------------------------------------------------------------------------
+ #@COPYRIGHT :
diff --git a/nixpkgs/pkgs/applications/science/biology/inormalize/nu_correct_norm-interp.patch b/nixpkgs/pkgs/applications/science/biology/inormalize/nu_correct_norm-interp.patch
new file mode 100644
index 000000000000..75dc46a799ce
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/inormalize/nu_correct_norm-interp.patch
@@ -0,0 +1,10 @@
+diff --git a/nu_correct_norm.in b/nu_correct_norm.in
+index 1dc84ac..1bc6235 100644
+--- a/nu_correct_norm.in
++++ b/nu_correct_norm.in
+@@ -1,4 +1,4 @@
+-#! @PERL@
++#! /usr/bin/perl
+  
+ #---------------------------------------------------------------------------
+ #@COPYRIGHT :
diff --git a/nixpkgs/pkgs/applications/science/biology/itsx/default.nix b/nixpkgs/pkgs/applications/science/biology/itsx/default.nix
new file mode 100644
index 000000000000..843f0df57924
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/itsx/default.nix
@@ -0,0 +1,34 @@
+{ lib, stdenv, fetchurl, hmmer, perl }:
+
+stdenv.mkDerivation rec {
+  version = "1.1.1";
+  pname = "itsx";
+
+  src = fetchurl {
+    url = "http://microbiology.se/sw/ITSx_${version}.tar.gz";
+    sha256 = "0lrmy2n3ax7f208k0k8l3yz0j5cpz05hv4hx1nnxzn0c51z1pc31";
+  };
+
+  buildInputs = [ hmmer perl ];
+
+  buildPhase = ''
+    sed -e "s,profileDB = .*,profileDB = \"$out/share/ITSx_db/HMMs\";," -i ITSx
+    sed "3 a \$ENV{\'PATH\'}='${hmmer}/bin:'.\"\$ENV{\'PATH\'}\";" -i ITSx
+    mkdir bin
+    mv ITSx bin
+  '';
+
+  installPhase = ''
+    mkdir -p $out/share/doc && cp -a bin $out/
+    cp *pdf $out/share/doc
+    cp -r ITSx_db $out/share
+  '';
+
+  meta = with lib; {
+    description = "Improved software detection and extraction of ITS1 and ITS2 from ribosomal ITS sequences of fungi and other eukaryotes for use in environmental sequencing";
+    homepage = "https://microbiology.se/software/itsx/";
+    license = licenses.gpl3;
+    maintainers = [ maintainers.bzizou ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/iv/default.nix b/nixpkgs/pkgs/applications/science/biology/iv/default.nix
new file mode 100644
index 000000000000..ba1b91298bb3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/iv/default.nix
@@ -0,0 +1,43 @@
+{ lib
+, stdenv
+, fetchurl
+, neuron-version
+, libX11
+, libXext
+, patchelf
+}:
+
+stdenv.mkDerivation rec {
+  pname = "iv";
+  version = "19";
+
+  src = fetchurl {
+    url = "https://www.neuron.yale.edu/ftp/neuron/versions/v${neuron-version}/iv-${version}.tar.gz";
+    sha256 = "07a3g8zzay4h0bls7fh89dd0phn7s34c2g15pij6dsnwpmjg06yx";
+  };
+
+  nativeBuildInputs = [ patchelf ];
+  buildInputs = [ libXext ];
+  propagatedBuildInputs = [ libX11 ];
+
+  hardeningDisable = [ "format" ];
+
+  postInstall = ''
+    for dir in $out/*; do # */
+      if [ -d $dir/lib ]; then
+        mv $dir/* $out # */
+        rmdir $dir
+        break
+      fi
+    done
+  '' + lib.optionalString stdenv.isLinux ''
+    patchelf --add-needed ${libX11}/lib/libX11.so $out/lib/libIVhines.so
+  '';
+
+  meta = with lib; {
+    description = "InterViews graphical library for Neuron";
+    license = licenses.bsd3;
+    homepage = "http://www.neuron.yale.edu/neuron";
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/kallisto/default.nix b/nixpkgs/pkgs/applications/science/biology/kallisto/default.nix
new file mode 100644
index 000000000000..156f55161291
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/kallisto/default.nix
@@ -0,0 +1,30 @@
+{ lib, stdenv, fetchFromGitHub, autoconf, cmake, hdf5, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "kallisto";
+  version = "0.48.0";
+
+  src = fetchFromGitHub {
+    repo = "kallisto";
+    owner = "pachterlab";
+    rev = "v${version}";
+    sha256 = "sha256-r0cdR0jTRa1wu/LDKW6NdxI3XaKj6wcIVbIlct0fFvI=";
+  };
+
+  nativeBuildInputs = [ autoconf cmake ];
+
+  buildInputs = [ hdf5 zlib ];
+
+  cmakeFlags = [ "-DUSE_HDF5=ON" ];
+
+  # Parallel build fails in some cases: https://github.com/pachterlab/kallisto/issues/160
+  enableParallelBuilding = false;
+
+  meta = with lib; {
+    description = "Program for quantifying abundances of transcripts from RNA-Seq data";
+    homepage = "https://pachterlab.github.io/kallisto";
+    license = licenses.bsd2;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ arcadio ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/kent/default.nix b/nixpkgs/pkgs/applications/science/biology/kent/default.nix
new file mode 100644
index 000000000000..12bbfa09c251
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/kent/default.nix
@@ -0,0 +1,75 @@
+{ lib, stdenv
+, libpng
+, libuuid
+, zlib
+, bzip2
+, xz
+, openssl
+, curl
+, libmysqlclient
+, bash
+, fetchFromGitHub
+, which
+}:
+stdenv.mkDerivation rec {
+  pname = "kent";
+  version = "404";
+
+  src = fetchFromGitHub {
+    owner = "ucscGenomeBrowser";
+    repo = pname;
+    rev = "v${version}_base";
+    sha256 = "0l5lmqqc6sqkf4hyk3z4825ly0vdlj5xdfad6zd0708cb1v81nbx";
+  };
+
+  buildInputs = [ libpng libuuid zlib bzip2 xz openssl curl libmysqlclient ];
+
+  patchPhase = ''
+    substituteInPlace ./src/checkUmask.sh \
+      --replace "/bin/bash" "${bash}/bin/bash"
+
+    substituteInPlace ./src/hg/sqlEnvTest.sh \
+      --replace "which mysql_config" "${which}/bin/which ${libmysqlclient}/bin/mysql_config"
+  '';
+
+  buildPhase = ''
+    export MACHTYPE=$(uname -m)
+    export CFLAGS="-fPIC"
+    export MYSQLINC=$(mysql_config --include | sed -e 's/^-I//g')
+    export MYSQLLIBS=$(mysql_config --libs)
+    export DESTBINDIR=$NIX_BUILD_TOP/bin
+    export HOME=$NIX_BUILD_TOP
+
+    cd ./src
+    chmod +x ./checkUmask.sh
+    ./checkUmask.sh
+
+    mkdir -p $NIX_BUILD_TOP/lib
+    mkdir -p $NIX_BUILD_TOP/bin/x86_64
+
+    make libs
+    cd jkOwnLib
+    make
+
+    cp ../lib/x86_64/jkOwnLib.a $NIX_BUILD_TOP/lib
+    cp ../lib/x86_64/jkweb.a $NIX_BUILD_TOP/lib
+
+    cd ../utils
+    make
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mkdir -p $out/lib
+    cp $NIX_BUILD_TOP/lib/jkOwnLib.a $out/lib
+    cp $NIX_BUILD_TOP/lib/jkweb.a $out/lib
+    cp $NIX_BUILD_TOP/bin/x86_64/* $out/bin
+  '';
+
+  meta = with lib; {
+    description = "UCSC Genome Bioinformatics Group's suite of biological analysis tools, i.e. the kent utilities";
+    license = licenses.unfree;
+    maintainers = with maintainers; [ scalavision ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/kssd/default.nix b/nixpkgs/pkgs/applications/science/biology/kssd/default.nix
new file mode 100644
index 000000000000..bcf47e6b6a3d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/kssd/default.nix
@@ -0,0 +1,27 @@
+{ lib, stdenv, fetchFromGitHub, zlib, automake, autoconf, libtool }:
+
+stdenv.mkDerivation rec {
+  pname = "kssd";
+  version = "1.1";
+
+  src = fetchFromGitHub {
+    owner = "yhg926";
+    repo = "public_kssd";
+    rev = "v${version}";
+    sha256 = "sha256-8jzYqo9LXF66pQ1EIusm+gba2VbTYpJz2K3NVlA3QxY=";
+  };
+
+  buildInputs = [ zlib automake autoconf libtool ];
+
+  installPhase = ''
+      install -vD kssd $out/bin/kssd
+  '';
+
+  meta = with lib; {
+    description = "K-mer substring space decomposition";
+    license     = licenses.asl20;
+    homepage    = "https://github.com/yhg926/public_kssd";
+    maintainers = with maintainers; [ unode ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/last/default.nix b/nixpkgs/pkgs/applications/science/biology/last/default.nix
new file mode 100644
index 000000000000..bbe661b4f0a0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/last/default.nix
@@ -0,0 +1,32 @@
+{ lib, stdenv, fetchFromGitLab, unzip, zlib, python3, parallel }:
+
+stdenv.mkDerivation rec {
+  pname = "last";
+  version = "1268";
+
+  src = fetchFromGitLab {
+    owner = "mcfrith";
+    repo = "last";
+    rev = version;
+    sha256 = "sha256-9yzeLg3xporl32sZ1Ks8s63jXJNGUiI64XyQmhbQF4M=";
+  };
+
+  nativeBuildInputs = [ unzip ];
+  buildInputs = [ zlib python3 ];
+
+  makeFlags = [ "prefix=${placeholder "out"}" ];
+
+  postFixup = ''
+    for f in $out/bin/parallel-* ; do
+      sed -i 's|parallel |${parallel}/bin/parallel |' $f
+    done
+  '';
+
+  meta = with lib; {
+    description = "Genomic sequence aligner";
+    homepage = "https://gitlab.com/mcfrith/last";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ jbedo ];
+    platforms = platforms.x86_64;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/macse/default.nix b/nixpkgs/pkgs/applications/science/biology/macse/default.nix
new file mode 100644
index 000000000000..66f4a1671d1c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/macse/default.nix
@@ -0,0 +1,32 @@
+{ lib, stdenv, fetchurl, jre, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  pname = "macse";
+  version = "2.03";
+
+  src = fetchurl {
+    url = "https://bioweb.supagro.inra.fr/${pname}/releases/${pname}_v${version}.jar";
+    sha256 = "0jnjyz4f255glg37rawzdv4m6nfs7wfwc5dny7afvx4dz2sv4ssh";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  dontUnpack = true;
+  dontBuild = true;
+
+  installPhase = ''
+    runHook preInstall
+    mkdir -p $out/share/java
+    cp -s $src $out/share/java/macse.jar
+    makeWrapper ${jre}/bin/java $out/bin/macse --add-flags "-jar $out/share/java/macse.jar"
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Multiple alignment of coding sequences";
+    homepage = "https://bioweb.supagro.inra.fr/macse/";
+    license = licenses.gpl2;
+    maintainers = [ maintainers.bzizou ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/manta/default.nix b/nixpkgs/pkgs/applications/science/biology/manta/default.nix
new file mode 100644
index 000000000000..1f46e0141da3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/manta/default.nix
@@ -0,0 +1,35 @@
+{ lib, stdenv, fetchFromGitHub, cmake, zlib, python2 }:
+
+stdenv.mkDerivation rec {
+  pname = "manta";
+  version = "1.6.0";
+
+  src = fetchFromGitHub {
+    owner = "Illumina";
+    repo = "manta";
+    rev = "v${version}";
+    sha256 = "1711xkcw8rpw9xv3bbm7v1aryjz4r341rkq5255192dg38sgq7w2";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ zlib python2 ];
+  postFixup = ''
+    sed -i 's|/usr/bin/env python2|${python2.interpreter}|' $out/lib/python/makeRunScript.py
+    sed -i 's|/usr/bin/env python|${python2.interpreter}|' $out/lib/python/pyflow/pyflow.py
+    sed -i 's|/bin/bash|${stdenv.shell}|' $out/lib/python/pyflow/pyflowTaskWrapper.py
+  '';
+  doInstallCheck = true;
+  installCheckPhase = ''
+    rm $out/lib/python/**/*.pyc
+    PYTHONPATH=$out/lib/python:$PYTHONPATH python -c 'import makeRunScript'
+    PYTHONPATH=$out/lib/python/pyflow:$PYTHONPATH python -c 'import pyflowTaskWrapper; import pyflow'
+  '';
+
+  meta = with lib; {
+    description = "Structural variant caller";
+    license = licenses.gpl3;
+    homepage = "https://github.com/Illumina/manta";
+    maintainers = with maintainers; [ jbedo ];
+    platforms =  platforms.x86_64;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/megahit/default.nix b/nixpkgs/pkgs/applications/science/biology/megahit/default.nix
new file mode 100644
index 000000000000..ee2f16f389b2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/megahit/default.nix
@@ -0,0 +1,24 @@
+{ lib, stdenv, fetchFromGitHub, cmake, zlib }:
+
+stdenv.mkDerivation rec {
+  pname    = "megahit";
+  version = "1.2.9";
+
+  src = fetchFromGitHub {
+    owner = "voutcn";
+    repo = "megahit";
+    rev = "v${version}";
+    sha256 = "1r5d9nkdmgjsbrpj43q9hy3s8jwsabaz3ji561v18hy47v58923c";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ zlib ];
+
+  meta = with lib; {
+    description = "An ultra-fast single-node solution for large and complex metagenomics assembly via succinct de Bruijn graph";
+    license     = licenses.gpl3;
+    homepage    = "https://github.com/voutcn/megahit";
+    maintainers = with maintainers; [ luispedro ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/meme-suite/default.nix b/nixpkgs/pkgs/applications/science/biology/meme-suite/default.nix
new file mode 100644
index 000000000000..bfa561437e74
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/meme-suite/default.nix
@@ -0,0 +1,21 @@
+{ lib, stdenv, fetchurl, python3, perl, glibc, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "meme-suite";
+  version = "5.1.1";
+
+  src = fetchurl {
+    url = "https://meme-suite.org/meme-software/${version}/meme-${version}.tar.gz";
+    sha256 = "38d73d256d431ad4eb7da2c817ce56ff2b4e26c39387ff0d6ada088938b38eb5";
+  };
+
+  buildInputs = [ zlib ];
+  nativeBuildInputs = [ perl python3 ];
+
+  meta = with lib; {
+    description = "Motif-based sequence analysis tools";
+    license = licenses.unfree;
+    maintainers = with maintainers; [ gschwartz ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/messer-slim/default.nix b/nixpkgs/pkgs/applications/science/biology/messer-slim/default.nix
new file mode 100644
index 000000000000..79cce7b9f744
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/messer-slim/default.nix
@@ -0,0 +1,26 @@
+{ lib, stdenv, fetchFromGitHub, cmake, gcc, gcc-unwrapped }:
+
+stdenv.mkDerivation rec {
+  version = "3.7.1";
+  pname = "messer-slim";
+
+  src = fetchFromGitHub {
+    owner = "MesserLab";
+    repo = "SLiM";
+    rev = "v${version}";
+    sha256 = "sha256-3ox+9hzqI8s4gmEkQ3Xm1Ih639LBtcSJNNmJgbpWaoM=";
+  };
+
+  nativeBuildInputs = [ cmake gcc gcc-unwrapped ];
+
+  cmakeFlags = [ "-DCMAKE_AR=${gcc-unwrapped}/bin/gcc-ar"
+                 "-DCMAKE_RANLIB=${gcc-unwrapped}/bin/gcc-ranlib" ];
+
+  meta = {
+     description = "An evolutionary simulation framework";
+     homepage = "https://messerlab.org/slim/";
+     license = with lib.licenses; [ gpl3 ];
+     maintainers = with lib.maintainers; [ bzizou ];
+     platforms = lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/migrate/default.nix b/nixpkgs/pkgs/applications/science/biology/migrate/default.nix
new file mode 100644
index 000000000000..36790b22b228
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/migrate/default.nix
@@ -0,0 +1,24 @@
+{ lib, gccStdenv, fetchurl, zlib, mpi }:
+
+gccStdenv.mkDerivation rec {
+  version = "3.7.2";
+  pname = "migrate";
+
+  src = fetchurl {
+    url = "https://peterbeerli.com/migrate-html5/download_version3/${pname}-${version}.src.tar.gz";
+    sha256 = "1p2364ffjc56i82snzvjpy6pkf6wvqwvlvlqxliscx2c303fxs8v";
+  };
+
+  buildInputs = [ zlib mpi ];
+  setSourceRoot = "sourceRoot=$(echo */src)";
+  buildFlags = [ "thread" "mpis" ];
+  preInstall = "mkdir -p $out/man/man1";
+
+  meta = with lib; {
+    description = "Estimates population size, migration, population splitting parameters using genetic/genomic data";
+    homepage = "https://peterbeerli.com/migrate-html5/index.html";
+    license = licenses.mit;
+    maintainers = [ maintainers.bzizou ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/minc-tools/default.nix b/nixpkgs/pkgs/applications/science/biology/minc-tools/default.nix
new file mode 100644
index 000000000000..3dece25915b4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/minc-tools/default.nix
@@ -0,0 +1,36 @@
+{ lib, stdenv, fetchFromGitHub, cmake, makeWrapper, flex, bison, perl, TextFormat,
+  libminc, libjpeg, nifticlib, zlib }:
+
+stdenv.mkDerivation rec {
+  pname   = "minc-tools";
+  version = "unstable-2020-07-25";
+
+  src = fetchFromGitHub {
+    owner  = "BIC-MNI";
+    repo   = pname;
+    rev    = "fb0a68a07d281e4e099c5d54df29925240de14c1";
+    sha256 = "0zcv2sdj3k6k0xjqdq8j5bxq8smm48dzai90vwsmz8znmbbm6kvw";
+  };
+
+  nativeBuildInputs = [ cmake flex bison makeWrapper ];
+  buildInputs = [ libminc libjpeg nifticlib zlib ];
+  propagatedBuildInputs = [ perl TextFormat ];
+
+  cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/cmake"
+                 "-DZNZ_INCLUDE_DIR=${nifticlib}/include/nifti"
+                 "-DNIFTI_INCLUDE_DIR=${nifticlib}/include/nifti" ];
+
+  postFixup = ''
+    for prog in minccomplete minchistory mincpik; do
+      wrapProgram $out/bin/$prog --prefix PERL5LIB : $PERL5LIB
+    done
+  '';
+
+  meta = with lib; {
+    homepage = "https://github.com/BIC-MNI/minc-tools";
+    description = "Command-line utilities for working with MINC files";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license   = licenses.free;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/minc-widgets/default.nix b/nixpkgs/pkgs/applications/science/biology/minc-widgets/default.nix
new file mode 100644
index 000000000000..e8aef4138b05
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/minc-widgets/default.nix
@@ -0,0 +1,34 @@
+{ lib, stdenv, fetchFromGitHub, cmake, makeWrapper,
+  perlPackages,
+  libminc, octave, coreutils, minc_tools }:
+
+stdenv.mkDerivation rec {
+  pname = "minc-widgets";
+  name  = "${pname}-2016-04-20";
+
+
+  src = fetchFromGitHub {
+    owner  = "BIC-MNI";
+    repo   = pname;
+    rev    = "f08b643894c81a1a2e0fbfe595a17a42ba8906db";
+    sha256 = "1b9g6lf37wpp211ikaji4rf74rl9xcmrlyqcw1zq3z12ji9y33bm";
+  };
+
+  nativeBuildInputs = [ cmake makeWrapper ];
+  buildInputs = [ libminc ];
+  propagatedBuildInputs = (with perlPackages; [ perl GetoptTabular MNI-Perllib ]) ++ [ octave coreutils minc_tools ];
+
+  postFixup = ''
+    for p in $out/bin/*; do
+      wrapProgram $p --prefix PERL5LIB : $PERL5LIB --set PATH "${lib.makeBinPath [ coreutils minc_tools ]}";
+    done
+  '';
+
+  meta = with lib; {
+    homepage = "https://github.com/BIC-MNI/${pname}";
+    description = "Collection of Perl and shell scripts for processing MINC files";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license = licenses.free;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/minia/default.nix b/nixpkgs/pkgs/applications/science/biology/minia/default.nix
new file mode 100644
index 000000000000..6b6bc300e0d9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/minia/default.nix
@@ -0,0 +1,33 @@
+{ lib, stdenv, fetchFromGitHub, cmake, hdf5, boost }:
+
+stdenv.mkDerivation rec {
+  pname = "minia";
+  version = "3.2.1";
+
+  src = fetchFromGitHub {
+    owner = "GATB";
+    repo = "minia";
+    rev = "v${version}";
+    sha256 = "0bmfrywixaaql898l0ixsfkhxjf2hb08ssnqzlzacfizxdp46siq";
+    fetchSubmodules = true;
+  };
+
+  patches = [ ./no-bundle.patch ];
+
+  NIX_CFLAGS_COMPILE = [ "-Wformat" ];
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ hdf5 boost ];
+
+  prePatch = ''
+    rm -rf thirdparty/gatb-core/gatb-core/thirdparty/{hdf5,boost}
+  '';
+
+  meta = with lib; {
+    description = "Short read genome assembler";
+    homepage = "https://github.com/GATB/minia";
+    license = licenses.agpl3;
+    maintainers = with maintainers; [ jbedo ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/minia/no-bundle.patch b/nixpkgs/pkgs/applications/science/biology/minia/no-bundle.patch
new file mode 100644
index 000000000000..21d12c7f6f2d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/minia/no-bundle.patch
@@ -0,0 +1,222 @@
+diff --git a/thirdparty/gatb-core/gatb-core/CMakeLists.txt b/thirdparty/gatb-core/gatb-core/CMakeLists.txt
+index f48a70b..0e11ece 100644
+--- a/thirdparty/gatb-core/gatb-core/CMakeLists.txt
++++ b/thirdparty/gatb-core/gatb-core/CMakeLists.txt
+@@ -257,7 +257,6 @@ ADD_SUBDIRECTORY(thirdparty)
+ #  DEPENDENCIES 
+ ################################################################################
+ # we must be sure that hdf5 is built and installed before building gatb-core
+-ADD_DEPENDENCIES (gatbcore-static hdf5 hdf5_postbuild)
+ 
+ ################################################################################
+ #  DOCUMENTATION GENERATION 
+@@ -288,7 +287,6 @@ IF (NOT DEFINED GATB_CORE_INSTALL_EXCLUDE)
+     INSTALL (FILES ${PROJECT_SOURCE_DIR}/doc/misc/README.txt  DESTINATION . OPTIONAL)
+     INSTALL (FILES ${PROJECT_SOURCE_DIR}/LICENCE              DESTINATION . OPTIONAL)
+     INSTALL (FILES ${PROJECT_SOURCE_DIR}/THIRDPARTIES.md      DESTINATION . OPTIONAL)
+-    INSTALL (DIRECTORY ${PROJECT_SOURCE_DIR}/thirdparty/boost DESTINATION ./include)
+ ENDIF()
+ 
+ ################################################################################
+diff --git a/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/LargeInt.hpp b/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/LargeInt.hpp
+index dfeee1c..d5553a2 100644
+--- a/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/LargeInt.hpp
++++ b/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/LargeInt.hpp
+@@ -35,7 +35,7 @@
+ #include <stdint.h>
+ #include <algorithm>
+ #include <iostream>
+-#include <hdf5/hdf5.h>
++#include <hdf5.h>
+ 
+ #include <gatb/system/api/Exception.hpp>
+ #include <gatb/system/api/config.hpp>
+diff --git a/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt128.hpp b/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt128.hpp
+index 60be5d5..25ae75e 100644
+--- a/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt128.hpp
++++ b/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt128.hpp
+@@ -33,7 +33,7 @@
+ /********************************************************************************/
+ 
+ #include <iostream>
+-#include <hdf5/hdf5.h>
++#include <hdf5.h>
+ 
+ #include <gatb/system/api/types.hpp>
+ #include <gatb/tools/misc/api/Abundance.hpp>
+diff --git a/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt16.hpp b/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt16.hpp
+index 6a71bb0..b9205df 100644
+--- a/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt16.hpp
++++ b/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt16.hpp
+@@ -31,7 +31,7 @@
+ #include <iostream>
+ #include <gatb/system/api/types.hpp>
+ #include <gatb/tools/misc/api/Abundance.hpp>
+-#include <hdf5/hdf5.h>
++#include <hdf5.h>
+ 
+ /********************************************************************************/
+ namespace gatb  {
+diff --git a/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt32.hpp b/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt32.hpp
+index c22b892..62e6586 100644
+--- a/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt32.hpp
++++ b/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt32.hpp
+@@ -31,7 +31,7 @@
+ #include <iostream>
+ #include <gatb/system/api/types.hpp>
+ #include <gatb/tools/misc/api/Abundance.hpp>
+-#include <hdf5/hdf5.h>
++#include <hdf5.h>
+ 
+ /********************************************************************************/
+ namespace gatb  {
+diff --git a/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt64.hpp b/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt64.hpp
+index c06aaab..e0befba 100644
+--- a/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt64.hpp
++++ b/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt64.hpp
+@@ -31,7 +31,7 @@
+ #include <iostream>
+ #include <gatb/system/api/types.hpp>
+ #include <gatb/tools/misc/api/Abundance.hpp>
+-#include <hdf5/hdf5.h>
++#include <hdf5.h>
+ 
+ extern const unsigned char revcomp_4NT[];
+ extern const unsigned char comp_NT    [];
+diff --git a/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt8.hpp b/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt8.hpp
+index 9659874..0c79ff6 100644
+--- a/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt8.hpp
++++ b/thirdparty/gatb-core/gatb-core/src/gatb/tools/math/NativeInt8.hpp
+@@ -31,7 +31,7 @@
+ #include <iostream>
+ #include <gatb/system/api/types.hpp>
+ #include <gatb/tools/misc/api/Abundance.hpp>
+-#include <hdf5/hdf5.h>
++#include <hdf5.h>
+ 
+ /********************************************************************************/
+ namespace gatb  {
+diff --git a/thirdparty/gatb-core/gatb-core/src/gatb/tools/misc/api/Abundance.hpp b/thirdparty/gatb-core/gatb-core/src/gatb/tools/misc/api/Abundance.hpp
+index 3cb84f8..cd5d382 100644
+--- a/thirdparty/gatb-core/gatb-core/src/gatb/tools/misc/api/Abundance.hpp
++++ b/thirdparty/gatb-core/gatb-core/src/gatb/tools/misc/api/Abundance.hpp
+@@ -31,7 +31,7 @@
+ /********************************************************************************/
+ 
+ #include <sys/types.h>
+-#include <hdf5/hdf5.h>
++#include <hdf5.h>
+ 
+ /********************************************************************************/
+ namespace gatb      {
+diff --git a/thirdparty/gatb-core/gatb-core/src/gatb/tools/misc/api/IHistogram.hpp b/thirdparty/gatb-core/gatb-core/src/gatb/tools/misc/api/IHistogram.hpp
+index b8f6c79..a040832 100644
+--- a/thirdparty/gatb-core/gatb-core/src/gatb/tools/misc/api/IHistogram.hpp
++++ b/thirdparty/gatb-core/gatb-core/src/gatb/tools/misc/api/IHistogram.hpp
+@@ -28,7 +28,7 @@
+ 
+ #include <gatb/system/api/ISmartPointer.hpp>
+ #include <gatb/tools/storage/impl/Storage.hpp>
+-#include <hdf5/hdf5.h>
++#include <hdf5.h>
+ 
+ /********************************************************************************/
+ namespace gatb      {
+diff --git a/thirdparty/gatb-core/gatb-core/src/gatb/tools/storage/impl/CollectionHDF5.hpp b/thirdparty/gatb-core/gatb-core/src/gatb/tools/storage/impl/CollectionHDF5.hpp
+index 2645abd..fad48c0 100644
+--- a/thirdparty/gatb-core/gatb-core/src/gatb/tools/storage/impl/CollectionHDF5.hpp
++++ b/thirdparty/gatb-core/gatb-core/src/gatb/tools/storage/impl/CollectionHDF5.hpp
+@@ -40,7 +40,7 @@
+ #include <string>
+ #include <vector>
+ #include <stdarg.h>
+-#include <hdf5/hdf5.h>
++#include <hdf5.h>
+ 
+ /********************************************************************************/
+ namespace gatb      {
+diff --git a/thirdparty/gatb-core/gatb-core/src/gatb/tools/storage/impl/CollectionHDF5Patch.hpp b/thirdparty/gatb-core/gatb-core/src/gatb/tools/storage/impl/CollectionHDF5Patch.hpp
+index a92b729..66d552f 100644
+--- a/thirdparty/gatb-core/gatb-core/src/gatb/tools/storage/impl/CollectionHDF5Patch.hpp
++++ b/thirdparty/gatb-core/gatb-core/src/gatb/tools/storage/impl/CollectionHDF5Patch.hpp
+@@ -40,7 +40,7 @@
+ #include <string>
+ #include <vector>
+ #include <stdarg.h>
+-#include <hdf5/hdf5.h>
++#include <hdf5.h>
+ 
+ /********************************************************************************/
+ namespace gatb      {
+diff --git a/thirdparty/gatb-core/gatb-core/src/gatb/tools/storage/impl/StorageHDF5.hpp b/thirdparty/gatb-core/gatb-core/src/gatb/tools/storage/impl/StorageHDF5.hpp
+index 29e0949..0565cc4 100644
+--- a/thirdparty/gatb-core/gatb-core/src/gatb/tools/storage/impl/StorageHDF5.hpp
++++ b/thirdparty/gatb-core/gatb-core/src/gatb/tools/storage/impl/StorageHDF5.hpp
+@@ -33,7 +33,7 @@
+ #include <gatb/tools/storage/impl/CollectionHDF5.hpp>
+ #include <gatb/tools/storage/impl/CollectionHDF5Patch.hpp>
+ #include <gatb/system/impl/System.hpp>
+-#include <hdf5/hdf5.h>
++#include <hdf5.h>
+ #include <sstream>
+ 
+ /********************************************************************************/
+diff --git a/thirdparty/gatb-core/gatb-core/thirdparty/CMakeLists.txt b/thirdparty/gatb-core/gatb-core/thirdparty/CMakeLists.txt
+index 6e0b5c4..34aef28 100644
+--- a/thirdparty/gatb-core/gatb-core/thirdparty/CMakeLists.txt
++++ b/thirdparty/gatb-core/gatb-core/thirdparty/CMakeLists.txt
+@@ -1,54 +1,3 @@
+-################################################################################
+-#  HDF5 GENERATION 
+-################################################################################
+-
+-#SET (HDF5_ENABLE_THREADSAFE       ON)
+-#SET (H5_HAVE_THREADSAFE 1)
+-
+-##########  MOMENTARY DEACTIVATED => CRASH ON MACOS TO BE INVESTIGATED  ##########
+-SET (HDF5_BUILD_TOOLS             ON CACHE BOOL "Build HDF5 Tools")
+-#SET (CMAKE_EXE_LINKER_FLAGS       "-lpthread -lz")
+-
+-SET (HDF5_EXTERNALLY_CONFIGURED     ON)
+-
+-#SET (HDF5_INSTALL_BIN_DIR           ${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE})
+-#SET (HDF5_INSTALL_LIB_DIR           ${PROJECT_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE})
+-SET (HDF5_INSTALL_BIN_DIR           bin)
+-SET (HDF5_INSTALL_LIB_DIR           lib)
+-
+-SET (HDF5_INSTALL_INCLUDE_DIR       ${PROJECT_BINARY_DIR}/include/${CMAKE_BUILD_TYPE}/hdf5)
+-SET (HDF5_INSTALL_DATA_DIR          ${PROJECT_BINARY_DIR}/share/${CMAKE_BUILD_TYPE})
+-SET (HDF5_INSTALL_CMAKE_DIR         ${PROJECT_BINARY_DIR}/share/${CMAKE_BUILD_TYPE})
+-
+-IF (NOT DEFINED GATB_CORE_INSTALL_EXCLUDE)
+-    SET (HDF5_EXPORTED_TARGETS          "gatb-hdf5")
+-ENDIF()
+-
+-IF (NOT DEFINED GATB_CORE_EXCLUDE_HDF5_ZLIB)
+-	OPTION (HDF5_ENABLE_Z_LIB_SUPPORT "Enable Zlib Filters" ON)
+-ENDIF()
+-
+-# We don't want warnings from HDF5 compilation
+-set (COMPILE_DEFINITIONS  "${COMPILE_DEFINITIONS}  -w")
+-add_definitions (${COMPILE_DEFINITIONS})
+-
+-# add HDF5 generation
+-ADD_SUBDIRECTORY (hdf5)
+-
+-# We add a custom target for copying header files.
+-add_custom_target (hdf5_postbuild ALL)
+-
+-# We build the output directory
+-add_custom_command (TARGET hdf5_postbuild POST_BUILD  COMMAND ${CMAKE_COMMAND} -E make_directory ${HDF5_INSTALL_INCLUDE_DIR})
+-
+-# We define all the header files to be copied
+-file (GLOB headerfiles ${PROJECT_SOURCE_DIR}/thirdparty/hdf5/src/*.h ${PROJECT_BINARY_DIR}/thirdparty/hdf5/H5pubconf.h)
+-
+-# We copy each header file
+-foreach (header ${headerfiles})
+-  add_custom_command (TARGET hdf5_postbuild POST_BUILD  COMMAND ${CMAKE_COMMAND} -E copy_if_different ${header} ${HDF5_INSTALL_INCLUDE_DIR}  )
+-endforeach()
+-
+ # include other smaller libraries (json, Boophf)
+ 
+ add_custom_target (thirdparty_copy ALL)
diff --git a/nixpkgs/pkgs/applications/science/biology/minimap2/default.nix b/nixpkgs/pkgs/applications/science/biology/minimap2/default.nix
new file mode 100644
index 000000000000..7e162e2d27c6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/minimap2/default.nix
@@ -0,0 +1,32 @@
+{ lib, stdenv, fetchFromGitHub, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "minimap2";
+  version = "2.24";
+
+  src = fetchFromGitHub {
+    repo = pname;
+    owner = "lh3";
+    rev = "v${version}";
+    sha256 = "sha256-sEp7/Y5ifV9LTqrkhlkfykTJYMMuc+VtF7PvmIpBxUw=";
+  };
+
+  buildInputs = [ zlib ];
+
+  makeFlags = lib.optionals stdenv.isAarch64 [ "arm_neon=1" "aarch64=1" ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp minimap2 $out/bin
+    mkdir -p $out/share/man/man1
+    cp minimap2.1 $out/share/man/man1
+  '';
+
+  meta = with lib; {
+    description = "A versatile pairwise aligner for genomic and spliced nucleotide sequences";
+    homepage = "https://lh3.github.io/minimap2";
+    license = licenses.mit;
+    platforms = platforms.all;
+    maintainers = [ maintainers.arcadio ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/mni_autoreg/default.nix b/nixpkgs/pkgs/applications/science/biology/mni_autoreg/default.nix
new file mode 100644
index 000000000000..b0ec8a70e149
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/mni_autoreg/default.nix
@@ -0,0 +1,35 @@
+{ lib, stdenv, fetchFromGitHub, cmake, makeWrapper, perlPackages, libminc }:
+
+stdenv.mkDerivation rec {
+  pname = "mni_autoreg";
+  version = "unstable-2017-09-22";
+
+  src = fetchFromGitHub {
+    owner = "BIC-MNI";
+    repo = pname;
+    rev = "ab99e29987dc029737785baebf24896ec37a2d76";
+    sha256 = "0axl069nv57vmb2wvqq7s9v3bfxwspzmk37bxm4973ai1irgppjq";
+  };
+
+  nativeBuildInputs = [ cmake makeWrapper ];
+  buildInputs = [ libminc ];
+  propagatedBuildInputs = with perlPackages; [ perl GetoptTabular MNI-Perllib ];
+
+  cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/cmake" ];
+  # testing broken: './minc_wrapper: Permission denied' from Testing/ellipse0.mnc
+
+  postFixup = ''
+    for prog in autocrop mritoself mritotal xfmtool; do
+      echo $out/bin/$prog
+      wrapProgram $out/bin/$prog --prefix PERL5LIB : $PERL5LIB;
+    done
+  '';
+
+  meta = with lib; {
+    homepage = "https://github.com/BIC-MNI/mni_autoreg";
+    description = "Tools for automated registration using the MINC image format";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license = licenses.free;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/mosdepth/default.nix b/nixpkgs/pkgs/applications/science/biology/mosdepth/default.nix
new file mode 100644
index 000000000000..fa93ab3fcdb0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/mosdepth/default.nix
@@ -0,0 +1,24 @@
+{lib, nimPackages, fetchFromGitHub, pcre}:
+
+nimPackages.buildNimPackage rec {
+  pname = "mosdepth";
+  version = "0.3.3";
+  nimBinOnly = true;
+
+  src = fetchFromGitHub {
+    owner = "brentp";
+    repo = "mosdepth";
+    rev = "v${version}";
+    sha256 = "sha256-de3h3SXnXlqjuLT1L66jj/1AoiTuFc3PVJYjm7s8Fj8=";
+  };
+
+  buildInputs = with nimPackages; [ docopt hts-nim pcre ];
+
+  meta = with lib; {
+    description = "fast BAM/CRAM depth calculation for WGS, exome, or targeted sequencing";
+    license = licenses.mit;
+    homepage = "https://github.com/brentp/mosdepth";
+    maintainers = with maintainers; [ jbedo ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/mrbayes/default.nix b/nixpkgs/pkgs/applications/science/biology/mrbayes/default.nix
new file mode 100644
index 000000000000..e4c2bbe65652
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/mrbayes/default.nix
@@ -0,0 +1,30 @@
+{ lib, stdenv, fetchFromGitHub, readline }:
+
+stdenv.mkDerivation rec {
+  pname = "mrbayes";
+  version = "3.2.7a";
+
+  src = fetchFromGitHub {
+    owner = "NBISweden";
+    repo = "MrBayes";
+    rev = "v${version}";
+    sha256 = "sha256-pkkxZ6YHRn/I1SJpT9A+EK4S5hWGmFdcDBJS0zh5mLA=";
+  };
+
+  meta = with lib; {
+    description = "Bayesian Inference of Phylogeny";
+    longDescription = ''
+      Bayesian inference of phylogeny is based upon a
+      quantity called the posterior probability distribution of trees, which is
+      the probability of a tree conditioned on the observations. The conditioning
+      is accomplished using Bayes's theorem. The posterior probability
+      distribution of trees is impossible to calculate analytically; instead,
+      MrBayes uses a simulation technique called Markov chain Monte Carlo (or
+      MCMC) to approximate the posterior probabilities of trees.
+    '';
+    maintainers = with maintainers; [ ];
+    license = licenses.gpl2Plus;
+    homepage = "https://nbisweden.github.io/MrBayes/";
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/mrtrix/default.nix b/nixpkgs/pkgs/applications/science/biology/mrtrix/default.nix
new file mode 100644
index 000000000000..10bfb633f4af
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/mrtrix/default.nix
@@ -0,0 +1,95 @@
+{ stdenv, lib, fetchFromGitHub, python, makeWrapper
+, eigen, fftw, libtiff, libpng, zlib, ants, bc
+, qt5, libGL, libGLU, libX11, libXext
+, withGui ? true, less }:
+
+stdenv.mkDerivation rec {
+  pname = "mrtrix";
+  version = "unstable-2021-11-25";
+
+  src = fetchFromGitHub {
+    owner  = "MRtrix3";
+    repo   = "mrtrix3";
+    rev    = "994498557037c9e4f7ba67f255820ef84ea899d9";
+    sha256 = "sha256-8eFDS5z4ZxMzi9Khk90KAS4ndma/Syd6JDXM2Fpr0M8=";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [ eigen makeWrapper ] ++ lib.optional withGui qt5.wrapQtAppsHook;
+
+  buildInputs = [
+    ants
+    python
+    fftw
+    libtiff
+    libpng
+    zlib
+  ] ++ lib.optionals withGui [
+    libGL
+    libGLU
+    libX11
+    libXext
+    qt5.qtbase
+    qt5.qtsvg
+  ];
+
+  installCheckInputs = [ bc ];
+
+  postPatch = ''
+    patchShebangs ./build ./configure ./run_tests ./bin/*
+
+    # patching interpreters before fixup is needed for tests:
+    patchShebangs ./bin/*
+    patchShebangs testing/binaries/data/vectorstats/*py
+
+    substituteInPlace ./run_tests  \
+      --replace 'git submodule update --init $datadir >> $LOGFILE 2>&1' ""
+
+    substituteInPlace ./build  \
+      --replace '"less -RX "' '"${less}/bin/less -RX "'
+  '';
+
+  configurePhase = ''
+    export EIGEN_CFLAGS="-isystem ${eigen}/include/eigen3"
+    unset LD  # similar to https://github.com/MRtrix3/mrtrix3/issues/1519
+    ./configure ${lib.optionalString (!withGui) "-nogui"};
+  '';
+
+  buildPhase = ''
+    ./build
+    (cd testing && ../build)
+  '';
+
+  installCheckPhase = ''
+    ./run_tests units
+    ./run_tests binaries
+
+    # can also `./run_tests scripts`, but this fails due to lack of FSL package
+    # (and there's no convenient way to disable individual tests)
+  '';
+  doInstallCheck = true;
+
+  installPhase = ''
+    runHook preInstall
+    mkdir -p $out
+    cp -ar lib $out/lib
+    cp -ar bin $out/bin
+    runHook postInstall
+  '';
+
+  postInstall = ''
+    for prog in $out/bin/*; do
+      if [[ -x "$prog" ]]; then
+        wrapProgram $prog --prefix PATH : ${lib.makeBinPath [ ants ]}
+      fi
+    done
+  '';
+
+  meta = with lib; {
+    homepage = "https://github.com/MRtrix3/mrtrix3";
+    description = "Suite of tools for diffusion imaging";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.linux;
+    license   = licenses.mpl20;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/muscle/default.nix b/nixpkgs/pkgs/applications/science/biology/muscle/default.nix
new file mode 100644
index 000000000000..f4f6d0c46e0f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/muscle/default.nix
@@ -0,0 +1,35 @@
+{ lib, stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  _name   = "muscle";
+  name    = "${_name}-${version}";
+  version = "3.8.31";
+
+  src = fetchurl {
+    url = "https://www.drive5.com/muscle/downloads${version}/${_name}${version}_src.tar.gz";
+    sha256 = "1b89z0x7h098g99g00nqadgjnb2r5wpi9s11b7ddffqkh9m9dia3";
+  };
+
+  patches = [
+    ./muscle-3.8.31-no-static.patch
+  ];
+
+  preBuild = ''
+    cd ./src/
+    patchShebangs mk
+  '';
+
+  installPhase = ''
+    install -vD muscle $out/bin/muscle
+  '';
+
+  meta = with lib; {
+    description = "A multiple sequence alignment method with reduced time and space complexity";
+    license     = licenses.publicDomain;
+    homepage    = "https://www.drive5.com/muscle/";
+    maintainers = [ maintainers.unode ];
+    # NOTE: Supposed to be compatible with darwin/intel & PPC but currently fails.
+    # Anyone with access to these platforms is welcome to give it a try
+    platforms   = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/muscle/muscle-3.8.31-no-static.patch b/nixpkgs/pkgs/applications/science/biology/muscle/muscle-3.8.31-no-static.patch
new file mode 100644
index 000000000000..7f4b2129518d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/muscle/muscle-3.8.31-no-static.patch
@@ -0,0 +1,21 @@
+--- a/src/mk	2010-05-02 01:15:42.000000000 +0200
++++ b/src/mk	2018-01-27 17:07:23.539092748 +0100
+@@ -5,14 +5,14 @@
+ rm -f *.o muscle.make.stdout.txt muscle.make.stderr.txt
+ for CPPName in $CPPNames
+ do
+-  echo $CPPName >> /dev/tty
++  echo $CPPName
+   g++ $ENV_GCC_OPTS -c -O3 -msse2 -mfpmath=sse -D_FILE_OFFSET_BITS=64 -DNDEBUG=1 $CPPName.cpp -o $CPPName.o  >> muscle.make.stdout.txt 2>> muscle.make.stderr.txt
+ done
+ 
+ LINK_OPTS=
+-if [ `uname -s` == Linux ] ; then
+-    LINK_OPTS=-static
+-fi
++#if [ `uname -s` == Linux ] ; then
++#    LINK_OPTS=-static
++#fi
+ g++ $LINK_OPTS $ENV_LINK_OPTS -g -o muscle $ObjNames  >> muscle.make.stdout.txt 2>> muscle.make.stderr.txt
+ tail muscle.make.stderr.txt
+ 
diff --git a/nixpkgs/pkgs/applications/science/biology/ncbi-tools/default.nix b/nixpkgs/pkgs/applications/science/biology/ncbi-tools/default.nix
new file mode 100644
index 000000000000..0e273dbefaac
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/ncbi-tools/default.nix
@@ -0,0 +1,34 @@
+{stdenv, fetchurl, cpio}:
+
+# The NCBI package only builds on 32bits - on 64bits it breaks because
+# of position dependent code. Debian packagers have written replacement
+# make files(!). Either we use these, or negotiate a version which can
+# be pushed upstream to NCBI.
+#
+# Another note: you may want the older and deprecated C-libs at ftp://ftp.ncbi.nih.gov/toolbox/ncbi_tools++/2008/Mar_17_2008/NCBI_C_Toolkit/ncbi_c--Mar_17_2008.tar.gz
+
+stdenv.mkDerivation rec {
+  name = "ncbi_tools";
+  ncbi_version = "Dec_31_2008";
+  src = fetchurl {
+    url = "ftp://ftp.ncbi.nih.gov/toolbox/ncbi_tools++/2008/${ncbi_version}/ncbi_cxx--${ncbi_version}.tar.gz";
+    sha256 = "1b2v0dcdqn3bysgdkj57sxmd6s0hc9wpnxssviz399g6plhxggbr";
+  };
+
+  configureFlags = [
+    "--without-debug"
+    "--with-bin-release"
+    "--with-dll"
+    "--without-static"
+  ];
+  buildInputs = [ cpio ];
+
+  meta = {
+    description = "NCBI Bioinformatics toolbox (incl. BLAST)";
+    longDescription = "The NCBI Bioinformatics toolsbox, including command-line utilties, libraries and include files. No X11 support";
+    homepage = "http://www.ncbi.nlm.nih.gov/IEB/ToolBox/";
+    license = "GPL";
+    priority = 5;   # zlib.so gives a conflict with zlib
+    broken = true;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/neuron/default.nix b/nixpkgs/pkgs/applications/science/biology/neuron/default.nix
new file mode 100644
index 000000000000..4dc850f50627
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/neuron/default.nix
@@ -0,0 +1,88 @@
+{ lib, stdenv
+, fetchurl
+, pkg-config
+, automake
+, autoconf
+, libtool
+, ncurses
+, readline
+, which
+, python ? null
+, useMpi ? false
+, mpi
+, iv
+}:
+
+stdenv.mkDerivation rec {
+  pname = "neuron${lib.optionalString useMpi "-mpi"}";
+  version = "7.5";
+
+  nativeBuildInputs = [ which pkg-config automake autoconf libtool ];
+  buildInputs = [ ncurses readline python iv ]
+    ++ lib.optional useMpi mpi;
+
+  src = fetchurl {
+    url = "https://www.neuron.yale.edu/ftp/neuron/versions/v${version}/nrn-${version}.tar.gz";
+    sha256 = "0f26v3qvzblcdjg7isq0m9j2q8q7x3vhmkfllv8lsr3gyj44lljf";
+  };
+
+  patches = (lib.optional (stdenv.isDarwin) [ ./neuron-carbon-disable.patch ]);
+
+  # With LLVM 3.8 and above, clang (really libc++) gets upset if you attempt to redefine these...
+  postPatch = lib.optionalString stdenv.cc.isClang ''
+    substituteInPlace src/gnu/neuron_gnu_builtin.h \
+      --replace 'double abs(double arg);' "" \
+      --replace 'float abs(float arg);' "" \
+      --replace 'short abs(short arg);' "" \
+      --replace 'long abs(long arg);' ""
+  '' + lib.optionalString stdenv.isDarwin ''
+    # we are darwin, but we don't have all the quirks the source wants to compensate for
+    substituteInPlace src/nrnpython/setup.py.in --replace 'readline="edit"' 'readline="readline"'
+    for f in src/nrnpython/*.[ch] ; do
+      substituteInPlace $f --replace "<Python/Python.h>" "<Python.h>"
+    done
+  '';
+
+  enableParallelBuilding = true;
+
+  ## neuron install by default everything under prefix/${host_arch}/*
+  ## override this to support nix standard file hierarchy
+  ## without issues: install everything under prefix/
+  preConfigure = ''
+    ./build.sh
+    export prefix="''${prefix} --exec-prefix=''${out}"
+  '';
+
+  configureFlags = with lib;
+                    [ "--with-readline=${readline}" "--with-iv=${iv}" ]
+                    ++  optionals (python != null)  [ "--with-nrnpython=${python.interpreter}" ]
+                    ++ (if useMpi then ["--with-mpi" "--with-paranrn"]
+                        else ["--without-mpi"]);
+
+
+  postInstall = lib.optionalString (python != null) ''
+    ## standardise python neuron install dir if any
+    if [[ -d $out/lib/python ]]; then
+        mkdir -p ''${out}/${python.sitePackages}
+        mv ''${out}/lib/python/*  ''${out}/${python.sitePackages}/
+    fi
+  '';
+
+  propagatedBuildInputs = [ readline ncurses which libtool ];
+
+  meta = with lib; {
+    description = "Simulation environment for empirically-based simulations of neurons and networks of neurons";
+
+    longDescription = "NEURON is a simulation environment for developing and exercising models of
+                neurons and networks of neurons. It is particularly well-suited to problems where
+                cable properties of cells play an important role, possibly including extracellular
+                potential close to the membrane), and where cell membrane properties are complex,
+                involving many ion-specific channels, ion accumulation, and second messengers";
+
+    license     = licenses.bsd3;
+    homepage    = "http://www.neuron.yale.edu/neuron";
+    maintainers = [ maintainers.adev ];
+    # source claims it's only tested for x86 and powerpc
+    platforms   = platforms.x86_64 ++ platforms.i686;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/neuron/neuron-carbon-disable.patch b/nixpkgs/pkgs/applications/science/biology/neuron/neuron-carbon-disable.patch
new file mode 100644
index 000000000000..923bffb1c338
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/neuron/neuron-carbon-disable.patch
@@ -0,0 +1,21 @@
+--- nrn-7.4/src/mac/Makefile.am	2015-11-12 21:42:45.000000000 +0100
++++ nrn-7.4.new/src/mac/Makefile.am	2016-08-24 17:43:39.000000000 +0200
+@@ -15,18 +15,8 @@
+ host_cpu = @host_cpu@
+ 
+ if MAC_DARWIN
+-carbon = @enable_carbon@
+ bin_SCRIPTS = $(launch_scripts)
+ install: install-am
+-if UniversalMacBinary
+-	$(CC) -arch ppc -o aoutppc -Dcpu="\"$(host_cpu)\"" -I. $(srcdir)/launch.c $(srcdir)/mac2uxarg.c -framework Carbon
+-	$(CC) -arch i386 -o aouti386 -Dcpu="\"$(host_cpu)\"" -I. $(srcdir)/launch.c $(srcdir)/mac2uxarg.c -framework Carbon
+-	lipo aouti386 aoutppc -create -output a.out
+-else
+-	gcc -g -arch i386 -Dncpu="\"$(host_cpu)\"" -I. $(srcdir)/launch.c $(srcdir)/mac2uxarg.c -framework Carbon
+-
+-endif
+-	carbon=$(carbon) sh $(srcdir)/launch_inst.sh "$(host_cpu)" "$(DESTDIR)$(prefix)" "$(srcdir)"
+ 	for i in $(S) ; do \
+ 		sed "s/^CPU.*/CPU=\"$(host_cpu)\"/" < $(DESTDIR)$(bindir)/$$i > temp; \
+ 		mv temp $(DESTDIR)$(bindir)/$$i; \
diff --git a/nixpkgs/pkgs/applications/science/biology/niftyreg/default.nix b/nixpkgs/pkgs/applications/science/biology/niftyreg/default.nix
new file mode 100644
index 000000000000..d5f625893e92
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/niftyreg/default.nix
@@ -0,0 +1,24 @@
+{ lib, stdenv, fetchurl, cmake, zlib }:
+
+stdenv.mkDerivation rec {
+  pname   = "niftyreg";
+  version = "1.3.9";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/${pname}/nifty_reg-${version}/nifty_reg-${version}.tar.gz";
+    sha256 = "07v9v9s41lvw72wpb1jgh2nzanyc994779bd35p76vg8mzifmprl";
+  };
+
+  NIX_CFLAGS_COMPILE = [ "-Wno-error=narrowing" ];
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ zlib ];
+
+  meta = with lib; {
+    homepage = "http://cmictig.cs.ucl.ac.uk/wiki/index.php/NiftyReg";
+    description = "Medical image registration software";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = [ "x86_64-linux" ];
+    license   = licenses.bsd3;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/niftyseg/default.nix b/nixpkgs/pkgs/applications/science/biology/niftyseg/default.nix
new file mode 100644
index 000000000000..0fd658b0addc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/niftyseg/default.nix
@@ -0,0 +1,25 @@
+{ lib, stdenv, fetchFromGitHub, cmake, eigen, zlib }:
+
+stdenv.mkDerivation rec {
+  pname   = "niftyseg";
+  version = "1.0";
+
+  src = fetchFromGitHub {
+    owner = "KCL-BMEIS";
+    repo = "NiftySeg";
+    rev = "v${version}";
+    sha256 = "sha256-FDthq1ild9XOw3E3O7Lpfn6hBF1Frhv1NxfEA8500n8=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ eigen zlib ];
+
+  meta = with lib; {
+    homepage = "http://cmictig.cs.ucl.ac.uk/research/software/software-nifty/niftyseg";
+    description = "Software for medical image segmentation, bias field correction, and cortical thickness calculation";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license   = licenses.bsd3;
+  };
+
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/obitools/obitools3.nix b/nixpkgs/pkgs/applications/science/biology/obitools/obitools3.nix
new file mode 100644
index 000000000000..b38af2f64b54
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/obitools/obitools3.nix
@@ -0,0 +1,35 @@
+{ stdenv, lib, fetchurl, python3Packages, cmake, python3 }:
+
+python3Packages.buildPythonApplication rec {
+  pname = "obitools3";
+  version = "3.0.1b11";
+
+  src = fetchurl {
+    url = "https://git.metabarcoding.org/obitools/${pname}/repository/v${version}/archive.tar.gz";
+    sha256 = "1x7a0nrr9agg1pfgq8i1j8r1p6c0jpyxsv196ylix1dd2iivmas1";
+  };
+
+  nativeBuildInputs = [ python3Packages.cython cmake ];
+
+  postPatch = lib.optionalString stdenv.isAarch64 ''
+      substituteInPlace setup.py \
+      --replace "'-msse2'," ""
+  '';
+
+  preBuild = ''
+    substituteInPlace src/CMakeLists.txt --replace \$'{PYTHONLIB}' "$out/lib/${python3.libPrefix}/site-packages";
+    export NIX_CFLAGS_COMPILE="-L $out/lib/${python3.libPrefix}/site-packages $NIX_CFLAGS_COMPILE"
+  '';
+
+  dontConfigure = true;
+
+  doCheck = true;
+
+  meta = with lib ; {
+    description = "Management of analyses and data in DNA metabarcoding";
+    homepage = "https://git.metabarcoding.org/obitools/obitools3";
+    license = licenses.cecill20;
+    maintainers = [ maintainers.bzizou ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/octopus/default.nix b/nixpkgs/pkgs/applications/science/biology/octopus/default.nix
new file mode 100644
index 000000000000..95912d3a7c32
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/octopus/default.nix
@@ -0,0 +1,29 @@
+{lib, stdenv, fetchFromGitHub, cmake, boost, gmp, htslib, zlib, xz, pkg-config}:
+
+stdenv.mkDerivation rec {
+  pname = "octopus";
+  version = "0.7.4";
+
+  src = fetchFromGitHub {
+    owner = "luntergroup";
+    repo = "octopus";
+    rev = "v${version}";
+    sha256 = "sha256-FAogksVxUlzMlC0BqRu22Vchj6VX+8yNlHRLyb3g1sE=";
+  };
+
+  nativeBuildInputs = [ cmake pkg-config ];
+  buildInputs = [ boost gmp htslib zlib xz ];
+
+  postInstall = ''
+    mkdir $out/bin
+    mv $out/octopus $out/bin
+  '';
+
+  meta = with lib; {
+    description = "Bayesian haplotype-based mutation calling";
+    license = licenses.mit;
+    homepage = "https://github.com/luntergroup/octopus";
+    maintainers = with maintainers; [ jbedo ];
+    platforms = platforms.x86_64;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/paml/default.nix b/nixpkgs/pkgs/applications/science/biology/paml/default.nix
new file mode 100644
index 000000000000..d288edca9330
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/paml/default.nix
@@ -0,0 +1,33 @@
+{stdenv, fetchurl}:
+
+stdenv.mkDerivation rec {
+  version = "4.9j";
+  pname = "paml";
+  src = fetchurl {
+    url = "http://abacus.gene.ucl.ac.uk/software/paml${version}.tgz";
+    sha256 = "0qflf3i27x6jwks3c6q560m1q8r043ja96syah145113iz5wdalp";
+  };
+
+  preBuild = ''
+    cd ./src/
+  '';
+  installPhase = ''
+    mkdir -pv $out/bin
+    cp -v codeml $out/bin
+    cp -v baseml $out/bin
+    cp -v basemlg $out/bin
+    cp -v chi2 $out/bin
+    cp -v codeml $out/bin
+    cp -v evolver $out/bin
+    cp -v mcmctree $out/bin
+    cp -v pamp $out/bin
+    cp -v yn00 $out/bin
+  '';
+
+  meta = {
+    description     = "Phylogenetic Analysis by Maximum Likelihood (PAML)";
+    longDescription = "PAML is a package of programs for phylogenetic analyses of DNA or protein sequences using maximum likelihood. It is maintained and distributed for academic use free of charge by Ziheng Yang. ANSI C source codes are distributed for UNIX/Linux/Mac OSX, and executables are provided for MS Windows. PAML is not good for tree making. It may be used to estimate parameters and test hypotheses to study the evolutionary process, when you have reconstructed trees using other programs such as PAUP*, PHYLIP, MOLPHY, PhyML, RaxML, etc.";
+    license     = "non-commercial";
+    homepage    = "http://abacus.gene.ucl.ac.uk/software/paml.html";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/picard-tools/default.nix b/nixpkgs/pkgs/applications/science/biology/picard-tools/default.nix
new file mode 100644
index 000000000000..526a5b3ed33b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/picard-tools/default.nix
@@ -0,0 +1,31 @@
+{lib, stdenv, fetchurl, jre, makeWrapper}:
+
+stdenv.mkDerivation rec {
+  pname = "picard-tools";
+  version = "2.26.11";
+
+  src = fetchurl {
+    url = "https://github.com/broadinstitute/picard/releases/download/${version}/picard.jar";
+    sha256 = "sha256-0swggo1a5gExpj3VgaWKT/TYd7rfSFBcqRrAURnTPjM=";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ jre ];
+
+  dontUnpack = true;
+
+  installPhase = ''
+    mkdir -p $out/libexec/picard
+    cp $src $out/libexec/picard/picard.jar
+    mkdir -p $out/bin
+    makeWrapper ${jre}/bin/java $out/bin/picard --add-flags "-jar $out/libexec/picard/picard.jar"
+  '';
+
+  meta = with lib; {
+    description = "Tools for high-throughput sequencing (HTS) data and formats such as SAM/BAM/CRAM and VCF";
+    license = licenses.mit;
+    homepage = "https://broadinstitute.github.io/picard/";
+    maintainers = with maintainers; [ jbedo ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/platypus/default.nix b/nixpkgs/pkgs/applications/science/biology/platypus/default.nix
new file mode 100644
index 000000000000..d602395b8757
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/platypus/default.nix
@@ -0,0 +1,39 @@
+{lib, stdenv, fetchFromGitHub, python27, htslib, zlib, makeWrapper}:
+
+let python = python27.withPackages (ps: with ps; [ cython ]);
+
+in stdenv.mkDerivation {
+  pname = "platypus-unstable";
+  version = "2018-07-22";
+
+  src = fetchFromGitHub {
+    owner = "andyrimmer";
+    repo = "Platypus";
+    rev = "3e72641c69800da0cd4906b090298e654d316ee1";
+    sha256 = "0nah6r54b8xm778gqyb8b7rsd76z8ji4g73sm6rvpw5s96iib1vw";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ htslib python zlib ];
+
+  buildPhase = ''
+    patchShebangs .
+    make
+  '';
+
+  installPhase = ''
+    mkdir -p $out/libexec/platypus
+    cp -r ./* $out/libexec/platypus
+
+    mkdir -p $out/bin
+    makeWrapper ${python}/bin/python $out/bin/platypus --add-flags "$out/libexec/platypus/bin/Platypus.py"
+  '';
+
+  meta = with lib; {
+    description = "The Platypus variant caller";
+    license = licenses.gpl3;
+    homepage = "https://github.com/andyrimmer/Platypus";
+    maintainers = with maintainers; [ jbedo ];
+    platforms = platforms.x86_64;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/plink-ng/default.nix b/nixpkgs/pkgs/applications/science/biology/plink-ng/default.nix
new file mode 100644
index 000000000000..26c3e7ba66b6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/plink-ng/default.nix
@@ -0,0 +1,39 @@
+{ lib, stdenv, fetchFromGitHub, zlib, blas, lapack, darwin}:
+
+stdenv.mkDerivation rec {
+  pname = "plink-ng";
+  version = "1.90b3";
+
+  src = fetchFromGitHub {
+    owner = "chrchang";
+    repo = "plink-ng";
+    rev = "v${version}";
+    sha256 = "1zhffjbwpd50dxywccbnv1rxy9njwz73l4awc5j7i28rgj3davcq";
+  };
+
+  buildInputs = [ zlib ] ++ (if stdenv.isDarwin then [ darwin.apple_sdk.frameworks.Accelerate ] else [ blas lapack ]) ;
+
+  preBuild = ''
+    sed -i 's|zlib-1.2.8/zlib.h|zlib.h|g' *.c *.h
+    ${if stdenv.cc.isClang then "sed -i 's|g++|clang++|g' Makefile.std" else ""}
+
+    makeFlagsArray+=(
+      ZLIB=-lz
+      BLASFLAGS="-lblas -lcblas -llapack"
+    );
+  '';
+
+  makefile = "Makefile.std";
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp plink $out/bin
+  '';
+
+  meta = {
+    description = "A comprehensive update to the PLINK association analysis toolset";
+    homepage = "https://www.cog-genomics.org/plink2";
+    license = lib.licenses.gpl3;
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/poretools/default.nix b/nixpkgs/pkgs/applications/science/biology/poretools/default.nix
new file mode 100755
index 000000000000..efbedf9a121a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/poretools/default.nix
@@ -0,0 +1,22 @@
+{ lib, python2Packages, fetchFromGitHub }:
+
+python2Packages.buildPythonPackage rec {
+  pname = "poretools";
+  version = "unstable-2016-07-10";
+
+  src = fetchFromGitHub {
+    repo = pname;
+    owner = "arq5x";
+    rev = "e426b1f09e86ac259a00c261c79df91510777407";
+    sha256 = "0bglj833wxpp3cq430p1d3xp085ls221js2y90w7ir2x5ay8l7am";
+  };
+
+  propagatedBuildInputs = [python2Packages.h5py python2Packages.matplotlib python2Packages.seaborn python2Packages.pandas];
+
+  meta = {
+    description = "a toolkit for working with nanopore sequencing data from Oxford Nanopore";
+    license = lib.licenses.mit;
+    homepage = "https://poretools.readthedocs.io/en/latest/";
+    maintainers = [lib.maintainers.rybern];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/prodigal/default.nix b/nixpkgs/pkgs/applications/science/biology/prodigal/default.nix
new file mode 100644
index 000000000000..28a21522c6b8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/prodigal/default.nix
@@ -0,0 +1,26 @@
+{ lib, stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  pname = "prodigal";
+  version = "2.6.3";
+
+  src = fetchFromGitHub {
+    repo = "Prodigal";
+    owner = "hyattpd";
+    rev = "v${version}";
+    sha256 = "1fs1hqk83qjbjhrvhw6ni75zakx5ki1ayy3v6wwkn3xvahc9hi5s";
+  };
+
+  makeFlags = [
+    "CC=${stdenv.cc.targetPrefix}cc"
+    "INSTALLDIR=$(out)/bin"
+  ];
+
+  meta = with lib; {
+    description = "Fast, reliable protein-coding gene prediction for prokaryotic genomes";
+    homepage = "https://github.com/hyattpd/Prodigal";
+    license = licenses.gpl3;
+    platforms = platforms.all;
+    maintainers = with maintainers; [ luispedro ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/quast/default.nix b/nixpkgs/pkgs/applications/science/biology/quast/default.nix
new file mode 100644
index 000000000000..553fb1de5398
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/quast/default.nix
@@ -0,0 +1,58 @@
+{ lib, stdenv, fetchurl, python3Packages, zlib, bash, coreutils }:
+
+let
+  pythonPackages = python3Packages;
+  inherit (pythonPackages) python;
+in
+
+pythonPackages.buildPythonApplication rec {
+  pname = "quast";
+  version = "5.0.2";
+
+  src = fetchurl {
+    url = "https://github.com/ablab/quast/releases/download/${pname}_${version}/${pname}-${version}.tar.gz";
+    sha256 = "13ml8qywbb4cc7wf2x7z5mz1rjqg51ab8wkizwcg4f6c40zgif6d";
+  };
+
+  pythonPath = with pythonPackages; [ simplejson joblib setuptools matplotlib ];
+
+  nativeBuildInputs = [ coreutils ];
+
+  buildInputs = [ zlib ] ++ pythonPath;
+
+  dontConfigure = true;
+
+  dontBuild = true;
+
+  installPhase = ''
+    substituteInPlace quast_libs/bedtools/Makefile \
+      --replace "/bin/bash" "${bash}/bin/bash"
+    mkdir -p "$out/${python.sitePackages}"
+    export PYTHONPATH="$out/${python.sitePackages}:$PYTHONPATH"
+    ${python.interpreter} setup.py install \
+      --install-lib=$out/${python.sitePackages} \
+      --prefix="$out"
+  '';
+
+   postFixup = ''
+   for file in $(find $out -type f -type f -perm /0111); do
+       old_rpath=$(patchelf --print-rpath $file) && \
+       patchelf --set-rpath $old_rpath:${stdenv.cc.cc.lib}/lib $file || true
+   done
+   # Link to the master program
+   ln -s $out/bin/quast.py $out/bin/quast
+  '';
+
+  dontPatchELF = true;
+
+  # Tests need to download data files, so manual run after packaging is needed
+  doCheck = false;
+
+  meta = with lib ; {
+    description = "Evaluates genome assemblies by computing various metrics";
+    homepage = "https://github.com/ablab/quast";
+    license = licenses.gpl2;
+    maintainers = [ maintainers.bzizou ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/raxml/default.nix b/nixpkgs/pkgs/applications/science/biology/raxml/default.nix
new file mode 100644
index 000000000000..d02d47266297
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/raxml/default.nix
@@ -0,0 +1,40 @@
+{ lib, stdenv
+, fetchFromGitHub
+, useMpi ? false
+, mpi
+}:
+
+stdenv.mkDerivation rec {
+  pname = "RAxML${lib.optionalString useMpi "-mpi"}";
+  version = "8.2.12";
+
+  src = fetchFromGitHub {
+    owner = "stamatak";
+    repo = "standard-RAxML";
+    rev = "v${version}";
+    sha256 = "1jqjzhch0rips0vp04prvb8vmc20c5pdmsqn8knadcf91yy859fh";
+  };
+
+  buildInputs = lib.optionals useMpi [ mpi ];
+
+  # TODO darwin, AVX and AVX2 makefile targets
+  buildPhase = if useMpi then ''
+      make -f Makefile.MPI.gcc
+    '' else ''
+      make -f Makefile.SSE3.PTHREADS.gcc
+    '';
+
+  installPhase = if useMpi then ''
+    mkdir -p $out/bin && cp raxmlHPC-MPI $out/bin
+  '' else ''
+    mkdir -p $out/bin && cp raxmlHPC-PTHREADS-SSE3 $out/bin
+  '';
+
+  meta = with lib; {
+    description = "A tool for Phylogenetic Analysis and Post-Analysis of Large Phylogenies";
+    license = licenses.gpl3;
+    homepage = "https://sco.h-its.org/exelixis/web/software/raxml/";
+    maintainers = [ maintainers.unode ];
+    platforms = [ "i686-linux" "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/repseek/default.nix b/nixpkgs/pkgs/applications/science/biology/repseek/default.nix
new file mode 100644
index 000000000000..5966c83b7a5f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/repseek/default.nix
@@ -0,0 +1,27 @@
+{ lib, stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  pname = "repseek";
+  version = "9Sep2014";
+  src = fetchurl {
+    url = "https://bioinfo.mnhn.fr/abi/public/RepSeek/RepSeek.${version}.tgz";
+    sha256 = "1jiknji3ivrv7zmrfbf2mccfpdwhin3lfxfsciaqwf69b3sda8nf";
+  };
+
+  preConfigure = ''
+    mkdir -p $out/bin
+    substituteInPlace Makefile \
+      --replace "INSTALLDIR = \$\$HOME/bin" "INSTALLDIR = $out/bin/" \
+      --replace "CC= gcc" "CC = $CC"
+  '' + lib.optionalString stdenv.isLinux ''
+    substituteInPlace Makefile --replace "MACHINE = MACOSX" "MACHINE = LINUX"
+  '';
+
+  meta = {
+    description = "Tool to retrieve approximate repeats from large DNA sequences";
+    homepage = "https://bioinfo.mnhn.fr/abi/public/RepSeek";
+    maintainers = [ lib.maintainers.bzizou ];
+    license = lib.licenses.lgpl21;
+  };
+
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/sambamba/default.nix b/nixpkgs/pkgs/applications/science/biology/sambamba/default.nix
new file mode 100644
index 000000000000..36e950a18121
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/sambamba/default.nix
@@ -0,0 +1,39 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, python3
+, which
+, ldc
+, zlib
+, lz4
+}:
+
+stdenv.mkDerivation rec {
+  pname = "sambamba";
+  version = "0.8.2";
+
+  src = fetchFromGitHub {
+    owner = "biod";
+    repo = "sambamba";
+    rev = "v${version}";
+    sha256 = "sha256-FEa9QjQoGNUOAtMNMZcqpTKMKVtXoBuOomTy0mpos/0=";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [ which python3 ldc ];
+  buildInputs = [ zlib lz4 ];
+
+  # Upstream's install target is broken; copy manually
+  installPhase = ''
+    mkdir -p $out/bin
+    cp bin/sambamba-${version} $out/bin/sambamba
+  '';
+
+  meta = with lib; {
+    description = "SAM/BAM processing tool";
+    homepage = "https://lomereiter.github.io/sambamba/";
+    maintainers = with maintainers; [ jbedo ];
+    license = with licenses; gpl2;
+    platforms = platforms.x86_64;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/samblaster/default.nix b/nixpkgs/pkgs/applications/science/biology/samblaster/default.nix
new file mode 100644
index 000000000000..4315dd2767e1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/samblaster/default.nix
@@ -0,0 +1,28 @@
+{ lib, stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  pname = "samblaster";
+  version = "0.1.26";
+
+  src = fetchFromGitHub {
+    owner = "GregoryFaust";
+    repo = "samblaster";
+    rev = "v.${version}";
+    sha256 = "0g24fq5hplnfgqkh3xqpg3lgx3wmxwnh9c7m6yw7pbi40lmgl1jv";
+  };
+
+  makeFlags = [ "CPP=${stdenv.cc.targetPrefix}c++" ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp samblaster $out/bin
+  '';
+
+  meta = with lib; {
+    description = "Tool for marking duplicates and extracting discordant/split reads from SAM/BAM files";
+    maintainers = with maintainers; [ jbedo ];
+    license = licenses.mit;
+    homepage = "https://github.com/GregoryFaust/samblaster";
+    platforms = platforms.x86_64;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/samtools/default.nix b/nixpkgs/pkgs/applications/science/biology/samtools/default.nix
new file mode 100644
index 000000000000..98b0394c35f1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/samtools/default.nix
@@ -0,0 +1,43 @@
+{ lib, stdenv, fetchurl, fetchpatch, zlib, htslib, perl, ncurses ? null }:
+
+stdenv.mkDerivation rec {
+  pname = "samtools";
+  version = "1.13";
+
+  src = fetchurl {
+    url = "https://github.com/samtools/samtools/releases/download/${version}/${pname}-${version}.tar.bz2";
+    sha256 = "sha256-YWyi4FHMgAmh6cAc/Yx8r4twkW3f9m87dpFAeUZfjGA=";
+  };
+
+  patches = [
+    # Pull upstream patch for ncurses-6.3 support
+    (fetchpatch {
+      name = "ncurses-6.3.patch";
+      url = "https://github.com/samtools/samtools/commit/396ef20eb0854d6b223c3223b60bb7efe42301f7.patch";
+      sha256 = "sha256-p0l9ymXK9nqL2w8EytbW+qeaI7dD86IQgIVxacBj838=";
+    })
+  ];
+
+  nativeBuildInputs = [ perl ];
+
+  buildInputs = [ zlib ncurses htslib ];
+
+  configureFlags = [ "--with-htslib=${htslib}" ]
+    ++ lib.optional (ncurses == null) "--without-curses";
+
+  preCheck = ''
+    patchShebangs test/
+  '';
+
+  enableParallelBuilding = true;
+
+  doCheck = true;
+
+  meta = with lib; {
+    description = "Tools for manipulating SAM/BAM/CRAM format";
+    license = licenses.mit;
+    homepage = "http://www.htslib.org/";
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ mimame unode ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/samtools/samtools-0.1.19-no-curses.patch b/nixpkgs/pkgs/applications/science/biology/samtools/samtools-0.1.19-no-curses.patch
new file mode 100644
index 000000000000..a7782a1a0264
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/samtools/samtools-0.1.19-no-curses.patch
@@ -0,0 +1,22 @@
+diff --git a/Makefile b/Makefile
+index 2f51bfc..395d6f1 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,7 +1,7 @@
+ CC=			gcc
+ CFLAGS=		-g -Wall -O2
+ #LDFLAGS=		-Wl,-rpath,\$$ORIGIN/../lib
+-DFLAGS=		-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_USE_KNETFILE -D_CURSES_LIB=1
++DFLAGS=		-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_USE_KNETFILE # -D_CURSES_LIB=1
+ KNETFILE_O=	knetfile.o
+ LOBJS=		bgzf.o kstring.o bam_aux.o bam.o bam_import.o sam.o bam_index.o	\
+ 			bam_pileup.o bam_lpileup.o bam_md.o razf.o faidx.o bedidx.o \
+@@ -15,7 +15,7 @@ PROG=		samtools
+ INCLUDES=	-I.
+ SUBDIRS=	. bcftools misc
+ LIBPATH=
+-LIBCURSES=	-lcurses # -lXCurses
++LIBCURSES=	# -lcurses # -lXCurses
+ 
+ .SUFFIXES:.c .o
+ .PHONY: all lib
diff --git a/nixpkgs/pkgs/applications/science/biology/samtools/samtools_0_1_19.nix b/nixpkgs/pkgs/applications/science/biology/samtools/samtools_0_1_19.nix
new file mode 100644
index 000000000000..590f10dd87a1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/samtools/samtools_0_1_19.nix
@@ -0,0 +1,33 @@
+{ lib, stdenv, fetchurl, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "samtools";
+  version = "0.1.19";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/samtools/${pname}-${version}.tar.bz2";
+    sha256 = "d080c9d356e5f0ad334007e4461cbcee3c4ca97b8a7a5a48c44883cf9dee63d4";
+  };
+
+  patches = [
+    ./samtools-0.1.19-no-curses.patch
+  ];
+
+  buildInputs = [ zlib ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mkdir -p $out/share/man
+
+    cp samtools $out/bin
+    cp samtools.1 $out/share/man
+  '';
+
+  meta = with lib; {
+    description = "Tools for manipulating SAM/BAM/CRAM format";
+    license = licenses.mit;
+    homepage = "http://samtools.sourceforge.net/";
+    platforms = platforms.unix;
+    maintainers = [ maintainers.unode ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/seaview/default.nix b/nixpkgs/pkgs/applications/science/biology/seaview/default.nix
new file mode 100644
index 000000000000..9cfa7cb933b0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/seaview/default.nix
@@ -0,0 +1,41 @@
+{ lib, stdenv, fetchurl, coreutils, fltk, libjpeg }:
+
+stdenv.mkDerivation rec {
+  version = "5.0.5";
+  pname = "seaview";
+
+  src = fetchurl {
+    url = "ftp://pbil.univ-lyon1.fr/pub/mol_phylogeny/seaview/archive/seaview_${version}.tar.gz";
+    sha256 = "sha256-zo9emLpHiDv6kekbx55NOibxWN2Zg7XngzGkUqSx+PI=";
+  };
+
+  buildInputs = [ fltk libjpeg ];
+
+  patchPhase = "sed -i 's#PATH=/bin:/usr/bin rm#'${coreutils}/bin/rm'#' seaview.cxx";
+  installPhase = "mkdir -p $out/bin; cp seaview $out/bin";
+
+  meta = with lib; {
+    description = "GUI for molecular phylogeny";
+    longDescription = ''
+      SeaView is a multiplatform, graphical user interface for multiple sequence alignment and molecular phylogeny.
+        - SeaView reads and writes various file formats (NEXUS, MSF, CLUSTAL, FASTA, PHYLIP, MASE, Newick) of DNA and protein sequences and of phylogenetic trees.
+        - SeaView drives programs muscle or Clustal Omega for multiple sequence alignment, and also allows to use any external alignment algorithm able to read and write FASTA-formatted files.
+        - Seaview drives the Gblocks program to select blocks of evolutionarily conserved sites.
+        - SeaView computes phylogenetic trees by
+          + parsimony, using PHYLIP's dnapars/protpars algorithm,
+          + distance, with NJ or BioNJ algorithms on a variety of evolutionary distances,
+          + maximum likelihood, driving program PhyML 3.1.
+        - Seaview can use the Transfer Bootstrap Expectation method to compute the bootstrap support of PhyML and distance trees.
+        - SeaView prints and draws phylogenetic trees on screen, SVG, PDF or PostScript files.
+        - SeaView allows to download sequences from EMBL/GenBank/UniProt using the Internet.
+
+      Seaview is published in:
+
+          Gouy M., Guindon S. & Gascuel O. (2010) SeaView version 4 : a multiplatform graphical user interface for sequence alignment and phylogenetic tree building. Molecular Biology and Evolution 27(2):221-224.
+    '';
+    homepage = "http://doua.prabi.fr/software/seaview";
+    license = licenses.gpl3;
+    maintainers = [ maintainers.iimog ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/snpeff/default.nix b/nixpkgs/pkgs/applications/science/biology/snpeff/default.nix
new file mode 100644
index 000000000000..4c32516b29f6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/snpeff/default.nix
@@ -0,0 +1,34 @@
+{lib, stdenv, fetchurl, jre, unzip, makeWrapper}:
+
+stdenv.mkDerivation rec {
+  pname = "snpeff";
+  version = "4.3t";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/project/snpeff/snpEff_v${builtins.replaceStrings [ "." ] [ "_" ] version}_core.zip";
+    sha256 = "0i12mv93bfv8xjwc3rs2x73d6hkvi7kgbbbx3ry984l3ly4p6nnm";
+  };
+
+  nativeBuildInputs = [ makeWrapper unzip ];
+  buildInputs = [ jre ];
+
+  sourceRoot = "snpEff";
+
+  installPhase = ''
+    mkdir -p $out/libexec/snpeff
+    cp *.jar *.config $out/libexec/snpeff
+
+    mkdir -p $out/bin
+    makeWrapper ${jre}/bin/java $out/bin/snpeff --add-flags "-jar $out/libexec/snpeff/snpEff.jar"
+    makeWrapper ${jre}/bin/java $out/bin/snpsift --add-flags "-jar $out/libexec/snpeff/SnpSift.jar"
+  '';
+
+  meta = with lib; {
+    description = "Genetic variant annotation and effect prediction toolbox";
+    license = licenses.lgpl3;
+    homepage = "http://snpeff.sourceforge.net/";
+    maintainers = with maintainers; [ jbedo ];
+    platforms = platforms.all;
+  };
+
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/somatic-sniper/default.nix b/nixpkgs/pkgs/applications/science/biology/somatic-sniper/default.nix
new file mode 100644
index 000000000000..034409cfb013
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/somatic-sniper/default.nix
@@ -0,0 +1,29 @@
+{lib, stdenv, fetchFromGitHub, cmake, zlib, ncurses}:
+
+stdenv.mkDerivation rec {
+  pname = "somatic-sniper";
+  version = "1.0.5.0";
+
+  src = fetchFromGitHub {
+    owner = "genome";
+    repo = "somatic-sniper";
+    rev = "v${version}";
+    sha256 = "0lk7p9sp6mp50f6w1nppqhr40fcwy1asw06ivw8w8jvvnwaqf987";
+  };
+
+  patches = [ ./somatic-sniper.patch ];
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ zlib ncurses ];
+
+  enableParallelBuilding = false;
+
+  meta = with lib; {
+    description = "Identify single nucleotide positions that are different between tumor and normal";
+    license = licenses.mit;
+    homepage = "https://github.com/genome/somatic-sniper";
+    maintainers = with maintainers; [ jbedo ];
+    platforms = platforms.linux;
+  };
+
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/somatic-sniper/somatic-sniper.patch b/nixpkgs/pkgs/applications/science/biology/somatic-sniper/somatic-sniper.patch
new file mode 100644
index 000000000000..9af04c0a0696
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/somatic-sniper/somatic-sniper.patch
@@ -0,0 +1,26 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 6d5a180..7254292 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -11,7 +11,7 @@ set(CMAKE_MODULE_PATH
+     )
+ 
+ include(TestHelper)
+-include(VersionHelper)
++#include(VersionHelper)
+ include(ProjectHelper)
+ 
+ # NOTE: for sniper we want the exe suffix to be like 0.7.4, not just 0.7
+diff --git a/vendor/samtools.patch b/vendor/samtools.patch
+index f173017..654f878 100644
+--- a/vendor/samtools.patch
++++ b/vendor/samtools.patch
+@@ -6,7 +6,7 @@ diff -Nuar a/Makefile b/Makefile
+  
+  samtools:lib $(AOBJS)
+ -		$(CC) $(CFLAGS) -o $@ $(AOBJS) -lm $(LIBPATH) $(LIBCURSES) -lz -L. -lbam
+-+		$(CC) $(CFLAGS) -o $@ $(AOBJS) -lm $(LIBPATH) $(LIBCURSES) -L. -lbam -lz
+++		$(CC) $(CFLAGS) -o $@ $(AOBJS) -lm $(LIBPATH) -lncurses -L. -lbam -lz
+  
+  razip:razip.o razf.o
+  		$(CC) $(CFLAGS) -o $@ razf.o razip.o -lz
diff --git a/nixpkgs/pkgs/applications/science/biology/sortmerna/default.nix b/nixpkgs/pkgs/applications/science/biology/sortmerna/default.nix
new file mode 100644
index 000000000000..11530c6a7226
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/sortmerna/default.nix
@@ -0,0 +1,46 @@
+{ lib, stdenv, cmake, rocksdb, rapidjson, pkg-config, fetchFromGitHub, fetchpatch, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "sortmerna";
+  version = "4.2.0";
+
+  src = fetchFromGitHub {
+    repo = pname;
+    owner = "biocore";
+    rev = "v${version}";
+    sha256 = "0r91viylzr069jm7kpcgb45kagvf8sqcj5zc1af4arl9sgfs1f3j";
+  };
+
+  nativeBuildInputs = [ cmake pkg-config ];
+  buildInputs = [ zlib rocksdb rapidjson ];
+
+  cmakeFlags = [
+    "-DCMAKE_BUILD_TYPE=Release"
+    "-DPORTABLE=off"
+    "-DRAPIDJSON_HOME=${rapidjson}"
+    "-DROCKSDB_HOME=${rocksdb}"
+    "-DROCKSDB_STATIC=off"
+    "-DZLIB_STATIC=off"
+  ];
+
+  postPatch = ''
+    # Fix formatting string error:
+    # https://github.com/biocore/sortmerna/issues/255
+    substituteInPlace src/sortmerna/indexdb.cpp \
+      --replace 'is_verbose, ss' 'is_verbose, "%s", ss'
+
+    # Fix missing pthread dependency for the main binary.
+    substituteInPlace src/sortmerna/CMakeLists.txt \
+      --replace "target_link_libraries(sortmerna" \
+        "target_link_libraries(sortmerna Threads::Threads"
+  '';
+
+  meta = with lib; {
+    description = "Tools for filtering, mapping, and OTU-picking from shotgun genomics data";
+    license = licenses.lgpl3;
+    platforms = platforms.x86_64;
+    homepage = "https://bioinfo.lifl.fr/RNA/sortmerna/";
+    maintainers = with maintainers; [ luispedro ];
+    broken = stdenv.isDarwin;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/spades/default.nix b/nixpkgs/pkgs/applications/science/biology/spades/default.nix
new file mode 100644
index 000000000000..5302b43bb026
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/spades/default.nix
@@ -0,0 +1,27 @@
+{ lib, stdenv, fetchurl, zlib, bzip2, cmake, python3 }:
+
+stdenv.mkDerivation rec {
+  pname = "SPAdes";
+  version = "3.15.4";
+
+  src = fetchurl {
+    url = "http://cab.spbu.ru/files/release${version}/${pname}-${version}.tar.gz";
+    sha256 = "sha256-OyQcUopCqL398j5b+PAISDR5BZDQhJHezqnw8AnYWJ8=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  buildInputs = [ zlib bzip2 python3 ];
+
+  doCheck = true;
+
+  sourceRoot = "${pname}-${version}/src";
+
+  meta = with lib; {
+    description = "St. Petersburg genome assembler: assembly toolkit containing various assembly pipelines";
+    license = licenses.gpl2Only;
+    homepage = "http://cab.spbu.ru/software/spades/";
+    platforms = with platforms; [ "x86_64-linux" "x86_64-darwin"];
+    maintainers = [ maintainers.bzizou ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/stacks/default.nix b/nixpkgs/pkgs/applications/science/biology/stacks/default.nix
new file mode 100644
index 000000000000..5fcb367ce5cb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/stacks/default.nix
@@ -0,0 +1,19 @@
+{ lib, stdenv, fetchurl, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "stacks";
+  version = "2.60";
+  src = fetchurl {
+    url = "http://catchenlab.life.illinois.edu/stacks/source/${pname}-${version}.tar.gz";
+    sha256 = "sha256-ppKG7Z1TyLwUyqRnGYk3QWPJqKeNcW04GMW7myPFSNM=";
+  };
+
+  buildInputs = [ zlib ];
+
+  meta = {
+    description = "Software pipeline for building loci from short-read sequences";
+    homepage = "http://catchenlab.life.illinois.edu/stacks/";
+    maintainers = [ lib.maintainers.bzizou ];
+    license = lib.licenses.gpl3Plus;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/star/default.nix b/nixpkgs/pkgs/applications/science/biology/star/default.nix
new file mode 100644
index 000000000000..3555929a33ea
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/star/default.nix
@@ -0,0 +1,39 @@
+{ lib, stdenv, fetchFromGitHub, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "star";
+  version = "2.7.10a";
+
+  src = fetchFromGitHub {
+    repo = "STAR";
+    owner = "alexdobin";
+    rev = version;
+    sha256 = "sha256-qwddCGMOKWgx76qGwRQXwvv9fCSeVsZbWHmlBwEqGKE=";
+  };
+
+  sourceRoot = "source/source";
+
+  postPatch = ''
+    substituteInPlace Makefile --replace "/bin/rm" "rm"
+  '';
+
+  buildInputs = [ zlib ];
+
+  buildFlags = [ "STAR" "STARlong" ];
+
+  enableParallelBuilding = true;
+
+  installPhase = ''
+    runHook preInstall
+    install -D STAR STARlong -t $out/bin
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Spliced Transcripts Alignment to a Reference";
+    homepage = "https://github.com/alexdobin/STAR";
+    license = licenses.gpl3Plus;
+    platforms = [ "x86_64-linux" ];
+    maintainers = [ maintainers.arcadio ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/strelka/default.nix b/nixpkgs/pkgs/applications/science/biology/strelka/default.nix
new file mode 100644
index 000000000000..8585f3770fbc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/strelka/default.nix
@@ -0,0 +1,43 @@
+{lib, stdenv, fetchFromGitHub, cmake, zlib, python2}:
+
+stdenv.mkDerivation rec {
+  pname = "strelka";
+  version = "2.9.10";
+
+  src = fetchFromGitHub {
+    owner = "Illumina";
+    repo = "strelka";
+    rev = "v${version}";
+    sha256 = "1nykbmim1124xh22nrhrsn8xgjb3s2y7akrdapn9sl1gdych4ppf";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ zlib python2 ];
+
+  NIX_CFLAGS_COMPILE = [
+    "-Wno-error=maybe-uninitialized"
+    "-Wno-error=pessimizing-move"
+  ];
+
+  preConfigure = ''
+    sed -i 's|/usr/bin/env python|${python2}/bin/python|' src/python/lib/makeRunScript.py
+    patchShebangs .
+  '';
+
+  postFixup = ''
+    pushd $out/lib/python/pyflow
+    sed -i 's|/bin/bash|${stdenv.shell}|' pyflowTaskWrapper.py
+    rm pyflowTaskWrapper.pyc
+    echo "import pyflowTaskWrapper" | python2
+    popd
+  '';
+
+  meta = with lib; {
+    description = "Germline and small variant caller";
+    license = licenses.gpl3;
+    homepage = "https://github.com/Illumina/strelka";
+    maintainers = with maintainers; [ jbedo ];
+    platforms = [ "x86_64-linux" ];
+  };
+
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/subread/default.nix b/nixpkgs/pkgs/applications/science/biology/subread/default.nix
new file mode 100644
index 000000000000..431bd3788e7d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/subread/default.nix
@@ -0,0 +1,40 @@
+{ lib
+, stdenv
+, fetchurl
+, zlib
+}:
+
+stdenv.mkDerivation rec {
+  pname = "subread";
+  version = "2.0.3";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/subread/subread-${version}/subread-${version}-source.tar.gz";
+    sha256 = "sha256-Vs7zovkU1DJxMGnVwoL0iDHDoezIlDKtVYDKoyKl9Ws=";
+  };
+
+  buildInputs = [
+    zlib
+  ];
+
+  configurePhase = ''
+    cd src
+    cp Makefile.${if stdenv.isLinux then "Linux" else "MacOS"} Makefile
+  '';
+
+  makeFlags = [ "CC_EXEC=cc" ];
+
+  installPhase = ''
+    mkdir $out
+    cp -r ../bin $out
+  '';
+
+  meta = with lib; {
+    description = "High-performance read alignment, quantification and mutation discovery";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ jbedo ];
+    platforms = [ "x86_64-darwin" "x86_64-linux" ];
+    homepage = "http://subread.sourceforge.net/";
+  };
+
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/sumatools/default.nix b/nixpkgs/pkgs/applications/science/biology/sumatools/default.nix
new file mode 100644
index 000000000000..2a30f33172b9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/sumatools/default.nix
@@ -0,0 +1,68 @@
+{ lib, gccStdenv, fetchFromGitLab, zlib }:
+
+let
+  stdenv = gccStdenv;
+  meta = with lib; {
+    description = "Fast and exact comparison and clustering of sequences";
+    homepage = "https://metabarcoding.org/sumatra";
+    maintainers = [ maintainers.bzizou ];
+    platforms = platforms.unix;
+  };
+
+in rec {
+
+  # Suma library
+  sumalibs = stdenv.mkDerivation rec {
+    version = "1.0.34";
+    pname = "sumalibs";
+    src = fetchFromGitLab {
+      domain = "git.metabarcoding.org";
+      owner = "obitools";
+      repo = pname;
+      rev = "sumalib_v${version}";
+      sha256 = "0hwkrxzfz7m5wdjvmrhkjg8kis378iaqr5n4nhdhkwwhn8x1jn5a";
+    };
+    makeFlags = [ "PREFIX=$(out)" ];
+    inherit meta;
+  };
+
+  # Sumatra
+  sumatra = stdenv.mkDerivation rec {
+    version = "1.0.34";
+    pname = "sumatra";
+    src = fetchFromGitLab {
+      domain = "git.metabarcoding.org";
+      owner = "obitools";
+      repo = pname;
+      rev = "${pname}_v${version}";
+      sha256 = "1bbpbdkshdc3xffqnr1qfy8qk64ldsmdc3s8mrcrlx132rgbi5f6";
+    };
+    buildInputs = [ sumalibs zlib ];
+    makeFlags = [
+      "LIBSUMA=${sumalibs}/lib/libsuma.a"
+      "LIBSUMAPATH=-L${sumalibs}"
+      "PREFIX=$(out)"
+    ];
+    inherit meta;
+  };
+
+  # Sumaclust
+  sumaclust = stdenv.mkDerivation rec {
+    version = "1.0.34";
+    pname = "sumaclust";
+    src = fetchFromGitLab {
+      domain = "git.metabarcoding.org";
+      owner = "obitools";
+      repo = pname;
+      rev = "${pname}_v${version}";
+      sha256 = "0x8yi3k3jxhmv2krp4rcjlj2f9zg0qrk7gx4kpclf9c3yxgsgrds";
+    };
+    buildInputs = [ sumalibs ];
+    makeFlags = [
+      "LIBSUMA=${sumalibs}/lib/libsuma.a"
+      "LIBSUMAPATH=-L${sumalibs}"
+      "PREFIX=$(out)"
+    ];
+    inherit meta;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/svaba/default.nix b/nixpkgs/pkgs/applications/science/biology/svaba/default.nix
new file mode 100644
index 000000000000..1aed501919f9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/svaba/default.nix
@@ -0,0 +1,42 @@
+{ lib, stdenv, zlib, bzip2, xz, fetchFromGitHub } :
+
+stdenv.mkDerivation rec {
+  version = "1.1.0";
+  pname = "svaba";
+
+  src = fetchFromGitHub {
+    owner = "walaj";
+    repo = pname;
+    rev = version;
+    sha256 = "1vv5mc9z5d22kgdy7mm27ya5aahnqgkcrskdr2405058ikk9g8kp";
+    fetchSubmodules = true;
+  };
+
+  buildInputs = [ zlib bzip2 xz ];
+
+  installPhase = ''
+    runHook preInstall
+    install -Dm555 src/svaba/svaba $out/bin/svaba
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Structural variant and INDEL caller for DNA sequencing data, using genome-wide local assembly";
+    license = licenses.gpl3;
+    homepage = "https://github.com/walaj/svaba";
+    maintainers = with maintainers; [ scalavision ];
+    platforms = platforms.linux;
+    longDescription = ''
+      SvABA is a method for detecting structural variants in sequencing data
+      using genome-wide local assembly. Under the hood, SvABA uses a custom
+      implementation of SGA (String Graph Assembler) by Jared Simpson,
+      and BWA-MEM by Heng Li. Contigs are assembled for every 25kb window
+      (with some small overlap) for every region in the genome.
+      The default is to use only clipped, discordant, unmapped and indel reads,
+      although this can be customized to any set of reads at the command line using VariantBam rules.
+      These contigs are then immediately aligned to the reference with BWA-MEM and parsed to identify variants.
+      Sequencing reads are then realigned to the contigs with BWA-MEM, and variants are scored by their read support.
+    '';
+
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/tebreak/default.nix b/nixpkgs/pkgs/applications/science/biology/tebreak/default.nix
new file mode 100644
index 000000000000..e56d91dc2cd1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/tebreak/default.nix
@@ -0,0 +1,48 @@
+{ lib, fetchFromGitHub, last, exonerate, minia, python3, bwa
+, samtools, findutils }:
+
+python3.pkgs.buildPythonApplication rec {
+  pname = "tebreak";
+  version = "1.1";
+
+  src = fetchFromGitHub {
+    owner = "adamewing";
+    repo = "tebreak";
+    rev = version;
+    sha256 = "13mgh775d8hkl340923lfwwm4r5ps70girn8d6wgfxzwzxylz8iz";
+  };
+
+  nativeBuildInputs = [ findutils python3.pkgs.cython ];
+  propagatedBuildInputs = with python3.pkgs; [
+    pysam
+    scipy
+    bx-python
+    scikit-bio
+  ];
+
+  preConfigure = ''
+    # patch the paths to all required software
+    for f in $(find . -type f) ; do
+      sed -i "s|'bwa'|'${bwa}/bin/bwa'|" $f
+      sed -i "s|'minia'|'${minia}/bin/minia'|" $f
+      sed -i "s|'exonerate'|'${exonerate}/bin/exonerate'|" $f
+      sed -i "s|'samtools'|'${samtools}/bin/samtools'|" $f
+      sed -i "s|'lastal'|'${last}/bin/lastal'|" $f
+      sed -i "s|'lastdb'|'${last}/bin/lastdb'|" $f
+    done
+  '';
+
+  checkPhase = ''
+    $out/bin/tebreak -b test/data/example.ins.bam  -r test/data/Homo_sapiens_chr4_50000000-60000000_assembly19.fasta -p 4 --pickle test/example.pickle --detail_out test/example.tebreak.detail.out -i lib/teref.human.fa
+    pushd test
+    ${python3.interpreter} checktest.py
+  '';
+
+  meta = with lib; {
+    description = "Find and characterise transposable element insertions";
+    homepage = "https://github.com/adamewing/tebreak";
+    license = licenses.mit;
+    maintainers = with maintainers; [ jbedo ];
+    platforms = platforms.x86_64;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/trimal/default.nix b/nixpkgs/pkgs/applications/science/biology/trimal/default.nix
new file mode 100755
index 000000000000..b27a63a2135a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/trimal/default.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  pname = "trimal";
+  version = "1.4.1";
+
+  src = fetchFromGitHub {
+    repo = pname;
+    owner = "scapella";
+    rev = "v${version}";
+    sha256 = "0isc7s3514di4z953xq53ncjkbi650sh4q9yyw5aag1n9hqnh7k0";
+  };
+
+  postUnpack = ''
+    sourceRoot=''${sourceRoot}/source
+    echo Source root reset to ''${sourceRoot}
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp -a trimal readal statal $out/bin
+  '';
+
+  meta = with lib; {
+    description = "A tool for the automated removal of spurious sequences or poorly aligned regions from a multiple sequence alignment";
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+    homepage = "http://trimal.cgenomics.org";
+    maintainers = [ maintainers.bzizou ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/truvari/default.nix b/nixpkgs/pkgs/applications/science/biology/truvari/default.nix
new file mode 100644
index 000000000000..31c1fc50ee3e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/truvari/default.nix
@@ -0,0 +1,52 @@
+{ lib
+, fetchFromGitHub
+, python3Packages
+}:
+
+python3Packages.buildPythonApplication rec {
+  pname = "truvari";
+  version = "2.1.1";
+
+  src = fetchFromGitHub {
+    owner = "spiralgenetics";
+    repo = "truvari";
+    rev = "v${version}";
+    sha256 = "14nsdbj063qm175xxixs34cihvsiskc9gym8pg7gbwsh13k5a00h";
+  };
+
+  postPatch = ''
+    substituteInPlace setup.py \
+      --replace 'python-Levenshtein==0.12.1' 'python-Levenshtein>=0.12.1'
+  '';
+
+  propagatedBuildInputs = with python3Packages; [
+    pyvcf
+    python-Levenshtein
+    progressbar2
+    pysam
+    pyfaidx
+    intervaltree
+    pytabix
+    acebinf
+    bwapy
+    joblib
+    pandas
+  ];
+
+  # no tests
+  doCheck = false;
+  pythonImportsCheck = [ "truvari" ];
+
+  meta = with lib; {
+    description = "Structural variant comparison tool for VCFs";
+    homepage = "https://github.com/spiralgenetics/truvari";
+    license = licenses.mit;
+    maintainers = with maintainers; [ scalavision ];
+    longDescription = ''
+      Truvari is a benchmarking tool for comparison sets of SVs.
+      It can calculate the recall, precision, and f-measure of a
+      vcf from a given structural variant caller. The tool
+      is created by Spiral Genetics.
+    '';
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/varscan/default.nix b/nixpkgs/pkgs/applications/science/biology/varscan/default.nix
new file mode 100644
index 000000000000..7b09f601ad68
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/varscan/default.nix
@@ -0,0 +1,37 @@
+{lib, stdenv, fetchurl, jre, makeWrapper}:
+
+stdenv.mkDerivation rec {
+  pname = "varscan";
+  version = "2.4.4";
+
+  src = fetchurl {
+    url = "https://github.com/dkoboldt/varscan/raw/master/VarScan.v${version}.jar";
+    sha256 = "sha256-+yO3KrZ2+1qJvQIJHCtsmv8hC5a+4E2d7mrvTYtygU0=";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ jre ];
+
+  dontUnpack = true;
+
+  installPhase = ''
+    mkdir -p $out/libexec/varscan
+    cp $src $out/libexec/varscan/varscan.jar
+    mkdir -p $out/bin
+    makeWrapper ${jre}/bin/java $out/bin/varscan --add-flags "-jar $out/libexec/varscan/varscan.jar"
+  '';
+
+  meta = with lib; {
+    description = "Variant calling and somatic mutation/CNV detection for next-generation sequencing data";
+    # VarScan 2 is free for non-commercial use by academic,
+    # government, and non-profit/not-for-profit institutions. A
+    # commercial version of the software is available, and licensed
+    # through the Office of Technology Management at Washington
+    # University School of Medicine.
+    license = licenses.unfree;
+    homepage = "https://github.com/dkoboldt/varscan";
+    maintainers = with maintainers; [ jbedo ];
+    platforms = platforms.all;
+  };
+
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/vcftools/default.nix b/nixpkgs/pkgs/applications/science/biology/vcftools/default.nix
new file mode 100755
index 000000000000..9f88079627e0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/vcftools/default.nix
@@ -0,0 +1,23 @@
+{ lib, stdenv, fetchFromGitHub, zlib, autoreconfHook, pkg-config, perl }:
+
+stdenv.mkDerivation rec {
+  pname = "vcftools";
+  version = "0.1.16";
+
+  src = fetchFromGitHub {
+    repo = pname;
+    owner = "vcftools";
+    rev = "v${version}";
+    sha256 = "0msb09d2cnm8rlpg8bsc1lhjddvp3kf3i9dsj1qs4qgsdlzhxkyx";
+  };
+
+  buildInputs = [ autoreconfHook pkg-config zlib perl ];
+
+  meta = with lib; {
+    description = "A set of tools written in Perl and C++ for working with VCF files, such as those generated by the 1000 Genomes Project";
+    license = licenses.lgpl3;
+    platforms = platforms.linux;
+    homepage = "https://vcftools.github.io/index.html";
+    maintainers = [ maintainers.rybern ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/whisper/default.nix b/nixpkgs/pkgs/applications/science/biology/whisper/default.nix
new file mode 100644
index 000000000000..8552eede170b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/whisper/default.nix
@@ -0,0 +1,34 @@
+{ lib, stdenv, fetchFromGitHub, fetchurl }:
+
+stdenv.mkDerivation rec {
+  pname = "whisper";
+  version = "2.0.1";
+
+  src = fetchFromGitHub {
+    owner = "refresh-bio";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "0wpx1w1mar2d6zq2v14vy6nn896ds1n3zshxhhrrj5d528504iyw";
+  };
+
+  preConfigure = ''
+    cd src
+
+    # disable default static linking
+    sed -i 's/ -static / /' makefile
+  '';
+
+  installPhase = ''
+    runHook preInstall
+    install -Dt $out/bin whisper whisper-index
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Short read sequence mapper";
+    license = licenses.gpl3;
+    homepage = "https://github.com/refresh-bio/whisper";
+    maintainers = with maintainers; [ jbedo ];
+    platforms = platforms.x86_64;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/biology/xenomapper/default.nix b/nixpkgs/pkgs/applications/science/biology/xenomapper/default.nix
new file mode 100644
index 000000000000..194db966915e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/xenomapper/default.nix
@@ -0,0 +1,23 @@
+{ python3, lib, fetchFromGitHub }:
+
+python3.pkgs.buildPythonApplication rec {
+  pname = "xenomapper";
+  version = "1.0.2";
+
+  src = fetchFromGitHub {
+    owner = "genomematt";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "0mnmfzlq5mhih6z8dq5bkx95vb8whjycz9mdlqwbmlqjb3gb3zhr";
+  };
+
+  propagatedBuildInputs = with python3.pkgs; [ statistics ];
+
+  meta = with lib; {
+    homepage = "https://github.com/genomematt/xenomapper";
+    description = "A utility for post processing mapped reads that have been aligned to a primary genome and a secondary genome and binning reads into species specific, multimapping in each species, unmapped and unassigned bins";
+    license = licenses.gpl3;
+    platforms = platforms.all;
+    maintainers = [ maintainers.jbedo ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/avogadro/default.nix b/nixpkgs/pkgs/applications/science/chemistry/avogadro/default.nix
new file mode 100644
index 000000000000..c6339bab1228
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/avogadro/default.nix
@@ -0,0 +1,30 @@
+{ lib, stdenv, fetchurl, cmake, qt4, zlib, eigen, openbabel, pkg-config, libGLU, libGL, libX11, doxygen }:
+
+stdenv.mkDerivation rec {
+  pname = "avogadro";
+  version = "1.1.1";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/avogadro/avogadro-${version}.tar.bz2";
+    sha256 = "050ag9p4vg7jg8hj1wqfv7lsm6ar2isxjw2vw85s49vsl7g7nvzy";
+  };
+
+  buildInputs = [ qt4 eigen zlib openbabel libGL libGLU libX11 ];
+
+  nativeBuildInputs = [ cmake pkg-config doxygen ];
+
+  NIX_CFLAGS_COMPILE = "-include ${libGLU.dev}/include/GL/glu.h";
+
+  patches = [
+    (fetchurl {
+      url = "https://data.gpo.zugaina.org/fusion809/sci-chemistry/avogadro/files/avogadro-1.1.0-xlibs.patch";
+      sha256 = "1p113v19z3zwr9gxj2k599f8p97a8rwm93pa4amqvd0snn31mw0k";
+    })
+  ];
+
+  meta = with lib; {
+    description = "Molecule editor and visualizer";
+    maintainers = with maintainers; [ danielbarter ];
+    platforms = platforms.mesaPlatforms;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/avogadro2/default.nix b/nixpkgs/pkgs/applications/science/chemistry/avogadro2/default.nix
new file mode 100644
index 000000000000..6931c8621c96
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/avogadro2/default.nix
@@ -0,0 +1,49 @@
+{ lib, stdenv, fetchFromGitHub, cmake, eigen, avogadrolibs, molequeue, hdf5
+, openbabel, qttools, wrapQtAppsHook
+}:
+
+let
+  avogadroI18N = fetchFromGitHub {
+    owner = "OpenChemistry";
+    repo = "avogadro-i18n";
+    rev = "3b8a86cc37e988b043d1503d2f11068389b0aca3";
+    sha256 = "9wLY7/EJyIZYnlUAMsViCwD5kGc1vCNbk8vUhb90LMQ=";
+  };
+
+in stdenv.mkDerivation rec {
+  pname = "avogadro2";
+  version = "1.95.1";
+
+  src = fetchFromGitHub {
+    owner = "OpenChemistry";
+    repo = "avogadroapp";
+    rev = version;
+    sha256 = "9GnsxQsMuik6CPDmJbJPF0/+LXbZHf/JLevpSsMEoP0=";
+  };
+
+  postUnpack = ''
+    cp -r ${avogadroI18N} avogadro-i18n
+  '';
+
+  nativeBuildInputs = [ cmake wrapQtAppsHook ];
+
+  buildInputs = [
+    avogadrolibs
+    molequeue
+    eigen
+    hdf5
+    qttools
+  ];
+
+  propagatedBuildInputs = [ openbabel ];
+
+  qtWrapperArgs = [ "--prefix PATH : ${openbabel}/bin" ];
+
+  meta = with lib; {
+    description = "Molecule editor and visualizer";
+    maintainers = with maintainers; [ sheepforce ];
+    homepage = "https://github.com/OpenChemistry/avogadroapp";
+    platforms = platforms.mesaPlatforms;
+    license = licenses.bsd3;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/chemtool/default.nix b/nixpkgs/pkgs/applications/science/chemistry/chemtool/default.nix
new file mode 100644
index 000000000000..bf78aeb825d5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/chemtool/default.nix
@@ -0,0 +1,51 @@
+{ lib
+, stdenv
+, fetchurl
+, pkg-config
+, libX11
+, gtk2
+, fig2dev
+, wrapGAppsHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "chemtool";
+  version = "1.6.14";
+
+  src = fetchurl {
+    url = "http://ruby.chemie.uni-freiburg.de/~martin/${pname}/${pname}-${version}.tar.gz";
+    sha256 = "hhYaBGE4azNKX/sXzfCUpJGUGIRngnL0V0mBNRTdr8s=";
+  };
+
+  nativeBuildInputs = [ pkg-config wrapGAppsHook ];
+  buildInputs = [
+    libX11
+    gtk2
+    fig2dev
+  ];
+
+  preFixup = ''
+    gappsWrapperArgs+=(--prefix PATH : "${lib.makeBinPath [ fig2dev ]}")
+  '';
+
+  meta = with lib; {
+    homepage = "http://ruby.chemie.uni-freiburg.de/~martin/chemtool/";
+    description = "Draw chemical structures";
+    longDescription = ''
+      Chemtool is a program for drawing organic molecules. It runs under the X
+      Window System using the GTK widget set.
+
+      Most operations in chemtool can be accomplished using the mouse - the
+      first (usually the left) button is used to select or place things, the
+      middle button modifies properties (e.g. reverses the direction of a bond),
+      and the right button is used to delete objects.
+
+      The program offers essentially unlimited undo/redo, two text fonts plus
+      symbols, seven colors, drawing at several zoom scales, and square and
+      hexagonal backdrop grids for easier alignment.
+    '';
+    license = licenses.mit;
+    maintainers = with maintainers; [ AndersonTorres ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/cp2k/default.nix b/nixpkgs/pkgs/applications/science/chemistry/cp2k/default.nix
new file mode 100644
index 000000000000..26cf411cb78a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/cp2k/default.nix
@@ -0,0 +1,121 @@
+{ lib, stdenv, fetchFromGitHub, python3, gfortran, blas, lapack
+, fftw, libint, libvori, libxc, mpi, gsl, scalapack, openssh, makeWrapper
+, libxsmm, spglib, which, pkg-config
+, enableElpa ? false
+, elpa
+} :
+
+let
+  cp2kVersion = "psmp";
+  arch = "Linux-x86-64-gfortran";
+
+in stdenv.mkDerivation rec {
+  pname = "cp2k";
+  version = "9.1.0";
+
+  src = fetchFromGitHub {
+    owner = "cp2k";
+    repo = "cp2k";
+    rev = "v${version}";
+    hash = "sha256-P9RwZmrE1E0UTQVasQxWAqa3LBLyJNGeJo8T6u5WWcw=";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [ python3 which openssh makeWrapper pkg-config ];
+  buildInputs = [
+    gfortran
+    fftw
+    gsl
+    libint
+    libvori
+    libxc
+    libxsmm
+    spglib
+    scalapack
+    blas
+    lapack
+  ] ++ lib.optional enableElpa elpa;
+
+  propagatedBuildInputs = [ mpi ];
+  propagatedUserEnvPkgs = [ mpi ];
+
+  makeFlags = [
+    "ARCH=${arch}"
+    "VERSION=${cp2kVersion}"
+  ];
+
+  doCheck = true;
+
+  enableParallelBuilding = true;
+
+  postPatch = ''
+    patchShebangs tools exts/dbcsr/tools/build_utils exts/dbcsr/.cp2k
+    substituteInPlace exts/build_dbcsr/Makefile \
+      --replace '/usr/bin/env python3' '${python3}/bin/python' \
+      --replace 'SHELL = /bin/sh' 'SHELL = bash'
+  '';
+
+  configurePhase = ''
+    cat > arch/${arch}.${cp2kVersion} << EOF
+    CC         = mpicc
+    CPP        =
+    FC         = mpif90
+    LD         = mpif90
+    AR         = ar -r
+    DFLAGS     = -D__FFTW3 -D__LIBXC -D__LIBINT -D__parallel -D__SCALAPACK \
+                 -D__MPI_VERSION=3 -D__F2008 -D__LIBXSMM -D__SPGLIB \
+                 -D__MAX_CONTR=4 -D__LIBVORI ${lib.optionalString enableElpa "-D__ELPA"}
+    CFLAGS    = -fopenmp
+    FCFLAGS    = \$(DFLAGS) -O2 -ffree-form -ffree-line-length-none \
+                 -ftree-vectorize -funroll-loops -msse2 \
+                 -std=f2008 \
+                 -fopenmp -ftree-vectorize -funroll-loops \
+                 -I${libxc}/include -I${libxsmm}/include \
+                 -I${libint}/include ${lib.optionalString enableElpa "$(pkg-config --variable=fcflags elpa)"}
+    LIBS       = -lfftw3 -lfftw3_threads \
+                 -lscalapack -lblas -llapack \
+                 -lxcf03 -lxc -lxsmmf -lxsmm -lsymspg \
+                 -lint2 -lstdc++ -lvori \
+                 -lgomp -lpthread -lm \
+                 -fopenmp ${lib.optionalString enableElpa "$(pkg-config --libs elpa)"}
+    LDFLAGS    = \$(FCFLAGS) \$(LIBS)
+    EOF
+  '';
+
+  checkPhase = ''
+    export OMP_NUM_THREADS=1
+
+    export HYDRA_IFACE=lo  # Fix to make mpich run in a sandbox
+    export OMPI_MCA_rmaps_base_oversubscribe=1
+    export CP2K_DATA_DIR=data
+
+    mpirun -np 2 exe/${arch}/libcp2k_unittest.${cp2kVersion}
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin $out/share/cp2k
+
+    cp exe/${arch}/* $out/bin
+
+    for i in cp2k cp2k_shell graph; do
+      wrapProgram $out/bin/$i.${cp2kVersion} \
+        --set-default CP2K_DATA_DIR $out/share/cp2k
+    done
+
+    wrapProgram $out/bin/cp2k.popt \
+      --set-default CP2K_DATA_DIR $out/share/cp2k \
+      --set OMP_NUM_THREADS 1
+
+    cp -r data/* $out/share/cp2k
+  '';
+
+  passthru = { inherit mpi; };
+
+  meta = with lib; {
+    description = "Quantum chemistry and solid state physics program";
+    homepage = "https://www.cp2k.org";
+    license = licenses.gpl2Plus;
+    maintainers = [ maintainers.sheepforce ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/d-seams/default.nix b/nixpkgs/pkgs/applications/science/chemistry/d-seams/default.nix
new file mode 100644
index 000000000000..74260bacabcc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/d-seams/default.nix
@@ -0,0 +1,33 @@
+{ clangStdenv, fetchFromGitHub, catch2, rang, fmt, libyamlcpp, cmake
+, eigen, lua, luaPackages, liblapack, blas, lib, boost, gsl }:
+
+clangStdenv.mkDerivation rec {
+  version = "1.0.1";
+  pname = "d-SEAMS";
+
+  src = fetchFromGitHub {
+    owner = "d-SEAMS";
+    repo = "seams-core";
+    rev = "v${version}";
+    sha256 = "03zhhl9vhi3rhc3qz1g3zb89jksgpdlrk15fcr8xcz8pkj6r5b1i";
+  };
+
+  nativeBuildInputs = [ cmake lua luaPackages.luafilesystem ];
+  buildInputs = [ fmt rang libyamlcpp eigen catch2 boost gsl liblapack blas ];
+
+  meta = with lib; {
+    description =
+      "d-SEAMS: Deferred Structural Elucidation Analysis for Molecular Simulations";
+    longDescription = ''
+      d-SEAMS, is a free and open-source postprocessing engine for the analysis
+      of molecular dynamics trajectories, which is specifically able to
+      qualitatively classify ice structures in both strong-confinement and bulk
+      systems. The engine is in C++, with extensions via the Lua scripting
+      interface.
+    '';
+    homepage = "https://dseams.info";
+    license = licenses.gpl3Plus;
+    platforms = [ "x86_64-linux" ];
+    maintainers = [ maintainers.HaoZeke ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/dkh/default.nix b/nixpkgs/pkgs/applications/science/chemistry/dkh/default.nix
new file mode 100644
index 000000000000..a0bed24336a9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/dkh/default.nix
@@ -0,0 +1,32 @@
+{ lib, stdenv, gfortran, fetchFromGitHub, cmake } :
+
+stdenv.mkDerivation rec {
+  pname = "dkh";
+  version = "1.2";
+
+  src = fetchFromGitHub  {
+    owner = "psi4";
+    repo = pname;
+    rev = "v${version}";
+    sha256= "1wb4qmb9f8rnrwnnw1gdhzx1fmhy628bxfrg56khxy3j5ljxkhck";
+  };
+
+  nativeBuildInputs = [
+    gfortran
+    cmake
+  ];
+
+  cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" ];
+
+  hardeningDisable = [
+    "format"
+  ];
+
+  meta = with lib; {
+    description = "Arbitrary-order scalar-relativistic Douglas-Kroll-Hess module";
+    license = licenses.lgpl3Only;
+    homepage = "https://github.com/psi4/dkh";
+    platforms = platforms.unix;
+    maintainers = [ maintainers.sheepforce ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/element/default.nix b/nixpkgs/pkgs/applications/science/chemistry/element/default.nix
new file mode 100644
index 000000000000..812272e2fb9b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/element/default.nix
@@ -0,0 +1,22 @@
+{ lib, buildGoModule, fetchFromGitHub }:
+
+buildGoModule rec {
+  pname = "element";
+  version = "1.0.0";
+
+  src = fetchFromGitHub {
+    owner = "gennaro-tedesco";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "gjdcNvYNnxb6hOE/MQjTezZeYGBWTr4E8/Pt8YQv3lY=";
+  };
+
+  vendorSha256 = "A4g2rQTaYrA4/0rqldUv7iuibzNINEvx9StUnaN2/Yg=";
+
+  meta = with lib; {
+    description = "The periodic table on the command line";
+    homepage = "https://github.com/gennaro-tedesco/element";
+    license = licenses.asl20;
+    maintainers = [ maintainers.j0hax ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/ergoscf/default.nix b/nixpkgs/pkgs/applications/science/chemistry/ergoscf/default.nix
new file mode 100644
index 000000000000..b7d61848134e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/ergoscf/default.nix
@@ -0,0 +1,40 @@
+{ lib, stdenv, fetchurl, blas, lapack } :
+
+stdenv.mkDerivation rec {
+  pname = "ergoscf";
+  version = "3.8";
+
+  src = fetchurl {
+    url = "http://www.ergoscf.org/source/tarfiles/ergo-${version}.tar.gz";
+    sha256 = "1s50k2gfs3y6r5kddifn4p0wmj0yk85wm5vf9v3swm1c0h43riix";
+  };
+
+  buildInputs = [ blas lapack ];
+
+  patches = [ ./math-constants.patch ];
+
+  postPatch = ''
+    patchShebangs ./test
+  '';
+
+  configureFlags = [
+    "--enable-linalgebra-templates"
+    "--enable-performance"
+  ] ++ lib.optional stdenv.isx86_64 "--enable-sse-intrinsics";
+
+  LDFLAGS = "-lblas -llapack";
+
+  enableParallelBuilding = true;
+
+  OMP_NUM_THREADS = 2; # required for check phase
+
+  doCheck = true;
+
+  meta = with lib; {
+    description = "Quantum chemistry program for large-scale self-consistent field calculations";
+    homepage = "http://www.ergoscf.org";
+    license = licenses.gpl3Plus;
+    maintainers = [ maintainers.markuskowa ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/ergoscf/math-constants.patch b/nixpkgs/pkgs/applications/science/chemistry/ergoscf/math-constants.patch
new file mode 100644
index 000000000000..62209f1a3d84
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/ergoscf/math-constants.patch
@@ -0,0 +1,19 @@
+diff --git a/source/dft/functionals.h b/source/dft/functionals.h
+index fde49ba..f7a61fc 100644
+--- a/source/dft/functionals.h
++++ b/source/dft/functionals.h
+@@ -59,6 +59,14 @@
+ #define EXTERN_C
+ #endif
+ 
++#ifndef M_PI
++#define M_PI 3.14159265358979323846
++#endif
++
++#ifndef M_SQRT2
++#define M_SQRT2        1.41421356237309504880
++#endif
++
+ typedef ergo_real real;
+ 
+ #if defined(FUNC_PRECISION) && FUNC_PRECISION == 1
diff --git a/nixpkgs/pkgs/applications/science/chemistry/gwyddion/codegen.patch b/nixpkgs/pkgs/applications/science/chemistry/gwyddion/codegen.patch
new file mode 100644
index 000000000000..eb306d99f8a3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/gwyddion/codegen.patch
@@ -0,0 +1,22 @@
+--- gwyddion-2.55.orig/configure	2019-11-04 01:25:31.000000000 -0800
++++ gwyddion-2.55/configure	2020-03-20 18:49:43.860452655 -0700
+@@ -18560,7 +18560,7 @@
+ fi
+   if test "x$embed_pygtk" = xno; then
+     if test "x$PYGTK_CODEGENDIR" = 'x'; then
+-      PYGTK_CODEGENDIR=`$PKG_CONFIG --variable=codegendir pygtk-2.0`
++      PYGTK_CODEGENDIR=`$PKG_CONFIG --variable=codegendir pygobject-2.0`
+     fi
+   else
+     # Some silly OSes want to remove pygtk2.  We can build pygwy without
+--- gwyddion-2.55.orig/configure.ac	2019-11-04 01:25:16.000000000 -0800
++++ gwyddion-2.55/configure.ac	2020-03-20 18:52:55.042724547 -0700
+@@ -270,7 +270,7 @@
+                     [embed_pygtk=yes; pygwy_warn=" (embedded pygtk2)"])
+   if test "x$embed_pygtk" = xno; then
+     if test "x$PYGTK_CODEGENDIR" = 'x'; then
+-      PYGTK_CODEGENDIR=`$PKG_CONFIG --variable=codegendir pygtk-2.0`
++      PYGTK_CODEGENDIR=`$PKG_CONFIG --variable=codegendir pygobject-2.0`
+     fi
+   else
+     # Some silly OSes want to remove pygtk2.  We can build pygwy without
diff --git a/nixpkgs/pkgs/applications/science/chemistry/gwyddion/default.nix b/nixpkgs/pkgs/applications/science/chemistry/gwyddion/default.nix
new file mode 100644
index 000000000000..584554232ab2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/gwyddion/default.nix
@@ -0,0 +1,86 @@
+{ lib, stdenv, fetchurl, gtk2, pkg-config, fftw, file,
+  pythonSupport ? false, pythonPackages ? null,
+  gnome2 ? null,
+  openexrSupport ? true, openexr ? null,
+  libzipSupport ? true, libzip ? null,
+  libxml2Support ? true, libxml2 ? null,
+  libwebpSupport ? true, libwebp ? null,
+  # libXmu is not used if libunique is.
+  libXmuSupport ? false, xorg ? null,
+  libxsltSupport ? true, libxslt ? null,
+  fitsSupport ? true, cfitsio ? null,
+  zlibSupport ? true, zlib ? null,
+  libuniqueSupport ? true, libunique ? null,
+  libpngSupport ? true, libpng ? null,
+  openglSupport ? !stdenv.isDarwin
+}:
+
+assert openexrSupport -> openexr != null;
+assert libzipSupport -> libzip != null;
+assert libxml2Support -> libxml2 != null;
+assert libwebpSupport -> libwebp != null;
+assert libXmuSupport -> xorg != null;
+assert libxsltSupport -> libxslt != null;
+assert fitsSupport -> cfitsio != null;
+assert zlibSupport -> zlib != null;
+assert libuniqueSupport -> libunique != null;
+assert libpngSupport -> libpng != null;
+assert openglSupport -> gnome2 != null;
+assert pythonSupport -> (pythonPackages != null && gnome2 != null);
+
+let
+    inherit (pythonPackages) pygtk pygobject2 python;
+
+in
+
+stdenv.mkDerivation rec {
+  pname = "gwyddion";
+   version = "2.60";
+  src = fetchurl {
+    url = "mirror://sourceforge/gwyddion/gwyddion-${version}.tar.xz";
+    sha256 = "sha256-38PIardlOzDrVKWvV4AiQlecTYmwYegtzRya713Au/Y=";
+  };
+
+  nativeBuildInputs = [ pkg-config file ];
+
+  buildInputs = with lib;
+    [ gtk2 fftw ] ++
+    optional openglSupport gnome2.gtkglext ++
+    optional openexrSupport openexr ++
+    optional libXmuSupport xorg.libXmu ++
+    optional fitsSupport cfitsio ++
+    optional libpngSupport libpng ++
+    optional libxsltSupport libxslt ++
+    optional libxml2Support libxml2 ++
+    optional libwebpSupport libwebp ++
+    optional zlibSupport zlib ++
+    optional libuniqueSupport libunique ++
+    optional libzipSupport libzip;
+
+  propagatedBuildInputs = with lib;
+    optionals pythonSupport [ pygtk pygobject2 python gnome2.gtksourceview ];
+
+  # This patch corrects problems with python support, but should apply cleanly
+  # regardless of whether python support is enabled, and have no effects if
+  # it is disabled.
+  patches = [ ./codegen.patch ];
+  meta = {
+    homepage = "http://gwyddion.net/";
+
+    description = "Scanning probe microscopy data visualization and analysis";
+
+    longDescription = ''
+      A modular program for SPM (scanning probe microscopy) data
+      visualization and analysis. Primarily it is intended for the
+      analysis of height fields obtained by scanning probe microscopy
+      techniques (AFM, MFM, STM, SNOM/NSOM) and it supports a lot of
+      SPM data formats. However, it can be used for general height
+      field and (greyscale) image processing, for instance for the
+      analysis of profilometry data or thickness maps from imaging
+      spectrophotometry.
+    '';
+    license = lib.licenses.gpl2;
+    platforms = with lib.platforms; linux ++ darwin;
+    maintainers = [ lib.maintainers.cge ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/jmol/default.nix b/nixpkgs/pkgs/applications/science/chemistry/jmol/default.nix
new file mode 100644
index 000000000000..3f837edb4c8b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/jmol/default.nix
@@ -0,0 +1,61 @@
+{ stdenv
+, lib
+, fetchurl
+, unzip
+, makeDesktopItem
+, jre
+}:
+
+let
+  desktopItem = makeDesktopItem {
+    name = "jmol";
+    exec = "jmol";
+    desktopName = "JMol";
+    genericName = "Molecular Modeler";
+    mimeTypes = [
+      "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.32.30";
+  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 = "sha256-VpOoduUA0iD+nI83GSQYQDHoK2Snog0NHkHWHfpLqFM=";
+  };
+
+  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;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/marvin/LicenseManager.desktop b/nixpkgs/pkgs/applications/science/chemistry/marvin/LicenseManager.desktop
new file mode 100755
index 000000000000..90b8ed7d20a5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/marvin/LicenseManager.desktop
@@ -0,0 +1,9 @@
+#!/usr/bin/env xdg-open
+[Desktop Entry]
+Type=Application
+Name=ChemAxon License Manager
+Exec=@out@/bin/LicenseManager
+Icon=LicenseManager
+Categories=Education;Science;Chemistry;
+StartupWMClass=com-install4j-runtime-launcher-UnixLauncher
+Comment=License manager for ChemAxon software like MarvinSketch
diff --git a/nixpkgs/pkgs/applications/science/chemistry/marvin/MarvinSketch.desktop b/nixpkgs/pkgs/applications/science/chemistry/marvin/MarvinSketch.desktop
new file mode 100755
index 000000000000..d6e0343a78c3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/marvin/MarvinSketch.desktop
@@ -0,0 +1,10 @@
+#!/usr/bin/env xdg-open
+[Desktop Entry]
+Type=Application
+Name=MarvinSketch
+Exec=@out@/bin/msketch %f
+Icon=MarvinSketch
+MimeType=text/xml;text/plain;chemical/x-cml;chemical/x-mdl-molfile;chemical/x-mdl-sdfile;chemical/x-mol2;chemical/x-pdb;chemical/x-xyz;chemical/x-mdl-rdfile;chemical/x-mdl-rxnfile;chemical/x-inchi;
+Categories=Education;Science;Chemistry;
+StartupWMClass=com-install4j-runtime-launcher-UnixLauncher
+Comment=Molecular modelling, analysis and structure drawing program
diff --git a/nixpkgs/pkgs/applications/science/chemistry/marvin/MarvinView.desktop b/nixpkgs/pkgs/applications/science/chemistry/marvin/MarvinView.desktop
new file mode 100755
index 000000000000..07a3c3c7cf33
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/marvin/MarvinView.desktop
@@ -0,0 +1,10 @@
+#!/usr/bin/env xdg-open
+[Desktop Entry]
+Type=Application
+Name=MarvinView
+Exec=@out@/bin/mview %f
+Icon=MarvinView
+Comment=Molecule viewing program
+MimeType=text/xml;text/plain;chemical/x-cml;chemical/x-mdl-molfile;chemical/x-mdl-sdfile;chemical/x-mol2;chemical/x-pdb;chemical/x-xyz;chemical/x-mdl-rdfile;chemical/x-mdl-rxnfile;chemical/x-inchi;
+Categories=Education;Science;Chemistry;
+StartupWMClass=com-install4j-runtime-launcher-UnixLauncher
diff --git a/nixpkgs/pkgs/applications/science/chemistry/marvin/default.nix b/nixpkgs/pkgs/applications/science/chemistry/marvin/default.nix
new file mode 100644
index 000000000000..698095715cc5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/marvin/default.nix
@@ -0,0 +1,48 @@
+{ lib, stdenv, fetchurl, dpkg, makeWrapper, coreutils, gawk, gnugrep, gnused, jre }:
+
+with lib;
+
+stdenv.mkDerivation rec {
+  pname = "marvin";
+  version = "22.7.0";
+
+  src = fetchurl {
+    name = "marvin-${version}.deb";
+    url = "http://dl.chemaxon.com/marvin/${version}/marvin_linux_${versions.majorMinor version}.deb";
+    sha256 = "sha256-xK4C+0/Qpc2vXPmsI8KuHuDJLmJ5LXdAfRIREE+gkWA=";
+  };
+
+  nativeBuildInputs = [ dpkg makeWrapper ];
+
+  unpackPhase = ''
+    dpkg-deb -x $src opt
+  '';
+
+  installPhase = ''
+    wrapBin() {
+      makeWrapper $1 $out/bin/$(basename $1) \
+        --set INSTALL4J_JAVA_HOME "${jre}" \
+        --prefix PATH : ${makeBinPath [ coreutils gawk gnugrep gnused ]}
+    }
+    cp -r opt $out
+    mkdir -p $out/bin $out/share/pixmaps $out/share/applications
+    for name in LicenseManager MarvinSketch MarvinView; do
+      wrapBin $out/opt/chemaxon/marvinsuite/$name
+      ln -s {$out/opt/chemaxon/marvinsuite/.install4j,$out/share/pixmaps}/$name.png
+    done
+    for name in cxcalc cxtrain evaluate molconvert mview msketch; do
+      wrapBin $out/opt/chemaxon/marvinsuite/bin/$name
+    done
+    ${concatStrings (map (name: ''
+      substitute ${./. + "/${name}.desktop"} $out/share/applications/${name}.desktop --subst-var out
+    '') [ "LicenseManager" "MarvinSketch" "MarvinView" ])}
+  '';
+
+  meta = {
+    description = "A chemical modelling, analysis and structure drawing program";
+    homepage = "https://chemaxon.com/products/marvin";
+    maintainers = with maintainers; [ fusion809 ];
+    license = licenses.unfree;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/molden/default.nix b/nixpkgs/pkgs/applications/science/chemistry/molden/default.nix
new file mode 100644
index 000000000000..03f7c6c2b40f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/molden/default.nix
@@ -0,0 +1,43 @@
+{ lib, stdenv, fetchurl, which, gfortran, libGLU, xorg } :
+
+stdenv.mkDerivation rec {
+  version = "6.3";
+  pname = "molden";
+
+  src = fetchurl {
+    url = "https://ftp.science.ru.nl/Molden//molden${version}.tar.gz";
+    sha256 = "02qi16pz2wffn3cc47dpjqhfafzwfmb79waw4nnhfyir8a4h3cq1";
+  };
+
+  nativeBuildInputs = [ which ];
+  buildInputs = [ gfortran libGLU xorg.libX11 xorg.libXmu ];
+
+  patches = [ ./dont_register_file_types.patch ];
+
+  postPatch = ''
+     substituteInPlace ./makefile --replace '-L/usr/X11R6/lib'  "" \
+                                  --replace '-I/usr/X11R6/include' "" \
+                                  --replace '/usr/local/' $out/ \
+                                  --replace 'sudo' "" \
+                                  --replace '-C surf depend' '-C surf'
+     sed -in '/^# DO NOT DELETE THIS LINE/q;' surf/Makefile
+  '';
+
+  preInstall = ''
+     mkdir -p $out/bin
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+     description = "Display and manipulate molecular structures";
+     homepage = "http://www3.cmbi.umcn.nl/molden/";
+     license = {
+       fullName = "Free for academic/non-profit use";
+       url = "http://www3.cmbi.umcn.nl/molden/CopyRight.html";
+       free = false;
+     };
+     platforms = platforms.linux;
+     maintainers = with maintainers; [ markuskowa ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/molden/dont_register_file_types.patch b/nixpkgs/pkgs/applications/science/chemistry/molden/dont_register_file_types.patch
new file mode 100644
index 000000000000..75ce593ed29a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/molden/dont_register_file_types.patch
@@ -0,0 +1,29 @@
+diff --git a/makefile b/makefile
+index 58a9e74..64615b6 100644
+--- a/makefile
++++ b/makefile
+@@ -32,8 +32,6 @@ os :=
+ ifeq ($(uname), Linux)
+  os := $(shell head -n 1 /etc/issue | cut -d" " -f1)
+  ifeq ($(os), Ubuntu)
+-    EXTEN = exten
+-    EXTENZ = exten2
+     LIBSG = -L/usr/X11R6/lib -lGLU -lGL -lX11 -lm
+  endif
+  ifeq ($(os), Debian)
+@@ -278,7 +276,7 @@ LIBSOGL = -lglut -lGLU -lGL -lXmu -lX11 -lm
+ #
+ #LIBSG = -L/usr/X11R6/lib -Wl,-framework -Wl,GLUT -Wl,-framework -Wl,OpenGL -Wl,-framework -Wl,Cocoa -lGLU -lGL -lXmu -lX11 -lm
+ 
+-all:	molden gmolden ambfor/ambfor ambfor/ambmd surf/surf $(EXTEN)
++all:	molden gmolden ambfor/ambfor ambfor/ambmd surf/surf
+ xwin.o:	xwin.c rots.h
+ xwingl.o:	xwin.c rots.h
+ 
+@@ -344,5 +342,5 @@ exten:
+ exten2:
+ 	./register_extension.sh /usr/local/bin
+ 
+-install:	$(EXTENZ)
++install:
+ 	sudo install -t /usr/local/bin -m 755 molden gmolden ambfor/ambfor ambfor/ambmd surf/surf
diff --git a/nixpkgs/pkgs/applications/science/chemistry/octopus/default.nix b/nixpkgs/pkgs/applications/science/chemistry/octopus/default.nix
new file mode 100644
index 000000000000..86addd5bd696
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/octopus/default.nix
@@ -0,0 +1,75 @@
+{ lib, stdenv, fetchFromGitLab, gfortran, perl, procps
+, libyaml, libxc, fftw, blas, lapack, gsl, netcdf, arpack, autoreconfHook
+, python3
+, enableFma ? stdenv.hostPlatform.fmaSupport
+, enableFma4 ? stdenv.hostPlatform.fma4Support
+, enableAvx ? stdenv.hostPlatform.avx2Support
+, enableAvx512 ? stdenv.hostPlatform.avx512Support
+}:
+
+assert (!blas.isILP64) && (!lapack.isILP64);
+
+stdenv.mkDerivation rec {
+  pname = "octopus";
+  version = "11.3";
+
+  src = fetchFromGitLab {
+    owner = "octopus-code";
+    repo = "octopus";
+    rev = version;
+    sha256 = "0n04yvnc0rg3lvnkkdpbwkfl6zg544260p3s65vwkc5dflrhk34r";
+  };
+
+  nativeBuildInputs = [
+    perl
+    procps
+    autoreconfHook
+    gfortran
+  ];
+
+  buildInputs = [
+    libyaml
+    libxc
+    blas
+    lapack
+    gsl
+    fftw
+    netcdf
+    arpack
+    (python3.withPackages (ps: [ ps.pyyaml ]))
+  ];
+
+  configureFlags = with lib; [
+    "--with-yaml-prefix=${libyaml}"
+    "--with-blas=-lblas"
+    "--with-lapack=-llapack"
+    "--with-fftw-prefix=${fftw.dev}"
+    "--with-gsl-prefix=${gsl}"
+    "--with-libxc-prefix=${libxc}"
+    "--enable-openmp"
+  ] ++ optional enableFma "--enable-fma3"
+    ++ optional enableFma4 "--enable-fma4"
+    ++ optional enableAvx "--enable-avx"
+    ++ optional enableAvx512 "--enable-avx512";
+
+  doCheck = false;
+  checkTarget = "check-short";
+
+  postPatch = ''
+    patchShebangs ./
+  '';
+
+  postConfigure = ''
+    patchShebangs testsuite/oct-run_testsuite.sh
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    description = "Real-space time dependent density-functional theory code";
+    homepage = "https://octopus-code.org";
+    maintainers = with maintainers; [ markuskowa ];
+    license = with licenses; [ gpl2Only asl20 lgpl3Plus bsd3 ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/openmolcas/default.nix b/nixpkgs/pkgs/applications/science/chemistry/openmolcas/default.nix
new file mode 100644
index 000000000000..1c3203354873
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/openmolcas/default.nix
@@ -0,0 +1,89 @@
+{ lib, stdenv, fetchFromGitLab, cmake, gfortran, perl
+, openblas, hdf5-cpp, python3, texlive
+, armadillo, mpi, globalarrays, openssh
+, makeWrapper
+} :
+
+let
+  version = "21.10";
+  # The tag keeps moving, fix a hash instead
+  gitLabRev = "117305462bac932106e8e3a0347238b768bcb058";
+
+  python = python3.withPackages (ps : with ps; [ six pyparsing ]);
+
+in stdenv.mkDerivation {
+  pname = "openmolcas";
+  inherit version;
+
+  src = fetchFromGitLab {
+    owner = "Molcas";
+    repo = "OpenMolcas";
+    rev = gitLabRev;
+    sha256 = "sha256-GMi2dsNBog+TmpmP6fhQcp6Z5Bh2LelV//MqLnvRP5c=";
+  };
+
+  patches = [
+    # Required to handle openblas multiple outputs
+    ./openblasPath.patch
+  ];
+
+  nativeBuildInputs = [
+    perl
+    gfortran
+    cmake
+    texlive.combined.scheme-minimal
+    makeWrapper
+  ];
+
+  buildInputs = [
+    openblas
+    hdf5-cpp
+    python
+    armadillo
+    mpi
+    globalarrays
+    openssh
+  ];
+
+  cmakeFlags = [
+    "-DOPENMP=ON"
+    "-DGA=ON"
+    "-DMPI=ON"
+    "-DLINALG=OpenBLAS"
+    "-DTOOLS=ON"
+    "-DHDF5=ON"
+    "-DFDE=ON"
+    "-DOPENBLASROOT=${openblas.dev}"
+  ];
+
+  preConfigure = ''
+    export GAROOT=${globalarrays};
+  '';
+
+  postConfigure = ''
+    # The Makefile will install pymolcas during the build grrr.
+    mkdir -p $out/bin
+    export PATH=$PATH:$out/bin
+  '';
+
+  postInstall = ''
+    mv $out/pymolcas $out/bin
+  '';
+
+  postFixup = ''
+    # Wrong store path in shebang (no Python pkgs), force re-patching
+    sed -i "1s:/.*:/usr/bin/env python:" $out/bin/pymolcas
+    patchShebangs $out/bin
+
+    wrapProgram $out/bin/pymolcas --set MOLCAS $out
+  '';
+
+  meta = with lib; {
+    description = "Advanced quantum chemistry software package";
+    homepage = "https://gitlab.com/Molcas/OpenMolcas";
+    maintainers = [ maintainers.markuskowa ];
+    license = licenses.lgpl21Only;
+    platforms = [ "x86_64-linux" ];
+  };
+}
+
diff --git a/nixpkgs/pkgs/applications/science/chemistry/openmolcas/openblasPath.patch b/nixpkgs/pkgs/applications/science/chemistry/openmolcas/openblasPath.patch
new file mode 100644
index 000000000000..e47adcc3e9a3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/openmolcas/openblasPath.patch
@@ -0,0 +1,12 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 276ae4e2..db13e6e3 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1507,7 +1507,6 @@ if (LINALG STREQUAL "OpenBLAS")
+     NAMES openblas
+     PATHS ${OPENBLASROOT}
+     PATH_SUFFIXES lib
+-    NO_DEFAULT_PATH
+   )
+ 
+   if (NOT LIBOPENBLAS)
diff --git a/nixpkgs/pkgs/applications/science/chemistry/pymol/default.nix b/nixpkgs/pkgs/applications/science/chemistry/pymol/default.nix
new file mode 100644
index 000000000000..5f7c0c1f6be7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/pymol/default.nix
@@ -0,0 +1,75 @@
+{ lib
+, fetchFromGitHub
+, makeDesktopItem
+, python3
+, python3Packages
+, netcdf
+, glew
+, glm
+, freeglut
+, libpng
+, libxml2
+, tk
+, freetype
+, msgpack
+}:
+let
+  pname = "pymol";
+  description = "A Python-enhanced molecular graphics tool";
+
+  desktopItem = makeDesktopItem {
+    name = pname;
+    exec = pname;
+    desktopName = "PyMol Molecular Graphics System";
+    genericName = "Molecular Modeler";
+    comment = description;
+    icon = pname;
+    mimeTypes = [
+      "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
+python3Packages.buildPythonApplication rec {
+  inherit pname;
+  version = "2.5.0";
+  src = fetchFromGitHub {
+    owner = "schrodinger";
+    repo = "pymol-open-source";
+    rev = "v${version}";
+    sha256 = "sha256-JdsgcVF1w1xFPZxVcyS+GcWg4a1Bd4SvxFOuSdlz9SM=";
+  };
+
+  buildInputs = [ python3Packages.numpy glew glm freeglut libpng libxml2 tk freetype msgpack netcdf ];
+  NIX_CFLAGS_COMPILE = "-I ${libxml2.dev}/include/libxml2";
+  hardeningDisable = [ "format" ];
+
+  setupPyBuildFlags = [ "--glut" ];
+
+  installPhase = ''
+    python setup.py install --home="$out"
+    runHook postInstall
+  '';
+
+  postInstall = with python3Packages; ''
+    wrapProgram $out/bin/pymol \
+      --prefix PYTHONPATH : ${lib.makeSearchPathOutput "lib" python3.sitePackages [ Pmw tkinter ]}
+
+    mkdir -p "$out/share/icons/"
+    ln -s ../../lib/python/pymol/pymol_path/data/pymol/icons/icon2.svg "$out/share/icons/pymol.svg"
+    cp -r "${desktopItem}/share/applications/" "$out/share/"
+  '';
+
+  meta = with lib; {
+    inherit description;
+    homepage = "https://www.pymol.org/";
+    license = licenses.mit;
+    maintainers = with maintainers; [ samlich ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/quantum-espresso/default.nix b/nixpkgs/pkgs/applications/science/chemistry/quantum-espresso/default.nix
new file mode 100644
index 000000000000..9933d0d8c727
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/quantum-espresso/default.nix
@@ -0,0 +1,53 @@
+{ lib
+, stdenv
+, fetchFromGitLab
+, gfortran
+, fftw
+, blas
+, lapack
+, useMpi ? false
+, mpi
+}:
+
+stdenv.mkDerivation rec {
+  version = "6.6";
+  pname = "quantum-espresso";
+
+  src = fetchFromGitLab {
+    owner = "QEF";
+    repo = "q-e";
+    rev = "qe-${version}";
+    sha256 = "1mkfmw0fq1dabplzdn6v1abhw0ds55gzlvbx3a9brv493whk21yp";
+  };
+
+  passthru = {
+    inherit mpi;
+  };
+
+  preConfigure = ''
+    patchShebangs configure
+  '';
+
+  nativeBuildInputs = [ gfortran ];
+
+  buildInputs = [ fftw blas lapack ]
+    ++ (lib.optionals useMpi [ mpi ]);
+
+  configureFlags = if useMpi then [ "LD=${mpi}/bin/mpif90" ] else [ "LD=${gfortran}/bin/gfortran" ];
+
+  makeFlags = [ "all" ];
+
+  meta = with lib; {
+    description = "Electronic-structure calculations and materials modeling at the nanoscale";
+    longDescription = ''
+      Quantum ESPRESSO is an integrated suite of Open-Source computer codes for
+      electronic-structure calculations and materials modeling at the
+      nanoscale. It is based on density-functional theory, plane waves, and
+      pseudopotentials.
+    '';
+    homepage = "https://www.quantum-espresso.org/";
+    license = licenses.gpl2;
+    platforms = [ "x86_64-linux" "x86_64-darwin" ];
+    maintainers = [ maintainers.costrouc ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/chemistry/siesta/default.nix b/nixpkgs/pkgs/applications/science/chemistry/siesta/default.nix
new file mode 100644
index 000000000000..7ee46f7d7e22
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/siesta/default.nix
@@ -0,0 +1,75 @@
+{ lib, stdenv
+, gfortran, blas, lapack, scalapack
+, useMpi ? false
+, mpi
+, fetchFromGitLab
+}:
+
+stdenv.mkDerivation rec {
+  version = "4.1.5";
+  pname = "siesta";
+
+  src = fetchFromGitLab {
+    owner = "siesta-project";
+    repo = "siesta";
+    rev = "v${version}";
+    sha256 = "0lz8rfl5xwdj17zn7a30ipi7cgjwqki21a7wg9rdg7iwx27bpnmg";
+  };
+
+  passthru = {
+    inherit mpi;
+  };
+
+  nativeBuildInputs = [ gfortran ];
+
+  buildInputs = [ blas lapack ]
+    ++ lib.optionals useMpi [ mpi scalapack ];
+
+  enableParallelBuilding = true;
+
+  # Must do manualy becuase siesta does not do the regular
+  # ./configure; make; make install
+  configurePhase = ''
+    cd Obj
+    sh ../Src/obj_setup.sh
+    cp gfortran.make arch.make
+  '';
+
+  preBuild = if useMpi then ''
+    makeFlagsArray=(
+        CC="mpicc" FC="mpifort"
+        FPPFLAGS="-DMPI" MPI_INTERFACE="libmpi_f90.a" MPI_INCLUDE="."
+        COMP_LIBS="" LIBS="-lblas -llapack -lscalapack"
+    );
+  '' else ''
+    makeFlagsArray=(
+      COMP_LIBS="" LIBS="-lblas -llapack"
+    );
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp -a siesta $out/bin
+  '';
+
+  meta = with lib; {
+    description = "A first-principles materials simulation code using DFT";
+    longDescription = ''
+         SIESTA is both a method and its computer program
+         implementation, to perform efficient electronic structure
+         calculations and ab initio molecular dynamics simulations of
+         molecules and solids. SIESTA's efficiency stems from the use
+         of strictly localized basis sets and from the implementation
+         of linear-scaling algorithms which can be applied to suitable
+         systems. A very important feature of the code is that its
+         accuracy and cost can be tuned in a wide range, from quick
+         exploratory calculations to highly accurate simulations
+         matching the quality of other approaches, such as plane-wave
+         and all-electron methods.
+      '';
+    homepage = "https://siesta-project.org/siesta/";
+    license = licenses.gpl2;
+    platforms = [ "x86_64-linux" ];
+    maintainers = [ maintainers.costrouc ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/computer-architecture/qtrvsim/default.nix b/nixpkgs/pkgs/applications/science/computer-architecture/qtrvsim/default.nix
new file mode 100644
index 000000000000..24d9f642ec56
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/computer-architecture/qtrvsim/default.nix
@@ -0,0 +1,30 @@
+{ lib, stdenv, fetchFromGitHub, cmake, wrapQtAppsHook, qtbase }:
+
+stdenv.mkDerivation rec {
+  pname = "QtRVSim";
+  version = "0.9.1";
+
+  src = fetchFromGitHub {
+    owner = "cvut";
+    repo = "qtrvsim";
+    rev = "refs/tags/v${version}";
+    sha256 = "AOksVS0drIBnK4RCxZw40yVxf4E8GjG9kU0rIZsY9gA=";
+  };
+
+  nativeBuildInputs = [ cmake wrapQtAppsHook ];
+
+  buildInputs = [ qtbase ];
+
+  meta = with lib; {
+    description = "RISC-V CPU simulator for education purposes";
+    longDescription = ''
+      RISC-V CPU simulator for education purposes with pipeline and cache visualization.
+      Developed at FEE CTU for computer architecture classes.
+    '';
+    homepage = "https://github.com/cvut/qtrvsim";
+    license = licenses.gpl3Plus;
+    platforms = platforms.linux ++ platforms.darwin;
+    maintainers = with maintainers; [ jdupak ];
+    mainProgram = "qtrvsim_gui";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/adms/default.nix b/nixpkgs/pkgs/applications/science/electronics/adms/default.nix
new file mode 100644
index 000000000000..7b7e2a1af63a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/adms/default.nix
@@ -0,0 +1,26 @@
+{ lib, stdenv, fetchFromGitHub, autoreconfHook, flex, bison, gperf,
+  libxml2, perl, perlPackages, gd }:
+
+stdenv.mkDerivation rec {
+  version = "2.3.7";
+  pname = "adms";
+
+  src = fetchFromGitHub {
+    owner = "Qucs";
+    repo = "adms";
+    rev = "release-${version}";
+    sha256 = "0i37c9k6q1iglmzp9736rrgsnx7sw8xn3djqbbjw29zsyl3pf62c";
+  };
+
+  nativeBuildInputs = [ autoreconfHook ];
+  buildInputs = [ flex bison gperf libxml2 perl gd perlPackages.XMLLibXML ];
+  configureFlags = [ "--enable-maintainer-mode" ];
+
+  meta = {
+    description = "automatic device model synthesizer";
+    homepage = "https://github.com/Qucs/adms";
+    license = lib.licenses.gpl3;
+    maintainers = with lib.maintainers; [disassembler];
+    platforms = with lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/alliance/default.nix b/nixpkgs/pkgs/applications/science/electronics/alliance/default.nix
new file mode 100644
index 000000000000..cf135b9469a7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/alliance/default.nix
@@ -0,0 +1,58 @@
+{ lib, stdenv, fetchFromGitLab, xorgproto, motif, libX11, libXt, libXpm, bison
+, flex, automake, autoconf, libtool
+}:
+
+stdenv.mkDerivation rec {
+  pname = "alliance";
+  version = "unstable-2021-09-15";
+
+  src = fetchFromGitLab {
+    domain = "gitlab.lip6.fr";
+    owner = "vlsi-eda";
+    repo = "alliance";
+    rev = "5e83c92d0307cce9d599f7099fb0023f81d26d65";
+    sha256 = "Vd3MTT4eKn4FMt0/F4fQUPcWq25kH0FpeGxQUOetKPY=";
+  };
+
+  prePatch = "cd alliance/src";
+
+  nativeBuildInputs = [ libtool automake autoconf flex ];
+  buildInputs = [ xorgproto motif libX11 libXt libXpm bison ];
+
+  # Disable parallel build, errors:
+  #  ./pat_decl_y.y:736:5: error: expected '=', ...
+  enableParallelBuilding = false;
+
+  ALLIANCE_TOP = placeholder "out";
+
+  configureFlags = [
+    "--prefix=${placeholder "out"}" "--enable-alc-shared"
+  ];
+
+  postPatch = ''
+    # texlive for docs seems extreme
+    substituteInPlace autostuff \
+      --replace "$newdirs documentation" "$newdirs"
+
+    substituteInPlace sea/src/DEF_grammar_lex.l --replace "ifndef FLEX_BETA" \
+      "if (YY_FLEX_MAJOR_VERSION <= 2) && (YY_FLEX_MINOR_VERSION < 6)"
+
+    ./autostuff
+  '';
+
+  postInstall = ''
+    sed -i "s|ALLIANCE_TOP|$out|" distrib/*.desktop
+    mkdir -p $out/share/applications
+    cp -p distrib/*.desktop $out/share/applications/
+    mkdir -p $out/icons/hicolor/48x48/apps/
+    cp -p distrib/*.png $out/icons/hicolor/48x48/apps/
+  '';
+
+  meta = with lib; {
+    description = "(deprecated) Complete set of free CAD tools and portable libraries for VLSI design";
+    homepage = "http://coriolis.lip6.fr/";
+    license = with licenses; gpl2Plus;
+    maintainers = with maintainers; [ l-as ];
+    platforms = with platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/appcsxcad/default.nix b/nixpkgs/pkgs/applications/science/electronics/appcsxcad/default.nix
new file mode 100644
index 000000000000..7aafa70f7fa1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/appcsxcad/default.nix
@@ -0,0 +1,55 @@
+{ lib
+, mkDerivation
+, fetchFromGitHub
+, cmake
+, csxcad
+, qcsxcad
+, hdf5
+, vtkWithQt5
+, qtbase
+, wrapQtAppsHook
+, fparser
+, tinyxml
+, cgal
+, boost
+}:
+
+mkDerivation {
+  pname = "appcsxcad";
+  version = "unstable-2020-01-04";
+
+  src = fetchFromGitHub {
+    owner = "thliebig";
+    repo = "AppCSXCAD";
+    rev = "de8c271ec8b57e80233cb2a432e3d7fd54d30876";
+    sha256 = "0shnfa0if3w588a68gr82qi6k7ldg1j2921fnzji90mmay21birp";
+  };
+
+  nativeBuildInputs = [
+    cmake
+  ];
+
+  buildInputs = [
+    csxcad
+    qcsxcad
+    hdf5
+    vtkWithQt5
+    qtbase
+    fparser
+    tinyxml
+    cgal
+    boost
+  ];
+
+  postFixup = ''
+    rm $out/bin/AppCSXCAD.sh
+  '';
+
+  meta = with lib; {
+    description = "Minimal Application using the QCSXCAD library";
+    homepage = "https://github.com/thliebig/AppCSXCAD";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ matthuszagh ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/archimedes/default.nix b/nixpkgs/pkgs/applications/science/electronics/archimedes/default.nix
new file mode 100644
index 000000000000..8bceed08e1db
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/archimedes/default.nix
@@ -0,0 +1,18 @@
+{ lib, stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  pname = "archimedes";
+  version = "2.0.1";
+
+  src = fetchurl {
+    url = "mirror://gnu/archimedes/archimedes-${version}.tar.gz";
+    sha256 = "0jfpnd3pns5wxcxbiw49v5sgpmm5b4v8s4q1a5292hxxk2hzmb3z";
+  };
+
+  meta = {
+    description = "GNU package for semiconductor device simulations";
+    homepage = "https://www.gnu.org/software/archimedes";
+    license = lib.licenses.gpl2Plus;
+    platforms = with lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/bitscope/common.nix b/nixpkgs/pkgs/applications/science/electronics/bitscope/common.nix
new file mode 100644
index 000000000000..49415ea04841
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/bitscope/common.nix
@@ -0,0 +1,64 @@
+{ atk
+, buildFHSUserEnv
+, cairo
+, dpkg
+, gdk-pixbuf
+, glib
+, gtk2-x11
+, makeWrapper
+, pango
+, lib, stdenv
+, xorg
+}:
+
+{ src, toolName, version, ... } @ attrs:
+let
+  wrapBinary = libPaths: binaryName: ''
+    wrapProgram "$out/bin/${binaryName}" \
+      --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath libPaths}"
+  '';
+  pkg = stdenv.mkDerivation (rec {
+    inherit (attrs) version src;
+
+    name = "${toolName}-${version}";
+
+    meta = with lib; {
+      homepage = "http://bitscope.com/software/";
+      license = licenses.unfree;
+      platforms = [ "x86_64-linux" ];
+      maintainers = with maintainers; [
+        vidbina
+      ];
+    } // (attrs.meta or {});
+
+    buildInputs = [
+      dpkg
+      makeWrapper
+    ];
+
+    libs = attrs.libs or [
+      atk
+      cairo
+      gdk-pixbuf
+      glib
+      gtk2-x11
+      pango
+      xorg.libX11
+    ];
+
+    dontBuild = true;
+
+    unpackPhase = attrs.unpackPhase or ''
+      dpkg-deb -x ${attrs.src} ./
+    '';
+
+    installPhase = attrs.installPhase or ''
+      mkdir -p "$out/bin"
+      cp -a usr/* "$out/"
+      ${(wrapBinary libs) attrs.toolName}
+    '';
+  });
+in buildFHSUserEnv {
+  name = "${attrs.toolName}-${attrs.version}";
+  runScript = "${pkg.outPath}/bin/${attrs.toolName}";
+} // { inherit (pkg) meta name; }
diff --git a/nixpkgs/pkgs/applications/science/electronics/bitscope/packages.nix b/nixpkgs/pkgs/applications/science/electronics/bitscope/packages.nix
new file mode 100644
index 000000000000..11e1ed524ed2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/bitscope/packages.nix
@@ -0,0 +1,146 @@
+{ callPackage
+, fetchurl
+}:
+
+let
+  mkBitscope = callPackage (import ./common.nix) { };
+in {
+  chart = let
+    toolName = "bitscope-chart";
+    version = "2.0.FK22M";
+  in mkBitscope {
+    inherit toolName version;
+
+    meta = {
+      description = "Multi-channel waveform data acquisition and chart recording application";
+      homepage = "http://bitscope.com/software/chart/";
+    };
+
+    src = fetchurl {
+      url = "http://bitscope.com/download/files/${toolName}_${version}_amd64.deb";
+      sha256 = "08mc82pjamyyyhh15sagsv0sc7yx5v5n54bg60fpj7v41wdwrzxw";
+    };
+  };
+
+  console = let
+    toolName = "bitscope-console";
+    version = "1.0.FK29A";
+  in mkBitscope {
+    # NOTE: this is meant as a demo by BitScope
+    inherit toolName version;
+
+    meta = {
+      description = "Demonstrative communications program designed to make it easy to talk to any model BitScope";
+    };
+
+    src = fetchurl {
+      url = "http://bitscope.com/download/files/${toolName}_${version}_amd64.deb";
+      sha256 = "00b4gxwz7w6pmfrcz14326b24kl44hp0gzzqcqxwi5vws3f0y49d";
+    };
+  };
+
+  display = let
+    toolName = "bitscope-display";
+    version = "1.0.EC17A";
+  in mkBitscope {
+    inherit toolName version;
+
+    meta = {
+      description = "Display diagnostic application for BitScope";
+      homepage = "http://bitscope.com/software/display/";
+    };
+
+    src = fetchurl {
+      url = "http://bitscope.com/download/files/${toolName}_${version}_amd64.deb";
+      sha256 = "05xr5mnka1v3ibcasg74kmj6nlv1nmn3lca1wv77whkq85cmz0s1";
+    };
+  };
+
+  dso = let
+    toolName = "bitscope-dso";
+    version = "2.8.FE22H";
+  in mkBitscope {
+    inherit toolName version;
+
+    meta = {
+      description = "Test and measurement software for BitScope";
+      homepage = "http://bitscope.com/software/dso/";
+    };
+
+    src = fetchurl {
+      url = "http://bitscope.com/download/files/${toolName}_${version}_amd64.deb";
+      sha256 = "0fc6crfkprj78dxxhvhbn1dx1db5chm0cpwlqpqv8sz6whp12mcj";
+    };
+  };
+
+  logic = let
+    toolName = "bitscope-logic";
+    version = "1.2.FC20C";
+  in mkBitscope {
+    inherit toolName version;
+
+    meta = {
+      description = "Mixed signal logic timing and serial protocol analysis software for BitScope";
+      homepage = "http://bitscope.com/software/logic/";
+    };
+
+    src = fetchurl {
+      url = "http://bitscope.com/download/files/${toolName}_${version}_amd64.deb";
+      sha256 = "0lkb7z9gfkiyxdwh4dq1zxfls8gzdw0na1vrrbgnxfg3klv4xns3";
+    };
+  };
+
+  meter = let
+    toolName = "bitscope-meter";
+    version = "2.0.FK22G";
+  in mkBitscope {
+    inherit toolName version;
+
+    meta = {
+      description = "Automated oscilloscope, voltmeter and frequency meter for BitScope";
+      homepage = "http://bitscope.com/software/logic/";
+    };
+
+    src = fetchurl {
+      url = "http://bitscope.com/download/files/${toolName}_${version}_amd64.deb";
+      sha256 = "0nirbci6ymhk4h4bck2s4wbsl5r9yndk2jvvv72zwkg21248mnbp";
+    };
+  };
+
+  proto = let
+    toolName = "bitscope-proto";
+    version = "0.9.FG13B";
+  in mkBitscope {
+    inherit toolName version;
+    # NOTE: this is meant as a demo by BitScope
+    # NOTE: clicking on logo produces error
+    # TApplication.HandleException Executable not found: "http://bitscope.com/blog/DK/?p=DK15A"
+
+    meta = {
+      description = "Demonstrative prototype oscilloscope built using the BitScope Library";
+      homepage = "http://bitscope.com/blog/DK/?p=DK15A";
+    };
+
+    src = fetchurl {
+      url = "http://bitscope.com/download/files/${toolName}_${version}_amd64.deb";
+      sha256 = "1ybjfbh3narn29ll4nci4b7rnxy0hj3wdfm4v8c6pjr8pfvv9spy";
+    };
+  };
+
+  server = let
+    toolName = "bitscope-server";
+    version = "1.0.FK26A";
+  in mkBitscope {
+    inherit toolName version;
+
+    meta = {
+      description = "Remote access server solution for any BitScope";
+      homepage = "http://bitscope.com/software/server/";
+    };
+
+    src = fetchurl {
+      url = "http://bitscope.com/download/files/${toolName}_${version}_amd64.deb";
+      sha256 = "1079n7msq6ks0n4aasx40rd4q99w8j9hcsaci71nd2im2jvjpw9a";
+    };
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/caneda/default.nix b/nixpkgs/pkgs/applications/science/electronics/caneda/default.nix
new file mode 100644
index 000000000000..6a9a491af1ee
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/caneda/default.nix
@@ -0,0 +1,24 @@
+{ mkDerivation, lib, fetchFromGitHub, cmake, qtbase, qttools, qtsvg, qwt }:
+
+mkDerivation rec {
+  pname = "caneda";
+  version = "0.3.1";
+
+  src = fetchFromGitHub {
+    owner = "Caneda";
+    repo = "Caneda";
+    rev = version;
+    sha256 = "0hx8qid50j9xvg2kpbpqmbdyakgyjn6m373m1cvhp70v2gp1v8l2";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ qtbase qttools qtsvg qwt ];
+
+  meta = {
+    description = "Open source EDA software focused on easy of use and portability";
+    homepage = "http://caneda.org";
+    license = lib.licenses.gpl2Plus;
+    maintainers = with lib.maintainers; [viric];
+    platforms = with lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/caneda/gcc6.patch b/nixpkgs/pkgs/applications/science/electronics/caneda/gcc6.patch
new file mode 100644
index 000000000000..04c8f4502b2d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/caneda/gcc6.patch
@@ -0,0 +1,13 @@
+diff --git c/src/cgraphicsscene.cpp i/src/cgraphicsscene.cpp
+index ac2929a..c399706 100644
+--- c/src/cgraphicsscene.cpp
++++ i/src/cgraphicsscene.cpp
+@@ -1436,7 +1436,7 @@ namespace Caneda
+             QPointF newPos = m_currentWiringWire->mapFromScene(pos);
+             QPointF refPos = m_currentWiringWire->port1()->pos();
+ 
+-            if( abs(refPos.x()-newPos.x()) > abs(refPos.y()-newPos.y()) ) {
++            if( (refPos.x()-newPos.x()) > (refPos.y()-newPos.y()) ) {
+                 m_currentWiringWire->movePort2(QPointF(newPos.x(), refPos.y()));
+             }
+             else {
diff --git a/nixpkgs/pkgs/applications/science/electronics/csxcad/default.nix b/nixpkgs/pkgs/applications/science/electronics/csxcad/default.nix
new file mode 100644
index 000000000000..d9953a785739
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/csxcad/default.nix
@@ -0,0 +1,47 @@
+{ lib, stdenv
+, fetchFromGitHub
+, cmake
+, fparser
+, tinyxml
+, hdf5
+, cgal_5
+, vtk
+, boost
+, gmp
+, mpfr
+}:
+
+stdenv.mkDerivation rec {
+  pname = "csxcad";
+  version = "unstable-2020-02-08";
+
+  src = fetchFromGitHub {
+    owner = "thliebig";
+    repo = "CSXCAD";
+    rev = "ef6e40931dbd80e0959f37c8e9614c437bf7e518";
+    sha256 = "072s765jyzpdq8qqysdy0dld17m6sr9zfcs0ip2zk8c4imxaysnb";
+  };
+
+  patches = [./searchPath.patch ];
+
+  buildInputs = [
+    cgal_5
+    boost
+    gmp
+    mpfr
+    vtk
+    fparser
+    tinyxml
+    hdf5
+  ];
+
+  nativeBuildInputs = [ cmake ];
+
+  meta = with lib; {
+    description = "A C++ library to describe geometrical objects";
+    homepage = "https://github.com/thliebig/CSXCAD";
+    license = licenses.lgpl3;
+    maintainers = with maintainers; [ matthuszagh ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/csxcad/searchPath.patch b/nixpkgs/pkgs/applications/science/electronics/csxcad/searchPath.patch
new file mode 100644
index 000000000000..2fc0d77b3202
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/csxcad/searchPath.patch
@@ -0,0 +1,11 @@
+--- CSXCAD/matlab/searchBinary.m	2019-07-14 09:24:02.154291745 -0700
++++ CSXCAD/matlab/searchBinary.m	2019-07-14 09:20:20.900248280 -0700
+@@ -33,7 +33,7 @@
+
+ % try all search paths
+ for n=1:numel(searchpath)
+-    binary_location = [searchpath{n} name];
++    binary_location = [searchpath{n} filesep name];
+     if exist(binary_location, 'file')
+         return
+     end
diff --git a/nixpkgs/pkgs/applications/science/electronics/diylc/default.nix b/nixpkgs/pkgs/applications/science/electronics/diylc/default.nix
new file mode 100644
index 000000000000..ff4e3809fc2b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/diylc/default.nix
@@ -0,0 +1,76 @@
+{ lib, stdenv, fetchurl, makeDesktopItem, unzip, bash, jre8 }:
+
+let
+  pname = "diylc";
+  version = "4.18.0";
+  files = {
+    app = fetchurl {
+      url = "https://github.com/bancika/diy-layout-creator/releases/download/v${version}/diylc-${version}.zip";
+      sha256 = "09fpp3dn086clgnjz5yj4fh5bnjvj6mvxkx9n3zamcwszjmxr40d";
+    };
+    icon16 = fetchurl {
+      url = "https://raw.githubusercontent.com/bancika/diy-layout-creator/v${version}/diylc/diylc-core/src/org/diylc/core/images/icon_small.png";
+      sha256 = "1is50aidfwzwfzwqv57s2hwhx0r5c21cp77bkl93xkdqkh2wd8x4";
+    };
+    icon32 = fetchurl {
+      url = "https://raw.githubusercontent.com/bancika/diy-layout-creator/v${version}/diylc/diylc-core/src/org/diylc/core/images/icon_medium.png";
+      sha256 = "0a45p18n84xz1nd3zv3y16jlimvqzhbzg3q3f4lawgx4rcrn2n3d";
+    };
+    icon48 = fetchurl {
+      url = "https://raw.githubusercontent.com/bancika/diy-layout-creator/v${version}/diylc/diylc-core/src/org/diylc/core/images/icon_large.png";
+      sha256 = "06dkz0dcy8hfmnzr5ri5n1sh8r7mg83kzbvs3zy58wwhgzs1ddk6";
+    };
+  };
+  launcher = makeDesktopItem {
+    name = "diylc";
+    desktopName = "DIY Layout Creator";
+    comment = "Multi platform circuit layout and schematic drawing tool";
+    exec = "diylc";
+    icon = "diylc_icon";
+    categories = [ "Development" "Electronics" ];
+  };
+in
+stdenv.mkDerivation rec {
+  inherit pname version;
+
+  dontUnpack = true;
+
+  buildInputs = [ jre8 ];
+  nativeBuildInputs = [ unzip ];
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out/share/diylc
+    unzip -UU ${files.app} -d $out/share/diylc
+    rm $out/share/diylc/diylc.exe
+    rm $out/share/diylc/run.sh
+
+    # Nope, the icon cannot be named 'diylc' because KDE does not like it.
+    install -Dm644 ${files.icon16} $out/share/icons/hicolor/16x16/apps/diylc_icon.png
+    install -Dm644 ${files.icon32} $out/share/icons/hicolor/32x32/apps/diylc_icon.png
+    install -Dm644 ${files.icon48} $out/share/icons/hicolor/48x48/apps/diylc_icon.png
+
+    mkdir -p $out/share/applications
+    ln -s ${launcher}/share/applications/* $out/share/applications/
+
+    mkdir -p $out/bin
+    cat <<EOF > $out/bin/diylc
+    #!${bash}/bin/sh
+    cd $out/share/diylc
+    ${jre8}/bin/java -Xms512m -Xmx2048m -Dorg.diylc.scriptRun=true -Dfile.encoding=UTF-8 -cp diylc.jar:lib org.diylc.DIYLCStarter
+    EOF
+    chmod +x $out/bin/diylc
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Multi platform circuit layout and schematic drawing tool";
+    homepage = "https://bancika.github.io/diy-layout-creator/";
+    changelog = "https://github.com/bancika/diy-layout-creator/releases";
+    license = licenses.gpl3Plus;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/dsview/default.nix b/nixpkgs/pkgs/applications/science/electronics/dsview/default.nix
new file mode 100644
index 000000000000..eb8246a584d3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/dsview/default.nix
@@ -0,0 +1,55 @@
+{ lib, mkDerivation, fetchFromGitHub, pkg-config, cmake
+, libzip, boost, fftw, qtbase, libusb1, libsigrok4dsl
+, libsigrokdecode4dsl, python3, fetchpatch
+}:
+
+mkDerivation rec {
+  pname = "dsview";
+
+  version = "1.12";
+
+  src = fetchFromGitHub {
+      owner = "DreamSourceLab";
+      repo = "DSView";
+      rev = "v${version}";
+      sha256 = "q7F4FuK/moKkouXTNPZDVon/W/ZmgtNHJka4MiTxA0U=";
+  };
+
+  sourceRoot = "source/DSView";
+
+  patches = [
+    # Fix absolute install paths
+    ./install.patch
+
+    # Fix buld with Qt5.15 already merged upstream for future release
+    # Using local file instead of content of commit #33e3d896a47 because
+    # sourceRoot make it unappliable
+    ./qt515.patch
+
+    # Change from upstream master that removes extern-C scopes which
+    # cause failures with modern glib. This can likely be removed if
+    # there is an upstream release >1.12
+    (fetchpatch {
+      name = "fix-extern-c.patch";
+      url = "https://github.com/DreamSourceLab/DSView/commit/33cc733abe19872bf5ed08540a94b798d0d4ecf4.patch";
+      sha256 = "sha256-TLfLQa3sdyNHTpMMvId/V6uUuOFihOZMFJOj9frnDoY=";
+      stripLen = 2;
+      extraPrefix = "";
+    })
+  ];
+
+  nativeBuildInputs = [ cmake pkg-config ];
+
+  buildInputs = [
+    boost fftw qtbase libusb1 libzip libsigrokdecode4dsl libsigrok4dsl
+    python3
+  ];
+
+  meta = with lib; {
+    description = "A GUI program for supporting various instruments from DreamSourceLab, including logic analyzer, oscilloscope, etc";
+    homepage = "https://www.dreamsourcelab.com/";
+    license = licenses.gpl3Plus;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ bachp ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/dsview/install.patch b/nixpkgs/pkgs/applications/science/electronics/dsview/install.patch
new file mode 100644
index 000000000000..75c3e9628656
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/dsview/install.patch
@@ -0,0 +1,15 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index c1c33e1..208a184 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -427,8 +427,8 @@
+ install(FILES ../NEWS31 DESTINATION share/${PROJECT_NAME} RENAME NEWS31)
+ install(FILES ../ug25.pdf DESTINATION share/${PROJECT_NAME} RENAME ug25.pdf)
+ install(FILES ../ug31.pdf DESTINATION share/${PROJECT_NAME} RENAME ug31.pdf)
+-install(FILES DreamSourceLab.rules DESTINATION /etc/udev/rules.d/)
+-install(FILES DSView.desktop DESTINATION /usr/share/applications/)
++install(FILES DreamSourceLab.rules DESTINATION etc/udev/rules.d/)
++install(FILES DSView.desktop DESTINATION share/applications/)
+ 
+ #===============================================================================
+ #= Packaging (handled by CPack)
diff --git a/nixpkgs/pkgs/applications/science/electronics/dsview/libsigrok4dsl.nix b/nixpkgs/pkgs/applications/science/electronics/dsview/libsigrok4dsl.nix
new file mode 100644
index 000000000000..c33bfd408b92
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/dsview/libsigrok4dsl.nix
@@ -0,0 +1,28 @@
+{ lib, stdenv, pkg-config, autoreconfHook,
+glib, libzip, libserialport, check, libusb1, libftdi,
+systemd, alsa-lib, dsview
+}:
+
+stdenv.mkDerivation {
+  inherit (dsview) version src;
+
+  pname = "libsigrok4dsl";
+
+  postUnpack = ''
+    export sourceRoot=$sourceRoot/libsigrok4DSL
+  '';
+
+  nativeBuildInputs = [ pkg-config autoreconfHook ];
+
+  buildInputs = [
+    glib libzip libserialport libusb1 libftdi systemd check alsa-lib
+  ];
+
+  meta = with lib; {
+    description = "A fork of the sigrok library for usage with DSView";
+    homepage = "https://www.dreamsourcelab.com/";
+    license = licenses.gpl3Plus;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.bachp ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/dsview/libsigrokdecode4dsl.nix b/nixpkgs/pkgs/applications/science/electronics/dsview/libsigrokdecode4dsl.nix
new file mode 100644
index 000000000000..09eed4a67c57
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/dsview/libsigrokdecode4dsl.nix
@@ -0,0 +1,27 @@
+{ lib, stdenv, pkg-config, autoreconfHook,
+glib, check, python3, dsview
+}:
+
+stdenv.mkDerivation {
+  inherit (dsview) version src;
+
+  pname = "libsigrokdecode4dsl";
+
+  postUnpack = ''
+    export sourceRoot=$sourceRoot/libsigrokdecode4DSL
+  '';
+
+  nativeBuildInputs = [ pkg-config autoreconfHook ];
+
+  buildInputs = [
+    python3 glib check
+  ];
+
+  meta = with lib; {
+    description = "A fork of the sigrokdecode library for usage with DSView";
+    homepage = "https://www.dreamsourcelab.com/";
+    license = licenses.gpl3Plus;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.bachp ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/dsview/qt515.patch b/nixpkgs/pkgs/applications/science/electronics/dsview/qt515.patch
new file mode 100644
index 000000000000..552f2062ec57
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/dsview/qt515.patch
@@ -0,0 +1,13 @@
+diff --git a/pv/view/viewport.cpp b/pv/view/viewport.cpp
+index 921d3db..16cdce9 100755
+--- a/pv/view/viewport.cpp
++++ b/pv/view/viewport.cpp
+@@ -37,7 +37,7 @@
+ 
+ #include <QMouseEvent>
+ #include <QStyleOption>
+-
++#include <QPainterPath>
+ 
+ #include <math.h>
+ 
diff --git a/nixpkgs/pkgs/applications/science/electronics/dwfv/default.nix b/nixpkgs/pkgs/applications/science/electronics/dwfv/default.nix
new file mode 100644
index 000000000000..ed340271f262
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/dwfv/default.nix
@@ -0,0 +1,20 @@
+{ lib, rustPlatform, fetchCrate }:
+
+rustPlatform.buildRustPackage rec {
+  pname = "dwfv";
+  version = "0.4.1";
+
+  src = fetchCrate {
+    inherit version pname;
+    sha256 = "0xxgwbbbzaldbl04k5ksk61wa6i4f9mc84q04ljg438z0k8q6cr7";
+  };
+
+  cargoSha256 = "1z51yx3psdxdzmwny0rzlch5hjx2pssll73q79qij2bc7wgyjscy";
+
+  meta = with lib; {
+    description = "A simple digital waveform viewer with vi-like key bindings";
+    homepage = "https://github.com/psurply/dwfv";
+    license = licenses.mit;
+    maintainers = with maintainers; [ newam ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/eagle/eagle.nix b/nixpkgs/pkgs/applications/science/electronics/eagle/eagle.nix
new file mode 100644
index 000000000000..5b4c8eb790fe
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/eagle/eagle.nix
@@ -0,0 +1,80 @@
+{ lib, stdenv, mkDerivation, fetchurl, makeDesktopItem
+, libXrender, libXrandr, libXcursor, libX11, libXext, libXi, libxcb
+ , libGL, glib, nss, nspr, expat, alsa-lib
+, qtbase, qtdeclarative, qtsvg, qtlocation, qtwebchannel, qtwebengine
+}:
+
+let
+  libPath = lib.makeLibraryPath
+    [ libXrender libXrandr libXcursor libX11 libXext libXi libxcb
+      libGL glib nss nspr expat alsa-lib
+      qtbase qtdeclarative qtsvg qtlocation qtwebchannel qtwebengine
+    ];
+  in
+  mkDerivation rec {
+    pname = "eagle";
+    version = "9.6.2";
+
+    src = fetchurl {
+      url = "https://eagle-updates.circuits.io/downloads/${builtins.replaceStrings ["."] ["_"] version}/Autodesk_EAGLE_${version}_English_Linux_64bit.tar.gz";
+      sha256 = "18syygnskl286kn8aqfzzdsyzq59d2w19y1h1ynyxsnrvkyv71h0";
+    };
+
+    desktopItem = makeDesktopItem {
+      name = "eagle";
+      exec = "eagle";
+      icon = "eagle";
+      comment = "Schematic capture and PCB layout";
+      desktopName = "Eagle";
+      genericName = "Schematic editor";
+      categories = [ "Development" ];
+    };
+
+    buildInputs =
+      [ libXrender libXrandr libXcursor libX11 libXext libXi libxcb
+        libGL glib nss nspr expat alsa-lib
+        qtbase qtdeclarative qtsvg qtlocation qtwebchannel qtwebengine
+      ];
+
+    installPhase = ''
+      # Extract eagle tarball
+      mkdir "$out"
+      tar -xzf "$src" -C "$out"
+
+      # Install manpage
+      mkdir -p "$out"/share/man/man1
+      ln -s "$out"/eagle-${version}/doc/eagle.1 "$out"/share/man/man1/eagle.1
+
+      patchelf \
+        --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+        --set-rpath "${libPath}:$out/eagle-${version}/lib:${stdenv.cc.cc.lib}/lib" \
+        "$out"/eagle-${version}/eagle
+
+      mkdir -p "$out"/bin
+      ln -s "$out"/eagle-${version}/eagle "$out"/bin/eagle
+
+      # Remove bundled libraries that are available in nixpkgs
+      # TODO: There still may be unused bundled libraries
+      rm "$out"/eagle-${version}/lib/libQt5*.so.5
+      rm "$out"/eagle-${version}/lib/{libxcb-*.so.*,libX*.so.*,libxshmfence.so.1}
+      rm "$out"/eagle-${version}/lib/{libEGL.so.1,libglapi.so.0,libgbm.so.1}
+
+      # No longer needed (we don't use the bundled Qt libraries)
+      rm -r "$out"/eagle-${version}/libexec
+      rm -r "$out"/eagle-${version}/plugins
+
+      # Make desktop item
+      mkdir -p "$out"/share/applications
+      cp "$desktopItem"/share/applications/* "$out"/share/applications/
+      mkdir -p "$out"/share/pixmaps
+      ln -s "$out/eagle-${version}/bin/eagle-logo.png" "$out"/share/pixmaps/eagle.png
+    '';
+
+    meta = with lib; {
+      description = "Schematic editor and PCB layout tool from Autodesk (formerly CadSoft)";
+      homepage = "https://www.autodesk.com/products/eagle/overview";
+      license = licenses.unfree;
+      platforms = [ "x86_64-linux" ];
+      maintainers = [ ];
+    };
+  }
diff --git a/nixpkgs/pkgs/applications/science/electronics/eagle/eagle7.nix b/nixpkgs/pkgs/applications/science/electronics/eagle/eagle7.nix
new file mode 100644
index 000000000000..f48d08d40799
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/eagle/eagle7.nix
@@ -0,0 +1,97 @@
+{ lib, stdenv, fetchurl, makeDesktopItem, patchelf, zlib, freetype, fontconfig
+, openssl, libXrender, libXrandr, libXcursor, libX11, libXext, libXi
+, libxcb, cups, xkeyboardconfig, runtimeShell
+}:
+
+let
+
+  libPath = lib.makeLibraryPath
+    [ zlib freetype fontconfig openssl libXrender libXrandr libXcursor libX11
+      libXext libXi libxcb cups
+    ];
+
+in
+
+stdenv.mkDerivation rec {
+  pname = "eagle";
+  version = "7.7.0";
+
+  src =
+    if stdenv.hostPlatform.system == "i686-linux" then
+      fetchurl {
+        url = "ftp://ftp.cadsoft.de/eagle/program/7.7/eagle-lin32-${version}.run";
+        sha256 = "16fa66p77xigc7zvzfm7737mllrcs6nrgk2p7wvkjw3p9lvbz7z1";
+      }
+    else if stdenv.hostPlatform.system == "x86_64-linux" then
+      fetchurl {
+        url = "ftp://ftp.cadsoft.de/eagle/program/7.7/eagle-lin64-${version}.run";
+        sha256 = "18dcn6wqph1sqh0ah98qzfi05wip8a8ifbkaq79iskbrsi8iqnrg";
+      }
+    else
+      throw "Unsupported system: ${stdenv.hostPlatform.system}";
+
+  desktopItem = makeDesktopItem {
+    name = "eagle";
+    exec = "eagle";
+    icon = "eagle";
+    comment = "Schematic capture and PCB layout";
+    desktopName = "Eagle";
+    genericName = "Schematic editor";
+    categories = [ "Development" ];
+  };
+
+  buildInputs =
+    [ patchelf zlib freetype fontconfig openssl libXrender libXrandr libXcursor
+      libX11 libXext libXi
+    ];
+
+  dontUnpack = true;
+
+  # NOTES:
+  # Eagle for Linux comes as a self-extracting shell script with embedded
+  # tarball. The tarball data (.tar.bz2) starts after a __DATA__ marker.
+  #
+  # Eagle apparently doesn't like binary patching. This is what happens:
+  #   $ ./result/eagle-6.4.0/bin/eagle
+  #   argv[0] (/home/bfo/nixpkgs/result/eagle-6.4.0/bin/eagle) is not the currently executed program version!
+  installPhase = ''
+    # Extract eagle tarball
+    mkdir "$out"
+    sed '1,/^__DATA__$/d' "$src" | tar -xjf - -C "$out"
+
+    # Install manpage
+    mkdir -p "$out"/share/man/man1
+    ln -s "$out"/eagle-${version}/doc/eagle.1 "$out"/share/man/man1/eagle.1
+
+    # Build LD_PRELOAD library that redirects license file access to the home
+    # directory of the user
+    mkdir -p "$out"/lib
+    gcc -shared -fPIC -DEAGLE_PATH=\"$out/eagle-${version}\" ${./eagle7_fixer.c} -o "$out"/lib/eagle_fixer.so -ldl
+
+    # Make wrapper script
+    dynlinker="$(cat $NIX_CC/nix-support/dynamic-linker)"
+    mkdir -p "$out"/bin
+    cat > "$out"/bin/eagle << EOF
+    #!${runtimeShell}
+    export LD_LIBRARY_PATH="${stdenv.cc.cc.lib}/lib:${libPath}"
+    export LD_PRELOAD="$out/lib/eagle_fixer.so"
+    export QT_XKB_CONFIG_ROOT="${xkeyboardconfig}/share/X11/xkb"
+    exec "$dynlinker" "$out/eagle-${version}/bin/eagle" "\$@"
+    EOF
+    chmod a+x "$out"/bin/eagle
+
+    # Make desktop item
+    mkdir -p "$out"/share/applications
+    cp "$desktopItem"/share/applications/* "$out"/share/applications/
+    mkdir -p "$out"/share/icons
+    ln -s "$out/eagle-${version}/bin/eagleicon50.png" "$out"/share/icons/eagle.png
+  '';
+
+  meta = with lib; {
+    description = "Schematic editor and PCB layout tool from CadSoft";
+    homepage = "https://www.autodesk.com/products/eagle/overview";
+    license = licenses.unfree;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.bjornfor ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/eagle/eagle7_fixer.c b/nixpkgs/pkgs/applications/science/electronics/eagle/eagle7_fixer.c
new file mode 100644
index 000000000000..da9da4dcbd3a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/eagle/eagle7_fixer.c
@@ -0,0 +1,134 @@
+/*
+ * LD_PRELOAD trick to make Eagle (schematic editor and PCB layout tool from
+ * CadSoft) work from a read-only installation directory.
+ *
+ * When Eagle starts, it looks for the license file in <eagle>/bin/eagle.key
+ * (where <eagle> is the install path). If eagle.key is not found, Eagle checks
+ * for write access to <eagle>/bin/, shows a license dialog to the user and
+ * then attempts to write a license file to <eagle>/bin/.
+ *
+ * This will of course fail when Eagle is installed in the read-only Nix store.
+ * Hence this library that redirects accesses to the those paths in the
+ * following way:
+ *
+ *   <eagle>/bin              => $HOME
+ *   <eagle>/bin/eagle.key    => $HOME/.eagle.key
+ *
+ * Also, if copying an example project to ~/eagle/ (in the Eagle GUI), Eagle
+ * chmod's the destination with read-only permission bits (presumably because
+ * the source is read-only) and fails to complete the copy operation.
+ * Therefore, the mode argument in calls to chmod() is OR'ed with the S_IWUSR
+ * bit (write by owner).
+ *
+ * Usage:
+ *   gcc -shared -fPIC -DEAGLE_PATH="$out/eagle-${version}" eagle_fixer.c -o eagle_fixer.so -ldl
+ *   LD_PRELOAD=$PWD/eagle_fixer.so ./result/bin/eagle
+ *
+ * To see the paths that are modified at runtime, set the environment variable
+ * EAGLE_FIXER_DEBUG to 1.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <dlfcn.h>
+#include <limits.h>
+#include <sys/stat.h>
+
+#ifndef EAGLE_PATH
+#error Missing EAGLE_PATH, path to the eagle-${version} installation directory.
+#endif
+
+typedef FILE *(*fopen_func_t)(const char *path, const char *mode);
+typedef int (*access_func_t)(const char *pathname, int mode);
+typedef int (*chmod_func_t)(const char *path, mode_t mode);
+
+/*
+ * Map <eagle>/bin to $HOME and <eagle>/bin/eagle.key to $HOME/.eagle.key
+ *
+ * Path is truncated if bigger than PATH_MAX. It's not threadsafe, but that's
+ * OK.
+ */
+static const char *redirect(const char *pathname)
+{
+	static char buffer[PATH_MAX];
+	const char *homepath;
+	const char *new_path;
+	static int have_warned;
+
+	homepath = getenv("HOME");
+	if (!homepath) {
+		homepath = "/";
+		if (!have_warned && getenv("EAGLE_FIXER_DEBUG")) {
+			fprintf(stderr, "eagle_fixer: HOME is unset, using \"/\" (root) instead.\n");
+			have_warned = 1;
+		}
+	}
+
+	new_path = pathname;
+	if (strcmp(EAGLE_PATH "/bin", pathname) == 0) {
+		/* redirect to $HOME */
+		new_path = homepath;
+	} else if (strcmp(EAGLE_PATH "/bin/eagle.key", pathname) == 0) {
+		/* redirect to $HOME/.eagle.key */
+		snprintf(buffer, PATH_MAX, "%s/.eagle.key", homepath);
+		buffer[PATH_MAX-1] = '\0';
+		new_path = buffer;
+	}
+
+	return new_path;
+}
+
+FILE *fopen(const char *pathname, const char *mode)
+{
+	FILE *fp;
+	const char *path;
+	fopen_func_t orig_fopen;
+
+	orig_fopen = (fopen_func_t)dlsym(RTLD_NEXT, "fopen");
+	path = redirect(pathname);
+	fp = orig_fopen(path, mode);
+
+	if (path != pathname && getenv("EAGLE_FIXER_DEBUG")) {
+		fprintf(stderr, "eagle_fixer: fopen(\"%s\", \"%s\") => \"%s\": fp=%p\n", pathname, mode, path, fp);
+	}
+
+	return fp;
+}
+
+int access(const char *pathname, int mode)
+{
+	int ret;
+	const char *path;
+	access_func_t orig_access;
+
+	orig_access = (access_func_t)dlsym(RTLD_NEXT, "access");
+	path = redirect(pathname);
+	ret = orig_access(path, mode);
+
+	if (path != pathname && getenv("EAGLE_FIXER_DEBUG")) {
+		fprintf(stderr, "eagle_fixer: access(\"%s\", %d) => \"%s\": ret=%d\n", pathname, mode, path, ret);
+	}
+
+	return ret;
+}
+
+int chmod(const char *pathname, mode_t mode)
+{
+	int ret;
+	mode_t new_mode;
+	chmod_func_t orig_chmod;
+
+	orig_chmod = (chmod_func_t)dlsym(RTLD_NEXT, "chmod");
+	new_mode = mode | S_IWUSR;
+	ret = orig_chmod(pathname, new_mode);
+
+	if (getenv("EAGLE_FIXER_DEBUG")) {
+		fprintf(stderr, "eagle_fixer: chmod(\"%s\", %o) => %o: ret=%d\n", pathname, mode, new_mode, ret);
+	}
+
+	return ret;
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/flatcam/default.nix b/nixpkgs/pkgs/applications/science/electronics/flatcam/default.nix
new file mode 100644
index 000000000000..1f6679625ec7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/flatcam/default.nix
@@ -0,0 +1,57 @@
+{ lib
+, python3Packages
+, fetchFromBitbucket
+, fetchpatch
+}:
+
+python3Packages.buildPythonApplication rec {
+  pname = "flatcam";
+  version = "8.5";
+
+  src = fetchFromBitbucket {
+    owner = "jpcgt";
+    repo = pname;
+    rev = "533afd6a1772857cb633c011b5e0a15b60b1e92e"; # 8.5 with Red Hat packaging.
+    sha256 = "199kiiml18k34z1zhk2hbhibphmnv0kb11kxiajq52alps0mjb3m";
+  };
+
+  propagatedBuildInputs = with python3Packages; [
+    matplotlib
+    numpy
+    packaging
+    pyqt4
+    Rtree
+    scipy
+    setuptools
+    shapely
+    simplejson
+    six
+    svg-path
+  ];
+
+  packaging_fix_pull_request_patch = fetchpatch {
+    name = "packaging_fix_pull_request.patch";
+    url = "https://bitbucket.org/trepetti/flatcam/commits/5591ed889d1f48a5190fe237b562cb932cb5876c/raw";
+    sha256 = "19rhjdrf1n1q29cgpcry6pl2kl90zq0d613hhkwdir9bhq5bkknp";
+  };
+
+  patches = [
+    packaging_fix_pull_request_patch
+    ./release.patch
+  ];
+
+  # Only non-GUI tests can be run deterministically in the Nix build environment.
+  checkPhase = ''
+    python -m unittest tests.test_excellon
+    python -m unittest tests.test_gerber_buffer
+    python -m unittest tests.test_paint
+    python -m unittest tests.test_pathconnect
+  '';
+
+  meta = with lib; {
+    description = "2-D post processing for PCB fabrication on CNC routers";
+    homepage = "https://bitbucket.org/jpcgt/flatcam";
+    license = licenses.mit;
+    maintainers = with maintainers; [ trepetti ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/flatcam/release.patch b/nixpkgs/pkgs/applications/science/electronics/flatcam/release.patch
new file mode 100644
index 000000000000..945228e35bab
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/flatcam/release.patch
@@ -0,0 +1,13 @@
+diff --git a/FlatCAMVersion.py b/FlatCAMVersion.py
+index ba9e04a5..2c64d5a6 100644
+--- a/FlatCAMVersion.py
++++ b/FlatCAMVersion.py
+@@ -16,7 +16,7 @@ version = {
+     "number": 8.5,
+     "date": (2016, 7, 1),  # Year, Month, Day
+     "name": None,
+-    "release": False,
++    "release": True,
+ }
+ 
+ 
diff --git a/nixpkgs/pkgs/applications/science/electronics/fparser/default.nix b/nixpkgs/pkgs/applications/science/electronics/fparser/default.nix
new file mode 100644
index 000000000000..73db0575d0b1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/fparser/default.nix
@@ -0,0 +1,26 @@
+{ lib, stdenv
+, fetchFromGitHub
+, cmake
+}:
+
+stdenv.mkDerivation rec {
+  pname = "fparser";
+  version = "unstable-2015-09-25";
+
+  src = fetchFromGitHub {
+    owner = "thliebig";
+    repo = "fparser";
+    rev = "a59e1f51e32096bfe2a0a2640d5dffc7ae6ba37b";
+    sha256 = "0wayml1mlyi922gp6am3fsidhzsilziksdn5kbnpcln01h8555ad";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  meta = with lib; {
+    description = "C++ Library for Evaluating Mathematical Functions";
+    homepage = "https://github.com/thliebig/fparser";
+    license = licenses.lgpl3;
+    maintainers = with maintainers; [ matthuszagh ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/fped/default.nix b/nixpkgs/pkgs/applications/science/electronics/fped/default.nix
new file mode 100644
index 000000000000..f1c458f40d9f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/fped/default.nix
@@ -0,0 +1,44 @@
+{ lib, stdenv, fetchgit
+, flex, bison, fig2dev, imagemagick, netpbm, gtk2
+, pkg-config
+}:
+
+with lib;
+stdenv.mkDerivation {
+  pname = "fped";
+  version = "unstable-2017-05-11";
+
+  src = fetchgit {
+    url = "git://projects.qi-hardware.com/fped.git";
+    rev = "fa98e58157b6f68396d302c32421e882ac87f45b";
+    sha256 = "0xv364a00zwxhd9kg1z9sch5y0cxnrhk546asspyb9bh58sdzfy7";
+  };
+
+  # This uses '/bin/bash', '/usr/local' and 'lex' by default
+  makeFlags = [
+    "PREFIX=${placeholder "out"}"
+    "LEX=flex"
+    "RGBDEF=${netpbm.out}/share/netpbm/misc/rgb.txt"
+  ];
+
+  nativeBuildInputs = [
+    flex
+    bison
+    pkg-config
+    imagemagick
+    fig2dev
+    netpbm
+  ];
+
+  buildInputs = [
+    gtk2
+  ];
+
+  meta = {
+    description = "An editor that allows the interactive creation of footprints electronic components";
+    homepage = "http://projects.qi-hardware.com/index.php/p/fped/";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ expipiplus1 ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/fritzing/default.nix b/nixpkgs/pkgs/applications/science/electronics/fritzing/default.nix
new file mode 100644
index 000000000000..c5723dbab98e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/fritzing/default.nix
@@ -0,0 +1,84 @@
+{ mkDerivation
+, lib
+, fetchFromGitHub
+, fetchpatch
+, qmake
+, pkg-config
+, qtbase
+, qtsvg
+, qttools
+, qtserialport
+, boost
+, libgit2
+, quazip
+}:
+
+let
+  # SHA256 of the fritzing-parts HEAD on the master branch,
+  # which contains the latest stable parts definitions
+  partsSha = "640fa25650211afccd369f960375ade8ec3e8653";
+
+  parts = fetchFromGitHub {
+    owner = "fritzing";
+    repo = "fritzing-parts";
+    rev = partsSha;
+    sha256 = "sha256-4S65eX4LCnXCFQAOxmdvr8d0nAgTWcJooE2SpLYpcXI=";
+  };
+in
+
+mkDerivation rec {
+  pname = "fritzing";
+  version = "unstable-2021-09-22";
+
+  src = fetchFromGitHub {
+    owner = pname;
+    repo = "fritzing-app";
+    rev = "f0af53a9077f7cdecef31d231b85d8307de415d4";
+    sha256 = "sha256-fF38DrBoeZ0aKwVMNyYMPWa5rFPbIVXRARZT+eRat5Q=";
+  };
+
+  buildInputs = [ qtbase qtsvg qtserialport boost libgit2 quazip ];
+  nativeBuildInputs = [ qmake pkg-config qttools ];
+
+  patches = [
+    # Add support for QuaZip 1.x
+    (fetchpatch {
+      url = "https://github.com/fritzing/fritzing-app/commit/ef83ebd9113266bb31b3604e3e9d0332bb48c999.patch";
+      sha256 = "sha256-J43E6iBRIVbsuuo82gPk3Q7tyLhNkuuyYwtH8hUfcPU=";
+    })
+  ];
+
+  postPatch = ''
+    substituteInPlace phoenix.pro \
+      --replace 'LIBGIT_STATIC = true' 'LIBGIT_STATIC = false'
+
+    #TODO: Do not hardcode SHA.
+    substituteInPlace src/fapplication.cpp \
+      --replace 'PartsChecker::getSha(dir.absolutePath());' '"${partsSha}";'
+
+    mkdir parts
+    cp -a ${parts}/* parts/
+  '';
+
+  qmakeFlags = [
+    "phoenix.pro"
+    "DEFINES=QUAZIP_INSTALLED"
+    "DEFINES+=QUAZIP_1X"
+  ];
+
+  postFixup = ''
+    # generate the parts.db file
+    QT_QPA_PLATFORM=offscreen "$out/bin/Fritzing" \
+      -db "$out/share/fritzing/parts/parts.db" \
+      -pp "$out/share/fritzing/parts" \
+      -folder "$out/share/fritzing"
+  '';
+
+  meta = with lib; {
+    description = "An open source prototyping tool for Arduino-based projects";
+    homepage = "https://fritzing.org/";
+    license = with licenses; [ gpl3 cc-by-sa-30 ];
+    maintainers = with maintainers; [ robberer musfay ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/gaw/default.nix b/nixpkgs/pkgs/applications/science/electronics/gaw/default.nix
new file mode 100644
index 000000000000..928613737b47
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/gaw/default.nix
@@ -0,0 +1,34 @@
+{ stdenv
+, fetchurl
+, lib
+, gtk3
+, pkg-config
+}:
+
+stdenv.mkDerivation rec {
+  pname = "gaw";
+  version = "20200922";
+
+  src = fetchurl {
+    url = "https://download.tuxfamily.org/gaw/download/gaw3-${version}.tar.gz";
+    sha256 = "0qmap11v470a1yj4ypfvdq6wkfni77ijqpknka8b4fndi62sl4wa";
+  };
+
+  nativeBuildInputs = [ pkg-config ];
+
+  buildInputs = [ gtk3 ];
+
+  meta = with lib; {
+    description = "Gtk Analog Wave viewer";
+    longDescription = ''
+      Gaw is a software tool for displaying analog waveforms from
+      sampled datas, for example from the output of simulators or
+      input from sound cards. Data can be imported to gaw using files,
+      direct tcp/ip connection or directly from the sound card.
+    '';
+    homepage = "http://gaw.tuxfamily.org";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ fbeffa ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/geda/default.nix b/nixpkgs/pkgs/applications/science/electronics/geda/default.nix
new file mode 100644
index 000000000000..cf98e6963e1f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/geda/default.nix
@@ -0,0 +1,25 @@
+{ lib, stdenv, fetchurl, pkg-config, guile, gtk2, flex, gawk, perl }:
+
+stdenv.mkDerivation {
+  pname = "geda";
+  version = "1.8.2-20130925";
+
+  src = fetchurl {
+    url = "http://ftp.geda-project.org/geda-gaf/stable/v1.8/1.8.2/geda-gaf-1.8.2.tar.gz";
+    sha256 = "08dpa506xk4gjbbi8vnxcb640wq4ihlgmhzlssl52nhvxwx7gx5v";
+  };
+
+  configureFlags = [
+    "--disable-update-xdg-database"
+  ];
+  nativeBuildInputs = [ pkg-config ];
+  buildInputs = [ guile gtk2 flex gawk perl ];
+
+  meta = with lib; {
+    description = "Full GPL'd suite of Electronic Design Automation tools";
+    homepage = "http://www.geda-project.org/";
+    maintainers = with maintainers; [ pjones ];
+    platforms = platforms.linux;
+    license = licenses.gpl2;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/gerbv/default.nix b/nixpkgs/pkgs/applications/science/electronics/gerbv/default.nix
new file mode 100644
index 000000000000..94a8f081f69a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/gerbv/default.nix
@@ -0,0 +1,25 @@
+{ lib, stdenv, fetchgit, pkg-config, gettext, libtool, automake, autoconf, cairo, gtk2, autoreconfHook }:
+
+stdenv.mkDerivation {
+  pname = "gerbv";
+  version = "2015-10-08";
+
+  src = fetchgit {
+    url = "git://git.geda-project.org/gerbv.git";
+    rev = "76b8b67bfa10823ce98f1c4c3b49a2afcadf7659";
+    sha256 = "00jn1xhf6kblxc5gac1wvk8zm12fy6sk81nj3jwdag0z6wk3z446";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkg-config ];
+  buildInputs = [ gettext libtool automake autoconf cairo gtk2 ];
+
+  configureFlags = ["--disable-update-desktop-database"];
+
+  meta = with lib; {
+    description = "A Gerber (RS-274X) viewer";
+    homepage = "http://gerbv.geda-project.org/";
+    maintainers = with maintainers; [ mog ];
+    platforms = platforms.linux;
+    license = licenses.gpl2;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/gnucap/default.nix b/nixpkgs/pkgs/applications/science/electronics/gnucap/default.nix
new file mode 100644
index 000000000000..0ec10f2444fd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/gnucap/default.nix
@@ -0,0 +1,27 @@
+{ lib, stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  pname = "gnucap";
+  version = "20210107";
+
+  src = fetchurl {
+    url = "https://git.savannah.gnu.org/cgit/gnucap.git/snapshot/${pname}-${version}.tar.gz";
+    sha256 = "12rlwd4mfc54qq1wrx5k8qk578xls5z4isf94ybkf2z6qxk4mhnj";
+  };
+
+  doCheck = true;
+
+  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.isDarwin; # Relies on LD_LIBRARY_PATH
+    maintainers = [ maintainers.raboof ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/gtkwave/default.nix b/nixpkgs/pkgs/applications/science/electronics/gtkwave/default.nix
new file mode 100644
index 000000000000..bb6af8a20fd1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/gtkwave/default.nix
@@ -0,0 +1,42 @@
+{ bzip2
+, fetchurl
+, glib
+, gperf
+, gtk3
+, judy
+, lib
+, pkg-config
+, stdenv
+, tcl
+, tk
+, wrapGAppsHook
+, xz
+}:
+
+stdenv.mkDerivation rec {
+  pname = "gtkwave";
+  version = "3.3.111";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/gtkwave/${pname}-gtk3-${version}.tar.gz";
+    sha256 = "0cv222qhgldfniz6zys52zhrynfsp5v0h8ia857lng7v33vw5qdl";
+  };
+
+  nativeBuildInputs = [ pkg-config wrapGAppsHook ];
+  buildInputs = [ bzip2 glib gperf gtk3 judy tcl tk xz ];
+
+  configureFlags = [
+    "--with-tcl=${tcl}/lib"
+    "--with-tk=${tk}/lib"
+    "--enable-judy"
+    "--enable-gtk3"
+  ];
+
+  meta = {
+    description = "VCD/Waveform viewer for Unix and Win32";
+    homepage = "http://gtkwave.sourceforge.net";
+    license = lib.licenses.gpl2Plus;
+    maintainers = with lib.maintainers; [ thoughtpolice ];
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/hal-hardware-analyzer/default.nix b/nixpkgs/pkgs/applications/science/electronics/hal-hardware-analyzer/default.nix
new file mode 100644
index 000000000000..f1d34062d2aa
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/hal-hardware-analyzer/default.nix
@@ -0,0 +1,52 @@
+{ lib, stdenv, fetchFromGitHub, cmake, ninja, pkg-config, python3Packages
+, boost, rapidjson, qtbase, qtsvg, igraph, spdlog, wrapQtAppsHook
+, graphviz, llvmPackages, z3
+}:
+
+stdenv.mkDerivation rec {
+  version = "3.3.0";
+  pname = "hal-hardware-analyzer";
+
+  src = fetchFromGitHub {
+    owner = "emsec";
+    repo = "hal";
+    rev = "v${version}";
+    sha256 = "sha256-uNpELHhSAVRJL/4iypvnl3nX45SqB419r37lthd2WmQ=";
+  };
+  # make sure bundled dependencies don't get in the way - install also otherwise
+  # copies them in full to the output, bloating the package
+  postPatch = ''
+    shopt -s extglob
+    rm -rf deps/!(sanitizers-cmake)/*
+    shopt -u extglob
+  '';
+
+  nativeBuildInputs = [ cmake ninja pkg-config ];
+  buildInputs = [ qtbase qtsvg boost rapidjson igraph spdlog graphviz wrapQtAppsHook z3 ]
+    ++ (with python3Packages; [ python pybind11 ])
+    ++ lib.optional stdenv.cc.isClang llvmPackages.openmp;
+
+  cmakeFlags = with lib.versions; [
+    "-DHAL_VERSION_RETURN=${version}"
+    "-DHAL_VERSION_MAJOR=${major version}"
+    "-DHAL_VERSION_MINOR=${minor version}"
+    "-DHAL_VERSION_PATCH=${patch version}"
+    "-DHAL_VERSION_TWEAK=0"
+    "-DHAL_VERSION_ADDITIONAL_COMMITS=0"
+    "-DHAL_VERSION_DIRTY=false"
+    "-DHAL_VERSION_BROKEN=false"
+    "-DENABLE_INSTALL_LDCONFIG=off"
+    "-DBUILD_ALL_PLUGINS=on"
+  ];
+  # needed for macos build - this is why we use wrapQtAppsHook instead of
+  # the qt mkDerivation - the latter forcibly overrides this.
+  cmakeBuildType = "MinSizeRel";
+
+  meta = with lib; {
+    description = "A comprehensive reverse engineering and manipulation framework for gate-level netlists";
+    homepage = "https://github.com/emsec/hal";
+    license = licenses.mit;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ ris shamilton ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/horizon-eda/default.nix b/nixpkgs/pkgs/applications/science/electronics/horizon-eda/default.nix
new file mode 100644
index 000000000000..6029bf5a9948
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/horizon-eda/default.nix
@@ -0,0 +1,75 @@
+{ stdenv
+, boost
+, coreutils
+, cppzmq
+, curl
+, libepoxy
+, fetchFromGitHub
+, glm
+, gtkmm3
+, lib
+, libgit2
+, librsvg
+, libuuid
+, libzip
+, opencascade
+, pkg-config
+, podofo
+, python3
+, sqlite
+, wrapGAppsHook
+, zeromq
+}:
+
+stdenv.mkDerivation rec {
+  pname = "horizon-eda";
+  version = "2.2.0";
+
+  src = fetchFromGitHub {
+    owner = "horizon-eda";
+    repo = "horizon";
+    rev = "v${version}";
+    sha256 = "sha256-MUS1dIsULDJ5DahCtDpbHZq56nltHShli7+uoW1/Tqw=";
+  };
+
+  buildInputs = [
+    cppzmq
+    curl
+    libepoxy
+    glm
+    gtkmm3
+    libgit2
+    librsvg
+    libuuid
+    libzip
+    opencascade
+    podofo
+    python3
+    sqlite
+    zeromq
+  ];
+
+  nativeBuildInputs = [
+    boost.dev
+    pkg-config
+    wrapGAppsHook
+  ];
+
+  CASROOT = opencascade;
+
+  installFlags = [
+    "INSTALL=${coreutils}/bin/install"
+    "DESTDIR=$(out)"
+    "PREFIX="
+  ];
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    description = "A free EDA software to develop printed circuit boards";
+    homepage = "https://horizon-eda.org";
+    maintainers = with maintainers; [ guserav ];
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/hyp2mat/default.nix b/nixpkgs/pkgs/applications/science/electronics/hyp2mat/default.nix
new file mode 100644
index 000000000000..799af4c43086
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/hyp2mat/default.nix
@@ -0,0 +1,53 @@
+{ lib, stdenv
+, fetchFromGitHub
+, bison
+, flex
+, gengetopt
+, help2man
+, groff
+, libharu
+, autoreconfHook
+, pkg-config
+, libpng
+, zlib
+}:
+
+stdenv.mkDerivation rec {
+  pname = "hyp2mat";
+  version = "0.0.18";
+
+  src = fetchFromGitHub {
+    owner = "koendv";
+    repo = "hyp2mat";
+    rev = "v${version}";
+    sha256 = "03ibk51swxfl7pfrhcrfiffdi4mnf8kla0g1xj1lsrvrjwapfx03";
+  };
+
+  nativeBuildInputs = [
+    autoreconfHook
+    pkg-config
+  ];
+
+  buildInputs = [
+    libharu
+    libpng
+    zlib
+    bison
+    flex
+    gengetopt
+    help2man
+    groff
+  ];
+
+  configureFlags = [ "--enable-library" ];
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    description = "Import Hyperlynx Boardsim files to openEMS, an open source 3D full-wave electromagnetic field solver";
+    homepage = "https://github.com/koendv/hyp2mat";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ matthuszagh ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/kicad/base.nix b/nixpkgs/pkgs/applications/science/electronics/kicad/base.nix
new file mode 100644
index 000000000000..961519bad19b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/kicad/base.nix
@@ -0,0 +1,176 @@
+{ lib
+, stdenv
+, cmake
+, libGLU
+, libGL
+, zlib
+, wxGTK
+, libX11
+, gettext
+, glew
+, glm
+, cairo
+, curl
+, openssl
+, boost
+, pkg-config
+, doxygen
+, graphviz
+, pcre
+, libpthreadstubs
+, libXdmcp
+, lndir
+
+, util-linux
+, libselinux
+, libsepol
+, libthai
+, libdatrie
+, libxkbcommon
+, libepoxy
+, dbus
+, at-spi2-core
+, libXtst
+
+, swig
+, python
+, wxPython
+, opencascade-occt
+, libngspice
+, valgrind
+
+, stable
+, baseName
+, kicadSrc
+, kicadVersion
+, withOCC
+, withNgspice
+, withScripting
+, withI18n
+, withPCM
+, debug
+, sanitizeAddress
+, sanitizeThreads
+}:
+
+assert lib.assertMsg (!(sanitizeAddress && sanitizeThreads))
+  "'sanitizeAddress' and 'sanitizeThreads' are mutually exclusive, use one.";
+
+let
+  inherit (lib) optional optionals optionalString;
+in
+stdenv.mkDerivation rec {
+  pname = "kicad-base";
+  version = if (stable) then kicadVersion else builtins.substring 0 10 src.rev;
+
+  src = kicadSrc;
+
+  # tagged releases don't have "unknown"
+  # kicad nightlies use git describe --dirty
+  # nix removes .git, so its approximated here
+  postPatch = ''
+    substituteInPlace CMakeModules/KiCadVersion.cmake \
+      --replace "unknown" "${builtins.substring 0 10 src.rev}" \
+  '';
+
+  makeFlags = optionals (debug) [ "CFLAGS+=-Og" "CFLAGS+=-ggdb" ];
+
+  cmakeFlags = optionals (withScripting) [
+    "-DKICAD_SCRIPTING_WXPYTHON=ON"
+  ]
+  ++ optionals (!withScripting) [
+    "-DKICAD_SCRIPTING_WXPYTHON=OFF"
+  ]
+  ++ optional (!withNgspice) "-DKICAD_SPICE=OFF"
+  ++ optional (!withOCC) "-DKICAD_USE_OCC=OFF"
+  ++ optionals (withOCC) [
+    "-DKICAD_USE_OCC=ON"
+    "-DOCC_INCLUDE_DIR=${opencascade-occt}/include/opencascade"
+  ]
+  ++ optionals (debug) [
+    "-DCMAKE_BUILD_TYPE=Debug"
+    "-DKICAD_STDLIB_DEBUG=ON"
+    "-DKICAD_USE_VALGRIND=ON"
+  ]
+  ++ optionals (!doInstallCheck) [
+    "-DKICAD_BUILD_QA_TESTS=OFF"
+  ]
+  ++ optionals (sanitizeAddress) [
+    "-DKICAD_SANITIZE_ADDRESS=ON"
+  ]
+  ++ optionals (sanitizeThreads) [
+    "-DKICAD_SANITIZE_THREADS=ON"
+  ]
+  ++ optionals (withI18n) [
+    "-DKICAD_BUILD_I18N=ON"
+  ]
+  ++ optionals (!withPCM && stable) [
+    "-DKICAD_PCM=OFF"
+  ];
+
+  nativeBuildInputs = [
+    cmake
+    doxygen
+    graphviz
+    pkg-config
+    lndir
+  ]
+  # wanted by configuration on linux, doesn't seem to affect performance
+  # no effect on closure size
+  ++ optionals (stdenv.isLinux) [
+    util-linux
+    libselinux
+    libsepol
+    libthai
+    libdatrie
+    libxkbcommon
+    libepoxy
+    dbus.daemon
+    at-spi2-core
+    libXtst
+  ];
+
+  buildInputs = [
+    libGLU
+    libGL
+    zlib
+    libX11
+    wxGTK
+    wxGTK.gtk
+    pcre
+    libXdmcp
+    gettext
+    glew
+    glm
+    libpthreadstubs
+    cairo
+    curl
+    openssl
+    boost
+    swig
+    python
+  ]
+  ++ optional (withScripting) wxPython
+  ++ optional (withNgspice) libngspice
+  ++ optional (withOCC) opencascade-occt
+  ++ optional (debug) valgrind
+  ;
+
+  # debug builds fail all but the python test
+  #doInstallCheck = !debug;
+  # temporarily disabled until upstream issue 9888 is resolved
+  doInstallCheck = false;
+  installCheckTarget = "test";
+
+  dontStrip = debug;
+
+  meta = {
+    description = "Just the built source without the libraries";
+    longDescription = ''
+      Just the build products, the libraries are passed via an env var in the wrapper, default.nix
+    '';
+    homepage = "https://www.kicad.org/";
+    license = lib.licenses.agpl3;
+    platforms = lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/kicad/default.nix b/nixpkgs/pkgs/applications/science/electronics/kicad/default.nix
new file mode 100644
index 000000000000..95e88ff14071
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/kicad/default.nix
@@ -0,0 +1,239 @@
+{ lib, stdenv
+, fetchFromGitLab
+, gnome
+, dconf
+, wxGTK31-gtk3
+, makeWrapper
+, gsettings-desktop-schemas
+, hicolor-icon-theme
+, callPackage
+, callPackages
+, librsvg
+, cups
+
+, pname ? "kicad"
+, stable ? true
+, withOCC ? true
+, withNgspice ? true
+, libngspice
+, withScripting ? true
+, python3
+, debug ? false
+, sanitizeAddress ? false
+, sanitizeThreads ? false
+, with3d ? true
+, withI18n ? true
+, withPCM ? true # Plugin and Content Manager
+, srcs ? { }
+}:
+
+# The `srcs` parameter can be used to override the kicad source code
+# and all libraries, which are otherwise inaccessible
+# to overlays since most of the kicad build expression has been
+# refactored into base.nix, most of the library build expressions have
+# been refactored into libraries.nix. Overrides are only applied when
+# building `kicad-unstable`. The `srcs` parameter has
+# no effect for stable `kicad`. `srcs` takes an attribute set in which
+# any of the following attributes are meaningful (though none are
+# mandatory): "kicad", "kicadVersion", "symbols", "templates",
+# "footprints", "packages3d", and "libVersion". "kicadVersion" and
+# "libVersion" should be set to a string with the desired value for
+# the version attribute in kicad's `mkDerivation` and the version
+# attribute in any of the library's `mkDerivation`, respectively.
+# "kicad", "symbols", "templates", "footprints", and "packages3d"
+# should be set to an appropriate fetcher (e.g. `fetchFromGitLab`).
+# So, for example, a possible overlay for kicad is:
+#
+# final: prev:
+
+# {
+#   kicad-unstable = (prev.kicad-unstable.override {
+#     srcs = {
+#       kicadVersion = "2020-10-08";
+#       kicad = prev.fetchFromGitLab {
+#         group = "kicad";
+#         owner = "code";
+#         repo = "kicad";
+#         rev = "fd22fe8e374ce71d57e9f683ba996651aa69fa4e";
+#         sha256 = "sha256-F8qugru/jU3DgZSpQXQhRGNFSk0ybFRkpyWb7HAGBdc=";
+#       };
+#     };
+#   });
+# }
+
+let
+  baseName = if (stable) then "kicad" else "kicad-unstable";
+  versionsImport = import ./versions.nix;
+
+  # versions.nix does not provide us with version, src and rev. We
+  # need to turn this into approprate fetcher calls.
+  kicadSrcFetch = fetchFromGitLab {
+    group = "kicad";
+    owner = "code";
+    repo = "kicad";
+    rev = versionsImport.${baseName}.kicadVersion.src.rev;
+    sha256 = versionsImport.${baseName}.kicadVersion.src.sha256;
+  };
+
+  libSrcFetch = name: fetchFromGitLab {
+    group = "kicad";
+    owner = "libraries";
+    repo = "kicad-${name}";
+    rev = versionsImport.${baseName}.libVersion.libSources.${name}.rev;
+    sha256 = versionsImport.${baseName}.libVersion.libSources.${name}.sha256;
+  };
+
+  # only override `src` or `version` if building `kicad-unstable` with
+  # the appropriate attribute defined in `srcs`.
+  srcOverridep = attr: (!stable && builtins.hasAttr attr srcs);
+
+  # use default source and version (as defined in versions.nix) by
+  # default, or use the appropriate attribute from `srcs` if building
+  # unstable with `srcs` properly defined.
+  kicadSrc =
+    if srcOverridep "kicad" then srcs.kicad
+    else kicadSrcFetch;
+  kicadVersion =
+    if srcOverridep "kicadVersion" then srcs.kicadVersion
+    else versionsImport.${baseName}.kicadVersion.version;
+
+  libSrc = name: if srcOverridep name then srcs.${name} else libSrcFetch name;
+  # TODO does it make sense to only have one version for all libs?
+  libVersion =
+    if srcOverridep "libVersion" then srcs.libVersion
+    else versionsImport.${baseName}.libVersion.version;
+
+  wxGTK = wxGTK31-gtk3;
+  python = python3;
+  wxPython = python.pkgs.wxPython_4_1;
+
+  inherit (lib) concatStringsSep flatten optionalString optionals;
+in
+stdenv.mkDerivation rec {
+
+  # Common libraries, referenced during runtime, via the wrapper.
+  passthru.libraries = callPackages ./libraries.nix { inherit libSrc; };
+  base = callPackage ./base.nix {
+    inherit stable baseName;
+    inherit kicadSrc kicadVersion;
+    inherit wxGTK python wxPython;
+    inherit withOCC withNgspice withScripting withI18n withPCM;
+    inherit debug sanitizeAddress sanitizeThreads;
+  };
+
+  inherit pname;
+  version = if (stable) then kicadVersion else builtins.substring 0 10 src.src.rev;
+
+  src = base;
+  dontUnpack = true;
+  dontConfigure = true;
+  dontBuild = true;
+  dontFixup = true;
+
+  pythonPath = optionals (withScripting)
+    [ wxPython python.pkgs.six ];
+
+  nativeBuildInputs = [ makeWrapper ]
+    ++ optionals (withScripting)
+    [ python.pkgs.wrapPython ];
+
+  # We are emulating wrapGAppsHook, along with other variables to the
+  # wrapper
+  makeWrapperArgs = with passthru.libraries; [
+    "--prefix XDG_DATA_DIRS : ${base}/share"
+    "--prefix XDG_DATA_DIRS : ${hicolor-icon-theme}/share"
+    "--prefix XDG_DATA_DIRS : ${gnome.adwaita-icon-theme}/share"
+    "--prefix XDG_DATA_DIRS : ${wxGTK.gtk}/share/gsettings-schemas/${wxGTK.gtk.name}"
+    "--prefix XDG_DATA_DIRS : ${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}"
+    # wrapGAppsHook did these two as well, no idea if it matters...
+    "--prefix XDG_DATA_DIRS : ${cups}/share"
+    "--prefix GIO_EXTRA_MODULES : ${dconf}/lib/gio/modules"
+    # required to open a bug report link in firefox-wayland
+    "--set-default MOZ_DBUS_REMOTE 1"
+    "--set-default KICAD6_FOOTPRINT_DIR ${footprints}/share/kicad/footprints"
+    "--set-default KICAD6_SYMBOL_DIR ${symbols}/share/kicad/symbols"
+    "--set-default KICAD6_TEMPLATE_DIR ${templates}/share/kicad/template"
+    "--prefix KICAD6_TEMPLATE_DIR : ${symbols}/share/kicad/template"
+    "--prefix KICAD6_TEMPLATE_DIR : ${footprints}/share/kicad/template"
+  ]
+  ++ optionals (with3d)
+  [
+    "--set-default KICAD6_3DMODEL_DIR ${packages3d}/share/kicad/3dmodels"
+  ]
+  ++ optionals (withNgspice) [ "--prefix LD_LIBRARY_PATH : ${libngspice}/lib" ]
+
+  # infinisil's workaround for #39493
+  ++ [ "--set GDK_PIXBUF_MODULE_FILE ${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" ]
+  ;
+
+  # why does $makeWrapperArgs have to be added explicitly?
+  # $out and $program_PYTHONPATH don't exist when makeWrapperArgs gets set?
+  installPhase =
+    let
+      tools = [ "kicad" "pcbnew" "eeschema" "gerbview" "pcb_calculator" "pl_editor" "bitmap2component" ];
+      utils = [ "dxf2idf" "idf2vrml" "idfcyl" "idfrect" "kicad2step" ];
+    in
+    (concatStringsSep "\n"
+      (flatten [
+        "runHook preInstall"
+
+        (optionalString (withScripting) "buildPythonPath \"${base} $pythonPath\" \n")
+
+        # wrap each of the directly usable tools
+        (map
+          (tool: "makeWrapper ${base}/bin/${tool} $out/bin/${tool} $makeWrapperArgs"
+            + optionalString (withScripting) " --set PYTHONPATH \"$program_PYTHONPATH\""
+          )
+          tools)
+
+        # link in the CLI utils
+        (map (util: "ln -s ${base}/bin/${util} $out/bin/${util}") utils)
+
+        "runHook postInstall"
+      ])
+    )
+  ;
+
+  postInstall = ''
+    mkdir -p $out/share
+    ln -s ${base}/share/applications $out/share/applications
+    ln -s ${base}/share/icons $out/share/icons
+    ln -s ${base}/share/mime $out/share/mime
+    ln -s ${base}/share/metainfo $out/share/metainfo
+  '';
+
+  # can't run this for each pname
+  # stable and unstable are in the same versions.nix
+  # and kicad-small reuses stable
+  # with "all" it updates both, run it manually if you don't want that
+  # and can't git commit if this could be running in parallel with other scripts
+  passthru.updateScript = [ ./update.sh "all" ];
+
+  meta = rec {
+    description = (if (stable)
+    then "Open Source Electronics Design Automation suite"
+    else "Open Source EDA suite, development build")
+    + (if (!with3d) then ", without 3D models" else "");
+    homepage = "https://www.kicad.org/";
+    longDescription = ''
+      KiCad is an open source software suite for Electronic Design Automation.
+      The Programs handle Schematic Capture, and PCB Layout with Gerber output.
+    '';
+    license = lib.licenses.gpl3Plus;
+    maintainers = with lib.maintainers; [ evils kiwi ];
+    # kicad is cross platform
+    platforms = lib.platforms.all;
+    # despite that, nipkgs' wxGTK for darwin is "wxmac"
+    # and wxPython_4_0 does not account for this
+    # adjusting this package to downgrade to python2Packages.wxPython (wxPython 3),
+    # seems like more trouble than fixing wxPython_4_0 would be
+    # additionally, libngspice is marked as linux only, though it should support darwin
+
+    hydraPlatforms = if (with3d) then [ ] else platforms;
+    # We can't download the 3d models on Hydra,
+    # they are a ~1 GiB download and they occupy ~5 GiB in store.
+    # as long as the base and libraries (minus 3d) are build,
+    # this wrapper does not need to get built
+    # the kicad-*small "packages" cause this to happen
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/kicad/libraries.nix b/nixpkgs/pkgs/applications/science/electronics/kicad/libraries.nix
new file mode 100644
index 000000000000..9591cbc31c39
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/kicad/libraries.nix
@@ -0,0 +1,30 @@
+{ lib, stdenv
+, cmake
+, gettext
+, libSrc
+}:
+let
+  mkLib = name:
+    stdenv.mkDerivation {
+      pname = "kicad-${name}";
+      version = builtins.substring 0 10 (libSrc name).rev;
+
+      src = libSrc name;
+
+      nativeBuildInputs = [ cmake ];
+
+      meta = rec {
+        license = lib.licenses.cc-by-sa-40;
+        platforms = lib.platforms.all;
+        # the 3d models are a ~1 GiB download and occupy ~5 GiB in store.
+        # this would exceed the hydra output limit
+        hydraPlatforms = if (name == "packages3d") then [ ] else platforms;
+      };
+    };
+in
+{
+  symbols = mkLib "symbols";
+  templates = mkLib "templates";
+  footprints = mkLib "footprints";
+  packages3d = mkLib "packages3d";
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/kicad/update.sh b/nixpkgs/pkgs/applications/science/electronics/kicad/update.sh
new file mode 100755
index 000000000000..48270e962f53
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/kicad/update.sh
@@ -0,0 +1,189 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p coreutils git nix curl
+# shellcheck shell=bash enable=all
+
+set -e
+shopt -s inherit_errexit
+
+# this script will generate versions.nix in the right location
+# this should contain the versions' revs and hashes
+# the stable revs are stored only for ease of skipping
+
+# by default nix-prefetch-url uses XDG_RUNTIME_DIR as tmp
+# which is /run/user/1000, which defaults to 10% of your RAM
+# unless you have over 64GB of ram that'll be insufficient
+# resulting in "tar: no space left on device" for packages3d
+# hence:
+export TMPDIR=/tmp
+
+# if something goes unrepairably wrong, run 'update.sh all clean'
+
+# TODO
+# support parallel instances for each pname
+#   currently risks reusing old data
+# no getting around manually checking if the build product works...
+# if there is, default to commiting?
+#   won't work when running in parallel?
+# remove items left in /nix/store?
+
+# get the latest tag that isn't an RC or *.99
+latest_tags="$(git ls-remote --tags --sort -version:refname https://gitlab.com/kicad/code/kicad.git)"
+# using a scratch variable to ensure command failures get caught (SC2312)
+scratch="$(grep -o 'refs/tags/[0-9]*\.[0-9]*\.[0-9]*$' <<< "${latest_tags}")"
+scratch="$(grep -ve '\.99' -e '\.9\.9' <<< "${scratch}")"
+scratch="$(head -n 1 <<< "${scratch}")"
+latest_tag="$(cut -d '/' -f 3 <<< "${scratch}")"
+
+all_versions=( "${latest_tag}" master )
+
+prefetch="nix-prefetch-url --unpack --quiet"
+
+clean=""
+check_stable=""
+check_unstable=1
+commit=""
+
+for arg in "$@"; do
+  case "${arg}" in
+    help|-h|--help) echo "Read me!" >&2; exit 1; ;;
+    kicad|release|tag|stable|*small|5*|6*) check_stable=1; check_unstable="" ;;
+    all|both|full) check_stable=1; check_unstable=1 ;;
+    commit) commit=1 ;;
+    clean|fix|*fuck) check_stable=1; check_unstable=1; clean=1 ;;
+    master|*unstable|latest|now|today) check_unstable=1 ;;
+    *) ;;
+  esac
+done
+
+here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+now=$(date --iso-8601 --utc)
+
+file="${here}/versions.nix"
+# just in case this runs in parallel
+tmp="${here}/,versions.nix.${RANDOM}"
+
+libs=( symbols templates footprints packages3d )
+
+get_rev() {
+  git ls-remote --heads --tags "$@"
+}
+
+gitlab="https://gitlab.com/kicad"
+# append commit hash or tag
+src_pre="https://gitlab.com/api/v4/projects/kicad%2Fcode%2Fkicad/repository/archive.tar.gz?sha="
+lib_pre="https://gitlab.com/api/v4/projects/kicad%2Flibraries%2Fkicad-"
+lib_mid="/repository/archive.tar.gz?sha="
+
+count=0
+
+printf "Latest tag is\t%s\n" "${latest_tag}" >&2
+
+if [[ ! -f ${file} ]]; then
+  echo "No existing file, generating from scratch" >&2
+  check_stable=1; check_unstable=1; clean=1
+fi
+
+printf "Writing %s\n" "${tmp}" >&2
+
+# not a dangling brace, grouping the output to redirect to file
+{
+
+printf "# This file was generated by update.sh\n\n"
+printf "{\n"
+
+for version in "${all_versions[@]}"; do
+
+  if [[ ${version} == "master" ]]; then
+    pname="kicad-unstable"
+    today="${now}"
+  else
+    pname="kicad"
+    today="${version}"
+  fi
+  # skip a version if we don't want to check it
+  if [[ (${version} != "master" && -n ${check_stable}) \
+     || (${version} == "master" && -n ${check_unstable}) ]]; then
+
+    printf "\nChecking %s\n" "${pname}" >&2
+
+    printf "%2s\"%s\" = {\n" "" "${pname}"
+      printf "%4skicadVersion = {\n" ""
+        printf "%6sversion =\t\t\t\"%s\";\n" "" "${today}"
+        printf "%6ssrc = {\n" ""
+
+    echo "Checking src" >&2
+    scratch="$(get_rev "${gitlab}"/code/kicad.git "${version}")"
+    src_rev="$(cut -f1 <<< "${scratch}")"
+    has_rev="$(grep -sm 1 "\"${pname}\"" -A 4 "${file}" | grep -sm 1 "${src_rev}" || true)"
+    has_hash="$(grep -sm 1 "\"${pname}\"" -A 5 "${file}" | grep -sm 1 "sha256" || true)"
+
+    if [[ -n ${has_rev} && -n ${has_hash} && -z ${clean} ]]; then
+      echo "Reusing old ${pname}.src.sha256, already latest .rev" >&2
+      scratch=$(grep -sm 1 "\"${pname}\"" -A 5 "${file}")
+      grep -sm 1 "rev" -A 1 <<< "${scratch}"
+    else
+          prefetched="$(${prefetch} "${src_pre}${src_rev}")"
+          printf "%8srev =\t\t\t\"%s\";\n" "" "${src_rev}"
+          printf "%8ssha256 =\t\t\"%s\";\n" "" "${prefetched}"
+          count=$((count+1))
+    fi
+        printf "%6s};\n" ""
+      printf "%4s};\n" ""
+
+      printf "%4slibVersion = {\n" ""
+        printf "%6sversion =\t\t\t\"%s\";\n" "" "${today}"
+        printf "%6slibSources = {\n" ""
+
+          for lib in "${libs[@]}"; do
+            echo "Checking ${lib}" >&2
+            url="${gitlab}/libraries/kicad-${lib}.git"
+            scratch="$(get_rev "${url}" "${version}")"
+            scratch="$(cut -f1 <<< "${scratch}")"
+            lib_rev="$(tail -n1 <<< "${scratch}")"
+            has_rev="$(grep -sm 1 "\"${pname}\"" -A 19 "${file}" | grep -sm 1 "${lib_rev}" || true)"
+            has_hash="$(grep -sm 1 "\"${pname}\"" -A 20 "${file}" | grep -sm 1 "${lib}.sha256" || true)"
+            if [[ -n ${has_rev} && -n ${has_hash} && -z ${clean} ]]; then
+              echo "Reusing old kicad-${lib}-${today}.src.sha256, already latest .rev" >&2
+              scratch="$(grep -sm 1 "\"${pname}\"" -A 20 "${file}")"
+              grep -sm 1 "${lib}" -A 1 <<< "${scratch}"
+            else
+              prefetched="$(${prefetch} "${lib_pre}${lib}${lib_mid}${lib_rev}")"
+              printf "%8s%s.rev =\t" "" "${lib}"
+              case "${lib}" in
+                symbols|templates) printf "\t" ;; *) ;;
+              esac
+              printf "\"%s\";\n" "${lib_rev}"
+              printf "%8s%s.sha256 =\t\"%s\";\n" "" "${lib}" "${prefetched}"
+              count=$((count+1))
+            fi
+          done
+        printf "%6s};\n" ""
+      printf "%4s};\n" ""
+    printf "%2s};\n" ""
+  else
+    printf "\nReusing old %s\n" "${pname}" >&2
+    grep -sm 1 "\"${pname}\"" -A 21 "${file}"
+  fi
+done
+printf "}\n"
+} > "${tmp}"
+
+if grep '""' "${tmp}"; then
+  echo "empty value detected, out of space?" >&2
+  exit "1"
+fi
+
+mv "${tmp}" "${file}"
+
+printf "\nFinished\nMoved output to %s\n\n" "${file}" >&2
+
+if [[ ${count} -gt 0 ]]; then
+  if [[ ${count} -gt 1 ]]; then s="s"; else s=""; fi
+  echo "${count} revision${s} changed" >&2
+  if [[ -n ${commit} ]]; then
+    git commit -am "$(printf "kicad: automatic update of %s item%s\n" "${count}" "${s}")"
+  fi
+  echo "Please confirm the new versions.nix works before making a PR." >&2
+else
+  echo "No changes, those checked are up to date" >&2
+fi
diff --git a/nixpkgs/pkgs/applications/science/electronics/kicad/versions.nix b/nixpkgs/pkgs/applications/science/electronics/kicad/versions.nix
new file mode 100644
index 000000000000..364321afbf71
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/kicad/versions.nix
@@ -0,0 +1,48 @@
+# This file was generated by update.sh
+
+{
+  "kicad" = {
+    kicadVersion = {
+      version =			"6.0.2";
+      src = {
+        rev =			"378541a8ebe8a691b61c8ed1b4012c71343acfbb";
+        sha256 =		"1lcl25zkqkyj5rvw9rad3n7bklpg10kmhmhkyyrgg8ql7di6wa0f";
+      };
+    };
+    libVersion = {
+      version =			"6.0.2";
+      libSources = {
+        symbols.rev =		"80a176076a8f3785a4cd64e55ec87f27f6fcc163";
+        symbols.sha256 =	"1f57wv5b95iqd64k8ab82fvxnh5q890v7bzclmn019gl6ikisxj5";
+        templates.rev =		"c9a51b852eacc3e64639548032b50edd80ddb27c";
+        templates.sha256 =	"13h9ly6amiwm7zkwa2fd9730kh295ls8j95fszlfjp9rczv2yyzm";
+        footprints.rev =	"c81b399054b0d3842094d7e8dfe08eb04310573a";
+        footprints.sha256 =	"1xmnq2731v2afan1d08xb1qqgl5xd01v5jphi6cdmw28ri555cna";
+        packages3d.rev =	"75175a21b720c59a26efce9a8c6dba3d032392a9";
+        packages3d.sha256 =	"10zf8hp85ksi84cbiczsksn0ygvri4ffsa126v73nnkx6irw6nkk";
+      };
+    };
+  };
+  "kicad-unstable" = {
+    kicadVersion = {
+      version =			"2022-01-13";
+      src = {
+        rev =			"33a4c9b08e040a17daefae9069fdf834063555b4";
+        sha256 =		"1ma0i0vgvdsjrmlfzdi34byly7n1vsaynwp9f1hny4s1m53nirha";
+      };
+    };
+    libVersion = {
+      version =			"2022-01-13";
+      libSources = {
+        symbols.rev =		"e3b198d827817b79fb8a6df07f0cfc1cb9140edf";
+        symbols.sha256 =	"1azjx1bmxaz8bniyw75lq60mc8hvay00jn9qdc2zp7isy3c9ibp0";
+        templates.rev =		"a27d83f0a20f0be0c1ab04b139a0c518da51a5d4";
+        templates.sha256 =	"13h9ly6amiwm7zkwa2fd9730kh295ls8j95fszlfjp9rczv2yyzm";
+        footprints.rev =	"a939c691f1c515d6830e54cf035a420de3e5a92c";
+        footprints.sha256 =	"13g6y1l95znz6ixc4dpqsxp3icrzs951xpabnzr5znw42577gm9j";
+        packages3d.rev =	"196a26294d8e501b0e8b06c1df1abae0ebe23051";
+        packages3d.sha256 =	"0ywlk00dfwv7hc494finmazdh3g1yx0ir7bvnd8zp6cq4ql0nwl4";
+      };
+    };
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/lepton-eda/default.nix b/nixpkgs/pkgs/applications/science/electronics/lepton-eda/default.nix
new file mode 100644
index 000000000000..8d4217d0aba3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/lepton-eda/default.nix
@@ -0,0 +1,61 @@
+{ stdenv
+, lib
+, pkg-config
+, makeWrapper
+, texinfo
+, fetchurl
+, autoreconfHook
+, guile
+, flex
+, gtk2
+, glib
+, gtkextra
+, gettext
+, gawk
+, shared-mime-info
+, groff
+, libstroke
+}:
+
+stdenv.mkDerivation rec {
+  pname = "lepton-eda";
+  version = "1.9.17-20211219";
+
+  src = fetchurl {
+    url = "https://github.com/lepton-eda/lepton-eda/releases/download/${version}/lepton-eda-${builtins.head (lib.splitString "-" version)}.tar.gz";
+    sha256 = "sha256-lOneKeJUcw6jOX/3iv9BDWOJ3xip/vGhzxHHNAbtsS8=";
+  };
+
+  nativeBuildInputs = [ pkg-config makeWrapper texinfo autoreconfHook ];
+
+  propagatedBuildInputs = [ guile flex gtk2 glib gtkextra gettext gawk shared-mime-info groff libstroke ];
+
+  configureFlags = [
+    "--disable-update-xdg-database"
+  ];
+
+  CFLAGS = [
+    "-DSCM_DEBUG_TYPING_STRICTNESS=2"
+  ];
+
+  postInstall = ''
+    libs="${lib.makeLibraryPath propagatedBuildInputs}"
+    for program in $out/bin/*; do
+      wrapProgram "$program" \
+        --prefix LD_LIBRARY_PATH : "$libs" \
+        --prefix LTDL_LIBRARY_PATH : "$out/lib"
+    done
+  '';
+
+  meta = with lib; {
+    homepage = "https://github.com/lepton-eda";
+    description = "Lepton Electronic Design Automation";
+    longDescription = ''
+      Lepton EDA is a suite of free software tools for designing electronics.
+      It provides schematic capture, netlisting into over 30 netlist formats, and many other features.
+    '';
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ tesq0 ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/librepcb/default.nix b/nixpkgs/pkgs/applications/science/electronics/librepcb/default.nix
new file mode 100644
index 000000000000..15b64938b256
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/librepcb/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, lib, fetchFromGitHub
+, qtbase, qttools, cmake, wrapQtAppsHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "librepcb";
+  version = "0.1.6";
+
+  src = fetchFromGitHub {
+    owner  = pname;
+    repo   = pname;
+    rev    = version;
+    sha256 = "0gzf3asdgdicpikb412134ybqnbbark948yrfhvba2w4i9cwbk2r";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [ cmake qttools wrapQtAppsHook ];
+  buildInputs = [ qtbase ];
+
+  meta = with lib; {
+    description = "A free EDA software to develop printed circuit boards";
+    homepage    = "https://librepcb.org/";
+    maintainers = with maintainers; [ luz thoughtpolice ];
+    license     = licenses.gpl3Plus;
+    platforms   = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/magic-vlsi/0001-strip-bin-prefix.patch b/nixpkgs/pkgs/applications/science/electronics/magic-vlsi/0001-strip-bin-prefix.patch
new file mode 100644
index 000000000000..1cef96ea1408
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/magic-vlsi/0001-strip-bin-prefix.patch
@@ -0,0 +1,10 @@
+diff --git a/scripts/makedbh b/scripts/makedbh
+index 01e4fa5..d6299c6 100755
+--- a/scripts/makedbh
++++ b/scripts/makedbh
+@@ -1,4 +1,4 @@
+-#!/bin/csh -f
++#!/usr/bin/env tcsh
+ #
+ # makes the "database.h" (1st argument, $1) file from "database.h.in"
+ # (2nd argument, $2), setting various mask operation definitions
diff --git a/nixpkgs/pkgs/applications/science/electronics/magic-vlsi/0002-fix-format-security.patch b/nixpkgs/pkgs/applications/science/electronics/magic-vlsi/0002-fix-format-security.patch
new file mode 100644
index 000000000000..37ae35195503
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/magic-vlsi/0002-fix-format-security.patch
@@ -0,0 +1,19 @@
+diff --git a/database/DBio.c b/database/DBio.c
+index 93c4b0b..292ea5f 100644
+--- a/database/DBio.c
++++ b/database/DBio.c
+@@ -2378,12 +2378,12 @@ DBCellWriteFile(cellDef, f)
+ 
+ #define FPRINTF(f,s)\
+ {\
+-     if (fprintf(f,s) == EOF) goto ioerror;\
++     if (fprintf(f,"%s",s) == EOF) goto ioerror;\
+      DBFileOffset += strlen(s);\
+ }
+ #define FPRINTR(f,s)\
+ {\
+-     if (fprintf(f,s) == EOF) return 1;\
++     if (fprintf(f,"%s",s) == EOF) return 1;\
+      DBFileOffset += strlen(s);\
+ }
+ 
diff --git a/nixpkgs/pkgs/applications/science/electronics/magic-vlsi/default.nix b/nixpkgs/pkgs/applications/science/electronics/magic-vlsi/default.nix
new file mode 100644
index 000000000000..82d8dbd2ddc4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/magic-vlsi/default.nix
@@ -0,0 +1,60 @@
+{ lib, stdenv
+, fetchurl
+, python3
+, m4
+, cairo
+, libX11
+, mesa_glu
+, ncurses
+, tcl
+, tcsh
+, tk
+}:
+
+stdenv.mkDerivation rec {
+  pname = "magic-vlsi";
+  version = "8.3.109";
+
+  src = fetchurl {
+    url    = "http://opencircuitdesign.com/magic/archive/magic-${version}.tgz";
+    sha256 = "sha256-ZK4OF5XwjW1OJmOVUFqLklfpM10eIwCILygqIyjRbEQ=";
+  };
+
+  nativeBuildInputs = [ python3 ];
+  buildInputs = [
+    cairo
+    libX11
+    m4
+    mesa_glu
+    ncurses
+    tcl
+    tcsh
+    tk
+  ];
+
+  enableParallelBuilding = true;
+
+  configureFlags = [
+    "--with-tcl=${tcl}"
+    "--with-tk=${tk}"
+    "--disable-werror"
+  ];
+
+  postPatch = ''
+    patchShebangs scripts/*
+  '';
+
+  NIX_CFLAGS_COMPILE = "-Wno-implicit-function-declaration";
+
+  patches = [
+    ./0001-strip-bin-prefix.patch
+    ./0002-fix-format-security.patch
+  ];
+
+  meta = with lib; {
+    description = "VLSI layout tool written in Tcl";
+    homepage    = "http://opencircuitdesign.com/magic/";
+    license     = licenses.mit;
+    maintainers = with maintainers; [ anna328p thoughtpolice AndersonTorres ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/nanovna-saver/default.nix b/nixpkgs/pkgs/applications/science/electronics/nanovna-saver/default.nix
new file mode 100644
index 000000000000..af78fc71ebf3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/nanovna-saver/default.nix
@@ -0,0 +1,65 @@
+{ lib
+, python3
+, fetchFromGitHub
+, wrapQtAppsHook
+}:
+
+let
+  python = python3.override {
+    packageOverrides = self: super: {
+      scipy = super.scipy.overridePythonAttrs (oldAttrs: rec {
+        version = "1.4.1";
+        src = oldAttrs.src.override {
+          inherit version;
+          sha256 = "0ndw7zyxd2dj37775mc75zm4fcyiipnqxclc45mkpxy8lvrvpqfy";
+        };
+        doCheck = false;
+      });
+    };
+  };
+in python.pkgs.buildPythonApplication rec {
+  pname = "nanovna-saver";
+  version = "0.3.8";
+
+  src = fetchFromGitHub {
+    owner = "NanoVNA-Saver";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "0z83rwpnbbs1n74mx8dgh1d1crp90mannj9vfy161dmy4wzc5kpv";
+  };
+
+  nativeBuildInputs = [ wrapQtAppsHook ];
+
+  propagatedBuildInputs = with python.pkgs; [
+    cython
+    scipy
+    pyqt5
+    pyserial
+    numpy
+  ];
+
+  doCheck = false;
+
+  dontWrapGApps = true;
+  dontWrapQtApps = true;
+
+  preFixup = ''
+    makeWrapperArgs+=(
+      "''${gappsWrapperArgs[@]}"
+      "''${qtWrapperArgs[@]}"
+    )
+  '';
+
+  meta = with lib; {
+    homepage = "https://github.com/NanoVNA-Saver/nanovna-saver";
+    description =
+      "A tool for reading, displaying and saving data from the NanoVNA";
+    longDescription = ''
+      A multiplatform tool to save Touchstone files from the NanoVNA, sweep
+      frequency spans in segments to gain more than 101 data points, and
+      generally display and analyze the resulting data.
+    '';
+    license = licenses.gpl3Only;
+    maintainers = with maintainers; [ zaninime ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/ngspice/default.nix b/nixpkgs/pkgs/applications/science/electronics/ngspice/default.nix
new file mode 100644
index 000000000000..0eed8b1692aa
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/ngspice/default.nix
@@ -0,0 +1,36 @@
+{ lib, stdenv
+, fetchurl
+, bison
+, flex
+, readline
+, libX11
+, libICE
+, libXaw
+, libXmu
+, libXext
+, libXt
+, fftw
+}:
+
+stdenv.mkDerivation rec {
+  pname = "ngspice";
+  version = "34";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/ngspice/ngspice-${version}.tar.gz";
+    sha256 = "sha256-ImP//GaUdUlyr3By7wHP5irHkIANrWUbwpC/yueb17U=";
+  };
+
+  nativeBuildInputs = [ flex bison ];
+  buildInputs = [ readline libX11 libICE libXaw libXmu libXext libXt fftw ];
+
+  configureFlags = [ "--enable-x" "--with-x" "--with-readline" "--enable-xspice" "--enable-cider" ];
+
+  meta = with lib; {
+    description = "The Next Generation Spice (Electronic Circuit Simulator)";
+    homepage = "http://ngspice.sourceforge.net";
+    license = with licenses; [ "BSD" gpl2 ];
+    maintainers = with maintainers; [ bgamari rongcuid ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/openems/default.nix b/nixpkgs/pkgs/applications/science/electronics/openems/default.nix
new file mode 100644
index 000000000000..e7b947450acc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/openems/default.nix
@@ -0,0 +1,70 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, csxcad
+, fparser
+, tinyxml
+, hdf5
+, vtk
+, boost
+, zlib
+, cmake
+, octave
+, gl2ps
+, mpi
+, withQcsxcad ? true
+, withMPI ? false
+, withHyp2mat ? true
+, qcsxcad
+, hyp2mat
+}:
+
+stdenv.mkDerivation {
+  pname = "openems";
+  version = "unstable-2020-02-15";
+
+  src = fetchFromGitHub {
+    owner = "thliebig";
+    repo = "openEMS";
+    rev = "ba793ac84e2f78f254d6d690bb5a4c626326bbfd";
+    sha256 = "1dca6b6ccy771irxzsj075zvpa3dlzv4mjb8xyg9d889dqlgyl45";
+  };
+
+  nativeBuildInputs = [
+    cmake
+  ];
+
+  cmakeFlags = lib.optionals withMPI [ "-DWITH_MPI=ON" ];
+
+  buildInputs = [
+    fparser
+    tinyxml
+    hdf5
+    vtk
+    boost
+    zlib
+    csxcad
+    (octave.override { inherit hdf5; }) ]
+    ++ lib.optionals withQcsxcad [ qcsxcad ]
+    ++ lib.optionals withMPI [ mpi ]
+    ++ lib.optionals withHyp2mat [ hyp2mat ];
+
+  postFixup = ''
+    substituteInPlace $out/share/openEMS/matlab/setup.m \
+      --replace /usr/lib ${hdf5}/lib \
+      --replace /usr/include ${hdf5}/include
+
+    ${octave}/bin/mkoctfile -L${hdf5}/lib -I${hdf5}/include \
+      -lhdf5 $out/share/openEMS/matlab/h5readatt_octave.cc \
+      -o $out/share/openEMS/matlab/h5readatt_octave.oct
+  '';
+
+  meta = with lib; {
+    description = "Open Source Electromagnetic Field Solver";
+    homepage = "http://openems.de/index.php/Main_Page.html";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ matthuszagh ];
+    platforms = platforms.linux;
+    badPlatforms = platforms.aarch64;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/openhantek6022/default.nix b/nixpkgs/pkgs/applications/science/electronics/openhantek6022/default.nix
new file mode 100644
index 000000000000..09d36094e7c9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/openhantek6022/default.nix
@@ -0,0 +1,31 @@
+{ mkDerivation, lib, fetchFromGitHub, makeWrapper, cmake, qtbase, qttools, fftw, libusb1, libglvnd }:
+
+mkDerivation rec {
+  pname = "openhantek6022";
+  version = "3.2.5";
+
+  src = fetchFromGitHub {
+    owner = "OpenHantek";
+    repo = "OpenHantek6022";
+    rev = version;
+    sha256 = "sha256-QwJmbABAax4yCbcRONArtj5EUKO1gh3pVoLi2hF/WJI=";
+  };
+
+  nativeBuildInputs = [ cmake makeWrapper ];
+  buildInputs = [ fftw libusb1 libglvnd qtbase qttools ];
+
+  postPatch = ''
+    # Fix up install paths & checks
+    sed -i 's#if(EXISTS ".*")#if(1)#g' CMakeLists.txt
+    sed -i 's#/lib/udev#lib/udev#g' CMakeLists.txt
+    sed -i 's#/usr/share#share#g' CMakeLists.txt
+  '';
+
+  meta = with lib; {
+    description = "Free software for Hantek and compatible (Voltcraft/Darkwire/Protek/Acetech) USB digital signal oscilloscopes";
+    homepage = "https://github.com/OpenHantek/OpenHantek6022";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ baracoder ];
+    platforms = qtbase.meta.platforms;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/openroad/default.nix b/nixpkgs/pkgs/applications/science/electronics/openroad/default.nix
new file mode 100644
index 000000000000..1b1eb39cffa0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/openroad/default.nix
@@ -0,0 +1,94 @@
+{ lib
+, mkDerivation
+, fetchFromGitHub
+, bison
+, cmake
+, doxygen
+, flex
+, git
+, python3
+, swig4
+, boost172
+, cimg
+, eigen
+, lcov
+, lemon-graph
+, libjpeg
+, pcre
+, qtbase
+, readline
+, spdlog
+, tcl
+, tcllib
+, xorg
+, yosys
+, zlib
+}:
+
+mkDerivation rec {
+  pname = "openroad";
+  version = "2.0";
+
+  src = fetchFromGitHub {
+    owner = "The-OpenROAD-Project";
+    repo = "OpenROAD";
+    rev = "v${version}";
+    fetchSubmodules = true;
+    sha256 = "1p677xh16wskfj06jnplhpc3glibhdaqxmk0j09832chqlryzwyx";
+  };
+
+  nativeBuildInputs = [
+    bison
+    cmake
+    doxygen
+    flex
+    git
+    swig4
+  ];
+
+  buildInputs = [
+    boost172
+    cimg
+    eigen
+    lcov
+    lemon-graph
+    libjpeg
+    pcre
+    python3
+    qtbase
+    readline
+    spdlog
+    tcl
+    tcllib
+    yosys
+    xorg.libX11
+    zlib
+  ];
+
+  postPatch = ''
+    patchShebangs --build etc/find_messages.py
+  '';
+
+  # Enable output images from the placer.
+  cmakeFlags = [ "-DUSE_CIMG_LIB=ON" ];
+
+  # Resynthesis needs access to the Yosys binaries.
+  qtWrapperArgs = [ "--prefix PATH : ${lib.makeBinPath [ yosys ]}" ];
+
+  # Upstream uses vendored package versions for some dependencies, so regression testing is prudent
+  # to see if there are any breaking changes in unstable that should be vendored as well.
+  doCheck = false; # Disabled pending upstream release with fix for rcx log file creation.
+  checkPhase = ''
+    # Regression tests must be run from the project root not from within the CMake build directory.
+    cd ..
+    test/regression
+  '';
+
+  meta = with lib; {
+    description = "OpenROAD's unified application implementing an RTL-to-GDS flow";
+    homepage = "https://theopenroadproject.org";
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ trepetti ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/pcb/default.nix b/nixpkgs/pkgs/applications/science/electronics/pcb/default.nix
new file mode 100644
index 000000000000..d28f1d181215
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/pcb/default.nix
@@ -0,0 +1,65 @@
+{ lib, stdenv
+, fetchurl
+, pkg-config
+, gtk2
+, bison
+, intltool
+, flex
+, netpbm
+, imagemagick
+, dbus
+, xlibsWrapper
+, libGLU
+, libGL
+, shared-mime-info
+, tcl
+, tk
+, gnome2
+, gd
+, xorg
+}:
+
+stdenv.mkDerivation rec {
+  pname = "pcb";
+  version = "4.3.0";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/pcb/${pname}-${version}.tar.gz";
+    sha256 = "sha256-roUvRq+Eq6f1HYE/uRb8f82+6kP3E08VBQcCThdD+14=";
+  };
+
+  nativeBuildInputs = [
+    pkg-config
+    bison
+    intltool
+    flex
+    netpbm
+    imagemagick
+  ];
+
+  buildInputs = [
+    gtk2
+    dbus
+    xlibsWrapper
+    libGLU
+    libGL
+    tcl
+    shared-mime-info
+    tk
+    gnome2.gtkglext
+    gd
+    xorg.libXmu
+  ];
+
+  configureFlags = [
+    "--disable-update-desktop-database"
+  ];
+
+  meta = with lib; {
+    description = "Printed Circuit Board editor";
+    homepage = "http://pcb.geda-project.org/";
+    maintainers = with maintainers; [ mog ];
+    platforms = platforms.linux;
+    license = licenses.gpl2;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/picoscope/default.nix b/nixpkgs/pkgs/applications/science/electronics/picoscope/default.nix
new file mode 100644
index 000000000000..83c8e2c6dd33
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/picoscope/default.nix
@@ -0,0 +1,137 @@
+{ stdenv, lib, fetchurl, dpkg, makeWrapper , mono, gtk-sharp-3_0
+, glib, libusb1 , zlib, gtk3-x11, callPackage
+, scopes ? [
+  "picocv"
+  "ps2000"
+  "ps2000a"
+  "ps3000"
+  "ps3000a"
+  "ps4000"
+  "ps4000a"
+  "ps5000"
+  "ps5000a"
+  "ps6000"
+  "ps6000a"
+] }:
+
+let
+  shared_meta = lib:
+    with lib; {
+      homepage = "https://www.picotech.com/downloads/linux";
+      maintainers = with maintainers; [ expipiplus1 yorickvp wirew0rm ];
+      platforms = [ "x86_64-linux" ];
+      license = licenses.unfree;
+    };
+
+  libpicoipp = callPackage ({ stdenv, lib, fetchurl, autoPatchelfHook, dpkg }:
+    stdenv.mkDerivation rec {
+      pname = "libpicoipp";
+      inherit (sources.libpicoipp) version;
+      src = fetchurl { inherit (sources.libpicoipp) url sha256; };
+      nativeBuildInputs = [ dpkg autoPatchelfHook ];
+      buildInputs = [ stdenv.cc.cc.lib ];
+      sourceRoot = ".";
+      unpackCmd = "dpkg-deb -x $src .";
+      installPhase = ''
+        runHook preInstall
+        mkdir -p $out/lib
+        cp -d opt/picoscope/lib/* $out/lib
+        install -Dt $out/usr/share/doc/libpicoipp usr/share/doc/libpicoipp/copyright
+        runHook postInstall
+      '';
+      meta = with lib;
+        shared_meta lib // {
+          description = "library for picotech oscilloscope software";
+        };
+    }) { };
+
+  # If we don't have a platform available, put a dummy version here, so at
+  # least evaluation succeeds.
+  sources =
+    (lib.importJSON ./sources.json).${stdenv.system} or { picoscope.version = "unknown"; };
+
+  scopePkg = name:
+    { url, version, sha256 }:
+    stdenv.mkDerivation rec {
+      pname = "lib${name}";
+      inherit version;
+      src = fetchurl { inherit url sha256; };
+      # picoscope does a signature check, so we can't patchelf these
+      nativeBuildInputs = [ dpkg ];
+      sourceRoot = ".";
+      unpackCmd = "dpkg-deb -x $src .";
+      installPhase = ''
+        runHook preInstall
+        mkdir -p $out/lib
+        cp -d opt/picoscope/lib/* $out/lib
+         runHook postInstall
+      '';
+      meta = with lib;
+        shared_meta lib // {
+          description = "library for picotech oscilloscope ${name} series";
+        };
+    };
+
+  scopePkgs = lib.mapAttrs scopePkg sources;
+
+in stdenv.mkDerivation rec {
+  pname = "picoscope";
+  inherit (sources.picoscope) version;
+
+  src = fetchurl { inherit (sources.picoscope) url sha256; };
+
+  nativeBuildInputs = [ dpkg makeWrapper ];
+  buildInputs = [ gtk-sharp-3_0 mono glib libusb1 zlib ];
+
+  unpackCmd = "dpkg-deb -x $src .";
+  sourceRoot = ".";
+  scopeLibs = lib.attrVals (map (x: "lib${x}") scopes) scopePkgs;
+  MONO_PATH = "${gtk-sharp-3_0}/lib/mono/gtk-sharp-3.0:" + (lib.makeLibraryPath
+    ([
+      glib
+      gtk3-x11
+      gtk-sharp-3_0
+      libusb1
+      zlib
+      libpicoipp
+    ] ++ scopeLibs));
+
+  installPhase = ''
+    runHook preInstall
+    mkdir -p $out/
+    cp -dr usr/share $out/share
+    cp -dr opt/picoscope/* $out/
+    makeWrapper "$(command -v mono)" $out/bin/picoscope \
+      --add-flags $out/lib/PicoScope.GTK.exe \
+      --prefix MONO_PATH : "$MONO_PATH" \
+      --prefix LD_LIBRARY_PATH : "$MONO_PATH" \
+      --set LANG C
+    runHook postInstall
+  '';
+
+  # usage:
+  # services.udev.packages = [ pkgs.picoscope.rules ];
+  # users.groups.pico = {};
+  # users.users.you.extraGroups = [ "pico" ];
+  passthru.rules = lib.writeTextDir "lib/udev/rules.d/95-pico.rules" ''
+    SUBSYSTEMS=="usb", ATTRS{idVendor}=="0ce9", MODE="664",GROUP="pico"
+  '';
+
+  meta = with lib;
+    shared_meta lib // {
+      description =
+        "Oscilloscope application that works with all PicoScope models";
+      longDescription = ''
+        PicoScope for Linux is a powerful oscilloscope application that works
+        with all PicoScope models. The most important features from PicoScope
+        for Windows are included—scope, spectrum analyzer, advanced triggers,
+        automated measurements, interactive zoom, persistence modes and signal
+        generator control. More features are being added all the time.
+
+        Waveform captures can be saved for off-line analysis, and shared with
+        PicoScope for Linux, PicoScope for macOS and PicoScope for Windows
+        users, or exported in text, CSV and MathWorks MATLAB 4 formats.
+      '';
+    };
+}
+
diff --git a/nixpkgs/pkgs/applications/science/electronics/picoscope/sources.json b/nixpkgs/pkgs/applications/science/electronics/picoscope/sources.json
new file mode 100644
index 000000000000..aca5f8f4a0f2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/picoscope/sources.json
@@ -0,0 +1,69 @@
+{
+  "x86_64-linux": {
+    "libpicocv": {
+      "sha256": "c2e74c2b0679df0226993d063b38d0eda5b05ff59f29bbfa12ded5226df37024",
+      "url": "https://labs.picotech.com/rc/picoscope7/debian/pool/main/libp/libpicocv/libpicocv_1.1.27-1r153_amd64.deb",
+      "version": "1.1.27-1r153"
+    },
+    "libpicoipp": {
+      "sha256": "0e414ad547f506a39ff11a64772baec923e54f8ca98b81fc9b9cbd19ed573b22",
+      "url": "https://labs.picotech.com/rc/picoscope7/debian/pool/main/libp/libpicoipp/libpicoipp_1.3.0-4r130_amd64.deb",
+      "version": "1.3.0-4r130"
+    },
+    "libps2000": {
+      "sha256": "d1e94148719a03b70f233cea9a686ed48be03224f2931c9cd282571819a780c7",
+      "url": "https://labs.picotech.com/rc/picoscope7/debian/pool/main/libp/libps2000/libps2000_3.0.76-3r2981_amd64.deb",
+      "version": "3.0.76-3r2981"
+    },
+    "libps2000a": {
+      "sha256": "c665b70c04203c98bb1b509830ec522f58906b2f393f35c1b4f9c27217ac3572",
+      "url": "https://labs.picotech.com/rc/picoscope7/debian/pool/main/libp/libps2000a/libps2000a_2.1.76-5r2981_amd64.deb",
+      "version": "2.1.76-5r2981"
+    },
+    "libps3000": {
+      "sha256": "dbb9f9afdc694c4451e652f22a4c4c67ef609407f45229d26330ce7cfbb02b1c",
+      "url": "https://labs.picotech.com/rc/picoscope7/debian/pool/main/libp/libps3000/libps3000_4.0.76-3r2981_amd64.deb",
+      "version": "4.0.76-3r2981"
+    },
+    "libps3000a": {
+      "sha256": "5ab3daadc5d804b224215d138ca94abecc3c311bb91624638e2758ac2a490d25",
+      "url": "https://labs.picotech.com/rc/picoscope7/debian/pool/main/libp/libps3000a/libps3000a_2.1.76-6r2981_amd64.deb",
+      "version": "2.1.76-6r2981"
+    },
+    "libps4000": {
+      "sha256": "13504936207f1a7410f726c93358bb21c0c0cd1bd8b473332308a345ff6692c7",
+      "url": "https://labs.picotech.com/rc/picoscope7/debian/pool/main/libp/libps4000/libps4000_2.1.76-2r2981_amd64.deb",
+      "version": "2.1.76-2r2981"
+    },
+    "libps4000a": {
+      "sha256": "196ccce96e8cf29f5168cda83748857172ae43dc2b990adbacb3327511784492",
+      "url": "https://labs.picotech.com/rc/picoscope7/debian/pool/main/libp/libps4000a/libps4000a_2.1.76-2r2981_amd64.deb",
+      "version": "2.1.76-2r2981"
+    },
+    "libps5000": {
+      "sha256": "1793180d4067df12080ba7b01cbdf38397c2931a7f4915f13dbdb9295cc77cb3",
+      "url": "https://labs.picotech.com/rc/picoscope7/debian/pool/main/libp/libps5000/libps5000_2.1.76-3r2981_amd64.deb",
+      "version": "2.1.76-3r2981"
+    },
+    "libps5000a": {
+      "sha256": "b08a73f43bdcfa2bc02d01f398147da9b8cf2599477144b5a2b2af924d0bf0e9",
+      "url": "https://labs.picotech.com/rc/picoscope7/debian/pool/main/libp/libps5000a/libps5000a_2.1.76-5r2981_amd64.deb",
+      "version": "2.1.76-5r2981"
+    },
+    "libps6000": {
+      "sha256": "dda0fcb8b346f77a715053b52ad9e26b323991f8336001de7ff1bb6d04c716b4",
+      "url": "https://labs.picotech.com/rc/picoscope7/debian/pool/main/libp/libps6000/libps6000_2.1.76-6r2981_amd64.deb",
+      "version": "2.1.76-6r2981"
+    },
+    "libps6000a": {
+      "sha256": "786e5772055500e2e445ddfd5402fed359a9afa54177bd731912d24522729004",
+      "url": "https://labs.picotech.com/rc/picoscope7/debian/pool/main/libp/libps6000a/libps6000a_1.0.76-0r2981_amd64.deb",
+      "version": "1.0.76-0r2981"
+    },
+    "picoscope": {
+      "sha256": "12afae7992b9d60c93e5e39c7fe3f93955be3bdff554b52894064d5f320347f4",
+      "url": "https://labs.picotech.com/rc/picoscope7/debian/pool/main/p/picoscope/picoscope_7.0.86-1r9656_amd64.deb",
+      "version": "7.0.86-1r9656"
+    }
+  }
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/picoscope/update.py b/nixpkgs/pkgs/applications/science/electronics/picoscope/update.py
new file mode 100755
index 000000000000..ecbd2292030d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/picoscope/update.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env nix-shell
+#!nix-shell --pure -i python3 -p "python3.withPackages (ps: with ps; [ requests ])"
+import json
+import os
+import requests
+import sys
+
+def parse_packages(text):
+    res = []
+    for package in resp.text.split("\n\n"):
+        if not package: continue
+        pkg = {}
+        for field in package.split("\n"):
+            if field.startswith(" "): # multiline string
+                pkg[k] += "\n" + field[1:]
+            else:
+                [k, v] = field.split(": ", 1)
+                pkg[k] = v
+        res.append(pkg)
+    return res
+
+def generate_sources(packages):
+    sources_spec = {}
+    for pkg in pkgs:
+        sources_spec[pkg['Package']] = {
+            "url": "https://labs.picotech.com/rc/picoscope7/debian/" + pkg["Filename"],
+            "sha256": pkg["SHA256"],
+            "version": pkg["Version"]
+        }
+    return sources_spec
+
+out = {}
+for nix_system, release in {"x86_64-linux": "amd64"}.items():
+    resp = requests.get("https://labs.picotech.com/rc/picoscope7/debian//dists/picoscope/main/binary-"+release+"/Packages")
+    if resp.status_code != 200:
+        print("error: could not fetch data for release {} (code {})".format(release, resp.code), file=sys.stderr)
+        sys.exit(1)
+    pkgs = parse_packages(resp.text)
+    out[nix_system] = generate_sources(pkgs)
+
+with open(os.path.dirname(__file__) + "/sources.json", "w") as f:
+    json.dump(out, f, indent=2, sort_keys=True)
+    f.write('\n')
+
diff --git a/nixpkgs/pkgs/applications/science/electronics/pulseview/default.nix b/nixpkgs/pkgs/applications/science/electronics/pulseview/default.nix
new file mode 100644
index 000000000000..e9496ce60c22
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/pulseview/default.nix
@@ -0,0 +1,39 @@
+{ mkDerivation, lib, fetchurl, fetchpatch, pkg-config, cmake, glib, boost, libsigrok
+, libsigrokdecode, libserialport, libzip, udev, libusb1, libftdi1, glibmm
+, pcre, librevisa, python3, qtbase, qtsvg
+}:
+
+mkDerivation rec {
+  pname = "pulseview";
+  version = "0.4.1";
+
+  src = fetchurl {
+    url = "https://sigrok.org/download/source/pulseview/${pname}-${version}.tar.gz";
+    sha256 = "0bvgmkgz37n2bi9niskpl05hf7rsj1lj972fbrgnlz25s4ywxrwy";
+  };
+
+  nativeBuildInputs = [ cmake pkg-config ];
+
+  buildInputs = [
+    glib boost libsigrok libsigrokdecode libserialport libzip udev libusb1 libftdi1 glibmm
+    pcre librevisa python3
+    qtbase qtsvg
+  ];
+
+  patches = [
+    # Allow building with glib 2.68
+    # PR at https://github.com/sigrokproject/pulseview/pull/39
+    (fetchpatch {
+      url = "https://github.com/sigrokproject/pulseview/commit/fb89dd11f2a4a08b73c498869789e38677181a8d.patch";
+      sha256 = "07ifsis9jlc0jjp2d11f7hvw9kaxcbk0a57h2m4xsv1d7vzl9yfh";
+    })
+  ];
+
+  meta = with lib; {
+    description = "Qt-based LA/scope/MSO GUI for sigrok (a signal analysis software suite)";
+    homepage = "https://sigrok.org/";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ bjornfor ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/qfsm/default.nix b/nixpkgs/pkgs/applications/science/electronics/qfsm/default.nix
new file mode 100644
index 000000000000..b2e3704cba70
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/qfsm/default.nix
@@ -0,0 +1,28 @@
+{ lib, stdenv, fetchurl, qt4, cmake, graphviz, pkg-config }:
+
+stdenv.mkDerivation rec {
+  pname = "qfsm";
+  version = "0.54.0";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/qfsm/qfsm-${version}-Source.tar.bz2";
+    sha256 = "0rl7bc5cr29ng67yij4akciyid9z7npal812ys4c3m229vjvflrb";
+  };
+
+  nativeBuildInputs = [ cmake pkg-config ];
+  buildInputs = [ qt4 graphviz ];
+
+  patches = [
+    ./drop-hardcoded-prefix.patch
+    ./gcc6-fixes.patch
+  ];
+
+  hardeningDisable = [ "format" ];
+
+  meta = {
+    description = "Graphical editor for finite state machines";
+    homepage = "http://qfsm.sourceforge.net/";
+    license = lib.licenses.gpl3Plus;
+    platforms = lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/qfsm/drop-hardcoded-prefix.patch b/nixpkgs/pkgs/applications/science/electronics/qfsm/drop-hardcoded-prefix.patch
new file mode 100644
index 000000000000..965d67ac5526
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/qfsm/drop-hardcoded-prefix.patch
@@ -0,0 +1,20 @@
+diff -ubrw qfsm-0.53.0-Source-orig/CMakeLists.txt qfsm-0.53.0-Source-new/CMakeLists.txt
+--- qfsm-0.53.0-Source-orig/CMakeLists.txt	2012-11-11 20:13:01.935856229 +0100
++++ qfsm-0.53.0-Source-new/CMakeLists.txt	2012-11-11 20:13:24.962930007 +0100
+@@ -406,10 +406,6 @@
+ 
+ 
+ IF(UNIX AND NOT WIN32)
+-  SET(CMAKE_INSTALL_PREFIX "/usr")
+-ENDIF(UNIX AND NOT WIN32)
+-
+-IF(UNIX AND NOT WIN32)
+   ADD_DEFINITIONS(-DQFSM_LANGUAGE_DIR="${CMAKE_INSTALL_PREFIX}/share/qfsm/")
+   ADD_DEFINITIONS(-DQFSM_HELP_DIR="${CMAKE_INSTALL_PREFIX}/share/doc/qfsm/")
+ ELSE(UNIX AND NOT WIN32)
+@@ -472,5 +468,3 @@
+     )
+ 
+ ENDIF(UNIX AND NOT WIN32)
+-
+-
diff --git a/nixpkgs/pkgs/applications/science/electronics/qfsm/gcc6-fixes.patch b/nixpkgs/pkgs/applications/science/electronics/qfsm/gcc6-fixes.patch
new file mode 100644
index 000000000000..5cedc6476397
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/qfsm/gcc6-fixes.patch
@@ -0,0 +1,20 @@
+--- qfsm-0.54.0-Source-orig/src/FileIO.cpp	2015-01-02 19:01:46.000000000 +0100
++++ qfsm-0.54.0-Source/src/FileIO.cpp	2017-09-11 19:53:30.579488402 +0200
+@@ -1617,7 +1617,7 @@
+   QString ext;
+ 
+   if (!imp)
+-    return FALSE;
++    return NULL;
+ 
+   Project* p=NULL;
+   importdlg->setAcceptMode(QFileDialog::AcceptOpen);
+@@ -1641,7 +1641,7 @@
+   ifstream fin(act_importfile);
+ 
+   if (!fin)
+-    return FALSE;
++    return NULL;
+ 
+   emit setWaitCursor();
+ 
diff --git a/nixpkgs/pkgs/applications/science/electronics/qucs-s/default.nix b/nixpkgs/pkgs/applications/science/electronics/qucs-s/default.nix
new file mode 100644
index 000000000000..6507198a790f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/qucs-s/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, lib, fetchFromGitHub, flex, bison, qt4, libX11, cmake, gperf, adms,
+ngspice, wrapGAppsHook,
+kernels ? [ ngspice ] }:
+
+stdenv.mkDerivation rec {
+  pname = "qucs-s";
+  version = "0.0.22";
+
+  src = fetchFromGitHub {
+    owner = "ra3xdh";
+    repo = "qucs_s";
+    rev = version;
+    sha256 = "0rrq2ddridc09m6fixdmbngn42xmv8cmdf6r8zzn2s98fqib5qd6";
+  };
+
+  nativeBuildInputs = [ wrapGAppsHook cmake ];
+  buildInputs = [ flex bison qt4 libX11 gperf adms ] ++ kernels;
+
+  preConfigure = ''
+    # Make custom kernels avaible from qucs-s
+    gappsWrapperArgs+=(--prefix PATH ":" ${lib.makeBinPath kernels})
+  '';
+
+  QTDIR=qt4;
+
+  doInstallCheck = true;
+  installCheck = ''
+    $out/bin/qucs-s --version
+  '';
+
+  meta = with lib; {
+    description = "Spin-off of Qucs that allows custom simulation kernels";
+    longDescription = ''
+      Spin-off of Qucs that allows custom simulation kernels.
+      Default version is installed with ngspice.
+    '';
+    homepage = "https://ra3xdh.github.io/";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ mazurel ];
+    platforms = with platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/qucs/cmakelists.patch b/nixpkgs/pkgs/applications/science/electronics/qucs/cmakelists.patch
new file mode 100644
index 000000000000..27066f09c84e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/qucs/cmakelists.patch
@@ -0,0 +1,34 @@
+diff --git i/qucs-core/CMakeLists.txt w/qucs-core/CMakeLists.txt
+index 2dbbd41..d174b50 100644
+--- i/qucs-core/CMakeLists.txt
++++ w/qucs-core/CMakeLists.txt
+@@ -158,26 +158,9 @@ ENDIF()
+ 
+ #
+ # Need Bison
+-#
+-# This is a HACK to get arround a PATH issue with Qt Creator on OSX.
+-# It seams impossible to pass a custom PATH to Qt Creator on OSX, ie, cannot prepend `/usr/local/bin/` for intance.
+-# The FIND_PACKAGE fails. For now we provide a fallback with a custom FIND_PROGRAM. The variable BISON_DIR is also available.
+-IF(WIN32)
+-  FIND_PACKAGE(BISON 2.4 REQUIRED)
+-  IF(BISON_FOUND)
+-    #MESSAGE(STATUS "Found bison: ${BISON_EXECUTABLE} / Version: ${BISON_VERSION}" )
+-  ENDIF()
+-ELSE()  # Linux, OSX
+-  # use -DBISON_DIR=/path/ to provide the path to bison
+-  FIND_PROGRAM( BISON_EXECUTABLE bison
+-    PATHS /usr/local/bin/ /opt/local/bin/ /usr/bin ${BISON_DIR}
+-    DOC "bison path"
+-    NO_DEFAULT_PATH )
+-  IF(BISON_EXECUTABLE )
+-    MESSAGE(STATUS "Found bison: " ${BISON_EXECUTABLE})
+-  ELSE()
+-	  MESSAGE(FATAL_ERROR "Unable to find bison. Try to provide -DBISON_DIR=[path]")
+-  ENDIF()
++FIND_PACKAGE(BISON 2.4 REQUIRED)
++IF(BISON_FOUND)
++  #MESSAGE(STATUS "Found bison: ${BISON_EXECUTABLE} / Version: ${BISON_VERSION}" )
+ ENDIF()
+ 
+ #
diff --git a/nixpkgs/pkgs/applications/science/electronics/qucs/default.nix b/nixpkgs/pkgs/applications/science/electronics/qucs/default.nix
new file mode 100644
index 000000000000..a5f2cf394b44
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/qucs/default.nix
@@ -0,0 +1,30 @@
+{lib, stdenv, fetchFromGitHub, flex, bison, qt4, libX11, cmake, gperf, adms }:
+
+stdenv.mkDerivation rec {
+  version = "0.0.19";
+  pname = "qucs";
+
+  src = fetchFromGitHub {
+    owner = "Qucs";
+    repo = "qucs";
+    rev = "qucs-${version}";
+    sha256 = "106h3kjyg7c0hkmzkin7h8fcl32n60835121b2qqih8ixi6r5id6";
+  };
+
+  QTDIR=qt4;
+
+  patches = [
+    ./cmakelists.patch
+  ];
+
+  nativeBuildInputs = [ cmake flex bison ];
+  buildInputs = [ qt4 libX11 gperf adms ];
+
+  meta = {
+    description = "Integrated circuit simulator";
+    homepage = "http://qucs.sourceforge.net";
+    license = lib.licenses.gpl2Plus;
+    maintainers = with lib.maintainers; [viric];
+    platforms = with lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/tkgate/1.x.nix b/nixpkgs/pkgs/applications/science/electronics/tkgate/1.x.nix
new file mode 100644
index 000000000000..f8741cd8d180
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/tkgate/1.x.nix
@@ -0,0 +1,42 @@
+{ lib, stdenv, fetchurl, tcl, tk, libX11, glibc, which, bison, flex, imake, xorgproto, gccmakedep }:
+
+let
+  libiconvInc = lib.optionalString stdenv.isLinux "${glibc.dev}/include";
+  libiconvLib = lib.optionalString stdenv.isLinux "${glibc.out}/lib";
+in
+stdenv.mkDerivation rec {
+  pname = "tkgate";
+  version = "1.8.7";
+
+  src = fetchurl {
+    url = "http://www.tkgate.org/downloads/tkgate-${version}.tgz";
+    sha256 = "1pqywkidfpdbj18i03h97f4cimld4fb3mqfy8jjsxs12kihm18fs";
+  };
+
+  nativeBuildInputs = [ which bison flex imake gccmakedep ];
+  buildInputs = [ tcl tk libX11 xorgproto ];
+  dontUseImakeConfigure = true;
+
+  patchPhase = ''
+    sed -i config.h \
+      -e 's|.*#define.*TKGATE_TCLTK_VERSIONS.*|#define TKGATE_TCLTK_VERSIONS "${tcl.release}"|' \
+      -e 's|.*#define.*TKGATE_INCDIRS.*|#define TKGATE_INCDIRS "${tcl}/include ${tk}/include ${libiconvInc} ${libX11.dev}/include"|' \
+      -e 's|.*#define.*TKGATE_LIBDIRS.*|#define TKGATE_LIBDIRS "${tcl}/lib ${tk}/lib ${libiconvLib} ${libX11.out}/lib"|' \
+      \
+      -e '20 i #define TCL_LIBRARY "${tcl}/lib"' \
+      -e '20 i #define TK_LIBRARY "${tk}/lib/${tk.libPrefix}"' \
+      -e '20 i #define USE_ICONV 1' \
+      \
+      -e "s|.*#define.*TKGATE_HOMEDIRBASE.*|#define TKGATE_HOMEDIRBASE \\\"$out/lib\\\"|" \
+      -e "s|.*#define.*TKGATE_BINDIR.*|#define TKGATE_BINDIR \\\"$out/bin\\\"|" \
+      -e "s|.*#define.*TKGATE_MANDIR.*|#define TKGATE_MANDIR \\\"$out/share/man/man1\\\"|" \
+      -e "s|file:/usr/X11R6/lib/tkgate-|file://$out/lib/tkgate-|"
+  '';
+
+  meta = {
+    description = "Event driven digital circuit simulator with a TCL/TK-based graphical editor";
+    homepage = "http://www.tkgate.org/";
+    license = lib.licenses.gpl2Plus;
+    hydraPlatforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/verilator/default.nix b/nixpkgs/pkgs/applications/science/electronics/verilator/default.nix
new file mode 100644
index 000000000000..5ee89dfa8c43
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/verilator/default.nix
@@ -0,0 +1,42 @@
+{ lib, stdenv, fetchFromGitHub
+, perl, flex, bison, python3, autoconf
+}:
+
+stdenv.mkDerivation rec {
+  pname = "verilator";
+  version = "4.218";
+
+  src = fetchFromGitHub {
+    owner = pname;
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "sha256-FukC60z7Y3bb3I/dgzqCh6kFP6DDBOGi0M8IIZ50P3g=";
+  };
+
+  enableParallelBuilding = true;
+  buildInputs = [ perl ];
+  nativeBuildInputs = [ flex bison python3 autoconf ];
+
+  # these tests need some interpreter paths patched early on...
+  # see https://github.com/NixOS/nix/issues/1205
+  doCheck = false;
+  checkTarget = "test";
+
+  preConfigure = ''
+    autoconf
+  '';
+
+  postPatch = ''
+    patchShebangs \
+      src/flexfix \
+      src/vlcovgen
+  '';
+
+  meta = with lib; {
+    description = "Fast and robust (System)Verilog simulator/compiler";
+    homepage    = "https://www.veripool.org/wiki/verilator";
+    license     = with licenses; [ lgpl3Only artistic2 ];
+    platforms   = platforms.unix;
+    maintainers = with maintainers; [ thoughtpolice ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/verilog/default.nix b/nixpkgs/pkgs/applications/science/electronics/verilog/default.nix
new file mode 100644
index 000000000000..4cb8048df675
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/verilog/default.nix
@@ -0,0 +1,70 @@
+{ lib, stdenv
+, fetchFromGitHub
+, autoconf
+, bison
+, bzip2
+, flex
+, gperf
+, ncurses
+, perl
+, readline
+, zlib
+}:
+
+let
+  iverilog-test = fetchFromGitHub {
+    owner  = "steveicarus";
+    repo   = "ivtest";
+    rev    = "253609b89576355b3bef2f91e90db62223ecf2be";
+    sha256 = "18i7jlr2csp7mplcrwjhllwvb6w3v7x7mnx7vdw48nd3g5scrydx";
+  };
+in
+stdenv.mkDerivation rec {
+  pname   = "iverilog";
+  version = "11.0";
+
+  src = fetchFromGitHub {
+    owner  = "steveicarus";
+    repo   = pname;
+    rev    = "v${lib.replaceStrings ["."] ["_"] version}";
+    sha256 = "0nzcyi6l2zv9wxzsv9i963p3igyjds0n55x0ph561mc3pfbc7aqp";
+  };
+
+  nativeBuildInputs = [ autoconf bison flex gperf ];
+
+  buildInputs = [ bzip2 ncurses readline zlib ];
+
+  preConfigure = "sh autoconf.sh";
+
+  enableParallelBuilding = true;
+
+  # tests try to access /proc/ which does not exist on darwin
+  # Cannot locate IVL modules : couldn't get command path from OS.
+  doCheck = !stdenv.isDarwin;
+
+  installCheckInputs = [ perl ];
+
+  installCheckPhase = ''
+    # copy tests to allow writing results
+    export TESTDIR=$(mktemp -d)
+    cp -r ${iverilog-test}/* $TESTDIR
+
+    pushd $TESTDIR
+
+    # Run & check tests
+    PATH=$out/bin:$PATH perl vvp_reg.pl
+    # Check the tests, will error if unexpected tests fail. Some failures MIGHT be normal.
+    diff regression_report-devel.txt regression_report.txt
+    PATH=$out/bin:$PATH perl vpi_reg.pl
+
+    popd
+  '';
+
+  meta = with lib; {
+    description = "Icarus Verilog compiler";
+    homepage    = "http://iverilog.icarus.com/";  # https does not work
+    license     = with licenses; [ gpl2Plus lgpl21Plus ];
+    maintainers = with maintainers; [ winden thoughtpolice ];
+    platforms   = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/vhd2vl/default.nix b/nixpkgs/pkgs/applications/science/electronics/vhd2vl/default.nix
new file mode 100644
index 000000000000..f0dd990a35bc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/vhd2vl/default.nix
@@ -0,0 +1,52 @@
+{ lib, stdenv
+, fetchFromGitHub
+, fetchpatch
+, bison
+, flex
+, verilog
+, which
+}:
+
+stdenv.mkDerivation rec {
+  pname = "vhd2vl";
+  version = "unstable-2018-09-01";
+
+  src = fetchFromGitHub {
+    owner = "ldoolitt";
+    repo = pname;
+    rev = "37e3143395ce4e7d2f2e301e12a538caf52b983c";
+    sha256 = "17va2pil4938j8c93anhy45zzgnvq3k71a7glj02synfrsv6fs8n";
+  };
+
+  patches = lib.optionals (!stdenv.isAarch64) [
+    # fix build with verilog 11.0 - https://github.com/ldoolitt/vhd2vl/pull/15
+    # for some strange reason, this is not needed for aarch64
+    (fetchpatch {
+      url = "https://github.com/ldoolitt/vhd2vl/commit/ce9b8343ffd004dfe8779a309f4b5a594dbec45e.patch";
+      sha256 = "1qaqhm2mk66spb2dir9n91b385rarglc067js1g6pcg8mg5v3hhf";
+    })
+  ];
+
+  nativeBuildInputs = [
+    bison
+    flex
+    which
+  ];
+
+  buildInputs = [
+    verilog
+  ];
+
+  installPhase = ''
+    runHook preInstall
+    install -D -m755 src/vhd2vl $out/bin/vdh2vl
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "VHDL to Verilog converter";
+    homepage = "https://github.com/ldoolitt/vhd2vl";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ matthuszagh ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/xcircuit/default.nix b/nixpkgs/pkgs/applications/science/electronics/xcircuit/default.nix
new file mode 100644
index 000000000000..68322a191787
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/xcircuit/default.nix
@@ -0,0 +1,35 @@
+{ lib, stdenv, fetchurl, autoreconfHook, automake, pkg-config
+, cairo, ghostscript, ngspice, tcl, tk, xorg, zlib }:
+
+let
+  version = "3.10.12";
+  name = "xcircuit-${version}";
+  inherit (lib) getBin;
+
+in stdenv.mkDerivation {
+  inherit name version;
+
+  src = fetchurl {
+    url = "http://opencircuitdesign.com/xcircuit/archive/${name}.tgz";
+    sha256 = "1h1ywc3mr7plvwnhdii2zgnnv5ih2nhyl4qbdjpi83dq0aq1s2mn";
+  };
+
+  nativeBuildInputs = [ autoreconfHook automake pkg-config ];
+  hardeningDisable = [ "format" ];
+
+  configureFlags = [
+    "--with-tcl=${tcl}/lib"
+    "--with-tk=${tk}/lib"
+    "--with-ngspice=${getBin ngspice}/bin/ngspice"
+  ];
+
+  buildInputs = with xorg; [ cairo ghostscript libSM libXt libICE libX11 libXpm tcl tk zlib ];
+
+  meta = with lib; {
+    description = "Generic drawing program tailored to circuit diagrams";
+    homepage = "http://opencircuitdesign.com/xcircuit";
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ spacefrogg thoughtpolice ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/xoscope/default.nix b/nixpkgs/pkgs/applications/science/electronics/xoscope/default.nix
new file mode 100644
index 000000000000..7a9f58a0c6e3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/xoscope/default.nix
@@ -0,0 +1,32 @@
+{ lib
+, stdenv
+, fetchurl
+, gtk3
+, gtkdatabox
+, fftw
+, gnum4
+, comedilib
+, alsa-lib
+, pkg-config
+}:
+
+stdenv.mkDerivation rec {
+  pname = "xoscope";
+  version = "2.3";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/xoscope/${pname}-${version}.tar.gz";
+    sha256 = "0a5ycfc1qdmibvagc82r2mhv2i99m6pndy5i6ixas3j2297g6pgq";
+  };
+
+  nativeBuildInputs = [ pkg-config gnum4 ];
+  buildInputs = [ gtk3 gtkdatabox fftw comedilib alsa-lib ];
+
+  meta = {
+    description = "Oscilloscope through the sound card";
+    homepage = "http://xoscope.sourceforge.net";
+    license = lib.licenses.gpl2Plus;
+    maintainers = with lib.maintainers; [viric];
+    platforms = with lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/xschem/default.nix b/nixpkgs/pkgs/applications/science/electronics/xschem/default.nix
new file mode 100644
index 000000000000..25fa0aca4677
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/xschem/default.nix
@@ -0,0 +1,46 @@
+{ stdenv
+, fetchFromGitHub
+, lib
+, bison
+, cairo
+, flex
+, libX11
+, libXpm
+, pkg-config
+, tcl
+, tk
+}:
+
+stdenv.mkDerivation rec {
+  pname = "xschem";
+  version = "3.0.0";
+
+  src = fetchFromGitHub {
+    owner = "StefanSchippers";
+    repo = "xschem";
+    rev = version;
+    sha256 = "sha256-C57jo8tAbiqQAgf4Xp2lpFGOr6F1knPpFcYxPiqSM4k=";
+  };
+
+  nativeBuildInputs = [ bison flex pkg-config ];
+
+  buildInputs = [ cairo libX11 libXpm tcl tk ];
+
+  hardeningDisable = [ "format" ];
+
+  meta = with lib; {
+    description = "Schematic capture and netlisting EDA tool";
+    longDescription = ''
+      Xschem is a schematic capture program, it allows creation of
+      hierarchical representation of circuits with a top down approach.
+      By focusing on interfaces, hierarchy and instance properties a
+      complex system can be described in terms of simpler building
+      blocks. A VHDL or Verilog or Spice netlist can be generated from
+      the drawn schematic, allowing the simulation of the circuit.
+    '';
+    homepage = "https://xschem.sourceforge.io/stefan/";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ fbeffa ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/xyce/default.nix b/nixpkgs/pkgs/applications/science/electronics/xyce/default.nix
new file mode 100644
index 000000000000..8d9b02d909e9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/xyce/default.nix
@@ -0,0 +1,182 @@
+{ stdenv
+, fetchFromGitHub
+, fetchgit
+, lib
+, autoconf
+, automake
+, bison
+, blas
+, flex
+, fftw
+, gfortran
+, lapack
+, libtool_2
+, mpi
+, suitesparse
+, trilinos
+, withMPI ? false
+  # for doc
+, texlive
+, pandoc
+, enableDocs ? true
+  # for tests
+, bash
+, bc
+, openssh # required by MPI
+, perl
+, perlPackages
+, python3
+, enableTests ? true
+}:
+
+assert withMPI -> trilinos.withMPI;
+
+stdenv.mkDerivation rec {
+  pname = "xyce";
+  version = "7.4.0";
+
+  srcs = [
+    # useing fetchurl or fetchFromGitHub doesn't include the manuals
+    # due to .gitattributes files
+    (fetchgit {
+      url = "https://github.com/Xyce/Xyce.git";
+      rev = "Release-${version}";
+      sha256 = "sha256-sOHjQEo4FqlDseTtxFVdLa0SI/VAf2OkwQV7QSL7SNM=";
+    })
+    (fetchFromGitHub {
+      owner = "Xyce";
+      repo = "Xyce_Regression";
+      rev = "Release-${version}";
+      sha256 = "sha256-kSGUaFarOHDNJ8kA/TAGkmzicm9O7cfJ7mGFZcbqCZM=";
+    })
+  ];
+
+  sourceRoot = "./Xyce";
+
+  preConfigure = "./bootstrap";
+
+  configureFlags = [
+    "CXXFLAGS=-O3"
+    "--enable-xyce-shareable"
+    "--enable-shared"
+    "--enable-stokhos"
+    "--enable-amesos2"
+  ] ++ lib.optionals withMPI [
+    "--enable-mpi"
+    "CXX=mpicxx"
+    "CC=mpicc"
+    "F77=mpif77"
+  ];
+
+  enableParallelBuilding = true;
+
+  nativeBuildInputs = [
+    autoconf
+    automake
+    gfortran
+    libtool_2
+  ] ++ lib.optionals enableDocs [
+    (texlive.combine {
+      inherit (texlive)
+        scheme-medium
+        koma-script
+        optional
+        framed
+        enumitem
+        multirow
+        preprint;
+    })
+  ];
+
+  buildInputs = [
+    bison
+    blas
+    flex
+    fftw
+    lapack
+    suitesparse
+    trilinos
+  ] ++ lib.optionals withMPI [ mpi ];
+
+  doCheck = enableTests;
+
+  postPatch = ''
+    pushd ../source
+    find Netlists -type f -regex ".*\.sh\|.*\.pl" -exec chmod ugo+x {} \;
+    # some tests generate new files, some overwrite netlists
+    find . -type d -exec chmod u+w {} \;
+    find . -type f -name "*.cir" -exec chmod u+w {} \;
+    patchShebangs Netlists/ TestScripts/
+    # patch script generating functions
+    sed -i -E 's|/usr/bin/env perl|${lib.escapeRegex perl.outPath}/bin/perl|'  \
+      TestScripts/XyceRegression/Testing/Netlists/RunOptions/runOptions.cir.sh
+    sed -i -E 's|/bin/sh|${lib.escapeRegex bash.outPath}/bin/sh|' \
+      TestScripts/XyceRegression/Testing/Netlists/RunOptions/runOptions.cir.sh
+    popd
+  '';
+
+  checkInputs = [
+    bc
+    perl
+    perlPackages.DigestMD5
+    (python3.withPackages (ps: with ps; [ numpy scipy ]))
+  ] ++ lib.optionals withMPI [ mpi openssh ];
+
+  checkPhase = ''
+    XYCE_BINARY="$(pwd)/src/Xyce"
+    EXECSTRING="${lib.optionalString withMPI "mpirun -np 2 "}$XYCE_BINARY"
+    TEST_ROOT="$(pwd)/../source"
+
+    # Honor the TMP variable
+    sed -i -E 's|/tmp|\$TMP|' $TEST_ROOT/TestScripts/suggestXyceTagList.sh
+
+    EXLUDE_TESTS_FILE=$TMP/exclude_tests.$$
+    # Gold standard has additional ":R" suffix in result column label
+    echo "Output/HB/hb-step-tecplot.cir" >> $EXLUDE_TESTS_FILE
+    # This test makes Xyce access /sys/class/net when run with MPI
+    ${lib.optionalString withMPI "echo \"CommandLine/command_line.cir\" >> $EXLUDE_TESTS_FILE"}
+
+    $TEST_ROOT/TestScripts/run_xyce_regression \
+      --output="$(pwd)/Xyce_Test" \
+      --xyce_test="''${TEST_ROOT}" \
+      --taglist="$($TEST_ROOT/TestScripts/suggestXyceTagList.sh "$XYCE_BINARY" | sed -E -e 's/TAGLIST=([^ ]+).*/\1/' -e '2,$d')" \
+      --resultfile="$(pwd)/test_results" \
+      --excludelist="$EXLUDE_TESTS_FILE" \
+      "''${EXECSTRING}"
+  '';
+
+  outputs = [ "out" "doc" ];
+
+  postInstall = lib.optionalString enableDocs ''
+    local docFiles=("doc/Users_Guide/Xyce_UG"
+      "doc/Reference_Guide/Xyce_RG"
+      "doc/Release_Notes/Release_Notes_${lib.versions.majorMinor version}/Release_Notes_${lib.versions.majorMinor version}")
+
+    # Release notes refer to an image not in the repo.
+    sed -i -E 's/\\includegraphics\[height=(0.5in)\]\{snllineblubrd\}/\\mbox\{\\rule\{0mm\}\{\1\}\}/' ''${docFiles[2]}.tex
+
+    install -d $doc/share/doc/${pname}-${version}/
+    for d in ''${docFiles[@]}; do
+      # Use a public document class
+      sed -i -E 's/\\documentclass\[11pt,report\]\{SANDreport\}/\\documentclass\[11pt,letterpaper\]\{scrreprt\}/' $d.tex
+      sed -i -E 's/\\usepackage\[sand\]\{optional\}/\\usepackage\[report\]\{optional\}/' $d.tex
+      pushd $(dirname $d)
+      make
+      install -t $doc/share/doc/${pname}-${version}/ $(basename $d.pdf)
+      popd
+    done
+  '';
+
+  meta = with lib; {
+    description = "High-performance analog circuit simulator";
+    longDescription = ''
+      Xyce is a SPICE-compatible, high-performance analog circuit simulator,
+      capable of solving extremely large circuit problems by supporting
+      large-scale parallel computing platforms.
+    '';
+    homepage = "https://xyce.sandia.gov";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ fbeffa ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/geometry/antiprism/default.nix b/nixpkgs/pkgs/applications/science/geometry/antiprism/default.nix
new file mode 100644
index 000000000000..e5779478936e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/geometry/antiprism/default.nix
@@ -0,0 +1,29 @@
+{ lib, stdenv
+, fetchFromGitHub
+, autoreconfHook
+, libX11
+, libGL
+, libGLU
+, freeglut }:
+
+stdenv.mkDerivation rec {
+  pname = "antiprism";
+  version = "0.29";
+
+  src = fetchFromGitHub {
+    owner = "antiprism";
+    repo = pname;
+    rev = version;
+    sha256 = "sha256-MHzetkmRDLBXq3KrfXmUhxURY60/Y8z5zQsExT6N4cY=";
+  };
+
+  nativeBuildInputs = [ autoreconfHook ];
+  buildInputs = [ libX11 libGLU libGL.dev freeglut.dev ];
+
+  meta = with lib; {
+    homepage = "https://www.antiprism.com";
+    description = "A collection of programs for generating, manipulating, transforming and viewing polyhedra";
+    license = with licenses; [ mit ];
+    maintainers = with maintainers; [ AndersonTorres ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/geometry/drgeo/default.nix b/nixpkgs/pkgs/applications/science/geometry/drgeo/default.nix
new file mode 100644
index 000000000000..59d7315ef413
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/geometry/drgeo/default.nix
@@ -0,0 +1,29 @@
+{ lib, stdenv, fetchurl, libglade, gtk2, guile, libxml2, perl
+, intltool, libtool, pkg-config }:
+
+stdenv.mkDerivation rec {
+  pname = "drgeo";
+  version = "1.1.0";
+
+  hardeningDisable = [ "format" ];
+
+  src = fetchurl {
+    url = "mirror://sourceforge/ofset/${pname}-${version}.tar.gz";
+    sha256 = "05i2czgzhpzi80xxghinvkyqx4ym0gm9f38fz53idjhigiivp4wc";
+  };
+  patches = [ ./struct.patch ];
+
+  buildInputs = [libglade gtk2 guile libxml2
+    perl intltool libtool pkg-config];
+
+  prebuild = ''
+    cp drgeo.desktop.in drgeo.desktop
+  '';
+
+  meta = with lib; {
+    description = "Interactive geometry program";
+    homepage = "https://sourceforge.net/projects/ofset";
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/geometry/drgeo/struct.patch b/nixpkgs/pkgs/applications/science/geometry/drgeo/struct.patch
new file mode 100644
index 000000000000..7364cae5f58d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/geometry/drgeo/struct.patch
@@ -0,0 +1,68 @@
+-- drgeo-1.1.0/debian/patches/00list
+++ drgeo-1.1.0/debian/patches/00list
+@ -7 +7 @@
+
+07-fix_ftbfs-gcc-4.5.dpatch
+nly in patch2:
+nchanged:
+-- drgeo-1.1.0.orig/debian/patches/07-fix_ftbfs-gcc-4.5.dpatch
+++ drgeo-1.1.0/debian/patches/07-fix_ftbfs-gcc-4.5.dpatch
+@ -0,0 +1,58 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 07-fix_ftbfs-gcc-4.5.dpatch by Fabrice Coutadeur <fabric...@ubuntu.com>
+##
+## Description: fix FTBFS with gcc 4.5 with undefined reference to
+## `drgeoDialogData'
+## Author: Petr Gajdos <pgaj...@suse.cz>
+## Origin: https://build.opensuse.org/package/files?package=drgeo&project=openSUSE%3A11.3%3AContrib
+
+...@dpatch@
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' drgeo-1.1.0~/geo/drgeo_dialog.cc drgeo-1.1.0/geo/drgeo_dialog.cc
+--- drgeo-1.1.0~/geo/drgeo_dialog.cc	2003-10-27 10:17:25.000000000 +0000
++++ drgeo-1.1.0/geo/drgeo_dialog.cc	2010-11-13 07:26:03.258908003 +0000
+@@ -38,12 +38,7 @@
+ // Used in the style dialod callback, I know it's ugly, but so easy
+ static drgeoFigure *selected_figure;
+ 
+-struct
+-{
+-  drgeoPoint mouse;
+-  drgeoFigure *figure;
+-}
+-drgeoDialogData;
++DialogData drgeoDialogData;
+ 
+ 
+ static void drgeo_edit_dialog_cb (GtkWidget * dialog,
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' drgeo-1.1.0~/geo/drgeo_dialog.h drgeo-1.1.0/geo/drgeo_dialog.h
+--- drgeo-1.1.0~/geo/drgeo_dialog.h	2003-06-12 22:30:23.000000000 +0000
++++ drgeo-1.1.0/geo/drgeo_dialog.h	2010-11-13 07:26:03.258908003 +0000
+@@ -34,4 +34,11 @@
+ }
+ 
+ #endif				/* __cplusplus */
++
++typedef struct
++{
++  drgeoPoint mouse;
++  drgeoFigure *figure;
++} DialogData;
++
+ #endif
+diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' drgeo-1.1.0~/geo/drgeo_figure.cc drgeo-1.1.0/geo/drgeo_figure.cc
+--- drgeo-1.1.0~/geo/drgeo_figure.cc	2005-07-14 07:30:01.000000000 +0000
++++ drgeo-1.1.0/geo/drgeo_figure.cc	2010-11-13 07:26:03.258908003 +0000
+@@ -48,12 +48,7 @@
+ #include "drgeo_dialog.h"
+ #include "traite.h"
+ 
+-extern struct
+-{
+-  drgeoPoint mouse;
+-  drgeoFigure *figure;
+-}
+-drgeoDialogData;
++extern DialogData drgeoDialogData;
+ 
+ typedef struct drgeoSearchValue
+ {
diff --git a/nixpkgs/pkgs/applications/science/geometry/gama/default.nix b/nixpkgs/pkgs/applications/science/geometry/gama/default.nix
new file mode 100644
index 000000000000..b2226db46087
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/geometry/gama/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, lib, expat, octave, libxml2, texinfo, zip }:
+stdenv.mkDerivation rec {
+  pname = "gama";
+  version = "2.17";
+
+  src = fetchurl {
+    url = "mirror://gnu/${pname}/${pname}-${version}.tar.gz";
+    sha256 = "sha256-AyUjcYDUjAYI4p0vVDO7SGqhbO83Kesd+JUUgQf5GPU=";
+  };
+
+  buildInputs = [ expat ];
+
+  nativeBuildInputs = [ texinfo zip ];
+
+  checkInputs = [ octave libxml2 ];
+  doCheck = true;
+
+  meta = with lib ; {
+    description = "Tools for adjustment of geodetic networks";
+    homepage = "https://www.gnu.org/software/gama/";
+    license = licenses.gpl3Plus;
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/geometry/tetgen/1.4.nix b/nixpkgs/pkgs/applications/science/geometry/tetgen/1.4.nix
new file mode 100644
index 000000000000..684f5913f79f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/geometry/tetgen/1.4.nix
@@ -0,0 +1,23 @@
+{ lib, stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  pname = "tetgen";
+  version = "1.4.3";
+
+  src = fetchurl {
+    url = "${meta.homepage}/files/tetgen${version}.tar.gz";
+    sha256 = "0d70vjqdapmy1ghlsxjlvl5z9yp310zw697bapc4zxmp0sxi29wm";
+  };
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp tetgen $out/bin
+  '';
+
+  meta = {
+    description = "Quality Tetrahedral Mesh Generator and 3D Delaunay Triangulator";
+    homepage = "http://tetgen.org/";
+    license = lib.licenses.mit;
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/geometry/tetgen/default.nix b/nixpkgs/pkgs/applications/science/geometry/tetgen/default.nix
new file mode 100644
index 000000000000..ff2b211b34d2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/geometry/tetgen/default.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchurl, cmake }:
+
+stdenv.mkDerivation rec {
+  pname = "tetgen";
+  version = "1.6.0";
+
+  src = fetchurl {
+    url = "http://wias-berlin.de/software/tetgen/1.5/src/tetgen${version}.tar.gz";
+    sha256 = "sha256-h7XmHr06Rx/E8s3XEkwrEd1mOfT+sflBpdL1EQ0Fzjk=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out/{bin,lib,include}
+    cp tetgen $out/bin
+    cp libtet.a $out/lib
+    cp ../tetgen.{cxx,h} $out/include
+
+    runHook postInstall
+  '';
+
+  meta = {
+    description = "Quality Tetrahedral Mesh Generator and 3D Delaunay Triangulator";
+    homepage = "http://tetgen.org/";
+    license = lib.licenses.agpl3Plus;
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/abc/default.nix b/nixpkgs/pkgs/applications/science/logic/abc/default.nix
new file mode 100644
index 000000000000..60454ca9ce99
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/abc/default.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchFromGitHub
+, readline, cmake
+}:
+
+stdenv.mkDerivation rec {
+  pname   = "abc-verifier";
+  version = "2022.03.04";
+
+  src = fetchFromGitHub {
+    owner = "yosyshq";
+    repo  = "abc";
+    rev   = "d7ecb23eeee9c9b4924182ce570c2e33eb18abff";
+    hash  = "sha256-aufWRTggJNOaUFsjh5+HFDqEur+nuM0hZSsTfGptbks=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ readline ];
+
+  installPhase = "mkdir -p $out/bin && mv abc $out/bin";
+
+  # needed by yosys
+  passthru.rev = src.rev;
+
+  meta = with lib; {
+    description = "A tool for squential logic synthesis and formal verification";
+    homepage    = "https://people.eecs.berkeley.edu/~alanmi/abc";
+    license     = licenses.mit;
+    platforms   = platforms.unix;
+    maintainers = with maintainers; [ thoughtpolice ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/abella/default.nix b/nixpkgs/pkgs/applications/science/logic/abella/default.nix
new file mode 100644
index 000000000000..3d752b7d7b93
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/abella/default.nix
@@ -0,0 +1,38 @@
+{ lib, stdenv, fetchurl, rsync, ocamlPackages }:
+
+stdenv.mkDerivation rec {
+  pname = "abella";
+  version = "2.0.7";
+
+  src = fetchurl {
+    url = "http://abella-prover.org/distributions/${pname}-${version}.tar.gz";
+    sha256 = "sha256-/eOiebMFHgrurtrSHPlgZO3xmmxBOUmyAzswXZLd3Yc=";
+  };
+
+  buildInputs = [ rsync ] ++ (with ocamlPackages; [ ocaml ocamlbuild findlib ]);
+
+  installPhase = ''
+    mkdir -p $out/bin
+    rsync -av abella    $out/bin/
+
+    mkdir -p $out/share/emacs/site-lisp/abella/
+    rsync -av emacs/    $out/share/emacs/site-lisp/abella/
+
+    mkdir -p $out/share/abella/examples
+    rsync -av examples/ $out/share/abella/examples/
+  '';
+
+  meta = {
+    description = "Interactive theorem prover";
+    longDescription = ''
+      Abella is an interactive theorem prover based on lambda-tree syntax.
+      This means that Abella is well-suited for reasoning about the meta-theory
+      of programming languages and other logical systems which manipulate
+      objects with binding.
+    '';
+    homepage = "http://abella-prover.org/";
+    license = lib.licenses.gpl3;
+    maintainers = with lib.maintainers; [ bcdarwin ciil ];
+    platforms = lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/acgtk/default.nix b/nixpkgs/pkgs/applications/science/logic/acgtk/default.nix
new file mode 100644
index 000000000000..1de21e09f806
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/acgtk/default.nix
@@ -0,0 +1,30 @@
+{ lib, stdenv, fetchurl, dune_2, ocamlPackages }:
+
+stdenv.mkDerivation {
+
+  pname = "acgtk";
+  version = "1.5.2";
+
+  src = fetchurl {
+    url = "https://acg.loria.fr/software/acg-1.5.2-20201204.tar.gz";
+    sha256 = "09yax7dyw8kgwzlb69r9d20y7rrymzwi3bbq2dh0qdq01vjz2xwq";
+  };
+
+  buildInputs = [ dune_2 ] ++ (with ocamlPackages; [
+    ocaml findlib ansiterminal cairo2 cmdliner fmt logs menhir menhirLib mtime yojson
+  ]);
+
+  buildPhase = "dune build --profile=release";
+
+  installPhase = ''
+    dune install --prefix $out --libdir $OCAMLFIND_DESTDIR
+  '';
+
+  meta = with lib; {
+    homepage = "https://acg.loria.fr/";
+    description = "A toolkit for developing ACG signatures and lexicon";
+    license = licenses.cecill20;
+    inherit (ocamlPackages.ocaml.meta) platforms;
+    maintainers = [ maintainers.jirkamarsik ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/aiger/default.nix b/nixpkgs/pkgs/applications/science/logic/aiger/default.nix
new file mode 100644
index 000000000000..15c45466b132
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/aiger/default.nix
@@ -0,0 +1,55 @@
+{ lib, stdenv, fetchurl, picosat }:
+
+stdenv.mkDerivation rec {
+  pname = "aiger";
+  version = "1.9.9";
+
+  src = fetchurl {
+    url    = "http://fmv.jku.at/aiger/${pname}-${version}.tar.gz";
+    sha256 = "1ish0dw0nf9gyghxsdhpy1jjiy5wp54c993swp85xp7m6vdx6l0y";
+  };
+
+  enableParallelBuilding = true;
+
+  configurePhase = ''
+    # Set up picosat, so we can build 'aigbmc'
+    mkdir ../picosat
+    ln -s ${picosat}/include/picosat/picosat.h ../picosat/picosat.h
+    ln -s ${picosat}/lib/picosat.o             ../picosat/picosat.o
+    ln -s ${picosat}/share/picosat.version     ../picosat/VERSION
+    ./configure.sh
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin $dev/include $lib/lib
+
+    # Do the installation manually, as the Makefile has odd
+    # cyrillic characters, and this is easier than adding
+    # a whole .patch file.
+    BINS=( \
+      aigand aigdd aigflip aigfuzz aiginfo aigjoin   \
+      aigmiter aigmove aignm aigor aigreset aigsim   \
+      aigsplit aigstrip aigtoaig aigtoblif aigtocnf  \
+      aigtodot aigtosmv aigunconstraint aigunroll    \
+      andtoaig bliftoaig smvtoaig soltostim wrapstim \
+      aigbmc aigdep
+    )
+
+    for x in ''${BINS[*]}; do
+      install -m 755 -s $x $out/bin/$x
+    done
+
+    cp -v aiger.o $lib/lib
+    cp -v aiger.h $dev/include
+  '';
+
+  outputs = [ "out" "dev" "lib" ];
+
+  meta = {
+    description = "And-Inverter Graph (AIG) utilities";
+    homepage    = "http://fmv.jku.at/aiger/";
+    license     = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ thoughtpolice ];
+    platforms   = lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/alt-ergo/default.nix b/nixpkgs/pkgs/applications/science/logic/alt-ergo/default.nix
new file mode 100644
index 000000000000..096a648b4ddf
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/alt-ergo/default.nix
@@ -0,0 +1,49 @@
+{ fetchFromGitHub, lib, which, ocamlPackages }:
+
+let
+  pname = "alt-ergo";
+  version = "2.4.1";
+
+  src = fetchFromGitHub {
+    owner = "OCamlPro";
+    repo = pname;
+    rev = version;
+    sha256 = "0hglj1p0753w2isds01h90knraxa42d2jghr35dpwf9g8a1sm9d3";
+  };
+
+  useDune2 = true;
+in
+
+let alt-ergo-lib = ocamlPackages.buildDunePackage rec {
+  pname = "alt-ergo-lib";
+  inherit version src useDune2;
+  configureFlags = pname;
+  nativeBuildInputs = [ which ];
+  buildInputs = with ocamlPackages; [ dune-configurator ];
+  propagatedBuildInputs = with ocamlPackages; [ num ocplib-simplex stdlib-shims zarith ];
+}; in
+
+let alt-ergo-parsers = ocamlPackages.buildDunePackage rec {
+  pname = "alt-ergo-parsers";
+  inherit version src useDune2;
+  configureFlags = pname;
+  nativeBuildInputs = [ which ocamlPackages.menhir ];
+  propagatedBuildInputs = [ alt-ergo-lib ] ++ (with ocamlPackages; [ camlzip psmt2-frontend ]);
+}; in
+
+ocamlPackages.buildDunePackage {
+
+  inherit pname version src useDune2;
+
+  configureFlags = pname;
+
+  nativeBuildInputs = [ which ocamlPackages.menhir ];
+  buildInputs = [ alt-ergo-parsers ocamlPackages.cmdliner ];
+
+  meta = {
+    description = "High-performance theorem prover and SMT solver";
+    homepage    = "https://alt-ergo.ocamlpro.com/";
+    license     = lib.licenses.ocamlpro_nc;
+    maintainers = [ lib.maintainers.thoughtpolice ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/anders/default.nix b/nixpkgs/pkgs/applications/science/logic/anders/default.nix
new file mode 100644
index 000000000000..bb60b2b8321a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/anders/default.nix
@@ -0,0 +1,27 @@
+{ lib, fetchFromGitHub, ocamlPackages }:
+
+ocamlPackages.buildDunePackage rec {
+  pname = "anders";
+  version = "1.1.1";
+
+  useDune2 = true;
+
+  src = fetchFromGitHub {
+    owner = "groupoid";
+    repo = "anders";
+    rev = "${version}";
+    sha256 = "sha256-JUiZoo2rNLfgs94TlJqUNzul/7ODisCjSFAzhgSp1z4=";
+  };
+
+  strictDeps = true;
+
+  nativeBuildInputs = [ ocamlPackages.menhir ];
+  buildInputs = [ ocamlPackages.zarith ];
+
+  meta = with lib; {
+    description = "Modal Homotopy Type System";
+    homepage = "https://homotopy.dev/";
+    license = licenses.isc;
+    maintainers = [ maintainers.suhr ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/aspino/default.nix b/nixpkgs/pkgs/applications/science/logic/aspino/default.nix
new file mode 100644
index 000000000000..fc16423b671e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/aspino/default.nix
@@ -0,0 +1,51 @@
+{ lib, stdenv, fetchurl, fetchFromGitHub, zlib, boost }:
+
+let
+  glucose' = fetchurl {
+    url = "http://www.labri.fr/perso/lsimon/downloads/softwares/glucose-syrup.tgz";
+    sha256 = "0bq5l2jabhdfhng002qfk0mcj4pfi1v5853x3c7igwfrgx0jmfld";
+  };
+in
+
+stdenv.mkDerivation {
+  pname = "aspino";
+  version = "unstable-2017-03-09";
+
+  src = fetchFromGitHub {
+    owner = "alviano";
+    repo = "aspino";
+    rev = "e31c3b4e5791a454e6602439cb26bd98d23c4e78";
+    sha256 = "0annsjs2prqmv1lbs0lxr7yclfzh47xg9zyiq6mdxcc02rxsi14f";
+  };
+
+  buildInputs = [ zlib boost ];
+
+  postPatch = ''
+    substituteInPlace Makefile \
+      --replace "GCC = g++" "GCC = c++"
+
+    patchShebangs .
+  '';
+
+  preBuild = ''
+    cp ${glucose'} patches/glucose-syrup.tgz
+    ./bootstrap.sh
+  '';
+
+  installPhase = ''
+    runHook preInstall
+    mkdir -p $out/bin
+    install -m0755 build/release/{aspino,fairino-{bs,ls,ps},maxino-2015-{k16,kdyn}} $out/bin
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "SAT/PseudoBoolean/MaxSat/ASP solver using glucose";
+    maintainers = with maintainers; [ gebner ];
+    platforms = platforms.unix;
+    license = licenses.asl20;
+    homepage = "https://alviano.net/software/maxino/";
+    # See pkgs/applications/science/logic/glucose/default.nix
+    badPlatforms = [ "aarch64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/avy/default.nix b/nixpkgs/pkgs/applications/science/logic/avy/default.nix
new file mode 100644
index 000000000000..fe2f30a55a33
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/avy/default.nix
@@ -0,0 +1,50 @@
+{ lib, stdenv, fetchgit, cmake, zlib, boost }:
+
+stdenv.mkDerivation rec {
+  pname = "avy";
+  version = "2019.05.01"; # date of cav19 tag
+
+  src = fetchgit {
+    url    = "https://bitbucket.org/arieg/extavy";
+    rev    = "cav19";
+    sha256 = "0qdzy9srxp5f38x4dbb3prnr9il6cy0kz80avrvd7fxqzy7wdlwy";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ zlib boost.out boost.dev ];
+  NIX_CFLAGS_COMPILE = toString ([ "-Wno-narrowing" ]
+    # Squelch endless stream of warnings on same few things
+    ++ lib.optionals stdenv.cc.isClang [
+      "-Wno-empty-body"
+      "-Wno-tautological-compare"
+      "-Wc++11-compat-deprecated-writable-strings"
+      "-Wno-deprecated"
+    ]);
+
+  prePatch = ''
+    sed -i -e '1i#include <stdint.h>' abc/src/bdd/dsd/dsd.h
+    substituteInPlace abc/src/bdd/dsd/dsd.h --replace \
+               '((Child = Dsd_NodeReadDec(Node,Index))>=0);' \
+               '((intptr_t)(Child = Dsd_NodeReadDec(Node,Index))>=0);'
+
+    patch -p1 -d minisat -i ${./minisat-fenv.patch}
+    patch -p1 -d glucose -i ${./glucose-fenv.patch}
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp avy/src/{avy,avybmc} $out/bin/
+  '';
+
+  meta = {
+    description = "AIGER model checking for Property Directed Reachability";
+    homepage    = "https://arieg.bitbucket.io/avy/";
+    license     = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ thoughtpolice ];
+    platforms   = lib.platforms.linux;
+    # See pkgs/applications/science/logic/glucose/default.nix
+    # (The error is different due to glucose-fenv.patch, but the same)
+    badPlatforms = [ "aarch64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/avy/glucose-fenv.patch b/nixpkgs/pkgs/applications/science/logic/avy/glucose-fenv.patch
new file mode 100644
index 000000000000..dd19f7ec80e7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/avy/glucose-fenv.patch
@@ -0,0 +1,65 @@
+From d6e0cb60270e8653bda3f339e3a07ce2cd2d6eb0 Mon Sep 17 00:00:00 2001
+From: Will Dietz <w@wdtz.org>
+Date: Tue, 17 Oct 2017 23:01:36 -0500
+Subject: [PATCH] glucose: use fenv to set double precision
+
+---
+ core/Main.cc   | 8 ++++++--
+ simp/Main.cc   | 8 ++++++--
+ utils/System.h | 2 +-
+ 3 files changed, 13 insertions(+), 5 deletions(-)
+
+diff --git a/core/Main.cc b/core/Main.cc
+index c96aadd..994132b 100644
+--- a/core/Main.cc
++++ b/core/Main.cc
+@@ -96,8 +96,12 @@ int main(int argc, char** argv)
+         // printf("This is MiniSat 2.0 beta\n");
+         
+ #if defined(__linux__)
+-        fpu_control_t oldcw, newcw;
+-        _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw);
++        fenv_t fenv;
++
++        fegetenv(&fenv);
++        fenv.__control_word &= ~0x300; /* _FPU_EXTENDED */
++        fenv.__control_word |= 0x200; /* _FPU_DOUBLE */
++        fesetenv(&fenv);
+         printf("c WARNING: for repeatability, setting FPU to use double precision\n");
+ #endif
+         // Extra options:
+diff --git a/simp/Main.cc b/simp/Main.cc
+index 4f4772d..70c2e4b 100644
+--- a/simp/Main.cc
++++ b/simp/Main.cc
+@@ -97,8 +97,12 @@ int main(int argc, char** argv)
+         
+         
+ #if defined(__linux__)
+-        fpu_control_t oldcw, newcw;
+-        _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw);
++        fenv_t fenv;
++
++        fegetenv(&fenv);
++        fenv.__control_word &= ~0x300; /* _FPU_EXTENDED */
++        fenv.__control_word |= 0x200; /* _FPU_DOUBLE */
++        fesetenv(&fenv);
+         printf("WARNING: for repeatability, setting FPU to use double precision\n");
+ #endif
+         // Extra options:
+diff --git a/utils/System.h b/utils/System.h
+index 004d498..a768e99 100644
+--- a/utils/System.h
++++ b/utils/System.h
+@@ -22,7 +22,7 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
+ #define Glucose_System_h
+ 
+ #if defined(__linux__)
+-#include <fpu_control.h>
++#include <fenv.h>
+ #endif
+ 
+ #include "glucose/mtl/IntTypes.h"
+-- 
+2.14.2
+
diff --git a/nixpkgs/pkgs/applications/science/logic/avy/minisat-fenv.patch b/nixpkgs/pkgs/applications/science/logic/avy/minisat-fenv.patch
new file mode 100644
index 000000000000..686d5a1c5b49
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/avy/minisat-fenv.patch
@@ -0,0 +1,65 @@
+From 7f1016ceab9b0f57a935bd51ca6df3d18439b472 Mon Sep 17 00:00:00 2001
+From: Will Dietz <w@wdtz.org>
+Date: Tue, 17 Oct 2017 22:57:02 -0500
+Subject: [PATCH] use fenv instead of non-standard fpu_control
+
+---
+ core/Main.cc   | 8 ++++++--
+ simp/Main.cc   | 8 ++++++--
+ utils/System.h | 2 +-
+ 3 files changed, 13 insertions(+), 5 deletions(-)
+
+diff --git a/core/Main.cc b/core/Main.cc
+index 2b0d97b..8ad95fb 100644
+--- a/core/Main.cc
++++ b/core/Main.cc
+@@ -78,8 +78,12 @@ int main(int argc, char** argv)
+         // printf("This is MiniSat 2.0 beta\n");
+         
+ #if defined(__linux__)
+-        fpu_control_t oldcw, newcw;
+-        _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw);
++        fenv_t fenv;
++
++        fegetenv(&fenv);
++        fenv.__control_word &= ~0x300; /* _FPU_EXTENDED */
++        fenv.__control_word |= 0x200; /* _FPU_DOUBLE */
++        fesetenv(&fenv);
+         printf("WARNING: for repeatability, setting FPU to use double precision\n");
+ #endif
+         // Extra options:
+diff --git a/simp/Main.cc b/simp/Main.cc
+index 2804d7f..39bfb71 100644
+--- a/simp/Main.cc
++++ b/simp/Main.cc
+@@ -79,8 +79,12 @@ int main(int argc, char** argv)
+         // printf("This is MiniSat 2.0 beta\n");
+         
+ #if defined(__linux__)
+-        fpu_control_t oldcw, newcw;
+-        _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw);
++        fenv_t fenv;
++
++        fegetenv(&fenv);
++        fenv.__control_word &= ~0x300; /* _FPU_EXTENDED */
++        fenv.__control_word |= 0x200; /* _FPU_DOUBLE */
++        fesetenv(&fenv);
+         printf("WARNING: for repeatability, setting FPU to use double precision\n");
+ #endif
+         // Extra options:
+diff --git a/utils/System.h b/utils/System.h
+index 1758192..c0ad13a 100644
+--- a/utils/System.h
++++ b/utils/System.h
+@@ -22,7 +22,7 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
+ #define Minisat_System_h
+ 
+ #if defined(__linux__)
+-#include <fpu_control.h>
++#include <fenv.h>
+ #endif
+ 
+ #include "mtl/IntTypes.h"
+-- 
+2.14.2
+
diff --git a/nixpkgs/pkgs/applications/science/logic/beluga/default.nix b/nixpkgs/pkgs/applications/science/logic/beluga/default.nix
new file mode 100644
index 000000000000..66cfd306128b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/beluga/default.nix
@@ -0,0 +1,40 @@
+{ lib, fetchFromGitHub, ocamlPackages, rsync }:
+
+ocamlPackages.buildDunePackage rec {
+  pname = "beluga";
+  version = "1.0";
+
+  src = fetchFromGitHub {
+    owner  = "Beluga-lang";
+    repo   = "Beluga";
+    rev    = "v${version}";
+    sha256 = "1ziqjfv8jwidl8lj2mid2shhgqhv31dfh5wad2zxjpvf6038ahsw";
+  };
+
+  useDune2 = true;
+
+  buildInputs = with ocamlPackages; [
+    gen sedlex_2 ocaml_extlib dune-build-info linenoise
+  ];
+
+  postPatch = ''
+    patchShebangs ./TEST ./run_harpoon_test.sh
+  '';
+
+  checkPhase = "./TEST";
+  checkInputs = [ rsync ];
+  doCheck = true;
+
+  postInstall = ''
+    mkdir -p $out/share/emacs/site-lisp/beluga/
+    cp -r tools/beluga-mode.el $out/share/emacs/site-lisp/beluga
+  '';
+
+  meta = with lib; {
+    description = "A functional language for reasoning about formal systems";
+    homepage    = "http://complogic.cs.mcgill.ca/beluga/";
+    license     = licenses.gpl3Plus;
+    maintainers = [ maintainers.bcdarwin ];
+    platforms   = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/bitwuzla/default.nix b/nixpkgs/pkgs/applications/science/logic/bitwuzla/default.nix
new file mode 100644
index 000000000000..a8820b55b746
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/bitwuzla/default.nix
@@ -0,0 +1,67 @@
+{ stdenv
+, fetchFromGitHub
+, lib
+, python3
+, cmake
+, lingeling
+, btor2tools
+, gtest
+, gmp
+, cadical
+, minisat
+, picosat
+, cryptominisat
+, zlib
+, pkg-config
+  # "*** internal error in 'lglib.c': watcher stack overflow" on aarch64-linux
+, withLingeling ? !stdenv.hostPlatform.isAarch64
+}:
+
+stdenv.mkDerivation rec {
+  pname = "bitwuzla";
+  version = "unstable-2021-07-01";
+
+  src = fetchFromGitHub {
+    owner = "bitwuzla";
+    repo = "bitwuzla";
+    rev = "58d720598e359b1fdfec4a469c76f1d1f24db51a";
+    sha256 = "06ymqsdppyixb918161rmbgqvbnarj4nm4az88lkn3ri4gyimw04";
+  };
+
+  nativeBuildInputs = [ cmake pkg-config ];
+  buildInputs = [
+    cadical
+    cryptominisat
+    picosat
+    minisat
+    btor2tools
+    gmp
+    zlib
+  ] ++ lib.optional withLingeling lingeling;
+
+  cmakeFlags = [
+    "-DBUILD_SHARED_LIBS=ON"
+    "-DPicoSAT_INCLUDE_DIR=${lib.getDev picosat}/include/picosat"
+    "-DBtor2Tools_INCLUDE_DIR=${lib.getDev btor2tools}/include/btor2parser"
+    "-DBtor2Tools_LIBRARIES=${lib.getLib btor2tools}/lib/libbtor2parser${stdenv.hostPlatform.extensions.sharedLibrary}"
+  ] ++ lib.optional doCheck "-DTESTING=YES";
+
+  checkInputs = [ python3 gtest ];
+  # two tests fail on darwin and 3 on aarch64-linux
+  doCheck = stdenv.hostPlatform.isLinux && (!stdenv.hostPlatform.isAarch64);
+  preCheck = let
+    var = if stdenv.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH";
+  in
+    ''
+      export ${var}=$(readlink -f lib)
+      patchShebangs ..
+    '';
+
+  meta = with lib; {
+    description = "A SMT solver for fixed-size bit-vectors, floating-point arithmetic, arrays, and uninterpreted functions";
+    homepage = "https://bitwuzla.github.io";
+    license = licenses.mit;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ symphorien ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/boolector/cmake-gtest.patch b/nixpkgs/pkgs/applications/science/logic/boolector/cmake-gtest.patch
new file mode 100644
index 000000000000..61a64d3abbbf
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/boolector/cmake-gtest.patch
@@ -0,0 +1,16 @@
+diff --git a/cmake/googletest-download.cmake b/cmake/googletest-download.cmake
+index 0ec4d558..d0910313 100644
+--- a/cmake/googletest-download.cmake
++++ b/cmake/googletest-download.cmake
+@@ -9,10 +9,7 @@ ExternalProject_Add(
+   googletest
+   SOURCE_DIR "@GOOGLETEST_DOWNLOAD_ROOT@/googletest-src"
+   BINARY_DIR "@GOOGLETEST_DOWNLOAD_ROOT@/googletest-build"
+-  GIT_REPOSITORY
+-    https://github.com/google/googletest.git
+-  GIT_TAG
+-    release-1.10.0
++  URL REPLACEME
+   CONFIGURE_COMMAND ""
+   BUILD_COMMAND ""
+   INSTALL_COMMAND ""
diff --git a/nixpkgs/pkgs/applications/science/logic/boolector/default.nix b/nixpkgs/pkgs/applications/science/logic/boolector/default.nix
new file mode 100644
index 000000000000..74927dd434d0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/boolector/default.nix
@@ -0,0 +1,70 @@
+{ stdenv, fetchFromGitHub, lib, python3, fetchpatch
+, cmake, lingeling, btor2tools, gtest, gmp
+}:
+
+stdenv.mkDerivation rec {
+  pname = "boolector";
+  version = "3.2.2";
+
+  src = fetchFromGitHub {
+    owner  = "boolector";
+    repo   = "boolector";
+    rev    = version;
+    sha256 = "1smcy6yp8wvnw2brgnv5bf40v87k4v4fbdbrhi7987vja632k50z";
+  };
+
+  patches = [
+    # present in master - remove after 3.2.2
+    (fetchpatch {
+      name = "fix-parser-getc-char-casts.patch";
+      url = "https://github.com/Boolector/boolector/commit/cc3a70918538c1e71ea5e7273fa1ac098da37c1b.patch";
+      sha256 = "0pjvagcy74vxa2q75zbshcz8j7rvhl98549xfcf5y8yyxf5h8hyq";
+    })
+  ];
+
+  postPatch = ''
+    sed s@REPLACEME@file://${gtest.src}@ ${./cmake-gtest.patch} | patch -p1
+  '';
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ lingeling btor2tools gmp ];
+
+  cmakeFlags =
+    [ "-DBUILD_SHARED_LIBS=ON"
+      "-DUSE_LINGELING=YES"
+    ] ++ (lib.optional (gmp != null) "-DUSE_GMP=YES");
+
+  checkInputs = [ python3 ];
+  doCheck = true;
+  preCheck =
+    let var = if stdenv.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH";
+    in
+      # tests modelgen and modelgensmt2 spawn boolector in another processes and
+      # macOS strips DYLD_LIBRARY_PATH, hardcode it for testing
+      lib.optionalString stdenv.isDarwin ''
+        cp -r bin bin.back
+        install_name_tool -change libboolector.dylib $(pwd)/lib/libboolector.dylib bin/boolector
+      '' + ''
+        export ${var}=$(readlink -f lib)
+        patchShebangs ..
+      '';
+
+  postCheck = lib.optionalString stdenv.isDarwin ''
+    rm -rf bin
+    mv bin.back bin
+  '';
+
+  # this is what haskellPackages.boolector expects
+  postInstall = ''
+    cp $out/include/boolector/boolector.h $out/include/boolector.h
+    cp $out/include/boolector/btortypes.h $out/include/btortypes.h
+  '';
+
+  meta = with lib; {
+    description = "An extremely fast SMT solver for bit-vectors and arrays";
+    homepage    = "https://boolector.github.io";
+    license     = licenses.mit;
+    platforms   = with platforms; linux ++ darwin;
+    maintainers = with maintainers; [ thoughtpolice ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/btor2tools/default.nix b/nixpkgs/pkgs/applications/science/logic/btor2tools/default.nix
new file mode 100644
index 000000000000..992d8b1de58f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/btor2tools/default.nix
@@ -0,0 +1,33 @@
+{ lib, stdenv, cmake, fetchFromGitHub, fixDarwinDylibNames }:
+
+stdenv.mkDerivation rec {
+  pname = "btor2tools";
+  version = "1.0.0-pre_${src.rev}";
+
+  src = fetchFromGitHub {
+    owner  = "boolector";
+    repo   = "btor2tools";
+    rev    = "9831f9909fb283752a3d6d60d43613173bd8af42";
+    sha256 = "0mfqmkgvyw8fa2c09kww107dmk180ch1hp98r5kv41vnc04iqb0s";
+  };
+
+  nativeBuildInputs = [ cmake ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
+
+  installPhase = ''
+    mkdir -p $out $dev/include/btor2parser/ $lib/lib
+
+    cp -vr bin $out
+    cp -v  ../src/btor2parser/btor2parser.h $dev/include/btor2parser
+    cp -v  lib/libbtor2parser.* $lib/lib
+  '';
+
+  outputs = [ "out" "dev" "lib" ];
+
+  meta = with lib; {
+    description = "A generic parser and tool package for the BTOR2 format";
+    homepage    = "https://github.com/Boolector/btor2tools";
+    license     = licenses.mit;
+    platforms   = platforms.unix;
+    maintainers = with maintainers; [ thoughtpolice ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/cadical/default.nix b/nixpkgs/pkgs/applications/science/logic/cadical/default.nix
new file mode 100644
index 000000000000..c6b1f6652451
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/cadical/default.nix
@@ -0,0 +1,48 @@
+{ lib, stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  pname = "cadical";
+  version = "1.4.1";
+
+  src = fetchFromGitHub {
+    owner = "arminbiere";
+    repo = "cadical";
+    rev = "rel-${version}";
+    sha256 = "0y44z3np4gssgdh4aj5qila7pshrbphycdxn2083i8ayyyjbxshp";
+  };
+
+  outputs = [ "out" "dev" "lib" ];
+  doCheck = true;
+
+  # the configure script is not generated by autotools and does not accept the
+  # arguments that the default configurePhase passes like --prefix and --libdir
+  configurePhase = ''
+    runHook preConfigure
+
+    ./configure
+
+    runHook postConfigure
+  '';
+
+  installPhase = ''
+    runHook preInstall
+
+    install -Dm0755 build/cadical "$out/bin/cadical"
+    install -Dm0755 build/mobical "$out/bin/mobical"
+    install -Dm0644 src/ccadical.h "$dev/include/ccadical.h"
+    install -Dm0644 src/cadical.hpp "$dev/include/cadical.hpp"
+    install -Dm0644 build/libcadical.a "$lib/lib/libcadical.a"
+    mkdir -p "$out/share/doc/${pname}/"
+    install -Dm0755 {LICEN?E,README*,VERSION} "$out/share/doc/${pname}/"
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Simplified Satisfiability Solver";
+    maintainers = with maintainers; [ shnarazk ];
+    platforms = platforms.unix;
+    license = licenses.mit;
+    homepage = "http://fmv.jku.at/cadical";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/cedille/Fix-to-string.agda-to-compile-with-Agda-2.6.1.patch b/nixpkgs/pkgs/applications/science/logic/cedille/Fix-to-string.agda-to-compile-with-Agda-2.6.1.patch
new file mode 100644
index 000000000000..51f1478987eb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/cedille/Fix-to-string.agda-to-compile-with-Agda-2.6.1.patch
@@ -0,0 +1,31 @@
+From 563f023aba1034f4f433f412302b825b059ef5a5 Mon Sep 17 00:00:00 2001
+From: Mark Barbone <mark.l.barbone@gmail.com>
+Date: Sun, 19 Jul 2020 17:24:30 -0400
+Subject: [PATCH] Fix to-string.agda to compile with Agda 2.6.1
+
+---
+Adapted from https://github.com/cedille/cedille/pull/156.
+
+ src/to-string.agda | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/to-string.agda b/src/to-string.agda
+index 2505942..051a2da 100644
+--- a/src/to-string.agda
++++ b/src/to-string.agda
+@@ -100,9 +100,9 @@ no-parens {TK} _ _ _ = tt
+ no-parens {QUALIF} _ _ _ = tt
+ no-parens {ARG} _ _ _ = tt
+ 
+-pattern ced-ops-drop-spine = cedille-options.options.mk-options _ _ _ _ ff _ _ _ ff _
+-pattern ced-ops-conv-arr = cedille-options.options.mk-options _ _ _ _ _ _ _ _ ff _
+-pattern ced-ops-conv-abs = cedille-options.options.mk-options _ _ _ _ _ _ _ _ tt _
++pattern ced-ops-drop-spine = cedille-options.mk-options _ _ _ _ ff _ _ _ ff _
++pattern ced-ops-conv-arr = cedille-options.mk-options _ _ _ _ _ _ _ _ ff _
++pattern ced-ops-conv-abs = cedille-options.mk-options _ _ _ _ _ _ _ _ tt _
+ 
+ drop-spine : cedille-options.options → {ed : exprd} → ctxt → ⟦ ed ⟧ → ⟦ ed ⟧
+ drop-spine ops @ ced-ops-drop-spine = h
+-- 
+2.27.0
+
diff --git a/nixpkgs/pkgs/applications/science/logic/cedille/default.nix b/nixpkgs/pkgs/applications/science/logic/cedille/default.nix
new file mode 100644
index 000000000000..611bbbe979f8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/cedille/default.nix
@@ -0,0 +1,61 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, alex
+, happy
+, Agda
+, buildPlatform
+, buildPackages
+, ghcWithPackages
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.1.2";
+  pname = "cedille";
+
+  src = fetchFromGitHub {
+    owner = "cedille";
+    repo = "cedille";
+    rev = "v${version}";
+    sha256 = "1j745q9sd32fhcb96wjq6xvyqq1k6imppjnya6x0n99fyfnqzvg9";
+    fetchSubmodules = true;
+  };
+
+  patches = [
+    ./Fix-to-string.agda-to-compile-with-Agda-2.6.1.patch
+  ];
+
+  nativeBuildInputs = [ alex happy ];
+  buildInputs = [ Agda (ghcWithPackages (ps: [ps.ieee])) ];
+
+  LANG = "en_US.UTF-8";
+  LOCALE_ARCHIVE =
+    lib.optionalString (buildPlatform.libc == "glibc")
+      "${buildPackages.glibcLocales}/lib/locale/locale-archive";
+
+  postPatch = ''
+    patchShebangs create-libraries.sh
+  '';
+
+  installPhase = ''
+    install -Dm755 -t $out/bin/ cedille
+    install -Dm755 -t $out/bin/ core/cedille-core
+    install -Dm644 -t $out/share/info docs/info/cedille-info-main.info
+
+    mkdir -p $out/lib/
+    cp -r lib/ $out/lib/cedille/
+  '';
+
+  meta = with lib; {
+    description = "An interactive theorem-prover and dependently typed programming language, based on extrinsic (aka Curry-style) type theory";
+    homepage = "https://cedille.github.io/";
+    license = licenses.mit;
+    maintainers = with maintainers; [ marsam mpickering ];
+    platforms = platforms.unix;
+
+    # Broken due to Agda update.  See
+    # https://github.com/NixOS/nixpkgs/pull/129606#issuecomment-881107449.
+    broken = true;
+    hydraPlatforms = platforms.none;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/celf/default.nix b/nixpkgs/pkgs/applications/science/logic/celf/default.nix
new file mode 100644
index 000000000000..044a6f3ca1c4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/celf/default.nix
@@ -0,0 +1,36 @@
+{ lib, stdenv, fetchFromGitHub, smlnj }:
+
+stdenv.mkDerivation rec {
+  pname = "celf";
+  pversion = "2013-07-25";
+  name = "${pname}-${pversion}";
+
+  src = fetchFromGitHub {
+    owner  = "clf";
+    repo   = pname;
+    rev    = "d61d95900ab316468ae850fa34a2fe9488bc5b59";
+    sha256 = "0slrwcxglp0sdbp6wr65cdkl5wcap2i0fqxbwqfi1q3cpb6ph6hq";
+  };
+
+  buildInputs = [ smlnj ];
+
+  # (can also build with MLton)
+  buildPhase = ''
+    export SMLNJ_HOME=${smlnj}
+    sml < main-export.sml
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp .heap* $out/bin/
+    ./.mkexec ${smlnj}/bin/sml $out/bin celf
+  '';
+
+  meta = with lib; {
+    description = "Linear logic programming system";
+    homepage = "https://github.com/clf/celf";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/clprover/clprover.nix b/nixpkgs/pkgs/applications/science/logic/clprover/clprover.nix
new file mode 100644
index 000000000000..2a8c058a80bb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/clprover/clprover.nix
@@ -0,0 +1,27 @@
+{ lib, stdenv, fetchzip }:
+
+stdenv.mkDerivation {
+  pname = "clprover";
+  version = "1.0.3";
+
+  src = fetchzip {
+    url = "https://cgi.csc.liv.ac.uk/~ullrich/CLProver++/CLProver++-v1.0.3-18-04-2015.zip";
+    sha256 = "10kmlg4m572qwfzi6hkyb0ypb643xw8sfb55xx7866lyh37w1q3s";
+    stripRoot = false;
+  };
+
+  installPhase = ''
+    mkdir $out
+    cp -r bin $out/bin
+    mkdir -p $out/share/clprover
+    cp -r examples $out/share/clprover/examples
+  '';
+
+  meta = with lib; {
+    description = "Resolution-based theorem prover for Coalition Logic implemented in C++";
+    homepage = "https://cgi.csc.liv.ac.uk/~ullrich/CLProver++/";
+    license = licenses.gpl3; # Note that while the website states that it is GPLv2 but the file in the zip as well as the comments in the source state it is GPLv3
+    maintainers = with maintainers; [ mgttlinger ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/coq/default.nix b/nixpkgs/pkgs/applications/science/logic/coq/default.nix
new file mode 100644
index 000000000000..29959be2fa97
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/coq/default.nix
@@ -0,0 +1,212 @@
+# - coqide compilation can be disabled by setting buildIde to false
+# - The csdp program used for the Micromega tactic is statically referenced.
+#   However, coq can build without csdp by setting it to null.
+#   In this case some Micromega tactics will search the user's path for the csdp program and will fail if it is not found.
+# - The exact version can be specified through the `version` argument to
+#   the derivation; it defaults to the latest stable version.
+
+{ lib, stdenv, fetchzip, writeText, pkg-config, gnumake42
+, customOCamlPackages ? null
+, ocamlPackages_4_05, ocamlPackages_4_09, ocamlPackages_4_10, ocamlPackages_4_12, ncurses
+, buildIde ? true
+, glib, gnome, wrapGAppsHook, makeDesktopItem, copyDesktopItems
+, csdp ? null
+, version, coq-version ? null,
+}@args:
+let lib' = lib; in
+let lib = import ../../../../build-support/coq/extra-lib.nix {lib = lib';}; in
+with builtins; with lib;
+let
+  release = {
+   "8.5pl1".sha256     = "1976ki5xjg2r907xj9p7gs0kpdinywbwcqlgxqw75dgp0hkgi00n";
+   "8.5pl2".sha256     = "109rrcrx7mz0fj7725kjjghfg5ydwb24hjsa5hspa27b4caah7rh";
+   "8.5pl3".sha256     = "15c3rdk59nifzihsp97z4vjxis5xmsnrvpb86qiazj143z2fmdgw";
+   "8.6.0".sha256      = "148mb48zpdax56c0blfi7v67lx014lnmrvxxasi28hsibyz2lvg4";
+   "8.6.0".rev         = "V8.6";
+   "8.6.1".sha256      = "0llrxcxwy5j87vbbjnisw42rfw1n1pm5602ssx64xaxx3k176g6l";
+   "8.7.0".sha256      = "1h18b7xpnx3ix9vsi5fx4zdcbxy7bhra7gd5c5yzxmk53cgf1p9m";
+   "8.7.1".sha256      = "0gjn59jkbxwrihk8fx9d823wjyjh5m9gvj9l31nv6z6bcqhgdqi8";
+   "8.7.2".sha256      = "0a0657xby8wdq4aqb2xsxp3n7pmc2w4yxjmrb2l4kccs1aqvaj4w";
+   "8.8.0".sha256      = "13a4fka22hdxsjk11mgjb9ffzplfxyxp1sg5v1c8nk1grxlscgw8";
+   "8.8.1".sha256      = "1hlf58gwazywbmfa48219amid38vqdl94yz21i11b4map6jfwhbk";
+   "8.8.2".sha256      = "1lip3xja924dm6qblisk1bk0x8ai24s5xxqxphbdxj6djglj68fd";
+   "8.9.0".sha256      = "1dkgdjc4n1m15m1p724hhi5cyxpqbjw6rxc5na6fl3v4qjjfnizh";
+   "8.9.1".sha256      = "1xrq6mkhpq994bncmnijf8jwmwn961kkpl4mwwlv7j3dgnysrcv2";
+   "8.10.0".sha256     = "138jw94wp4mg5dgjc2asn8ng09ayz1mxdznq342n0m469j803gzg";
+   "8.10.1".sha256     = "072v2zkjzf7gj48137wpr3c9j0hg9pdhlr5l8jrgrwynld8fp7i4";
+   "8.10.2".sha256     = "0znxmpy71bfw0p6x47i82jf5k7v41zbz9bdpn901ysn3ir8l3wrz";
+   "8.11.0".sha256     = "1rfdic6mp7acx2zfwz7ziqk12g95bl9nyj68z4n20a5bcjv2pxpn";
+   "8.11.1".sha256     = "0qriy9dy36dajsv5qmli8gd6v55mah02ya334nw49ky19v7518m0";
+   "8.11.2".sha256     = "0f77ccyxdgbf1nrj5fa8qvrk1cyfy06fv8gj9kzfvlcgn0cf48sa";
+   "8.12.0".sha256     = "18dc7k0piv6v064zgdadpw6mkkxk7j663hb3svgj5236fihjr0cz";
+   "8.12.1".sha256     = "1rkcyjjrzcqw9xk93hsq0vvji4f8r5iq0f739mghk60bghkpnb7q";
+   "8.12.2".sha256     = "18gscfm039pqhq4msq01nraig5dm9ab98bjca94zldf8jvdv0x2n";
+   "8.13.0".sha256     = "0sjbqmz6qcvnz0hv87xha80qbhvmmyd675wyc5z4rgr34j2l1ymd";
+   "8.13.1".sha256     = "0xx2ns84mlip9bg2mkahy3pmc5zfcgrjxsviq9yijbzy1r95wf0n";
+   "8.13.2".sha256     = "1884vbmwmqwn9ngibax6dhnqh4cc02l0s2ajc6jb1xgr0i60whjk";
+   "8.14.0".sha256     = "04y2z0qyvag66zanfyc3f9agvmzbn4lsr0p1l7ck6yjhqx7vbm17";
+   "8.14.1".sha256     = "0sx78pgx0qw8v7v2r32zzy3l161zipzq95iacda628girim7psnl";
+   "8.15.0".sha256     = "sha256:1ma76wfrpfsl72yh10w1ys2a0vi0mdc2jc79kdc8nrmxkhpw1nxx";
+  };
+  releaseRev = v: "V${v}";
+  fetched = import ../../../../build-support/coq/meta-fetch/default.nix
+    { inherit lib stdenv fetchzip; }
+    { inherit release releaseRev; location = { owner = "coq"; repo = "coq";}; }
+    args.version;
+  version = fetched.version;
+  coq-version = args.coq-version or (if version != "dev" then versions.majorMinor version else "dev");
+  versionAtLeast = v: (coq-version == "dev") || (lib.versionAtLeast coq-version v);
+  ideFlags = optionalString (buildIde && !versionAtLeast "8.10")
+    "-lablgtkdir ${ocamlPackages.lablgtk}/lib/ocaml/*/site-lib/lablgtk2 -coqide opt";
+  csdpPatch = if csdp != null then ''
+    substituteInPlace plugins/micromega/sos.ml --replace "; csdp" "; ${csdp}/bin/csdp"
+    substituteInPlace plugins/micromega/coq_micromega.ml --replace "System.is_in_system_path \"csdp\"" "true"
+  '' else "";
+  ocamlPackages = if !isNull customOCamlPackages then customOCamlPackages
+    else with versions; switch coq-version [
+      { case = range "8.14" "8.14"; out = ocamlPackages_4_12; }
+      { case = range "8.11" "8.13"; out = ocamlPackages_4_10; }
+      { case = range "8.7" "8.10";  out = ocamlPackages_4_09; }
+      { case = range "8.5" "8.6";   out = ocamlPackages_4_05; }
+    ] ocamlPackages_4_12;
+  ocamlNativeBuildInputs = [ ocamlPackages.ocaml ocamlPackages.findlib ]
+    ++ optional (versionAtLeast "8.14") ocamlPackages.dune_2;
+  ocamlBuildInputs = []
+    ++ optional (!versionAtLeast "8.10") ocamlPackages.camlp5
+    ++ optional (!versionAtLeast "8.13") ocamlPackages.num
+    ++ optional (versionAtLeast "8.13") ocamlPackages.zarith;
+self = stdenv.mkDerivation {
+  pname = "coq";
+  inherit (fetched) version src;
+
+  passthru = {
+    inherit coq-version;
+    inherit ocamlPackages ocamlBuildInputs ocamlNativeBuildInputs;
+    # For compatibility
+    inherit (ocamlPackages) ocaml camlp5 findlib num ;
+    emacsBufferSetup = pkgs: ''
+      ; Propagate coq paths to children
+      (inherit-local-permanent coq-prog-name "${self}/bin/coqtop")
+      (inherit-local-permanent coq-dependency-analyzer "${self}/bin/coqdep")
+      (inherit-local-permanent coq-compiler "${self}/bin/coqc")
+      ; If the coq-library path was already set, re-set it based on our current coq
+      (when (fboundp 'get-coq-library-directory)
+        (inherit-local-permanent coq-library-directory (get-coq-library-directory))
+        (coq-prog-args))
+      (mapc (lambda (arg)
+        (when (file-directory-p (concat arg "/lib/coq/${coq-version}/user-contrib"))
+          (setenv "COQPATH" (concat (getenv "COQPATH") ":" arg "/lib/coq/${coq-version}/user-contrib")))) '(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)}))
+      ; TODO Abstract this pattern from here and nixBufferBuilders.withPackages!
+      (defvar nixpkgs--coq-buffer-count 0)
+      (when (eq nixpkgs--coq-buffer-count 0)
+        (make-variable-buffer-local 'nixpkgs--is-nixpkgs-coq-buffer)
+        (defun nixpkgs--coq-inherit (buf)
+          (inherit-local-inherit-child buf)
+          (with-current-buffer buf
+            (setq nixpkgs--coq-buffer-count (1+ nixpkgs--coq-buffer-count))
+            (add-hook 'kill-buffer-hook 'nixpkgs--decrement-coq-buffer-count nil t))
+          buf)
+        ; When generating a scomint buffer, do inherit-local inheritance and make it a nixpkgs-coq buffer
+        (defun nixpkgs--around-scomint-make (orig &rest r)
+          (if nixpkgs--is-nixpkgs-coq-buffer
+              (progn
+                (advice-add 'get-buffer-create :filter-return #'nixpkgs--coq-inherit)
+                (apply orig r)
+                (advice-remove 'get-buffer-create #'nixpkgs--coq-inherit))
+            (apply orig r)))
+        (advice-add 'scomint-make :around #'nixpkgs--around-scomint-make)
+        ; When we have no more coq buffers, tear down the buffer handling
+        (defun nixpkgs--decrement-coq-buffer-count ()
+          (setq nixpkgs--coq-buffer-count (1- nixpkgs--coq-buffer-count))
+          (when (eq nixpkgs--coq-buffer-count 0)
+            (advice-remove 'scomint-make #'nixpkgs--around-scomint-make)
+            (fmakunbound 'nixpkgs--around-scomint-make)
+            (fmakunbound 'nixpkgs--coq-inherit)
+            (fmakunbound 'nixpkgs--decrement-coq-buffer-count))))
+      (setq nixpkgs--coq-buffer-count (1+ nixpkgs--coq-buffer-count))
+      (add-hook 'kill-buffer-hook 'nixpkgs--decrement-coq-buffer-count nil t)
+      (setq nixpkgs--is-nixpkgs-coq-buffer t)
+      (inherit-local 'nixpkgs--is-nixpkgs-coq-buffer)
+    '';
+  };
+
+  nativeBuildInputs = [ pkg-config ]
+    ++ ocamlNativeBuildInputs
+    ++ optional buildIde copyDesktopItems
+    ++ optional (buildIde && versionAtLeast "8.10") wrapGAppsHook
+    ++ optional (!versionAtLeast "8.6") gnumake42;
+  buildInputs = [ ncurses ] ++ ocamlBuildInputs
+    ++ optionals buildIde
+      (if versionAtLeast "8.10"
+       then [ ocamlPackages.lablgtk3-sourceview3 glib gnome.adwaita-icon-theme ]
+       else [ ocamlPackages.lablgtk ])
+  ;
+
+  postPatch = ''
+    UNAME=$(type -tp uname)
+    RM=$(type -tp rm)
+    substituteInPlace tools/beautify-archive --replace "/bin/rm" "$RM"
+    ${if !versionAtLeast "8.7" then "substituteInPlace configure.ml --replace \"md5 -q\" \"md5sum\"" else ""}
+    ${csdpPatch}
+  '';
+
+  setupHook = writeText "setupHook.sh" ''
+    addCoqPath () {
+      if test -d "''$1/lib/coq/${coq-version}/user-contrib"; then
+        export COQPATH="''${COQPATH-}''${COQPATH:+:}''$1/lib/coq/${coq-version}/user-contrib/"
+      fi
+    }
+
+    addEnvHooks "$targetOffset" addCoqPath
+  '';
+
+  preConfigure = if versionAtLeast "8.10" then ''
+    patchShebangs dev/tools/
+  '' else ''
+    configureFlagsArray=(
+      ${ideFlags}
+    )
+  '';
+
+  prefixKey = "-prefix ";
+
+  buildFlags = [ "revision" "coq" ] ++ optional buildIde "coqide" ++ optional (!versionAtLeast "8.14") "bin/votour";
+  enableParallelBuilding = true;
+
+  createFindlibDestdir = true;
+
+  desktopItems = optional buildIde (makeDesktopItem {
+    name = "coqide";
+    exec = "coqide";
+    icon = "coq";
+    desktopName = "CoqIDE";
+    comment = "Graphical interface for the Coq proof assistant";
+    categories = [ "Development" "Science" "Math" "IDE" "GTK" ];
+  });
+
+  postInstall = let suffix = if versionAtLeast "8.14" then "-core" else ""; in ''
+    cp bin/votour $out/bin/
+    ln -s $out/lib/coq${suffix} $OCAMLFIND_DESTDIR/coq${suffix}
+  '' + optionalString (versionAtLeast "8.14") ''
+    ln -s $out/lib/coqide-server $OCAMLFIND_DESTDIR/coqide-server
+  '' + optionalString buildIde ''
+    mkdir -p "$out/share/pixmaps"
+    ln -s "$out/share/coq/coq.png" "$out/share/pixmaps/"
+  '';
+
+  meta = {
+    description = "Coq proof assistant";
+    longDescription = ''
+      Coq is a formal proof management system.  It provides a formal language
+      to write mathematical definitions, executable algorithms and theorems
+      together with an environment for semi-interactive development of
+      machine-checked proofs.
+    '';
+    homepage = "http://coq.inria.fr";
+    license = licenses.lgpl21;
+    branch = coq-version;
+    maintainers = with maintainers; [ roconnor thoughtpolice vbgl Zimmi48 ];
+    platforms = platforms.unix;
+    mainProgram = "coqide";
+  };
+}; in self
diff --git a/nixpkgs/pkgs/applications/science/logic/cryptominisat/default.nix b/nixpkgs/pkgs/applications/science/logic/cryptominisat/default.nix
new file mode 100644
index 000000000000..33de2d27dc90
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/cryptominisat/default.nix
@@ -0,0 +1,32 @@
+{ lib, stdenv, fetchFromGitHub, cmake, python3, xxd, boost, fetchpatch }:
+
+stdenv.mkDerivation rec {
+  pname = "cryptominisat";
+  version = "5.8.0";
+
+  src = fetchFromGitHub {
+    owner  = "msoos";
+    repo   = "cryptominisat";
+    rev    = version;
+    sha256 = "00hmxdlyhn7pwk9jlvc5g0l5z5xqfchjzf5jgn3pkj9xhl8yqq50";
+  };
+
+  patches = [
+    (fetchpatch {
+      # https://github.com/msoos/cryptominisat/pull/621
+      url = "https://github.com/msoos/cryptominisat/commit/11a97003b0bfbfb61ed6c4e640212110d390c28c.patch";
+      sha256 = "0hdy345bwcbxz0jl1jdxfa6mmfh77s2pz9rnncsr0jzk11b3j0cw";
+    })
+  ];
+
+  buildInputs = [ python3 boost ];
+  nativeBuildInputs = [ cmake xxd ];
+
+  meta = with lib; {
+    description = "An advanced SAT Solver";
+    homepage    = "https://github.com/msoos/cryptominisat";
+    license     = licenses.mit;
+    maintainers = with maintainers; [ mic92 ];
+    platforms   = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/cryptoverif/default.nix b/nixpkgs/pkgs/applications/science/logic/cryptoverif/default.nix
new file mode 100644
index 000000000000..195dd98aa3b4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/cryptoverif/default.nix
@@ -0,0 +1,37 @@
+{ lib, stdenv, fetchurl, ocaml }:
+
+stdenv.mkDerivation rec {
+  pname = "cryptoverif";
+  version = "2.05";
+
+  src = fetchurl {
+    url    = "http://prosecco.gforge.inria.fr/personal/bblanche/cryptoverif/cryptoverif${version}.tar.gz";
+    sha256 = "sha256-F5eVN5ATYo9Ivpi2eYh96ktuTWUeoqgWMR4BqHu8EFs=";
+  };
+
+  buildInputs = [ ocaml ];
+
+  /* Fix up the frontend to load the 'default' cryptoverif library
+  ** from under $out/libexec. By default, it expects to find the files
+  ** in $CWD which doesn't work. */
+  patchPhase = ''
+    substituteInPlace ./src/syntax.ml \
+      --replace \"default\" \"$out/libexec/default\"
+  '';
+
+  buildPhase = "./build";
+  installPhase = ''
+    mkdir -p $out/bin $out/libexec
+    cp ./cryptoverif   $out/bin
+    cp ./default.cvl   $out/libexec
+    cp ./default.ocvl  $out/libexec
+  '';
+
+  meta = {
+    description = "Cryptographic protocol verifier in the computational model";
+    homepage    = "https://prosecco.gforge.inria.fr/personal/bblanche/cryptoverif/";
+    license     = lib.licenses.cecill-b;
+    platforms   = lib.platforms.unix;
+    maintainers = [ lib.maintainers.thoughtpolice ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/cubicle/default.nix b/nixpkgs/pkgs/applications/science/logic/cubicle/default.nix
new file mode 100644
index 000000000000..aa3fba635ffc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/cubicle/default.nix
@@ -0,0 +1,24 @@
+{ lib, stdenv, fetchurl, ocamlPackages }:
+
+stdenv.mkDerivation rec {
+  pname = "cubicle";
+  version = "1.1.2";
+  src = fetchurl {
+    url = "http://cubicle.lri.fr/cubicle-${version}.tar.gz";
+    sha256 = "10kk80jdmpdvql88sdjsh7vqzlpaphd8vip2lp47aarxjkwjlz1q";
+  };
+
+  postPatch = ''
+    substituteInPlace Makefile.in --replace "\\n" ""
+  '';
+
+  buildInputs = with ocamlPackages; [ ocaml findlib functory ];
+
+  meta = with lib; {
+    description = "An open source model checker for verifying safety properties of array-based systems";
+    homepage = "http://cubicle.lri.fr/";
+    license = licenses.asl20;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ dwarfmaster ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/cvc3/cvc3-2.4.1-gccv6-fix.patch b/nixpkgs/pkgs/applications/science/logic/cvc3/cvc3-2.4.1-gccv6-fix.patch
new file mode 100644
index 000000000000..1fb3516b8c27
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/cvc3/cvc3-2.4.1-gccv6-fix.patch
@@ -0,0 +1,76 @@
+commit 4eb28b907e89be05d92eb704115f821b9b848e60
+Author: Matthew Dawson <matthew@mjdsystems.ca>
+Date:   Sun Oct 16 22:06:03 2016 -0400
+
+    Fix gcc v6 compile failures.
+    
+     * Use std::hash<const char*> over std::hash<char *>, as throwing away the const is not allowed.
+     * Use Hash::hash by default in CDMap over std::hash, to get Hash::hash<CVC3::expr>
+
+diff --git a/src/expr/expr_value.cpp b/src/expr/expr_value.cpp
+index 0c85ff6..e4dd251 100644
+--- a/src/expr/expr_value.cpp
++++ b/src/expr/expr_value.cpp
+@@ -29,7 +29,7 @@ namespace CVC3 {
+ // Class ExprValue static members
+ ////////////////////////////////////////////////////////////////////////
+ 
+-std::hash<char*> ExprValue::s_charHash;
++std::hash<const char*> ExprValue::s_charHash;
+ std::hash<long int> ExprValue::s_intHash;
+ 
+ ////////////////////////////////////////////////////////////////////////
+diff --git a/src/include/cdmap.h b/src/include/cdmap.h
+index faf682a..c3b094c 100644
+--- a/src/include/cdmap.h
++++ b/src/include/cdmap.h
+@@ -43,9 +43,9 @@ namespace CVC3 {
+ // Auxiliary class: almost the same as CDO (see cdo.h), but on
+ // setNull() call it erases itself from the map.
+ 
+-template <class Key, class Data, class HashFcn = std::hash<Key> > class CDMap;
++template <class Key, class Data, class HashFcn = Hash::hash<Key> > class CDMap;
+ 
+-template <class Key, class Data, class HashFcn = std::hash<Key> >
++template <class Key, class Data, class HashFcn = Hash::hash<Key> >
+ class CDOmap :public ContextObj {
+   Key d_key;
+   Data d_data;
+diff --git a/src/include/expr_hash.h b/src/include/expr_hash.h
+index b2107d7..baa2eab 100644
+--- a/src/include/expr_hash.h
++++ b/src/include/expr_hash.h
+@@ -20,7 +20,6 @@
+  * hash_set over Expr class.
+  */
+ /*****************************************************************************/
+-
+ #ifndef _cvc3__expr_h_
+ #include "expr.h"
+ #endif
+diff --git a/src/include/expr_value.h b/src/include/expr_value.h
+index 95102b2..f53aa4d 100644
+--- a/src/include/expr_value.h
++++ b/src/include/expr_value.h
+@@ -179,7 +179,7 @@ protected:
+   // Static hash functions.  They don't depend on the context
+   // (ExprManager and such), so it is still thread-safe to have them
+   // static.
+-  static std::hash<char*> s_charHash;
++  static std::hash<const char*> s_charHash;
+   static std::hash<long int> s_intHash;
+ 
+   static size_t pointerHash(void* p) { return s_intHash((long int)p); }
+diff --git a/src/theory_core/theory_core.cpp b/src/theory_core/theory_core.cpp
+index df5289f..37ccab9 100644
+--- a/src/theory_core/theory_core.cpp
++++ b/src/theory_core/theory_core.cpp
+@@ -710,7 +710,7 @@ TheoryCore::TheoryCore(ContextManager* cm,
+     //    d_termTheorems(cm->getCurrentContext()),
+     d_predicates(cm->getCurrentContext()),
+     d_solver(NULL),
+-    d_simplifyInPlace(false),
++    d_simplifyInPlace(NULL),
+     d_currentRecursiveSimplifier(NULL),
+     d_resourceLimit(0),
+     d_timeBase(0),
diff --git a/nixpkgs/pkgs/applications/science/logic/cvc3/default.nix b/nixpkgs/pkgs/applications/science/logic/cvc3/default.nix
new file mode 100644
index 000000000000..63efe0a2d05b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/cvc3/default.nix
@@ -0,0 +1,39 @@
+{ lib, stdenv, fetchurl, flex, bison, gmp, perl }:
+
+stdenv.mkDerivation rec {
+    pname = "cvc3";
+    version = "2.4.1";
+
+    src = fetchurl {
+      url = "http://www.cs.nyu.edu/acsys/cvc3/releases/${version}/${pname}-${version}.tar.gz";
+      sha256 = "1xxcwhz3y6djrycw8sm6xz83wb4hb12rd1n0skvc7fng0rh1snym";
+    };
+
+  buildInputs = [ gmp flex bison perl ];
+
+  patches = [ ./cvc3-2.4.1-gccv6-fix.patch ];
+
+  postPatch = ''
+    sed -e "s@ /bin/bash@bash@g" -i Makefile.std
+    find . -exec sed -e "s@/usr/bin/perl@${perl}/bin/perl@g" -i '{}' ';'
+
+    # bison 3.7 workaround
+    for f in parsePL parseLisp parsesmtlib parsesmtlib2 ; do
+      ln -s ../parser/''${f}_defs.h src/include/''${f}.hpp
+    done
+  '';
+
+  meta = with lib; {
+    description = "A prover for satisfiability modulo theory (SMT)";
+    maintainers = with maintainers;
+      [ raskin ];
+    platforms = platforms.unix;
+    license = licenses.free;
+    homepage = "http://www.cs.nyu.edu/acsys/cvc3/index.html";
+  };
+  passthru = {
+    updateInfo = {
+      downloadPage = "http://www.cs.nyu.edu/acsys/cvc3/download.html";
+    };
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/cvc4/default.nix b/nixpkgs/pkgs/applications/science/logic/cvc4/default.nix
new file mode 100644
index 000000000000..b0b3e5e610e6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/cvc4/default.nix
@@ -0,0 +1,45 @@
+{ lib, stdenv, fetchFromGitHub, cmake, cln, gmp, git, swig, pkg-config
+, readline, libantlr3c, boost, jdk, python3, antlr3_4
+}:
+
+stdenv.mkDerivation rec {
+  pname = "cvc4";
+  version = "1.8";
+
+  src = fetchFromGitHub {
+    owner  = "cvc4";
+    repo   = "cvc4";
+    rev    = version;
+    sha256 = "1rhs4pvzaa1wk00czrczp58b2cxfghpsnq534m0l3snnya2958jp";
+  };
+
+  nativeBuildInputs = [ pkg-config cmake ];
+  buildInputs = [ gmp git python3.pkgs.toml cln readline swig libantlr3c antlr3_4 boost jdk python3 ];
+  configureFlags = [
+    "--enable-language-bindings=c,c++,java"
+    "--enable-gpl"
+    "--with-cln"
+    "--with-readline"
+    "--with-boost=${boost.dev}"
+  ];
+
+  prePatch = ''
+    patch -p1 -i ${./minisat-fenv.patch} -d src/prop/minisat
+    patch -p1 -i ${./minisat-fenv.patch} -d src/prop/bvminisat
+  '';
+
+  preConfigure = ''
+    patchShebangs ./src/
+  '';
+  cmakeFlags = [
+    "-DCMAKE_BUILD_TYPE=Production"
+  ];
+
+  meta = with lib; {
+    description = "A high-performance theorem prover and SMT solver";
+    homepage    = "http://cvc4.cs.stanford.edu/web/";
+    license     = licenses.gpl3;
+    platforms   = platforms.unix;
+    maintainers = with maintainers; [ vbgl thoughtpolice gebner ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/cvc4/minisat-fenv.patch b/nixpkgs/pkgs/applications/science/logic/cvc4/minisat-fenv.patch
new file mode 100644
index 000000000000..686d5a1c5b49
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/cvc4/minisat-fenv.patch
@@ -0,0 +1,65 @@
+From 7f1016ceab9b0f57a935bd51ca6df3d18439b472 Mon Sep 17 00:00:00 2001
+From: Will Dietz <w@wdtz.org>
+Date: Tue, 17 Oct 2017 22:57:02 -0500
+Subject: [PATCH] use fenv instead of non-standard fpu_control
+
+---
+ core/Main.cc   | 8 ++++++--
+ simp/Main.cc   | 8 ++++++--
+ utils/System.h | 2 +-
+ 3 files changed, 13 insertions(+), 5 deletions(-)
+
+diff --git a/core/Main.cc b/core/Main.cc
+index 2b0d97b..8ad95fb 100644
+--- a/core/Main.cc
++++ b/core/Main.cc
+@@ -78,8 +78,12 @@ int main(int argc, char** argv)
+         // printf("This is MiniSat 2.0 beta\n");
+         
+ #if defined(__linux__)
+-        fpu_control_t oldcw, newcw;
+-        _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw);
++        fenv_t fenv;
++
++        fegetenv(&fenv);
++        fenv.__control_word &= ~0x300; /* _FPU_EXTENDED */
++        fenv.__control_word |= 0x200; /* _FPU_DOUBLE */
++        fesetenv(&fenv);
+         printf("WARNING: for repeatability, setting FPU to use double precision\n");
+ #endif
+         // Extra options:
+diff --git a/simp/Main.cc b/simp/Main.cc
+index 2804d7f..39bfb71 100644
+--- a/simp/Main.cc
++++ b/simp/Main.cc
+@@ -79,8 +79,12 @@ int main(int argc, char** argv)
+         // printf("This is MiniSat 2.0 beta\n");
+         
+ #if defined(__linux__)
+-        fpu_control_t oldcw, newcw;
+-        _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw);
++        fenv_t fenv;
++
++        fegetenv(&fenv);
++        fenv.__control_word &= ~0x300; /* _FPU_EXTENDED */
++        fenv.__control_word |= 0x200; /* _FPU_DOUBLE */
++        fesetenv(&fenv);
+         printf("WARNING: for repeatability, setting FPU to use double precision\n");
+ #endif
+         // Extra options:
+diff --git a/utils/System.h b/utils/System.h
+index 1758192..c0ad13a 100644
+--- a/utils/System.h
++++ b/utils/System.h
+@@ -22,7 +22,7 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
+ #define Minisat_System_h
+ 
+ #if defined(__linux__)
+-#include <fpu_control.h>
++#include <fenv.h>
+ #endif
+ 
+ #include "mtl/IntTypes.h"
+-- 
+2.14.2
+
diff --git a/nixpkgs/pkgs/applications/science/logic/drat-trim/default.nix b/nixpkgs/pkgs/applications/science/logic/drat-trim/default.nix
new file mode 100644
index 000000000000..c58a29dc2894
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/drat-trim/default.nix
@@ -0,0 +1,45 @@
+{ lib, stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation {
+  pname = "drat-trim-unstable";
+  version = "2020-06-05";
+
+  src = fetchFromGitHub {
+    owner = "marijnheule";
+    repo = "drat-trim";
+    rev = "9afad0f7156a1e9c6ce19dce5d72cf1cb9a3ef27";
+    sha256 = "1zq585igfaknwqbvv2cji744016zxadbvr0ifr5l6yq13m0vvn3b";
+  };
+
+  postPatch = ''
+    substituteInPlace Makefile --replace gcc cc
+  '';
+
+  installPhase = ''
+    install -Dt $out/bin drat-trim lrat-check
+  '';
+
+  meta = with lib; {
+    description = "A proof checker for unSAT proofs";
+    longDescription = ''
+      DRAT-trim is a satisfiability proof checking and trimming
+      utility designed to validate proofs for all known satisfiability
+      solving and preprocessing techniques.  DRAT-trim can also emit
+      trimmed formulas, optimized proofs, and TraceCheck+ dependency
+      graphs.
+
+      DRAT-trim has been used as part of the judging process in the
+      annual SAT Competition in recent years, in order to check
+      competing SAT solvers' work when they claim that a SAT instance
+      is unsatisfiable.
+
+      This package also contains the related tool LRAT-check, which checks a
+      proof format called LRAT which extends DRAT with hint statements to speed
+      up the checking process.
+    '';
+    homepage = "https://www.cs.utexas.edu/~marijn/drat-trim/";
+    license = licenses.mit;
+    maintainers = with maintainers; [ kini ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/ekrhyper/default.nix b/nixpkgs/pkgs/applications/science/logic/ekrhyper/default.nix
new file mode 100644
index 000000000000..d6d9bb11a9a0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/ekrhyper/default.nix
@@ -0,0 +1,26 @@
+{ lib, stdenv, fetchurl, ocaml, perl }:
+
+stdenv.mkDerivation rec {
+  pname = "ekrhyper";
+  version = "1_4_21022014";
+
+  src = fetchurl {
+    url = "http://userpages.uni-koblenz.de/~bpelzer/ekrhyper/ekrh_${version}.tar.gz";
+    sha256 = "sha256-fEe0DIMGj7wO+79/BZf45kykgyTXpbZJsyFSt31XqpM=";
+  };
+
+  buildInputs = [
+    ocaml
+    perl
+  ];
+  setSourceRoot = "export sourceRoot=$(echo */ekrh/src/)";
+  preInstall = "export INSTALLDIR=$out";
+  postInstall = ''for i in "$out/casc"/*; do ln -s "$i" "$out/bin/ekrh-casc-$(basename $i)"; done '';
+
+  meta = with lib; {
+    description = "Automated first-order theorem prover";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ raskin ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/elan/0001-dynamically-patchelf-binaries.patch b/nixpkgs/pkgs/applications/science/logic/elan/0001-dynamically-patchelf-binaries.patch
new file mode 100644
index 000000000000..768be10b6df3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/elan/0001-dynamically-patchelf-binaries.patch
@@ -0,0 +1,35 @@
+diff --git a/src/elan-dist/src/component/package.rs b/src/elan-dist/src/component/package.rs
+index c51e76d..ae8159e 100644
+--- a/src/elan-dist/src/component/package.rs
++++ b/src/elan-dist/src/component/package.rs
+@@ -56,6 +56,30 @@ fn unpack_without_first_dir<R: Read>(archive: &mut tar::Archive<R>, path: &Path)
+         entry
+             .unpack(&full_path)
+             .chain_err(|| ErrorKind::ExtractingPackage)?;
++        nix_patch_if_needed(&full_path)?;
++    }
++
++    Ok(())
++}
++
++fn nix_patch_if_needed(dest_path: &Path) -> Result<()> {
++    let is_bin = matches!(dest_path.parent(), Some(p) if p.ends_with("bin"));
++    if is_bin {
++        let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
++            .arg("--set-interpreter")
++            .arg("@dynamicLinker@")
++            .arg(dest_path)
++            .output();
++    }
++
++    if dest_path.file_name() == Some(::std::ffi::OsStr::new("leanc")) {
++        use std::os::unix::fs::PermissionsExt;
++        let new_path = dest_path.with_extension("orig");
++        ::std::fs::rename(dest_path, &new_path)?;
++        ::std::fs::write(dest_path, format!(r#"#! @shell@
++LEAN_CC="${{LEAN_CC:-@cc@}}" exec -a "$0" {} "$@" -L {}/lib  # use bundled libraries, but not bundled compiler that doesn't know about NIX_LDFLAGS
++"#, new_path.to_str().unwrap(), dest_path.parent().unwrap().parent().unwrap().to_str().unwrap()))?;
++        ::std::fs::set_permissions(dest_path, ::std::fs::Permissions::from_mode(0o755))?;
+     }
+ 
+     Ok(())
diff --git a/nixpkgs/pkgs/applications/science/logic/elan/default.nix b/nixpkgs/pkgs/applications/science/logic/elan/default.nix
new file mode 100644
index 000000000000..89331f53686a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/elan/default.nix
@@ -0,0 +1,65 @@
+{ stdenv, lib, runCommand, patchelf, makeWrapper, pkg-config, curl, runtimeShell
+, openssl, zlib, fetchFromGitHub, rustPlatform, libiconv }:
+
+rustPlatform.buildRustPackage rec {
+  pname = "elan";
+  version = "1.3.1";
+
+  src = fetchFromGitHub {
+    owner = "leanprover";
+    repo = "elan";
+    rev = "v${version}";
+    sha256 = "sha256-QNVzpnT77+9PXhq4Yz0q3o+GiQTVy7dOrg2yBTscoek=";
+  };
+
+  cargoSha256 = "sha256-G70QopoMqFrkOnuui3+3cEHYvmnf0meX1Ecv4q8FCpM=";
+
+  nativeBuildInputs = [ pkg-config makeWrapper ];
+
+  OPENSSL_NO_VENDOR = 1;
+  buildInputs = [ curl zlib openssl ]
+    ++ lib.optional stdenv.isDarwin libiconv;
+
+  buildFeatures = [ "no-self-update" ];
+
+  patches = lib.optionals stdenv.isLinux [
+    # Run patchelf on the downloaded binaries.
+    # This is necessary because Lean 4 is now dynamically linked.
+    (runCommand "0001-dynamically-patchelf-binaries.patch" {
+        CC = stdenv.cc;
+        cc = "${stdenv.cc}/bin/cc";
+        patchelf = patchelf;
+        shell = runtimeShell;
+      } ''
+     export dynamicLinker=$(cat $CC/nix-support/dynamic-linker)
+     substitute ${./0001-dynamically-patchelf-binaries.patch} $out \
+       --subst-var patchelf \
+       --subst-var dynamicLinker \
+       --subst-var cc \
+       --subst-var shell
+    '')
+  ];
+
+  postInstall = ''
+    pushd $out/bin
+    mv elan-init elan
+    for link in lean leanpkg leanchecker leanc leanmake lake; do
+      ln -s elan $link
+    done
+    popd
+
+    # tries to create .elan
+    export HOME=$(mktemp -d)
+    mkdir -p "$out/share/"{bash-completion/completions,fish/vendor_completions.d,zsh/site-functions}
+    $out/bin/elan completions bash > "$out/share/bash-completion/completions/elan"
+    $out/bin/elan completions fish > "$out/share/fish/vendor_completions.d/elan.fish"
+    $out/bin/elan completions zsh >  "$out/share/zsh/site-functions/_elan"
+  '';
+
+  meta = with lib; {
+    description = "Small tool to manage your installations of the Lean theorem prover";
+    homepage = "https://github.com/leanprover/elan";
+    license = with licenses; [ asl20 /* or */ mit ];
+    maintainers = with maintainers; [ gebner ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/eprover/default.nix b/nixpkgs/pkgs/applications/science/logic/eprover/default.nix
new file mode 100644
index 000000000000..400d636346c5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/eprover/default.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchurl, which, enableHO ? false }:
+
+stdenv.mkDerivation rec {
+  pname = "eprover";
+  version = "2.6";
+
+  src = fetchurl {
+    url = "https://wwwlehre.dhbw-stuttgart.de/~sschulz/WORK/E_DOWNLOAD/V_${version}/E.tgz";
+    sha256 = "sha256-qh896qIpFR5g1gdWAwGkbNJLBqUQCeCpuoYHHkDXPt0=";
+  };
+
+  buildInputs = [ which ];
+
+  preConfigure = ''
+    sed -e 's/ *CC *= *gcc$//' -i Makefile.vars
+  '';
+  configureFlags = [
+    "--exec-prefix=$(out)"
+    "--man-prefix=$(out)/share/man"
+  ] ++ lib.optionals enableHO [
+    "--enable-ho"
+  ];
+
+  meta = with lib; {
+    description = "Automated theorem prover for full first-order logic with equality";
+    homepage = "http://www.eprover.org/";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ raskin gebner ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/fast-downward/default.nix b/nixpkgs/pkgs/applications/science/logic/fast-downward/default.nix
new file mode 100644
index 000000000000..ece9367e30bd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/fast-downward/default.nix
@@ -0,0 +1,60 @@
+{ stdenv, lib, fetchhg, cmake, which, python3, osi, cplex }:
+
+stdenv.mkDerivation {
+  version = "19.12";
+  pname = "fast-downward";
+
+  src = fetchhg {
+    url = "http://hg.fast-downward.org/";
+    rev = "41688a4f16b3";
+    sha256 = "08m4k1mkx4sz7c2ab7xh7ip6b67zxv7kl68xrvwa83xw1yigqkna";
+  };
+
+  nativeBuildInputs = [ cmake which ];
+  buildInputs = [ python3 python3.pkgs.wrapPython osi ];
+
+  cmakeFlags =
+    lib.optional osi.withCplex [ "-DDOWNWARD_CPLEX_ROOT=${cplex}/cplex" ];
+
+  configurePhase = ''
+    python build.py release
+  '';
+
+  postPatch = ''
+    # Needed because the package tries to be too smart.
+    export CC="$(which $CC)"
+    export CXX="$(which $CXX)"
+  '';
+
+  installPhase = ''
+    install -Dm755 builds/release/bin/downward $out/libexec/fast-downward/downward
+    cp -r builds/release/bin/translate $out/libexec/fast-downward/
+    install -Dm755 fast-downward.py $out/bin/fast-downward
+    mkdir -p $out/${python3.sitePackages}
+    cp -r driver $out/${python3.sitePackages}
+
+    wrapPythonProgramsIn $out/bin "$out $pythonPath"
+    wrapPythonProgramsIn $out/libexec/fast-downward/translate "$out $pythonPath"
+    # Because fast-downward calls `python translate.py` we need to return wrapped scripts back.
+    for i in $out/libexec/fast-downward/translate/.*-wrapped; do
+      name="$(basename "$i")"
+      name1="''${name#.}"
+      name2="''${name1%-wrapped}"
+      dir="$(dirname "$i")"
+      dest="$dir/$name2"
+      echo "Moving $i to $dest"
+      mv "$i" "$dest"
+    done
+
+    substituteInPlace $out/${python3.sitePackages}/driver/arguments.py \
+      --replace 'args.build = "release"' "args.build = \"$out/libexec/fast-downward\""
+  '';
+
+  meta = with lib; {
+    description = "A domain-independent planning system";
+    homepage = "https://www.fast-downward.org/";
+    license = licenses.gpl3Plus;
+    platforms = with platforms; (linux ++ darwin);
+    maintainers = with maintainers; [ abbradar ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/formula/default.nix b/nixpkgs/pkgs/applications/science/logic/formula/default.nix
new file mode 100644
index 000000000000..13c13713a72e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/formula/default.nix
@@ -0,0 +1,32 @@
+{ lib, stdenv, fetchFromGitHub, buildDotnetModule, dotnetCorePackages }:
+
+buildDotnetModule rec {
+  pname = "formula-dotnet";
+  version = "2.0";
+
+  src = fetchFromGitHub {
+    owner = "VUISIS";
+    repo = "formula-dotnet";
+    rev = "e962438022350dca64335c0603c00d44cb10b528";
+    sha256 = "sha256-hVtwV1MdsXaN6ZrGW4RG2HcNcv/hys/5VxGjH9vFdRE=";
+  };
+
+  nugetDeps = ./nuget.nix;
+  projectFile = "Src/CommandLine/CommandLine.csproj";
+
+  postFixup = if stdenv.isLinux then ''
+    mv $out/bin/CommandLine $out/bin/formula
+  '' else lib.optionalString stdenv.isDarwin ''
+    makeWrapper ${dotnetCorePackages.runtime_5_0}/bin/dotnet $out/bin/formula \
+      --add-flags "$out/lib/formula-dotnet/CommandLine.dll" \
+      --prefix DYLD_LIBRARY_PATH : $out/lib/formula-dotnet/runtimes/macos/native
+  '';
+
+  meta = with lib; {
+    description = "Formal Specifications for Verification and Synthesis";
+    homepage = "https://github.com/VUISIS/formula-dotnet";
+    license = licenses.mspl;
+    maintainers = with maintainers; [ siraben ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/formula/nuget.nix b/nixpkgs/pkgs/applications/science/logic/formula/nuget.nix
new file mode 100644
index 000000000000..e7ee3005e973
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/formula/nuget.nix
@@ -0,0 +1,77 @@
+{ fetchNuGet }: [
+  (fetchNuGet { pname = "Antlr4.Runtime.Standard"; version = "4.7.2"; sha256 = "1pmrpsgqjfj0nzr1zqzk1m2fm0ynd4nklwq3dhvww08yjg5s0586"; })
+  (fetchNuGet { pname = "Microsoft.NETCore.Platforms"; version = "1.1.0"; sha256 = "08vh1r12g6ykjygq5d3vq09zylgb84l63k49jc4v8faw9g93iqqm"; })
+  (fetchNuGet { pname = "Microsoft.NETCore.Targets"; version = "1.1.0"; sha256 = "193xwf33fbm0ni3idxzbr5fdq3i2dlfgihsac9jj7whj0gd902nh"; })
+  (fetchNuGet { pname = "Microsoft.Win32.Primitives"; version = "4.3.0"; sha256 = "0j0c1wj4ndj21zsgivsc24whiya605603kxrbiw6wkfdync464wq"; })
+  (fetchNuGet { pname = "Microsoft.Z3.x64"; version = "4.8.7"; sha256 = "1wxlw29xm5x8vwji2s7gwk39wb88dkbpg76l9s9gq0hqpghwlmdz"; })
+  (fetchNuGet { pname = "NETStandard.Library"; version = "1.6.1"; sha256 = "1z70wvsx2d847a2cjfii7b83pjfs34q05gb037fdjikv5kbagml8"; })
+  (fetchNuGet { pname = "runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl"; version = "4.3.0"; sha256 = "16rnxzpk5dpbbl1x354yrlsbvwylrq456xzpsha1n9y3glnhyx9d"; })
+  (fetchNuGet { pname = "runtime.fedora.23-x64.runtime.native.System.Security.Cryptography.OpenSsl"; version = "4.3.0"; sha256 = "0hkg03sgm2wyq8nqk6dbm9jh5vcq57ry42lkqdmfklrw89lsmr59"; })
+  (fetchNuGet { pname = "runtime.fedora.24-x64.runtime.native.System.Security.Cryptography.OpenSsl"; version = "4.3.0"; sha256 = "0c2p354hjx58xhhz7wv6div8xpi90sc6ibdm40qin21bvi7ymcaa"; })
+  (fetchNuGet { pname = "runtime.native.System.IO.Compression"; version = "4.3.0"; sha256 = "1vvivbqsk6y4hzcid27pqpm5bsi6sc50hvqwbcx8aap5ifrxfs8d"; })
+  (fetchNuGet { pname = "runtime.native.System.Net.Http"; version = "4.3.0"; sha256 = "1n6rgz5132lcibbch1qlf0g9jk60r0kqv087hxc0lisy50zpm7kk"; })
+  (fetchNuGet { pname = "runtime.native.System.Security.Cryptography.Apple"; version = "4.3.0"; sha256 = "1b61p6gw1m02cc1ry996fl49liiwky6181dzr873g9ds92zl326q"; })
+  (fetchNuGet { pname = "runtime.native.System.Security.Cryptography.OpenSsl"; version = "4.3.0"; sha256 = "18pzfdlwsg2nb1jjjjzyb5qlgy6xjxzmhnfaijq5s2jw3cm3ab97"; })
+  (fetchNuGet { pname = "runtime.native.System"; version = "4.3.0"; sha256 = "15hgf6zaq9b8br2wi1i3x0zvmk410nlmsmva9p0bbg73v6hml5k4"; })
+  (fetchNuGet { pname = "runtime.opensuse.13.2-x64.runtime.native.System.Security.Cryptography.OpenSsl"; version = "4.3.0"; sha256 = "0qyynf9nz5i7pc26cwhgi8j62ps27sqmf78ijcfgzab50z9g8ay3"; })
+  (fetchNuGet { pname = "runtime.opensuse.42.1-x64.runtime.native.System.Security.Cryptography.OpenSsl"; version = "4.3.0"; sha256 = "1klrs545awhayryma6l7g2pvnp9xy4z0r1i40r80zb45q3i9nbyf"; })
+  (fetchNuGet { pname = "runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple"; version = "4.3.0"; sha256 = "10yc8jdrwgcl44b4g93f1ds76b176bajd3zqi2faf5rvh1vy9smi"; })
+  (fetchNuGet { pname = "runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.OpenSsl"; version = "4.3.0"; sha256 = "0zcxjv5pckplvkg0r6mw3asggm7aqzbdjimhvsasb0cgm59x09l3"; })
+  (fetchNuGet { pname = "runtime.rhel.7-x64.runtime.native.System.Security.Cryptography.OpenSsl"; version = "4.3.0"; sha256 = "0vhynn79ih7hw7cwjazn87rm9z9fj0rvxgzlab36jybgcpcgphsn"; })
+  (fetchNuGet { pname = "runtime.ubuntu.14.04-x64.runtime.native.System.Security.Cryptography.OpenSsl"; version = "4.3.0"; sha256 = "160p68l2c7cqmyqjwxydcvgw7lvl1cr0znkw8fp24d1by9mqc8p3"; })
+  (fetchNuGet { pname = "runtime.ubuntu.16.04-x64.runtime.native.System.Security.Cryptography.OpenSsl"; version = "4.3.0"; sha256 = "15zrc8fgd8zx28hdghcj5f5i34wf3l6bq5177075m2bc2j34jrqy"; })
+  (fetchNuGet { pname = "runtime.ubuntu.16.10-x64.runtime.native.System.Security.Cryptography.OpenSsl"; version = "4.3.0"; sha256 = "1p4dgxax6p7rlgj4q73k73rslcnz4wdcv8q2flg1s8ygwcm58ld5"; })
+  (fetchNuGet { pname = "System.AppContext"; version = "4.3.0"; sha256 = "1649qvy3dar900z3g817h17nl8jp4ka5vcfmsr05kh0fshn7j3ya"; })
+  (fetchNuGet { pname = "System.Buffers"; version = "4.3.0"; sha256 = "0fgns20ispwrfqll4q1zc1waqcmylb3zc50ys9x8zlwxh9pmd9jy"; })
+  (fetchNuGet { pname = "System.Collections.Concurrent"; version = "4.3.0"; sha256 = "0wi10md9aq33jrkh2c24wr2n9hrpyamsdhsxdcnf43b7y86kkii8"; })
+  (fetchNuGet { pname = "System.Collections"; version = "4.3.0"; sha256 = "19r4y64dqyrq6k4706dnyhhw7fs24kpp3awak7whzss39dakpxk9"; })
+  (fetchNuGet { pname = "System.Console"; version = "4.3.0"; sha256 = "1flr7a9x920mr5cjsqmsy9wgnv3lvd0h1g521pdr1lkb2qycy7ay"; })
+  (fetchNuGet { pname = "System.Diagnostics.Debug"; version = "4.3.0"; sha256 = "00yjlf19wjydyr6cfviaph3vsjzg3d5nvnya26i2fvfg53sknh3y"; })
+  (fetchNuGet { pname = "System.Diagnostics.DiagnosticSource"; version = "4.3.0"; sha256 = "0z6m3pbiy0qw6rn3n209rrzf9x1k4002zh90vwcrsym09ipm2liq"; })
+  (fetchNuGet { pname = "System.Diagnostics.Tools"; version = "4.3.0"; sha256 = "0in3pic3s2ddyibi8cvgl102zmvp9r9mchh82ns9f0ms4basylw1"; })
+  (fetchNuGet { pname = "System.Diagnostics.Tracing"; version = "4.3.0"; sha256 = "1m3bx6c2s958qligl67q7grkwfz3w53hpy7nc97mh6f7j5k168c4"; })
+  (fetchNuGet { pname = "System.Globalization.Calendars"; version = "4.3.0"; sha256 = "1xwl230bkakzzkrggy1l1lxmm3xlhk4bq2pkv790j5lm8g887lxq"; })
+  (fetchNuGet { pname = "System.Globalization.Extensions"; version = "4.3.0"; sha256 = "02a5zfxavhv3jd437bsncbhd2fp1zv4gxzakp1an9l6kdq1mcqls"; })
+  (fetchNuGet { pname = "System.Globalization"; version = "4.3.0"; sha256 = "1cp68vv683n6ic2zqh2s1fn4c2sd87g5hpp6l4d4nj4536jz98ki"; })
+  (fetchNuGet { pname = "System.IO.Compression.ZipFile"; version = "4.3.0"; sha256 = "1yxy5pq4dnsm9hlkg9ysh5f6bf3fahqqb6p8668ndy5c0lk7w2ar"; })
+  (fetchNuGet { pname = "System.IO.Compression"; version = "4.3.0"; sha256 = "084zc82yi6yllgda0zkgl2ys48sypiswbiwrv7irb3r0ai1fp4vz"; })
+  (fetchNuGet { pname = "System.IO.FileSystem.Primitives"; version = "4.3.0"; sha256 = "0j6ndgglcf4brg2lz4wzsh1av1gh8xrzdsn9f0yznskhqn1xzj9c"; })
+  (fetchNuGet { pname = "System.IO.FileSystem"; version = "4.3.0"; sha256 = "0z2dfrbra9i6y16mm9v1v6k47f0fm617vlb7s5iybjjsz6g1ilmw"; })
+  (fetchNuGet { pname = "System.IO"; version = "4.3.0"; sha256 = "05l9qdrzhm4s5dixmx68kxwif4l99ll5gqmh7rqgw554fx0agv5f"; })
+  (fetchNuGet { pname = "System.Linq.Expressions"; version = "4.3.0"; sha256 = "0ky2nrcvh70rqq88m9a5yqabsl4fyd17bpr63iy2mbivjs2nyypv"; })
+  (fetchNuGet { pname = "System.Linq"; version = "4.3.0"; sha256 = "1w0gmba695rbr80l1k2h4mrwzbzsyfl2z4klmpbsvsg5pm4a56s7"; })
+  (fetchNuGet { pname = "System.Net.Http"; version = "4.3.0"; sha256 = "1i4gc757xqrzflbk7kc5ksn20kwwfjhw9w7pgdkn19y3cgnl302j"; })
+  (fetchNuGet { pname = "System.Net.Primitives"; version = "4.3.0"; sha256 = "0c87k50rmdgmxx7df2khd9qj7q35j9rzdmm2572cc55dygmdk3ii"; })
+  (fetchNuGet { pname = "System.Net.Sockets"; version = "4.3.0"; sha256 = "1ssa65k6chcgi6mfmzrznvqaxk8jp0gvl77xhf1hbzakjnpxspla"; })
+  (fetchNuGet { pname = "System.ObjectModel"; version = "4.3.0"; sha256 = "191p63zy5rpqx7dnrb3h7prvgixmk168fhvvkkvhlazncf8r3nc2"; })
+  (fetchNuGet { pname = "System.Reflection.Emit.ILGeneration"; version = "4.3.0"; sha256 = "0w1n67glpv8241vnpz1kl14sy7zlnw414aqwj4hcx5nd86f6994q"; })
+  (fetchNuGet { pname = "System.Reflection.Emit.Lightweight"; version = "4.3.0"; sha256 = "0ql7lcakycrvzgi9kxz1b3lljd990az1x6c4jsiwcacrvimpib5c"; })
+  (fetchNuGet { pname = "System.Reflection.Emit"; version = "4.3.0"; sha256 = "11f8y3qfysfcrscjpjym9msk7lsfxkk4fmz9qq95kn3jd0769f74"; })
+  (fetchNuGet { pname = "System.Reflection.Extensions"; version = "4.3.0"; sha256 = "02bly8bdc98gs22lqsfx9xicblszr2yan7v2mmw3g7hy6miq5hwq"; })
+  (fetchNuGet { pname = "System.Reflection.Primitives"; version = "4.3.0"; sha256 = "04xqa33bld78yv5r93a8n76shvc8wwcdgr1qvvjh959g3rc31276"; })
+  (fetchNuGet { pname = "System.Reflection.TypeExtensions"; version = "4.3.0"; sha256 = "0y2ssg08d817p0vdag98vn238gyrrynjdj4181hdg780sif3ykp1"; })
+  (fetchNuGet { pname = "System.Reflection"; version = "4.3.0"; sha256 = "0xl55k0mw8cd8ra6dxzh974nxif58s3k1rjv1vbd7gjbjr39j11m"; })
+  (fetchNuGet { pname = "System.Resources.ResourceManager"; version = "4.3.0"; sha256 = "0sjqlzsryb0mg4y4xzf35xi523s4is4hz9q4qgdvlvgivl7qxn49"; })
+  (fetchNuGet { pname = "System.Runtime.Extensions"; version = "4.3.0"; sha256 = "1ykp3dnhwvm48nap8q23893hagf665k0kn3cbgsqpwzbijdcgc60"; })
+  (fetchNuGet { pname = "System.Runtime.Handles"; version = "4.3.0"; sha256 = "0sw2gfj2xr7sw9qjn0j3l9yw07x73lcs97p8xfc9w1x9h5g5m7i8"; })
+  (fetchNuGet { pname = "System.Runtime.InteropServices.RuntimeInformation"; version = "4.3.0"; sha256 = "0q18r1sh4vn7bvqgd6dmqlw5v28flbpj349mkdish2vjyvmnb2ii"; })
+  (fetchNuGet { pname = "System.Runtime.InteropServices"; version = "4.3.0"; sha256 = "00hywrn4g7hva1b2qri2s6rabzwgxnbpw9zfxmz28z09cpwwgh7j"; })
+  (fetchNuGet { pname = "System.Runtime.Numerics"; version = "4.3.0"; sha256 = "19rav39sr5dky7afygh309qamqqmi9kcwvz3i0c5700v0c5cg61z"; })
+  (fetchNuGet { pname = "System.Runtime"; version = "4.3.0"; sha256 = "066ixvgbf2c929kgknshcxqj6539ax7b9m570cp8n179cpfkapz7"; })
+  (fetchNuGet { pname = "System.Security.Cryptography.Algorithms"; version = "4.3.0"; sha256 = "03sq183pfl5kp7gkvq77myv7kbpdnq3y0xj7vi4q1kaw54sny0ml"; })
+  (fetchNuGet { pname = "System.Security.Cryptography.Cng"; version = "4.3.0"; sha256 = "1k468aswafdgf56ab6yrn7649kfqx2wm9aslywjam1hdmk5yypmv"; })
+  (fetchNuGet { pname = "System.Security.Cryptography.Csp"; version = "4.3.0"; sha256 = "1x5wcrddf2s3hb8j78cry7yalca4lb5vfnkrysagbn6r9x6xvrx1"; })
+  (fetchNuGet { pname = "System.Security.Cryptography.Encoding"; version = "4.3.0"; sha256 = "1jr6w70igqn07k5zs1ph6xja97hxnb3mqbspdrff6cvssgrixs32"; })
+  (fetchNuGet { pname = "System.Security.Cryptography.OpenSsl"; version = "4.3.0"; sha256 = "0givpvvj8yc7gv4lhb6s1prq6p2c4147204a0wib89inqzd87gqc"; })
+  (fetchNuGet { pname = "System.Security.Cryptography.Primitives"; version = "4.3.0"; sha256 = "0pyzncsv48zwly3lw4f2dayqswcfvdwq2nz0dgwmi7fj3pn64wby"; })
+  (fetchNuGet { pname = "System.Security.Cryptography.X509Certificates"; version = "4.3.0"; sha256 = "0valjcz5wksbvijylxijjxb1mp38mdhv03r533vnx1q3ikzdav9h"; })
+  (fetchNuGet { pname = "System.Text.Encoding.Extensions"; version = "4.3.0"; sha256 = "11q1y8hh5hrp5a3kw25cb6l00v5l5dvirkz8jr3sq00h1xgcgrxy"; })
+  (fetchNuGet { pname = "System.Text.Encoding"; version = "4.3.0"; sha256 = "1f04lkir4iladpp51sdgmis9dj4y8v08cka0mbmsy0frc9a4gjqr"; })
+  (fetchNuGet { pname = "System.Text.RegularExpressions"; version = "4.3.0"; sha256 = "1bgq51k7fwld0njylfn7qc5fmwrk2137gdq7djqdsw347paa9c2l"; })
+  (fetchNuGet { pname = "System.Threading.Tasks.Extensions"; version = "4.3.0"; sha256 = "1xxcx2xh8jin360yjwm4x4cf5y3a2bwpn2ygkfkwkicz7zk50s2z"; })
+  (fetchNuGet { pname = "System.Threading.Tasks"; version = "4.3.0"; sha256 = "134z3v9abw3a6jsw17xl3f6hqjpak5l682k2vz39spj4kmydg6k7"; })
+  (fetchNuGet { pname = "System.Threading.Timer"; version = "4.3.0"; sha256 = "1nx773nsx6z5whv8kaa1wjh037id2f1cxhb69pvgv12hd2b6qs56"; })
+  (fetchNuGet { pname = "System.Threading"; version = "4.3.0"; sha256 = "0rw9wfamvhayp5zh3j7p1yfmx9b5khbf4q50d8k5rk993rskfd34"; })
+  (fetchNuGet { pname = "System.Xml.ReaderWriter"; version = "4.3.0"; sha256 = "0c47yllxifzmh8gq6rq6l36zzvw4kjvlszkqa9wq3fr59n0hl3s1"; })
+  (fetchNuGet { pname = "System.Xml.XDocument"; version = "4.3.0"; sha256 = "08h8fm4l77n0nd4i4fk2386y809bfbwqb7ih9d7564ifcxr5ssxd"; })
+]
diff --git a/nixpkgs/pkgs/applications/science/logic/gappa/default.nix b/nixpkgs/pkgs/applications/science/logic/gappa/default.nix
new file mode 100644
index 000000000000..af6673caa54f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/gappa/default.nix
@@ -0,0 +1,24 @@
+{ lib, stdenv, fetchurl, gmp, mpfr, boost }:
+
+stdenv.mkDerivation rec {
+  pname = "gappa";
+  version = "1.4.0";
+
+  src = fetchurl {
+    url = "https://gforge.inria.fr/frs/download.php/file/38436/gappa-${version}.tar.gz";
+    sha256 = "12x42z901pr05ldmparqdi8sq9s7fxbavhzk2dbq3l6hy247dwbb";
+  };
+
+  buildInputs = [ gmp mpfr boost.dev ];
+
+  buildPhase = "./remake";
+  installPhase = "./remake install";
+
+  meta = {
+    homepage = "http://gappa.gforge.inria.fr/";
+    description = "Verifying and formally proving properties on numerical programs dealing with floating-point or fixed-point arithmetic";
+    license = with lib.licenses; [ cecill20 gpl2 ];
+    maintainers = with lib.maintainers; [ vbgl ];
+    platforms = lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/glucose/default.nix b/nixpkgs/pkgs/applications/science/logic/glucose/default.nix
new file mode 100644
index 000000000000..5ba8208d6e18
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/glucose/default.nix
@@ -0,0 +1,29 @@
+{ lib, stdenv, fetchurl, zlib }:
+stdenv.mkDerivation rec {
+  pname = "glucose";
+  version = "4.1";
+
+  src = fetchurl {
+    url = "http://www.labri.fr/perso/lsimon/downloads/softwares/glucose-syrup-${version}.tgz";
+    sha256 = "0aahrkaq7n0z986fpqz66yz946nxardfi6dh8calzcfjpvqiraji";
+  };
+
+  buildInputs = [ zlib ];
+
+  sourceRoot = "glucose-syrup-${version}/simp";
+  makeFlags = [ "r" ];
+  installPhase = ''
+    install -Dm0755 glucose_release $out/bin/glucose
+    mkdir -p "$out/share/doc/${pname}-${version}/"
+    install -Dm0755 ../{LICEN?E,README*,Changelog*} "$out/share/doc/${pname}-${version}/"
+  '';
+
+  meta = with lib; {
+    description = "Modern, parallel SAT solver (sequential version)";
+    license = licenses.mit;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ gebner ];
+    # Build uses _FPU_EXTENDED macro
+    badPlatforms = [ "aarch64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/glucose/syrup.nix b/nixpkgs/pkgs/applications/science/logic/glucose/syrup.nix
new file mode 100644
index 000000000000..17342858fb8f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/glucose/syrup.nix
@@ -0,0 +1,24 @@
+{ lib, stdenv, zlib, glucose }:
+stdenv.mkDerivation rec {
+  pname = "glucose-syrup";
+  version = glucose.version;
+
+  src = glucose.src;
+
+  buildInputs = [ zlib ];
+
+  sourceRoot = "glucose-syrup-${version}/parallel";
+  makeFlags = [ "r" ];
+  installPhase = ''
+    install -Dm0755 glucose-syrup_release $out/bin/glucose-syrup
+    mkdir -p "$out/share/doc/${pname}-${version}/"
+    install -Dm0755 ../{LICEN?E,README*,Changelog*} "$out/share/doc/${pname}-${version}/"
+  '';
+
+  meta = with lib; {
+    description = "Modern, parallel SAT solver (parallel version)";
+    license = licenses.unfreeRedistributable;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ gebner ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/hol/default.nix b/nixpkgs/pkgs/applications/science/logic/hol/default.nix
new file mode 100644
index 000000000000..8427249c4ce9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/hol/default.nix
@@ -0,0 +1,87 @@
+{lib, stdenv, pkgs, fetchurl, graphviz, fontconfig, liberation_ttf,
+ experimentalKernel ? true}:
+
+let
+  pname = "hol4";
+  vnum = "14";
+in
+
+let
+  version = "k.${vnum}";
+  longVersion = "kananaskis-${vnum}";
+  holsubdir = "hol-${longVersion}";
+  kernelFlag = if experimentalKernel then "--expk" else "--stdknl";
+in
+
+let
+  polymlEnableShared = with pkgs; lib.overrideDerivation polyml (attrs: {
+    configureFlags = [ "--enable-shared" ];
+  });
+in
+
+stdenv.mkDerivation {
+  name = "${pname}-${version}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/hol/hol/${longVersion}/${holsubdir}.tar.gz";
+    sha256 = "6Mc/qsEjzxGqzt6yP6x/1Tmqpwc1UDGlwV1Gl+4pMsY=";
+  };
+
+  buildInputs = [polymlEnableShared graphviz fontconfig liberation_ttf];
+
+  buildCommand = ''
+
+    mkdir chroot-fontconfig
+    cat ${fontconfig.out}/etc/fonts/fonts.conf > chroot-fontconfig/fonts.conf
+    sed -e 's@</fontconfig>@@' -i chroot-fontconfig/fonts.conf
+    echo "<dir>${liberation_ttf}</dir>" >> chroot-fontconfig/fonts.conf
+    echo "</fontconfig>" >> chroot-fontconfig/fonts.conf
+
+    export FONTCONFIG_FILE=$(pwd)/chroot-fontconfig/fonts.conf
+
+    mkdir -p "$out/src"
+    cd  "$out/src"
+
+    tar -xzf "$src"
+    cd ${holsubdir}
+
+    substituteInPlace tools/Holmake/Holmake_types.sml \
+      --replace "\"/bin/" "\"" \
+
+
+    for f in tools/buildutils.sml help/src-sml/DOT;
+    do
+      substituteInPlace $f --replace "\"/usr/bin/dot\"" "\"${graphviz}/bin/dot\""
+    done
+
+    #sed -ie "/compute/,999 d" tools/build-sequence # for testing
+
+    poly < tools/smart-configure.sml
+
+    bin/build ${kernelFlag}
+
+    mkdir -p "$out/bin"
+    ln -st $out/bin  $out/src/${holsubdir}/bin/*
+    # ln -s $out/src/hol4.${version}/bin $out/bin
+  '';
+
+  meta = with lib; {
+    description = "Interactive theorem prover based on Higher-Order Logic";
+    longDescription = ''
+      HOL4 is the latest version of the HOL interactive proof
+      assistant for higher order logic: a programming environment in
+      which theorems can be proved and proof tools
+      implemented. Built-in decision procedures and theorem provers
+      can automatically establish many simple theorems (users may have
+      to prove the hard theorems themselves!) An oracle mechanism
+      gives access to external programs such as SMT and BDD
+      engines. HOL4 is particularly suitable as a platform for
+      implementing combinations of deduction, execution and property
+      checking.
+    '';
+    homepage = "http://hol.sourceforge.net/";
+    license = licenses.bsd3;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ mudri ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/hol_light/default.nix b/nixpkgs/pkgs/applications/science/logic/hol_light/default.nix
new file mode 100644
index 000000000000..e66fe992e189
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/hol_light/default.nix
@@ -0,0 +1,58 @@
+{ lib, stdenv, runtimeShell, fetchFromGitHub, fetchpatch, ocaml, num, camlp5 }:
+
+let
+  load_num =
+    if num == null then "" else
+    ''
+      -I ${num}/lib/ocaml/${ocaml.version}/site-lib/num \
+      -I ${num}/lib/ocaml/${ocaml.version}/site-lib/top-num \
+      -I ${num}/lib/ocaml/${ocaml.version}/site-lib/stublibs \
+    '';
+
+  start_script =
+    ''
+      #!${runtimeShell}
+      cd $out/lib/hol_light
+      exec ${ocaml}/bin/ocaml \
+        -I \`${camlp5}/bin/camlp5 -where\` \
+        ${load_num} \
+        -init make.ml
+    '';
+in
+
+stdenv.mkDerivation {
+  pname = "hol_light";
+  version = "unstable-2019-10-06";
+
+  src = fetchFromGitHub {
+    owner = "jrh13";
+    repo = "hol-light";
+    rev = "5c91b2ded8a66db571824ecfc18b4536c103b23e";
+    sha256 = "0sxsk8z08ba0q5aixdyczcx5l29lb51ba4ip3d2fry7y604kjsx6";
+  };
+
+  patches = [
+    (fetchpatch {
+      url = "https://salsa.debian.org/ocaml-team/hol-light/-/raw/master/debian/patches/0004-Fix-compilation-with-camlp5-7.11.patch";
+      sha256 = "180qmxbrk3vb1ix7j77hcs8vsar91rs11s5mm8ir5352rz7ylicr";
+    })
+  ];
+
+  buildInputs = [ ocaml camlp5 ];
+  propagatedBuildInputs = [ num ];
+
+  installPhase = ''
+    mkdir -p "$out/lib/hol_light" "$out/bin"
+    cp -a  . $out/lib/hol_light
+    echo "${start_script}" > "$out/bin/hol_light"
+    chmod a+x "$out/bin/hol_light"
+  '';
+
+  meta = with lib; {
+    description = "Interactive theorem prover based on Higher-Order Logic";
+    homepage = "http://www.cl.cam.ac.uk/~jrh13/hol-light/";
+    license = licenses.bsd2;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ thoughtpolice maggesi vbgl ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/iprover/default.nix b/nixpkgs/pkgs/applications/science/logic/iprover/default.nix
new file mode 100644
index 000000000000..ff88586e0353
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/iprover/default.nix
@@ -0,0 +1,33 @@
+{ lib, stdenv, fetchurl, ocaml, eprover, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "iprover";
+  version = "3.1";
+
+  src = fetchurl {
+    url = "http://www.cs.man.ac.uk/~korovink/iprover/iprover-v${version}.tar.gz";
+    sha256 = "0lik8p7ayhjwpkln1iwf0ri84ramhch74j5nj6z7ph6wfi92pgg8";
+  };
+
+  buildInputs = [ ocaml eprover zlib ];
+
+  preConfigure = "patchShebangs .";
+
+  installPhase = ''
+    mkdir -p "$out/bin"
+    cp iproveropt "$out/bin"
+
+    mkdir -p "$out/share/${pname}-${version}"
+    cp *.p "$out/share/${pname}-${version}"
+    echo -e "#! ${stdenv.shell}\\n$out/bin/iproveropt --clausifier \"${eprover}/bin/eprover\" --clausifier_options \" --tstp-format --silent --cnf \" \"\$@\"" > "$out"/bin/iprover
+    chmod a+x  "$out"/bin/iprover
+  '';
+
+  meta = with lib; {
+    description = "An automated first-order logic theorem prover";
+    homepage = "http://www.cs.man.ac.uk/~korovink/iprover/";
+    maintainers = with maintainers; [ raskin gebner ];
+    platforms = platforms.linux;
+    license = licenses.gpl3;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/isabelle/default.nix b/nixpkgs/pkgs/applications/science/logic/isabelle/default.nix
new file mode 100644
index 000000000000..aaac288b615d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/isabelle/default.nix
@@ -0,0 +1,155 @@
+{ lib, stdenv, fetchurl, coreutils, nettools, java, scala, polyml, z3, veriT, vampire, eprover-ho, rlwrap, perl, makeDesktopItem }:
+# nettools needed for hostname
+
+stdenv.mkDerivation rec {
+  pname = "isabelle";
+  version = "2021-1";
+
+  dirname = "Isabelle${version}";
+
+  src =
+    if stdenv.isDarwin
+    then
+      fetchurl
+        {
+          url = "https://isabelle.in.tum.de/website-${dirname}/dist/${dirname}_macos.tar.gz";
+          sha256 = "0n1ls9vwf0ps1x8zpb7c1xz1wkasgvc34h5bz280hy2z6iqwmwbc";
+        }
+    else
+      fetchurl {
+        url = "https://isabelle.in.tum.de/website-${dirname}/dist/${dirname}_linux.tar.gz";
+        sha256 = "0jfaqckhg388jh9b4msrpkv6wrd6xzlw18m0bngbby8k8ywalp9i";
+      };
+
+  buildInputs = [ polyml z3 veriT vampire eprover-ho ]
+    ++ lib.optionals (!stdenv.isDarwin) [ nettools java ];
+
+  sourceRoot = dirname;
+
+  postPatch = ''
+    patchShebangs .
+
+    cat >contrib/z3*/etc/settings <<EOF
+      Z3_HOME=${z3}
+      Z3_VERSION=${z3.version}
+      Z3_SOLVER=${z3}/bin/z3
+      Z3_INSTALLED=yes
+    EOF
+
+    cat >contrib/verit-*/etc/settings <<EOF
+      ISABELLE_VERIT=${veriT}/bin/veriT
+    EOF
+
+    cat >contrib/e-*/etc/settings <<EOF
+      E_HOME=${eprover-ho}/bin
+      E_VERSION=${eprover-ho.version}
+    EOF
+
+    cat >contrib/vampire-*/etc/settings <<EOF
+      VAMPIRE_HOME=${vampire}/bin
+      VAMPIRE_VERSION=${vampire.version}
+      VAMPIRE_EXTRA_OPTIONS="--mode casc"
+    EOF
+
+    cat >contrib/polyml-*/etc/settings <<EOF
+      ML_SYSTEM_64=true
+      ML_SYSTEM=${polyml.name}
+      ML_PLATFORM=${stdenv.system}
+      ML_HOME=${polyml}/bin
+      ML_OPTIONS="--minheap 1000"
+      POLYML_HOME="\$COMPONENT"
+      ML_SOURCES="\$POLYML_HOME/src"
+    EOF
+
+    cat >contrib/jdk*/etc/settings <<EOF
+      ISABELLE_JAVA_PLATFORM=${stdenv.system}
+      ISABELLE_JDK_HOME=${java}
+    EOF
+
+    sed -i -e 's/naproche_server : bool = true/naproche_server : bool = false/' contrib/naproche-*/etc/options
+
+    echo ISABELLE_LINE_EDITOR=${rlwrap}/bin/rlwrap >>etc/settings
+
+    for comp in contrib/jdk* contrib/polyml-* contrib/z3-* contrib/verit-* contrib/vampire-* contrib/e-*; do
+      rm -rf $comp/x86*
+    done
+
+    substituteInPlace lib/Tools/env \
+      --replace /usr/bin/env ${coreutils}/bin/env
+
+    substituteInPlace src/Tools/Setup/src/Environment.java \
+      --replace 'cmd.add("/usr/bin/env");' "" \
+      --replace 'cmd.add("bash");' "cmd.add(\"$SHELL\");"
+
+    rm -r heaps
+  '' + (if ! stdenv.isLinux then "" else ''
+    arch=${if stdenv.hostPlatform.system == "x86_64-linux" then "x86_64-linux" else "x86-linux"}
+    for f in contrib/*/$arch/{bash_process,epclextract,nunchaku,SPASS,zipperposition}; do
+      patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f"
+    done
+    for d in contrib/kodkodi-*/jni/$arch; do
+      patchelf --set-rpath "${lib.concatStringsSep ":" [ "${java}/lib/openjdk/lib/server" "${stdenv.cc.cc.lib}/lib" ]}" $d/*.so
+    done
+  '');
+
+  buildPhase = ''
+    export HOME=$TMP # The build fails if home is not set
+    setup_name=$(basename contrib/isabelle_setup*)
+
+    #The following is adapted from https://isabelle.sketis.net/repos/isabelle/file/Isabelle2021-1/Admin/lib/Tools/build_setup
+    TARGET_DIR="contrib/$setup_name/lib"
+    rm -rf "$TARGET_DIR"
+    mkdir -p "$TARGET_DIR/isabelle/setup"
+    declare -a ARGS=("-Xlint:unchecked")
+
+    SOURCES="$(${perl}/bin/perl -e 'while (<>) { if (m/(\S+\.java)/)  { print "$1 "; } }' "src/Tools/Setup/etc/build.props")"
+    for SRC in $SOURCES
+    do
+      ARGS["''${#ARGS[@]}"]="src/Tools/Setup/$SRC"
+    done
+    ${java}/bin/javac -d "$TARGET_DIR" -classpath ${scala}/lib/scala-compiler.jar "''${ARGS[@]}"
+    ${java}/bin/jar -c -f "$TARGET_DIR/isabelle_setup.jar" -e "isabelle.setup.Setup" -C "$TARGET_DIR" isabelle
+    rm -rf "$TARGET_DIR/isabelle"
+
+    # Prebuild HOL Session
+    bin/isabelle build -v -o system_heaps -b HOL
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mv $TMP/$dirname $out
+    cd $out/$dirname
+    bin/isabelle install $out/bin
+
+    # icon
+    mkdir -p "$out/share/icons/hicolor/isabelle/apps"
+    cp "$out/Isabelle${version}/lib/icons/isabelle.xpm" "$out/share/icons/hicolor/isabelle/apps/"
+
+    # desktop item
+    mkdir -p "$out/share"
+    cp -r "${desktopItem}/share/applications" "$out/share/applications"
+  '';
+
+  desktopItem = makeDesktopItem {
+    name = "isabelle";
+    exec = "isabelle jedit";
+    icon = "isabelle";
+    desktopName = "Isabelle";
+    comment = meta.description;
+    categories = [ "Education" "Science" "Math" ];
+  };
+
+  meta = with lib; {
+    description = "A generic proof assistant";
+
+    longDescription = ''
+      Isabelle is a generic proof assistant.  It allows mathematical formulas
+      to be expressed in a formal language and provides tools for proving those
+      formulas in a logical calculus.
+    '';
+    homepage = "https://isabelle.in.tum.de/";
+    license = licenses.bsd3;
+    maintainers = [ maintainers.jwiegley maintainers.jvanbruegge ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/jonprl/default.nix b/nixpkgs/pkgs/applications/science/logic/jonprl/default.nix
new file mode 100644
index 000000000000..379a9a483540
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/jonprl/default.nix
@@ -0,0 +1,35 @@
+{ fetchgit, lib, stdenv, smlnj, which }:
+
+stdenv.mkDerivation rec {
+  pname = "jonprl";
+  version = "0.1.0";
+
+  src = fetchgit {
+    url = "https://github.com/jonsterling/JonPRL.git";
+    deepClone = true;
+    rev = "refs/tags/v${version}";
+    sha256 = "0czs13syvnw8fz24d075n4pmsyfs8rs8c7ksmvd7cgb3h55fvp4p";
+  };
+
+  buildInputs = [ smlnj which ];
+
+  installPhase = ''
+    mkdir -p "$out/bin"
+    cp bin/.heapimg.* "$out/bin/"
+    build/mkexec.sh "${smlnj}/bin/sml" "$out" jonprl
+  '';
+
+  meta = {
+    description = "Proof Refinement Logic - Computational Type Theory";
+    longDescription = ''
+      An proof refinement logic for computational type theory
+      based on Brouwer-realizability & meaning explanations.
+      Inspired by Nuprl
+    '';
+    homepage = "https://github.com/jonsterling/JonPRL";
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ puffnfresh ];
+    platforms = lib.platforms.linux;
+    broken = true;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/key/default.nix b/nixpkgs/pkgs/applications/science/logic/key/default.nix
new file mode 100644
index 000000000000..85a7ecb08c39
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/key/default.nix
@@ -0,0 +1,121 @@
+{ lib, stdenv
+, fetchurl
+, jdk
+, gradle_7
+, perl
+, jre
+, makeWrapper
+, makeDesktopItem
+, copyDesktopItems
+, testVersion
+, key
+}:
+
+let
+  pname = "key";
+  version = "2.10.0";
+  src = fetchurl {
+    url = "https://www.key-project.org/dist/${version}/key-${version}-sources.tgz";
+    sha256 = "1f201cbcflqd1z6ysrkh3mff5agspw3v74ybdc3s2lfdyz3b858w";
+  };
+  sourceRoot = "key-${version}/key";
+
+  # fake build to pre-download deps into fixed-output derivation
+  deps = stdenv.mkDerivation {
+    pname = "${pname}-deps";
+    inherit version src sourceRoot;
+    nativeBuildInputs = [ gradle_7 perl ];
+    buildPhase = ''
+      export GRADLE_USER_HOME=$(mktemp -d)
+      # https://github.com/gradle/gradle/issues/4426
+      ${lib.optionalString stdenv.isDarwin "export TERM=dumb"}
+      gradle --no-daemon classes testClasses
+    '';
+    # perl code mavenizes pathes (com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar -> com/squareup/okio/okio/1.13.0/okio-1.13.0.jar)
+    installPhase = ''
+      find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \
+        | perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \
+        | sh
+    '';
+    outputHashMode = "recursive";
+    outputHashAlgo = "sha256";
+    outputHash = "sha256-GjBUwJxeyJA6vGrPQVtNpcHb4CJlNlY4kHt1PT21xjo=";
+  };
+in stdenv.mkDerivation rec {
+  inherit pname version src sourceRoot;
+
+  nativeBuildInputs = [
+    jdk
+    gradle_7
+    makeWrapper
+    copyDesktopItems
+  ];
+
+  executable-name = "KeY";
+
+  desktopItems = [
+    (makeDesktopItem {
+      name = "KeY";
+      exec = executable-name;
+      icon = "key";
+      comment = meta.description;
+      desktopName = "KeY";
+      genericName = "KeY";
+      categories = [ "Science" ];
+    })
+  ];
+
+  # disable tests (broken on darwin)
+  gradleAction = if stdenv.isDarwin then "assemble" else "build";
+
+  buildPhase = ''
+    runHook preBuild
+
+    export GRADLE_USER_HOME=$(mktemp -d)
+    # https://github.com/gradle/gradle/issues/4426
+    ${lib.optionalString stdenv.isDarwin "export TERM=dumb"}
+    # point to offline repo
+    sed -ie "s#repositories {#repositories { maven { url '${deps}' }#g" build.gradle
+    cat <(echo "pluginManagement { repositories { maven { url '${deps}' } } }") settings.gradle > settings_new.gradle
+    mv settings_new.gradle settings.gradle
+    gradle --offline --no-daemon ${gradleAction}
+
+    runHook postBuild
+  '';
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out/share/java
+    cp key.ui/build/libs/key-*-exe.jar $out/share/java/KeY.jar
+    mkdir -p $out/bin
+    mkdir -p $out/share/icons/hicolor/256x256/apps
+    cp key.ui/src/main/resources/de/uka/ilkd/key/gui/images/key-color-icon-square.png $out/share/icons/hicolor/256x256/apps/key.png
+    makeWrapper ${jre}/bin/java $out/bin/KeY \
+      --add-flags "-cp $out/share/java/KeY.jar de.uka.ilkd.key.core.Main"
+
+    runHook postInstall
+  '';
+
+  passthru.tests.version =
+    testVersion {
+      package = key;
+      command = "KeY --help";
+    };
+
+  meta = with lib; {
+    description = "Java formal verification tool";
+    homepage = "https://www.key-project.org"; # also https://formal.iti.kit.edu/key/
+    longDescription = ''
+      The KeY System is a formal software development tool that aims to
+      integrate design, implementation, formal specification, and formal
+      verification of object-oriented software as seamlessly as possible.
+      At the core of the system is a novel theorem prover for the first-order
+      Dynamic Logic for Java with a user-friendly graphical interface.
+    '';
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ fgaz ];
+    platforms = platforms.all;
+  };
+}
+
diff --git a/nixpkgs/pkgs/applications/science/logic/kissat/default.nix b/nixpkgs/pkgs/applications/science/logic/kissat/default.nix
new file mode 100644
index 000000000000..08be0740117a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/kissat/default.nix
@@ -0,0 +1,54 @@
+{ lib, stdenv, fetchFromGitHub
+, drat-trim, p7zip
+}:
+
+stdenv.mkDerivation rec {
+  pname = "kissat";
+  version = "2.0.1";
+
+  src = fetchFromGitHub {
+    owner = "arminbiere";
+    repo = "kissat";
+    # https://github.com/arminbiere/kissat/issues/18
+    rev = "abfa45fb782fa3b7c6e2eb6b939febe74d7270b7";
+    sha256 = "06pbmkjxgf2idhsrd1yzvbxr2wf8l06pjb38bzbygm6n9ami89b8";
+  };
+
+  outputs = [ "out" "dev" "lib" ];
+
+  checkInputs = [ drat-trim p7zip ];
+  doCheck = true;
+
+  # 'make test' assumes that /etc/passwd is not writable.
+  patches = [ ./writable-passwd-is-ok.patch ];
+
+  # the configure script is not generated by autotools and does not accept the
+  # arguments that the default configurePhase passes like --prefix and --libdir
+  dontAddPrefix = true;
+  setOutputFlags = false;
+
+  installPhase = ''
+    runHook preInstall
+
+    install -Dm0755 build/kissat "$out/bin/kissat"
+    install -Dm0644 src/kissat.h "$dev/include/kissat.h"
+    install -Dm0644 build/libkissat.a "$lib/lib/libkissat.a"
+    mkdir -p "$out/share/doc/kissat/"
+    install -Dm0644 {LICEN?E,README*,VERSION} "$out/share/doc/kissat/"
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "A 'keep it simple and clean bare metal SAT solver' written in C";
+    longDescription = ''
+      Kissat is a "keep it simple and clean bare metal SAT solver" written in C.
+      It is a port of CaDiCaL back to C with improved data structures,
+      better scheduling of inprocessing and optimized algorithms and implementation.
+    '';
+    maintainers = with maintainers; [ shnarazk ];
+    platforms = platforms.unix;
+    license = licenses.mit;
+    homepage = "http://fmv.jku.at/kissat";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/kissat/writable-passwd-is-ok.patch b/nixpkgs/pkgs/applications/science/logic/kissat/writable-passwd-is-ok.patch
new file mode 100644
index 000000000000..f2cca54e1d36
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/kissat/writable-passwd-is-ok.patch
@@ -0,0 +1,13 @@
+diff --git a/test/testfile.c b/test/testfile.c
+index cb311d5..0726244 100644
+--- a/test/testfile.c
++++ b/test/testfile.c
+@@ -92,8 +92,6 @@ do { \
+   WRITABLE (true, "../test/file/non-existing");
+   WRITABLE (false, "/kissat-test-file-writable");
+   WRITABLE (false, "non-existing-directory/file-in-non-existing-directory");
+-  if (kissat_file_exists ("/etc/passwd"))
+-    WRITABLE (false, "/etc/passwd");
+ #undef WRITABLE
+ }
+ 
diff --git a/nixpkgs/pkgs/applications/science/logic/klee/default.nix b/nixpkgs/pkgs/applications/science/logic/klee/default.nix
new file mode 100644
index 000000000000..e0ace7e81c82
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/klee/default.nix
@@ -0,0 +1,110 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, fetchpatch
+, cmake
+, llvmPackages_9
+, clang_9
+, python3
+, zlib
+, z3
+, stp
+, cryptominisat
+, gperftools
+, sqlite
+, gtest
+, lit
+, debug ? false
+}:
+
+let
+  kleePython = python3.withPackages (ps: with ps; [ tabulate ]);
+in
+stdenv.mkDerivation rec {
+  pname = "klee";
+  version = "2.2";
+  src = fetchFromGitHub {
+    owner = "klee";
+    repo = "klee";
+    rev = "v${version}";
+    sha256 = "Ar3BKfADjJvvP0dI9+x/l3RDs8ncx4jmO7ol4MgOr4M=";
+  };
+  buildInputs = [
+    llvmPackages_9.llvm clang_9 z3 stp cryptominisat
+    gperftools sqlite
+  ];
+  nativeBuildInputs = [
+    cmake
+  ];
+  checkInputs = [
+    gtest
+
+    # Should appear BEFORE lit, since lit passes through python rather
+    # than the python environment we make.
+    kleePython
+    (lit.override { python3 = kleePython; })
+  ];
+
+  cmakeFlags = let
+    buildType = if debug then "Debug" else "Release";
+  in
+  [
+    "-DCMAKE_BUILD_TYPE=${buildType}"
+    "-DKLEE_RUNTIME_BUILD_TYPE=${buildType}"
+    "-DENABLE_POSIX_RUNTIME=ON"
+    "-DENABLE_UNIT_TESTS=ON"
+    "-DENABLE_SYSTEM_TESTS=ON"
+    "-DGTEST_SRC_DIR=${gtest.src}"
+    "-DGTEST_INCLUDE_DIR=${gtest.src}/googletest/include"
+    "-Wno-dev"
+  ];
+
+  # Silence various warnings during the compilation of fortified bitcode.
+  NIX_CFLAGS_COMPILE = ["-Wno-macro-redefined"];
+
+  prePatch = ''
+    patchShebangs .
+  '';
+
+  /* This patch is currently necessary for the unit test suite to run correctly.
+   * See https://www.mail-archive.com/klee-dev@imperial.ac.uk/msg03136.html
+   * and https://github.com/klee/klee/pull/1458 for more information.
+   */
+  patches = map fetchpatch [
+    {
+      name = "fix-gtest";
+      sha256 = "F+/6videwJZz4sDF9lnV4B8lMx6W11KFJ0Q8t1qUDf4=";
+      url = "https://github.com/klee/klee/pull/1458.patch";
+    }
+  ];
+
+  doCheck = true;
+  checkTarget = "check";
+
+  meta = with lib; {
+    description = "A symbolic virtual machine built on top of LLVM";
+    longDescription = ''
+      KLEE is a symbolic virtual machine built on top of the LLVM compiler
+      infrastructure. Currently, there are two primary components:
+
+      1. The core symbolic virtual machine engine; this is responsible for
+         executing LLVM bitcode modules with support for symbolic values. This
+         is comprised of the code in lib/.
+
+      2. A POSIX/Linux emulation layer oriented towards supporting uClibc, with
+         additional support for making parts of the operating system environment
+         symbolic.
+
+      Additionally, there is a simple library for replaying computed inputs on
+      native code (for closed programs). There is also a more complicated
+      infrastructure for replaying the inputs generated for the POSIX/Linux
+      emulation layer, which handles running native programs in an environment
+      that matches a computed test input, including setting up files, pipes,
+      environment variables, and passing command line arguments.
+    '';
+    homepage = "https://klee.github.io/";
+    license = licenses.ncsa;
+    platforms = [ "x86_64-linux" ];
+    maintainers = with maintainers; [ numinit ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/lci/default.nix b/nixpkgs/pkgs/applications/science/logic/lci/default.nix
new file mode 100644
index 000000000000..593b2c54c5cf
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/lci/default.nix
@@ -0,0 +1,16 @@
+{lib, stdenv, fetchurl, readline}:
+stdenv.mkDerivation rec {
+  version = "0.6";
+  pname = "lci";
+  src = fetchurl {
+    url = "mirror://sourceforge/lci/${pname}-${version}.tar.gz";
+    sha256="204f1ca5e2f56247d71ab320246811c220ed511bf08c9cb7f305cf180a93948e";
+  };
+  buildInputs = [readline];
+  meta = {
+    description = "Lambda calculus interpreter";
+    maintainers = with lib.maintainers; [raskin];
+    platforms = with lib.platforms; linux;
+    license = lib.licenses.gpl3;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/lean/default.nix b/nixpkgs/pkgs/applications/science/logic/lean/default.nix
new file mode 100644
index 000000000000..1eea97a0fd23
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/lean/default.nix
@@ -0,0 +1,50 @@
+{ lib, stdenv, fetchFromGitHub, cmake, gmp, coreutils }:
+
+stdenv.mkDerivation rec {
+  pname = "lean";
+  version = "3.41.0";
+
+  src = fetchFromGitHub {
+    owner  = "leanprover-community";
+    repo   = "lean";
+    # lean's version string contains the commit sha1 it was built
+    # from. this is then used to check whether an olean file should be
+    # rebuilt. don't use a tag as rev because this will get replaced into
+    # src/githash.h.in in preConfigure.
+    rev    = "154ac72f4ff674bc4486ac611f926a3d6b999f9f";
+    sha256 = "0mpxlfjq460x1vi3v6qzgjv74asg0qlhykd51pj347795x5b1hf1";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ gmp ];
+
+  cmakeDir = "../src";
+
+  # Running the tests is required to build the *.olean files for the core
+  # library.
+  doCheck = true;
+
+  preConfigure = assert builtins.stringLength src.rev == 40; ''
+     substituteInPlace src/githash.h.in \
+       --subst-var-by GIT_SHA1 "${src.rev}"
+     substituteInPlace library/init/version.lean.in \
+       --subst-var-by GIT_SHA1 "${src.rev}"
+  '';
+
+  postPatch = "patchShebangs .";
+
+  postInstall = lib.optionalString stdenv.isDarwin ''
+    substituteInPlace $out/bin/leanpkg \
+      --replace "greadlink" "${coreutils}/bin/readlink"
+  '';
+
+  meta = with lib; {
+    description = "Automatic and interactive theorem prover";
+    homepage    = "https://leanprover.github.io/";
+    changelog   = "https://github.com/leanprover-community/lean/blob/v${version}/doc/changes.md";
+    license     = licenses.asl20;
+    platforms   = platforms.unix;
+    maintainers = with maintainers; [ thoughtpolice gebner ];
+  };
+}
+
diff --git a/nixpkgs/pkgs/applications/science/logic/lean2/default.nix b/nixpkgs/pkgs/applications/science/logic/lean2/default.nix
new file mode 100644
index 000000000000..24d11c3a5319
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/lean2/default.nix
@@ -0,0 +1,37 @@
+{ lib, stdenv, fetchFromGitHub, cmake, gmp, mpfr, python2
+, gperftools, ninja, makeWrapper }:
+
+stdenv.mkDerivation {
+  pname = "lean2";
+  version = "2017-07-22";
+
+  src = fetchFromGitHub {
+    owner  = "leanprover";
+    repo   = "lean2";
+    rev    = "34dbd6c3ae612186b8f0f80d12fbf5ae7a059ec9";
+    sha256 = "1xv3j487zhh1zf2b4v19xzw63s2sgjhg8d62a0kxxyknfmdf3khl";
+  };
+
+  nativeBuildInputs = [ cmake makeWrapper ninja ];
+  buildInputs = [ gmp mpfr python2 gperftools ];
+
+  preConfigure = ''
+    patchShebangs bin/leantags
+    cd src
+  '';
+
+  cmakeFlags = [ "-GNinja" ];
+
+  postInstall = ''
+    wrapProgram $out/bin/linja --prefix PATH : $out/bin:${ninja}/bin
+  '';
+
+  meta = with lib; {
+    description = "Automatic and interactive theorem prover (version with HoTT support)";
+    homepage    = "http://leanprover.github.io";
+    license     = licenses.asl20;
+    platforms   = platforms.unix;
+    maintainers = with maintainers; [ thoughtpolice gebner ];
+    broken = true;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/leo2/default.nix b/nixpkgs/pkgs/applications/science/logic/leo2/default.nix
new file mode 100644
index 000000000000..cbc85c5544cc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/leo2/default.nix
@@ -0,0 +1,49 @@
+{ lib, stdenv, fetchurl, fetchpatch, makeWrapper, eprover, ocaml, camlp4, perl, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "leo2";
+  version = "1.7.0";
+
+  src = fetchurl {
+    url = "https://page.mi.fu-berlin.de/cbenzmueller/leo/leo2_v${version}.tgz";
+    sha256 = "sha256:1b2q7vsz6s9ighypsigqjm1mzjiq3xgnz5id5ssb4rh9zm190r82";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ eprover ocaml camlp4 perl zlib ];
+
+  patches = [ (fetchpatch {
+      url = "https://github.com/niklasso/minisat/commit/7eb6015313561a2586032574788fcb133eeaa19f.patch";
+      stripLen = 1;
+      extraPrefix = "lib/";
+      sha256 = "sha256:01ln7hi6nvvkqkhn9hciqizizz5qspvqffgksvgmzn9x7kdd9pnh";
+    })
+  ];
+
+  preConfigure = ''
+    cd src
+    patchShebangs configure
+    substituteInPlace Makefile.pre \
+      --replace '+camlp4' "${camlp4}/lib/ocaml/${ocaml.version}/site-lib/camlp4"
+  '';
+
+  buildFlags = [ "opt" ];
+
+  preInstall = "mkdir -p $out/bin";
+
+  postInstall = ''
+    mkdir -p "$out/etc"
+    echo -e "e = ${eprover}/bin/eprover\\nepclextract = ${eprover}/bin/epclextract" > "$out/etc/leoatprc"
+
+    wrapProgram $out/bin/leo \
+      --add-flags "--atprc $out/etc/leoatprc"
+  '';
+
+  meta = with lib; {
+    description = "A high-performance typed higher order prover";
+    maintainers = [ maintainers.raskin ];
+    platforms = platforms.linux;
+    license = licenses.bsd3;
+    homepage = "http://www.leoprover.org/";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/leo3/binary.nix b/nixpkgs/pkgs/applications/science/logic/leo3/binary.nix
new file mode 100644
index 000000000000..6196f6443702
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/leo3/binary.nix
@@ -0,0 +1,28 @@
+{lib, stdenv, fetchurl, openjdk, runtimeShell}:
+stdenv.mkDerivation rec {
+  pname = "leo3";
+  version = "1.2";
+
+  src = fetchurl {
+    url = "https://github.com/leoprover/Leo-III/releases/download/v${version}/leo3.jar";
+    sha256 = "1lgwxbr1rnk72rnvc8raq5i1q71ckhn998pwd9xk6zf27wlzijk7";
+  };
+
+  dontUnpack = true;
+
+  installPhase = ''
+    mkdir -p "$out"/{bin,lib/java/leo3}
+    cp "${src}" "$out/lib/java/leo3/leo3.jar"
+    echo "#!${runtimeShell}" > "$out/bin/leo3"
+    echo "'${openjdk}/bin/java' -jar '$out/lib/java/leo3/leo3.jar' \"\$@\""  >> "$out/bin/leo3"
+    chmod a+x "$out/bin/leo3"
+  '';
+
+  meta = with lib; {
+    description = "An automated theorem prover for classical higher-order logic with choice";
+    license = licenses.bsd3;
+    maintainers = [maintainers.raskin];
+    platforms = platforms.linux;
+    homepage = "https://page.mi.fu-berlin.de/lex/leo3/";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/lingeling/default.nix b/nixpkgs/pkgs/applications/science/logic/lingeling/default.nix
new file mode 100644
index 000000000000..1abf38b49cf8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/lingeling/default.nix
@@ -0,0 +1,48 @@
+{ lib, stdenv, fetchFromGitHub
+, aiger
+}:
+
+stdenv.mkDerivation {
+  pname = "lingeling";
+  # This is the version used in satcomp2020
+  version = "pre1_708beb26";
+
+  src = fetchFromGitHub {
+    owner  = "arminbiere";
+    repo   = "lingeling";
+    rev    = "708beb26a7d5b5d5e7abd88d6f552fb1946b07c1";
+    sha256 = "1lb2g37nd8qq5hw5g6l691nx5095336yb2zlbaw43mg56hkj8357";
+  };
+
+  configurePhase = ''
+    ./configure.sh
+
+    # Rather than patch ./configure, just sneak in use of aiger here, since it
+    # doesn't handle real build products very well (it works on a build-time
+    # dir, not installed copy)... This is so we can build 'blimc'
+    substituteInPlace ./makefile \
+      --replace 'targets: liblgl.a' 'targets: liblgl.a blimc'      \
+      --replace '$(AIGER)/aiger.o'  '${aiger.lib}/lib/aiger.o'     \
+      --replace '$(AIGER)/aiger.h'  '${aiger.dev}/include/aiger.h' \
+      --replace '-I$(AIGER)'        '-I${aiger.dev}/include'
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin $lib/lib $dev/include
+
+    cp lglib.h  $dev/include
+    cp liblgl.a $lib/lib
+
+    cp lingeling plingeling treengeling ilingeling blimc $out/bin
+  '';
+
+  outputs = [ "out" "dev" "lib" ];
+
+  meta = with lib; {
+    description = "Fast SAT solver";
+    homepage    = "http://fmv.jku.at/lingeling/";
+    license     = licenses.mit;
+    platforms   = platforms.unix;
+    maintainers = with maintainers; [ thoughtpolice ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/logisim-evolution/default.nix b/nixpkgs/pkgs/applications/science/logic/logisim-evolution/default.nix
new file mode 100644
index 000000000000..67e699bc63fa
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/logisim-evolution/default.nix
@@ -0,0 +1,49 @@
+{ lib, stdenv, fetchurl, jre, makeWrapper, copyDesktopItems, makeDesktopItem, unzip }:
+
+stdenv.mkDerivation rec {
+  pname = "logisim-evolution";
+  version = "3.7.2";
+
+  src = fetchurl {
+    url = "https://github.com/logisim-evolution/logisim-evolution/releases/download/v${version}/logisim-evolution-${version}-all.jar";
+    sha256 = "sha256-RI+ioOHj13UAGuPzseAAy3oQBQYkja/ucjj4QMeRZhw=";
+  };
+
+  dontUnpack = true;
+
+  nativeBuildInputs = [ makeWrapper copyDesktopItems unzip ];
+
+  desktopItems = [
+    (makeDesktopItem {
+      name = pname;
+      desktopName = "Logisim-evolution";
+      exec = "logisim-evolution";
+      icon = "logisim-evolution";
+      comment = meta.description;
+      categories = [ "Education" ];
+    })
+  ];
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out/bin
+    makeWrapper ${jre}/bin/java $out/bin/logisim-evolution --add-flags "-jar $src"
+
+    # Create icons
+    unzip $src "resources/logisim/img/*"
+    for size in 16 32 48 128 256; do
+      install -D "./resources/logisim/img/logisim-icon-$size.png" "$out/share/icons/hicolor/''${size}x''${size}/apps/logisim-evolution.png"
+    done
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    homepage = "https://github.com/logisim-evolution/logisim-evolution";
+    description = "Digital logic designer and simulator";
+    maintainers = with maintainers; [ emilytrau ];
+    license = licenses.gpl2Plus;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/logisim/default.nix b/nixpkgs/pkgs/applications/science/logic/logisim/default.nix
new file mode 100644
index 000000000000..06dc024e6d23
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/logisim/default.nix
@@ -0,0 +1,50 @@
+{ lib, stdenv, fetchurl, jre, makeWrapper, copyDesktopItems, makeDesktopItem, unzip }:
+
+stdenv.mkDerivation rec {
+  pname = "logisim";
+  version = "2.7.1";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/project/circuit/${lib.versions.majorMinor version}.x/${version}/logisim-generic-${version}.jar";
+    sha256 = "1hkvc9zc7qmvjbl9579p84hw3n8wl3275246xlzj136i5b0phain";
+  };
+
+  dontUnpack = true;
+
+  nativeBuildInputs = [ makeWrapper copyDesktopItems unzip ];
+
+  desktopItems = [
+    (makeDesktopItem {
+      name = pname;
+      desktopName = "Logisim";
+      exec = "logisim";
+      icon = "logisim";
+      comment = meta.description;
+      categories = [ "Education" ];
+    })
+  ];
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out/bin
+    makeWrapper ${jre}/bin/java $out/bin/logisim --add-flags "-jar $src"
+
+    # Create icons
+    unzip $src "resources/logisim/img/*"
+    for size in 16 20 24 48 64 128
+    do
+      install -D "./resources/logisim/img/logisim-icon-$size.png" "$out/share/icons/hicolor/''${size}x''${size}/apps/logisim.png"
+    done
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    homepage = "http://www.cburch.com/logisim/";
+    description = "Educational tool for designing and simulating digital logic circuits";
+    maintainers = with maintainers; [ emilytrau ];
+    license = licenses.gpl2Plus;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/ltl2ba/default.nix b/nixpkgs/pkgs/applications/science/logic/ltl2ba/default.nix
new file mode 100644
index 000000000000..30c13c6036f9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/ltl2ba/default.nix
@@ -0,0 +1,31 @@
+{ fetchurl, lib, stdenv }:
+
+stdenv.mkDerivation rec {
+  pname = "ltl2ba";
+  version = "1.3";
+
+  src = fetchurl {
+    url    = "http://www.lsv.ens-cachan.fr/~gastin/ltl2ba/${pname}-${version}.tar.gz";
+    sha256 = "1bz9gjpvby4mnvny0nmxgd81rim26mqlcnjlznnxxk99575pfa4i";
+  };
+
+  hardeningDisable = [ "format" ];
+
+  preConfigure = ''
+    substituteInPlace Makefile \
+    --replace "CC=gcc" ""
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mv ltl2ba $out/bin
+  '';
+
+  meta = {
+    description = "Fast translation from LTL formulae to Buchi automata";
+    homepage    = "http://www.lsv.ens-cachan.fr/~gastin/ltl2ba";
+    license     = lib.licenses.gpl2Plus;
+    platforms   = lib.platforms.darwin ++ lib.platforms.linux;
+    maintainers = [ lib.maintainers.thoughtpolice ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/mcrl2/default.nix b/nixpkgs/pkgs/applications/science/logic/mcrl2/default.nix
new file mode 100644
index 000000000000..da9231efb813
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/mcrl2/default.nix
@@ -0,0 +1,30 @@
+{lib, stdenv, fetchurl, cmake, libGLU, libGL, qt5, boost}:
+
+stdenv.mkDerivation rec {
+  version = "201707";
+  build_nr = "1";
+  pname = "mcrl2";
+
+  src = fetchurl {
+    url = "https://www.mcrl2.org/download/release/mcrl2-${version}.${build_nr}.tar.gz";
+    sha256 = "1c8h94ja7271ph61zrcgnjgblxppld6v22f7f900prjgzbcfy14m";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ libGLU libGL qt5.qtbase boost ];
+
+  dontWrapQtApps = true;
+
+  meta = with lib; {
+    description = "A toolset for model-checking concurrent systems and protocols";
+    longDescription = ''
+      A formal specification language with an associated toolset,
+      that can be used for modelling, validation and verification of
+      concurrent systems and protocols
+    '';
+    homepage = "https://www.mcrl2.org/";
+    license = licenses.boost;
+    maintainers = with maintainers; [ moretea ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/mcy/default.nix b/nixpkgs/pkgs/applications/science/logic/mcy/default.nix
new file mode 100644
index 000000000000..dc1094f3e27d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/mcy/default.nix
@@ -0,0 +1,51 @@
+{ lib, stdenv, fetchFromGitHub
+, yosys, symbiyosys, python3
+}:
+
+let
+  python = python3.withPackages (p: with p; [ flask ]);
+in
+stdenv.mkDerivation {
+  pname = "mcy";
+  version = "2020.08.03";
+
+  src = fetchFromGitHub {
+    owner  = "YosysHQ";
+    repo   = "mcy";
+    rev    = "62048e69df13f8e03670424626755ae8ef4c36ff";
+    sha256 = "15xxgzx1zxzx5kshqyrxnfx33cz6cjzxcdcn6z98jhs9bwyvf96f";
+  };
+
+  buildInputs = [ python ];
+  patchPhase = ''
+    chmod +x scripts/create_mutated.sh
+    patchShebangs .
+
+    substituteInPlace mcy.py \
+      --replace yosys '${yosys}/bin/yosys' \
+      --replace 'os.execvp("mcy-dash"' "os.execvp(\"$out/bin/mcy-dash\""
+    substituteInPlace mcy-dash.py \
+      --replace 'app.run(debug=True)' 'app.run(host="0.0.0.0",debug=True)' \
+      --replace 'subprocess.Popen(["mcy"' "subprocess.Popen([\"$out/bin/mcy\""
+    substituteInPlace scripts/create_mutated.sh \
+      --replace yosys '${yosys}/bin/yosys'
+  '';
+
+  # the build needs a bit of work...
+  buildPhase = "true";
+  installPhase = ''
+    mkdir -p $out/bin $out/share/mcy/{dash,scripts}
+    install mcy.py      $out/bin/mcy      && chmod +x $out/bin/mcy
+    install mcy-dash.py $out/bin/mcy-dash && chmod +x $out/bin/mcy-dash
+    cp -r dash/.    $out/share/mcy/dash/.
+    cp -r scripts/. $out/share/mcy/scripts/.
+  '';
+
+  meta = {
+    description = "Mutation-based coverage testing for hardware designs, with Yosys";
+    homepage    = "https://github.com/YosysHQ/mcy";
+    license     = lib.licenses.isc;
+    maintainers = with lib.maintainers; [ thoughtpolice ];
+    platforms   = lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/metis-prover/default.nix b/nixpkgs/pkgs/applications/science/logic/metis-prover/default.nix
new file mode 100644
index 000000000000..e30a897e5659
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/metis-prover/default.nix
@@ -0,0 +1,32 @@
+{ lib, stdenv, fetchFromGitHub, perl, mlton }:
+
+stdenv.mkDerivation {
+  pname = "metis-prover";
+  version = "2.3.20160713";
+
+  src = fetchFromGitHub {
+    owner = "gilith";
+    repo = "metis";
+    rev = "f0b1a17cd57eb098077e963ab092477aee9fb340";
+    sha256 = "1i7paax7b4byk8110f5zk4071mh5603r82bq7hbprqzljvsiipk7";
+  };
+
+  nativeBuildInputs = [ perl ];
+  buildInputs = [ mlton ];
+
+  patchPhase = "patchShebangs .";
+
+  buildPhase = "make mlton";
+
+  installPhase = ''
+    install -Dm0755 bin/mlton/metis $out/bin/metis
+  '';
+
+  meta = with lib; {
+    description = "Automatic theorem prover for first-order logic with equality";
+    homepage = "http://www.gilith.com/research/metis/";
+    license = licenses.mit;
+    maintainers = with maintainers; [ gebner ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/minisat/default.nix b/nixpkgs/pkgs/applications/science/logic/minisat/default.nix
new file mode 100644
index 000000000000..10d380882744
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/minisat/default.nix
@@ -0,0 +1,24 @@
+{ lib, stdenv, fetchFromGitHub, cmake, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "minisat";
+  version = "2.2.1";
+
+  src = fetchFromGitHub {
+    owner = "stp";
+    repo = pname;
+    rev = "releases/${version}";
+    sha256 = "14vcbjnlia00lpyv2fhbmw3wbc9bk9h7bln9zpyc3nwiz5cbjz4a";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ zlib ];
+
+  meta = with lib; {
+    description = "Compact and readable SAT solver";
+    maintainers = with maintainers; [ gebner raskin ];
+    platforms = platforms.unix;
+    license = licenses.mit;
+    homepage = "http://minisat.se/";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/monosat/default.nix b/nixpkgs/pkgs/applications/science/logic/monosat/default.nix
new file mode 100644
index 000000000000..1356c88d478f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/monosat/default.nix
@@ -0,0 +1,89 @@
+{ lib, stdenv, fetchpatch, fetchFromGitHub, cmake, zlib, gmp, jdk8,
+  # The JDK we use on Darwin currenly makes extensive use of rpaths which are
+  # annoying and break the python library, so let's not bother for now
+  includeJava ? !stdenv.hostPlatform.isDarwin, includeGplCode ? true }:
+
+with lib;
+
+let
+  boolToCmake = x: if x then "ON" else "OFF";
+
+  rev    = "1.8.0";
+  sha256 = "0q3a8x3iih25xkp2bm842sm2hxlb8hxlls4qmvj7vzwrh4lvsl7b";
+
+  pname   = "monosat";
+  version = rev;
+
+  src = fetchFromGitHub {
+    owner = "sambayless";
+    repo  = pname;
+    inherit rev sha256;
+  };
+
+  patches = [
+    # Python 3.8 compatibility
+    (fetchpatch {
+      url = "https://github.com/sambayless/monosat/commit/a5079711d0df0451f9840f3a41248e56dbb03967.patch";
+      sha256 = "1p2y0jw8hb9c90nbffhn86k1dxd6f6hk5v70dfmpzka3y6g1ksal";
+    })
+  ];
+
+  # source behind __linux__ check assumes system is also x86 and
+  # tries to disable x86/x87-specific extended precision mode
+  # https://github.com/sambayless/monosat/issues/33
+  commonPostPatch = lib.optionalString (!stdenv.hostPlatform.isx86) ''
+    substituteInPlace src/monosat/Main.cc \
+      --replace 'defined(__linux__)' '0'
+  '';
+
+  core = stdenv.mkDerivation {
+    name = "${pname}-${version}";
+    inherit src patches;
+    postPatch = commonPostPatch;
+    nativeBuildInputs = [ cmake ];
+    buildInputs = [ zlib gmp jdk8 ];
+
+    cmakeFlags = [
+      "-DBUILD_STATIC=OFF"
+      "-DJAVA=${boolToCmake includeJava}"
+      "-DGPL=${boolToCmake includeGplCode}"
+    ];
+
+    postInstall = optionalString includeJava ''
+      mkdir -p $out/share/java
+      cp monosat.jar $out/share/java
+    '';
+
+    passthru = { inherit python; };
+
+    meta = {
+      description = "SMT solver for Monotonic Theories";
+      platforms   = platforms.unix;
+      license     = if includeGplCode then licenses.gpl2 else licenses.mit;
+      homepage    = "https://github.com/sambayless/monosat";
+      maintainers = [ maintainers.acairncross ];
+    };
+  };
+
+  python = { buildPythonPackage, cython }: buildPythonPackage {
+    inherit pname version src patches;
+
+    propagatedBuildInputs = [ core cython ];
+
+    # This tells setup.py to use cython, which should produce faster bindings
+    MONOSAT_CYTHON = true;
+
+    # After patching src, move to where the actually relevant source is. This could just be made
+    # the sourceRoot if it weren't for the patch.
+    postPatch = commonPostPatch + ''
+      cd src/monosat/api/python
+    '' +
+    # The relative paths here don't make sense for our Nix build
+    # TODO: do we want to just reference the core monosat library rather than copying the
+    # shared lib? The current setup.py copies the .dylib/.so...
+    ''
+      substituteInPlace setup.py \
+        --replace 'library_dir = "../../../../"' 'library_dir = "${core}/lib/"'
+    '';
+  };
+in core
diff --git a/nixpkgs/pkgs/applications/science/logic/open-wbo/default.nix b/nixpkgs/pkgs/applications/science/logic/open-wbo/default.nix
new file mode 100644
index 000000000000..193f603656dc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/open-wbo/default.nix
@@ -0,0 +1,28 @@
+{ lib, stdenv, fetchFromGitHub, zlib, gmp }:
+
+stdenv.mkDerivation {
+  pname = "open-wbo";
+  version = "2.0";
+
+  src = fetchFromGitHub {
+    owner = "sat-group";
+    repo = "open-wbo";
+    rev = "f193a3bd802551b13d6424bc1baba6ad35ec6ba6";
+    sha256 = "1742i15qfsbf49c4r837wz35c1p7yafvz7ar6vmgcj6cmfwr8jb4";
+  };
+
+  buildInputs = [ zlib gmp ];
+
+  makeFlags = [ "r" ];
+  installPhase = ''
+    install -Dm0755 open-wbo_release $out/bin/open-wbo
+  '';
+
+  meta = with lib; {
+    description = "State-of-the-art MaxSAT and Pseudo-Boolean solver";
+    maintainers = with maintainers; [ gebner ];
+    platforms = platforms.unix;
+    license = licenses.mit;
+    homepage = "http://sat.inesc-id.pt/open-wbo/";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/opensmt/default.nix b/nixpkgs/pkgs/applications/science/logic/opensmt/default.nix
new file mode 100644
index 000000000000..ef6f9b157d2f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/opensmt/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, lib, fetchFromGitHub
+, cmake, libedit, gmpxx, bison, flex
+, enableReadline ? false, readline
+, gtest
+}:
+
+stdenv.mkDerivation rec {
+  pname = "opensmt";
+  version = "2.3.0";
+
+  src = fetchFromGitHub {
+    owner = "usi-verification-and-security";
+    repo = "opensmt";
+    rev = "v${version}";
+    sha256 = "sha256-5Gw9+J+3LHNUNbcHxsQR/ivWndL2P7yBt/Q35fBMg58=";
+  };
+
+  nativeBuildInputs = [ cmake bison flex ];
+  buildInputs = [ libedit gmpxx ]
+    ++ lib.optional enableReadline readline;
+
+  preConfigure = ''
+    substituteInPlace test/CMakeLists.txt \
+      --replace 'FetchContent_Populate' '#FetchContent_Populate'
+  '';
+  cmakeFlags = [
+    "-Dgoogletest_SOURCE_DIR=${gtest.src}"
+    "-Dgoogletest_BINARY_DIR=./gtest-build"
+  ];
+
+  meta = with lib; {
+    description = "A satisfiability modulo theory (SMT) solver";
+    maintainers = [ maintainers.raskin ];
+    platforms = platforms.linux;
+    license = if enableReadline then licenses.gpl2Plus else licenses.mit;
+    homepage = "https://github.com/usi-verification-and-security/opensmt";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/ott/default.nix b/nixpkgs/pkgs/applications/science/logic/ott/default.nix
new file mode 100644
index 000000000000..8752c4ef59d4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/ott/default.nix
@@ -0,0 +1,45 @@
+{ lib, stdenv, fetchFromGitHub, pkg-config, ocaml, opaline }:
+
+stdenv.mkDerivation rec {
+  pname = "ott";
+  version = "0.31";
+
+  src = fetchFromGitHub {
+    owner = "ott-lang";
+    repo = "ott";
+    rev = version;
+    sha256 = "0l81126i2qkz11fs5yrjdgymnqgjcs5avb7f951h61yh1s68jpnn";
+  };
+
+  nativeBuildInputs = [ pkg-config opaline ];
+  buildInputs = [ ocaml ];
+
+  installTargets = "ott.install";
+
+  postInstall = ''
+    opaline -prefix $out
+  ''
+  # There is `emacsPackages.ott-mode` for this now.
+  + ''
+    rm -r $out/share/emacs
+  '';
+
+  meta = {
+    description = "A tool for the working semanticist";
+    longDescription = ''
+      Ott is a tool for writing definitions of programming languages and
+      calculi. It takes as input a definition of a language syntax and
+      semantics, in a concise and readable ASCII notation that is close to
+      what one would write in informal mathematics. It generates LaTeX to
+      build a typeset version of the definition, and Coq, HOL, and Isabelle
+      versions of the definition. Additionally, it can be run as a filter,
+      taking a LaTeX/Coq/Isabelle/HOL source file with embedded (symbolic)
+      terms of the defined language, parsing them and replacing them by
+      target-system terms.
+    '';
+    homepage = "http://www.cl.cam.ac.uk/~pes20/ott";
+    license = lib.licenses.bsd3;
+    maintainers = with lib.maintainers; [ jwiegley ];
+    platforms = lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/otter/default.nix b/nixpkgs/pkgs/applications/science/logic/otter/default.nix
new file mode 100644
index 000000000000..2ad066e53f74
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/otter/default.nix
@@ -0,0 +1,53 @@
+{lib, stdenv, fetchurl, tcsh, libXaw, libXt, libX11}:
+let
+  s = # Generated upstream information
+  rec {
+    version = "3.3f";
+    name = "otter";
+    url = "https://www.cs.unm.edu/~mccune/otter/otter-${version}.tar.gz";
+    sha256 = "16mc1npl7sk9cmqhrf3ghfmvx29inijw76f1b1lsykllaxjqqb1r";
+  };
+  buildInputs = [
+    tcsh libXaw libXt libX11
+  ];
+in
+stdenv.mkDerivation {
+  name = "${s.name}-${s.version}";
+  inherit buildInputs;
+  src = fetchurl {
+    inherit (s) url sha256;
+  };
+
+  hardeningDisable = [ "format" ];
+
+  buildPhase = ''
+    find . -name Makefile | xargs sed -i -e "s@/bin/rm@$(type -P rm)@g"
+    find . -name Makefile | xargs sed -i -e "s@/bin/mv@$(type -P mv)@g"
+    find . -perm -0100 -type f | xargs sed -i -e "s@/bin/csh@$(type -P csh)@g"
+    find . -perm -0100 -type f | xargs sed -i -e "s@/bin/rm@$(type -P rm)@g"
+    find . -perm -0100 -type f | xargs sed -i -e "s@/bin/mv@$(type -P mv)@g"
+
+    sed -i -e "s/^XLIBS *=.*/XLIBS=-lXaw -lXt -lX11/" source/formed/Makefile
+
+    make all
+    make -C examples all
+    make -C examples-mace2 all
+    make -C source/formed realclean
+    make -C source/formed formed
+  '';
+
+  installPhase = ''
+    mkdir -p "$out"/{bin,share/otter}
+    cp bin/* source/formed/formed "$out/bin/"
+    cp -r examples examples-mace2 documents README* Legal Changelog Contents index.html "$out/share/otter/"
+  '';
+
+  meta = {
+    inherit (s) version;
+    description = "A reliable first-order theorem prover";
+    license = lib.licenses.publicDomain ;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.linux;
+    broken = true;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/petrinizer/default.nix b/nixpkgs/pkgs/applications/science/logic/petrinizer/default.nix
new file mode 100644
index 000000000000..e28137dde75b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/petrinizer/default.nix
@@ -0,0 +1,28 @@
+{ mkDerivation
+, async, base, bytestring, containers, fetchFromGitLab, mtl
+, parallel-io, parsec, lib, stm, transformers, sbv_7_13, z3
+}:
+
+mkDerivation rec {
+  pname = "petrinizer";
+  version = "0.9.1.1";
+
+  src = fetchFromGitLab {
+    domain = "gitlab.lrz.de";
+    owner = "i7";
+    repo = pname;
+    rev = version;
+    sha256 = "1n7fzm96gq5rxm2f8w8sr1yzm1zcxpf0b473c6xnhsgqsis5j4xw";
+  };
+
+  isLibrary = false;
+  isExecutable = true;
+  executableHaskellDepends = [
+    async base bytestring containers mtl parallel-io parsec sbv_7_13 stm
+    transformers
+  ];
+  description = "Safety and Liveness Analysis of Petri Nets with SMT solvers";
+  license = lib.licenses.gpl3;
+  maintainers = with lib.maintainers; [ raskin ];
+  inherit (sbv_7_13.meta) platforms;
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/picosat/default.nix b/nixpkgs/pkgs/applications/science/logic/picosat/default.nix
new file mode 100644
index 000000000000..48def5fc2e4d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/picosat/default.nix
@@ -0,0 +1,44 @@
+{ lib, stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  pname = "picosat";
+  version = "965";
+
+  src = fetchurl {
+    url = "http://fmv.jku.at/picosat/${pname}-${version}.tar.gz";
+    sha256 = "0m578rpa5rdn08d10kr4lbsdwp4402hpavrz6n7n53xs517rn5hm";
+  };
+
+  prePatch = ''
+    substituteInPlace picosat.c --replace "sys/unistd.h" "unistd.h"
+
+    substituteInPlace makefile.in \
+      --replace 'ar rc' '$(AR) rc' \
+      --replace 'ranlib' '$(RANLIB)'
+  '';
+
+  configurePhase = "./configure.sh --shared --trace";
+
+  makeFlags = lib.optional stdenv.isDarwin
+    "SONAME=-Wl,-install_name,$(out)/lib/libpicosat.so";
+
+  installPhase = ''
+   mkdir -p $out/bin $out/lib $out/share $out/include/picosat
+   cp picomus picomcs picosat picogcnf "$out"/bin
+
+   cp VERSION      "$out"/share/picosat.version
+   cp picosat.o    "$out"/lib
+   cp libpicosat.a "$out"/lib
+   cp libpicosat.so "$out"/lib
+
+   cp picosat.h "$out"/include/picosat
+  '';
+
+  meta = {
+    description = "SAT solver with proof and core support";
+    homepage    = "http://fmv.jku.at/picosat/";
+    license     = lib.licenses.mit;
+    platforms   = lib.platforms.unix;
+    maintainers = with lib.maintainers; [ roconnor thoughtpolice ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/poly/default.nix b/nixpkgs/pkgs/applications/science/logic/poly/default.nix
new file mode 100644
index 000000000000..7eff519375f2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/poly/default.nix
@@ -0,0 +1,27 @@
+{lib, stdenv, fetchFromGitHub, gmp, cmake, python3}:
+
+stdenv.mkDerivation rec {
+  pname = "libpoly";
+  version = "0.1.11";
+
+  src = fetchFromGitHub {
+    owner = "SRI-CSL";
+    repo = "libpoly";
+    # they've pushed to the release branch, use explicit tag
+    rev = "refs/tags/v${version}";
+    sha256 = "sha256-vrYB6RQYShipZ0c0j1KcSTJR1h0rQKAAeJvODMar1GM=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  buildInputs = [ gmp python3 ];
+
+  strictDeps = true;
+
+  meta = with lib; {
+    homepage = "https://github.com/SRI-CSL/libpoly";
+    description = "C library for manipulating polynomials";
+    license = licenses.lgpl3;
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/potassco/clingcon.nix b/nixpkgs/pkgs/applications/science/logic/potassco/clingcon.nix
new file mode 100644
index 000000000000..1614adf45537
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/potassco/clingcon.nix
@@ -0,0 +1,36 @@
+{ lib, stdenv
+, fetchFromGitHub
+, cmake
+, clingo
+}:
+
+stdenv.mkDerivation rec {
+  pname = "clingcon";
+  version = "5.0.0";
+
+  src = fetchFromGitHub {
+    owner = "potassco";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "1g2xkz9nsgqnrw3fdf5jchl16f0skj5mm32va61scc2yrchll166";
+   };
+
+  nativeBuildInputs = [ cmake clingo ];
+
+  cmakeFlags = [
+    "-DCLINGCON_MANAGE_RPATH=ON"
+    "-DPYCLINGCON_ENABLE=OFF"
+    "-DCLINGCON_BUILD_TESTS=ON"
+  ];
+
+  doCheck = true;
+
+  meta = {
+    description = "Extension of clingo to handle constraints over integers";
+    license = lib.licenses.mit;
+    platforms = lib.platforms.unix;
+    homepage = "https://potassco.org/";
+    downloadPage = "https://github.com/potassco/clingcon/releases/";
+    changelog = "https://github.com/potassco/clingcon/releases/tag/v${version}";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/potassco/clingo.nix b/nixpkgs/pkgs/applications/science/logic/potassco/clingo.nix
new file mode 100644
index 000000000000..754e12c03eea
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/potassco/clingo.nix
@@ -0,0 +1,26 @@
+{ lib, stdenv, fetchFromGitHub, cmake }:
+
+stdenv.mkDerivation rec {
+  pname = "clingo";
+  version = "5.5.1";
+
+  src = fetchFromGitHub {
+    owner = "potassco";
+    repo = "clingo";
+    rev = "v${version}";
+    sha256 = "sha256-KBCwGNkz5HqbgXbDxPVcqxMXC8B2+wRI8eZVVXMVpLI=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  cmakeFlags = [ "-DCLINGO_BUILD_WITH_PYTHON=OFF" ];
+
+  meta = {
+    description = "ASP system to ground and solve logic programs";
+    license = lib.licenses.mit;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.unix;
+    homepage = "https://potassco.org/";
+    downloadPage = "https://github.com/potassco/clingo/releases/";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/prooftree/default.nix b/nixpkgs/pkgs/applications/science/logic/prooftree/default.nix
new file mode 100644
index 000000000000..2606b94f4bbb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/prooftree/default.nix
@@ -0,0 +1,43 @@
+{ lib, stdenv, fetchurl, pkg-config, ncurses, ocamlPackages }:
+
+stdenv.mkDerivation rec {
+  pname = "prooftree";
+  version = "0.13";
+
+  src = fetchurl {
+    url = "https://askra.de/software/prooftree/releases/prooftree-${version}.tar.gz";
+    sha256 = "0z1z4wqbqwgppkh2bm89fgy07a0y2m6g4lvcyzs09sm1ysklk2dh";
+  };
+
+  nativeBuildInputs = [ pkg-config ];
+  buildInputs = [ ncurses ] ++ (with ocamlPackages; [
+    ocaml findlib camlp5 lablgtk ]);
+
+  dontAddPrefix = true;
+  configureFlags = [ "--prefix" "$(out)" ];
+
+  meta = with lib; {
+    description = "A program for proof-tree visualization";
+    longDescription = ''
+      Prooftree is a program for proof-tree visualization during interactive
+      proof development in a theorem prover. It is currently being developed
+      for Coq and Proof General. Prooftree helps against getting lost between
+      different subgoals in interactive proof development. It clearly shows
+      where the current subgoal comes from and thus helps in developing the
+      right plan for solving it.
+
+      Prooftree uses different colors for the already proven subgoals, the
+      current branch in the proof and the still open subgoals. Sequent texts
+      are not displayed in the proof tree itself, but they are shown as a
+      tool-tip when the mouse rests over a sequent symbol. Long proof commands
+      are abbreviated in the tree display, but show up in full length as
+      tool-tip. Both, sequents and proof commands, can be shown in the display
+      below the tree (on single click) or in a separate window (on double or
+      shift-click).
+    '';
+    homepage = "http://askra.de/software/prooftree";
+    platforms = platforms.unix;
+    maintainers = [ maintainers.jwiegley ];
+    license = licenses.gpl3;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/prover9/default.nix b/nixpkgs/pkgs/applications/science/logic/prover9/default.nix
new file mode 100644
index 000000000000..aa01469bfbb8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/prover9/default.nix
@@ -0,0 +1,46 @@
+{ lib, stdenv, fetchurl }:
+
+stdenv.mkDerivation {
+  pname = "prover9";
+  version = "2009-11a";
+
+  src = fetchurl {
+    url = "https://www.cs.unm.edu/~mccune/mace4/download/LADR-2009-11A.tar.gz";
+    sha256 = "1l2i3d3h5z7nnbzilb6z92r0rbx0kh6yaxn2c5qhn3000xcfsay3";
+  };
+
+  hardeningDisable = [ "format" ];
+
+  postPatch = ''
+    RM=$(type -tp rm)
+    MV=$(type -tp mv)
+    CP=$(type -tp cp)
+    for f in Makefile */Makefile; do
+      substituteInPlace $f --replace "/bin/rm" "$RM" \
+        --replace "/bin/mv" "$MV" \
+        --replace "/bin/cp" "$CP";
+    done
+  '';
+
+  buildFlags = [ "all" ];
+
+  checkPhase = "make test1";
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp bin/* $out/bin
+  '';
+
+  meta = with lib; {
+    homepage = "https://www.cs.unm.edu/~mccune/mace4/";
+    license = licenses.gpl1;
+    description = "Automated theorem prover for first-order and equational logic";
+    longDescription = ''
+      Prover9 is a resolution/paramodulation automated theorem prover
+      for first-order and equational logic. Prover9 is a successor of
+      the Otter Prover. This is the LADR command-line version.
+    '';
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/proverif/default.nix b/nixpkgs/pkgs/applications/science/logic/proverif/default.nix
new file mode 100644
index 000000000000..b6d15162fec3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/proverif/default.nix
@@ -0,0 +1,29 @@
+{ lib, stdenv, fetchurl, ocamlPackages }:
+
+stdenv.mkDerivation rec {
+  pname = "proverif";
+  version = "2.04";
+
+  src = fetchurl {
+    url    = "https://bblanche.gitlabpages.inria.fr/proverif/proverif${version}.tar.gz";
+    sha256 = "sha256:0xgwnp59779xc40sb7ck8rmfn620pilxyq79l3bymj9m7z0mwvm9";
+  };
+
+  buildInputs = with ocamlPackages; [ ocaml findlib ];
+
+  buildPhase = "./build -nointeract";
+  installPhase = ''
+    runHook preInstall
+    install -D -t $out/bin proverif proveriftotex
+    install -D -t $out/share/emacs/site-lisp/ emacs/proverif.el
+    runHook postInstall
+  '';
+
+  meta = {
+    description = "Cryptographic protocol verifier in the formal model";
+    homepage    = "https://bblanche.gitlabpages.inria.fr/proverif/";
+    license     = lib.licenses.gpl2;
+    platforms   = lib.platforms.unix;
+    maintainers = with lib.maintainers; [ thoughtpolice vbgl ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/redprl/default.nix b/nixpkgs/pkgs/applications/science/logic/redprl/default.nix
new file mode 100644
index 000000000000..656f3f1b653e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/redprl/default.nix
@@ -0,0 +1,37 @@
+{ lib, stdenv, fetchFromGitHub, mlton }:
+
+stdenv.mkDerivation {
+  pname = "redprl";
+  version = "unstable-2019-11-04";
+
+  src = fetchFromGitHub {
+    owner = "RedPRL";
+    repo = "sml-redprl";
+    rev = "c72190de76f7ed1cfbe1d2046c96e99ac5022b0c";
+    fetchSubmodules = true;
+    sha256 = "sha256-xrQT5o0bsIN+mCYUOz9iY4+j3HGROb1I6R2ADcLy8n4=";
+  };
+
+  buildInputs = [ mlton ];
+
+  postPatch = ''
+    patchShebangs ./script/
+  '';
+
+  buildPhase = ''
+    ./script/mlton.sh
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mv ./bin/redprl $out/bin
+  '';
+
+  meta = with lib; {
+    description = "A proof assistant for Nominal Computational Type Theory";
+    homepage = "http://www.redprl.org/";
+    license = licenses.mit;
+    maintainers = with maintainers; [ acowley ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/sad/default.nix b/nixpkgs/pkgs/applications/science/logic/sad/default.nix
new file mode 100644
index 000000000000..a509d70ed462
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/sad/default.nix
@@ -0,0 +1,41 @@
+{ lib, stdenv, fetchurl, haskell, spass }:
+
+stdenv.mkDerivation rec {
+  pname = "system-for-automated-deduction";
+  version = "2.3.25";
+  src = fetchurl {
+    url = "http://nevidal.org/download/sad-${version}.tar.gz";
+    sha256 = "10jd93xgarik7xwys5lq7fx4vqp7c0yg1gfin9cqfch1k1v8ap4b";
+  };
+  buildInputs = [ haskell.compiler.ghc844 spass ];
+  patches = [
+    ./patch.patch
+    # Since the LTS 12.0 update, <> is an operator in Prelude, colliding with
+    # the <> operator with a different meaning defined by this package
+    ./monoid.patch
+  ];
+  postPatch = ''
+    substituteInPlace Alice/Main.hs --replace init.opt $out/init.opt
+  '';
+  installPhase = ''
+    mkdir -p $out/{bin,provers}
+    install alice $out/bin
+    install provers/moses $out/provers
+    substituteAll provers/provers.dat $out/provers/provers.dat
+    substituteAll init.opt $out/init.opt
+    cp -r examples $out
+  '';
+  inherit spass;
+  meta = {
+    description = "A program for automated proving of mathematical texts";
+    longDescription = ''
+      The system for automated deduction is intended for automated processing of formal mathematical texts
+      written in a special language called ForTheL (FORmal THEory Language) or in a traditional first-order language
+    '';
+    license = lib.licenses.gpl3Plus;
+    maintainers = [ lib.maintainers.schmitthenner ];
+    homepage = "http://nevidal.org/sad.en.html";
+    platforms = lib.platforms.linux;
+    broken = true; # ghc-8.4.4 is gone from Nixpkgs
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/sad/monoid.patch b/nixpkgs/pkgs/applications/science/logic/sad/monoid.patch
new file mode 100644
index 000000000000..da9c21bcae91
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/sad/monoid.patch
@@ -0,0 +1,51 @@
+diff --git a/Alice/Core/Check.hs b/Alice/Core/Check.hs
+index 0700fa0388f..69815864710 100644
+--- a/Alice/Core/Check.hs
++++ b/Alice/Core/Check.hs
+@@ -18,8 +18,12 @@
+  -  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -}
+ 
++{-# LANGUAGE NoImplicitPrelude #-}
++
+ module Alice.Core.Check (fillDef) where
+ 
++import Prelude hiding ((<>))
++
+ import Control.Monad
+ import Data.Maybe
+ 
+diff --git a/Alice/Core/Reason.hs b/Alice/Core/Reason.hs
+index c361bcf220d..4e493d8c91b 100644
+--- a/Alice/Core/Reason.hs
++++ b/Alice/Core/Reason.hs
+@@ -17,9 +17,12 @@
+  -  You should have received a copy of the GNU General Public License
+  -  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -}
++{-# LANGUAGE NoImplicitPrelude #-}
+ 
+ module Alice.Core.Reason where
+ 
++import Prelude hiding ((<>))
++
+ import Control.Monad
+ 
+ import Alice.Core.Base
+diff --git a/Alice/Core/Verify.hs b/Alice/Core/Verify.hs
+index 4f8550bdf11..0f59d135b16 100644
+--- a/Alice/Core/Verify.hs
++++ b/Alice/Core/Verify.hs
+@@ -18,8 +18,12 @@
+  -  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -}
+ 
++{-# LANGUAGE NoImplicitPrelude #-}
++
+ module Alice.Core.Verify (verify) where
+ 
++import Prelude hiding ((<>))
++
+ import Control.Monad
+ import Data.IORef
+ import Data.Maybe
diff --git a/nixpkgs/pkgs/applications/science/logic/sad/patch.patch b/nixpkgs/pkgs/applications/science/logic/sad/patch.patch
new file mode 100644
index 000000000000..a5b1d6177083
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/sad/patch.patch
@@ -0,0 +1,200 @@
+diff -aur serious/sad-2.3-25/Alice/Core/Base.hs sad-2.3-25/Alice/Core/Base.hs
+--- serious/sad-2.3-25/Alice/Core/Base.hs	2008-03-29 18:24:12.000000000 +0000
++++ sad-2.3-25/Alice/Core/Base.hs	2015-11-27 06:38:28.740840823 +0000
+@@ -21,6 +21,7 @@
+ module Alice.Core.Base where
+ 
+ import Control.Monad
++import Control.Applicative
+ import Data.IORef
+ import Data.List
+ import Data.Time
+@@ -61,10 +62,21 @@
+ type CRMC a b = IORef RState -> IO a -> (b -> IO a) -> IO a
+ newtype CRM b = CRM { runCRM :: forall a . CRMC a b }
+ 
++instance Functor CRM where
++  fmap = liftM
++  
++instance Applicative CRM where
++  pure = return
++  (<*>) = ap
++
+ instance Monad CRM where
+   return r  = CRM $ \ _ _ k -> k r
+   m >>= n   = CRM $ \ s z k -> runCRM m s z (\ r -> runCRM (n r) s z k)
+ 
++instance Alternative CRM where
++  (<|>) = mplus
++  empty = mzero
++  
+ instance MonadPlus CRM where
+   mzero     = CRM $ \ _ z _ -> z
+   mplus m n = CRM $ \ s z k -> runCRM m s (runCRM n s z k) k
+diff -aur serious/sad-2.3-25/Alice/Core/Thesis.hs sad-2.3-25/Alice/Core/Thesis.hs
+--- serious/sad-2.3-25/Alice/Core/Thesis.hs	2008-03-05 13:10:50.000000000 +0000
++++ sad-2.3-25/Alice/Core/Thesis.hs	2015-11-27 06:35:08.311015166 +0000
+@@ -21,6 +21,7 @@
+ module Alice.Core.Thesis (thesis) where
+ 
+ import Control.Monad
++import Control.Applicative
+ import Data.List
+ import Data.Maybe
+ 
+@@ -126,11 +127,22 @@
+ 
+ newtype TM res = TM { runTM :: [String] -> [([String], res)] }
+ 
++instance Functor TM where
++  fmap = liftM
++
++instance Applicative TM where
++  pure = return
++  (<*>) = ap
++
+ instance Monad TM where
+   return r  = TM $ \ s -> [(s, r)]
+   m >>= k   = TM $ \ s -> concatMap apply (runTM m s)
+     where apply (s, r) = runTM (k r) s
+ 
++instance Alternative TM where
++  (<|>) = mplus
++  empty = mzero
++    
+ instance MonadPlus TM where
+   mzero     = TM $ \ _ -> []
+   mplus m k = TM $ \ s -> runTM m s ++ runTM k s
+diff -aur serious/sad-2.3-25/Alice/Export/Base.hs sad-2.3-25/Alice/Export/Base.hs
+--- serious/sad-2.3-25/Alice/Export/Base.hs	2008-03-09 09:36:39.000000000 +0000
++++ sad-2.3-25/Alice/Export/Base.hs	2015-11-27 06:32:47.782738005 +0000
+@@ -39,7 +39,7 @@
+ -- Database reader
+ 
+ readPrDB :: String -> IO [Prover]
+-readPrDB file = do  inp <- catch (readFile file) $ die . ioeGetErrorString
++readPrDB file = do  inp <- catchIOError (readFile file) $ die . ioeGetErrorString
+ 
+                     let dws = dropWhile isSpace
+                         cln = reverse . dws . reverse . dws
+diff -aur serious/sad-2.3-25/Alice/Export/Prover.hs sad-2.3-25/Alice/Export/Prover.hs
+--- serious/sad-2.3-25/Alice/Export/Prover.hs	2008-03-09 09:36:39.000000000 +0000
++++ sad-2.3-25/Alice/Export/Prover.hs	2015-11-27 06:36:47.632919161 +0000
+@@ -60,7 +60,7 @@
+       when (askIB IBPdmp False ins) $ putStrLn tsk
+ 
+       seq (length tsk) $ return $
+-        do  (wh,rh,eh,ph) <- catch run
++        do  (wh,rh,eh,ph) <- catchIOError run
+                 $ \ e -> die $ "run error: " ++ ioeGetErrorString e
+ 
+             hPutStrLn wh tsk ; hClose wh
+diff -aur serious/sad-2.3-25/Alice/ForTheL/Base.hs sad-2.3-25/Alice/ForTheL/Base.hs
+--- serious/sad-2.3-25/Alice/ForTheL/Base.hs	2008-03-09 09:36:39.000000000 +0000
++++ sad-2.3-25/Alice/ForTheL/Base.hs	2015-11-27 06:31:51.921230428 +0000
+@@ -226,7 +226,7 @@
+ varlist = do  vs <- chainEx (char ',') var
+               nodups vs ; return vs
+ 
+-nodups vs = unless (null $ dups vs) $
++nodups vs = unless ((null :: [a] -> Bool) $ dups vs) $
+               fail $ "duplicate names: " ++ show vs
+ 
+ hidden  = askPS psOffs >>= \ n -> return ('h':show n)
+diff -aur serious/sad-2.3-25/Alice/Import/Reader.hs sad-2.3-25/Alice/Import/Reader.hs
+--- serious/sad-2.3-25/Alice/Import/Reader.hs	2008-03-09 09:36:39.000000000 +0000
++++ sad-2.3-25/Alice/Import/Reader.hs	2015-11-27 06:36:41.818866167 +0000
+@@ -24,7 +24,7 @@
+ import Control.Monad
+ import System.IO
+ import System.IO.Error
+-import System.Exit
++import System.Exit hiding (die)
+ 
+ import Alice.Data.Text
+ import Alice.Data.Instr
+@@ -44,7 +44,7 @@
+ readInit ""   = return []
+ 
+ readInit file =
+-  do  input <- catch (readFile file) $ die file . ioeGetErrorString
++  do  input <- catchIOError (readFile file) $ die file . ioeGetErrorString
+       let tkn = tokenize input ; ips = initPS ()
+           inp = ips { psRest = tkn, psFile = file, psLang = "Init" }
+       liftM fst $ fireLPM instf inp
+@@ -74,7 +74,7 @@
+ reader lb fs (ps:ss) [TI (InStr ISfile file)] =
+   do  let gfl = if null file  then hGetContents stdin
+                               else readFile file
+-      input <- catch gfl $ die file . ioeGetErrorString
++      input <- catchIOError gfl $ die file . ioeGetErrorString
+       let tkn = tokenize input
+           ips = initPS $ (psProp ps) { tvr_expr = [] }
+           sps = ips { psRest = tkn, psFile = file, psOffs = psOffs ps }
+diff -aur serious/sad-2.3-25/Alice/Parser/Base.hs sad-2.3-25/Alice/Parser/Base.hs
+--- serious/sad-2.3-25/Alice/Parser/Base.hs	2008-03-09 09:36:40.000000000 +0000
++++ sad-2.3-25/Alice/Parser/Base.hs	2015-11-27 06:14:28.616734527 +0000
+@@ -20,6 +20,7 @@
+ 
+ module Alice.Parser.Base where
+ 
++import Control.Applicative
+ import Control.Monad
+ import Data.List
+ 
+@@ -45,11 +46,22 @@
+ type CPMC a b c = (c -> CPMS a b) -> (String -> CPMS a b) -> CPMS a b
+ newtype CPM a c = CPM { runCPM :: forall b . CPMC a b c }
+ 
++instance Functor (CPM a) where
++  fmap = liftM
++
++instance Applicative (CPM a) where
++  pure = return
++  (<*>) = ap
++
+ instance Monad (CPM a) where
+   return r  = CPM $ \ k _ -> k r
+   m >>= n   = CPM $ \ k l -> runCPM m (\ b -> runCPM (n b) k l) l
+   fail e    = CPM $ \ _ l -> l e
+ 
++instance Alternative (CPM a) where
++    (<|>) = mplus
++    empty = mzero
++  
+ instance MonadPlus (CPM a) where
+   mzero     = CPM $ \ _ _ _ z -> z
+   mplus m n = CPM $ \ k l s -> runCPM m k l s . runCPM n k l s
+diff -aur serious/sad-2.3-25/init.opt sad-2.3-25/init.opt
+--- serious/sad-2.3-25/init.opt	2007-10-11 15:25:45.000000000 +0000
++++ sad-2.3-25/init.opt	2015-11-27 07:23:41.372816854 +0000
+@@ -1,6 +1,6 @@
+ # Alice init options
+-[library examples]
+-[provers provers/provers.dat]
++[library @out@/examples]
++[provers @out@/provers/provers.dat]
+ [prover spass]
+ [timelimit 3]
+ [depthlimit 7]
+diff -aur serious/sad-2.3-25/provers/provers.dat sad-2.3-25/provers/provers.dat
+--- serious/sad-2.3-25/provers/provers.dat	2008-08-26 21:20:25.000000000 +0000
++++ sad-2.3-25/provers/provers.dat	2015-11-27 07:24:18.878169702 +0000
+@@ -3,7 +3,7 @@
+ Pmoses
+ LMoses
+ Fmoses
+-Cprovers/moses
++C@out@/provers/moses
+ Yproved in
+ Nfound unprovable in
+ Utimeout in
+@@ -12,7 +12,7 @@
+ Pspass
+ LSPASS
+ Fdfg
+-Cprovers/SPASS -CNFOptSkolem=0 -PProblem=0 -PGiven=0 -Stdin -TimeLimit=%d
++C@spass@/bin/SPASS -CNFOptSkolem=0 -PProblem=0 -PGiven=0 -Stdin -TimeLimit=%d
+ YSPASS beiseite: Proof found.
+ NSPASS beiseite: Completion found.
+ USPASS beiseite: Ran out of time.
diff --git a/nixpkgs/pkgs/applications/science/logic/satallax/default.nix b/nixpkgs/pkgs/applications/science/logic/satallax/default.nix
new file mode 100644
index 000000000000..7a523bbf24ef
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/satallax/default.nix
@@ -0,0 +1,70 @@
+{lib, stdenv, fetchurl, ocaml, zlib, which, eprover, makeWrapper, coq}:
+stdenv.mkDerivation rec {
+  pname = "satallax";
+  version = "2.7";
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ocaml zlib which eprover coq];
+  src = fetchurl {
+    url = "https://www.ps.uni-saarland.de/~cebrown/satallax/downloads/${pname}-${version}.tar.gz";
+    sha256 = "1kvxn8mc35igk4vigi5cp7w3wpxk2z3bgwllfm4n3h2jfs0vkpib";
+  };
+
+  patches = [
+    # GCC9 doesn't allow default value in friend declaration.
+    ./fix-declaration-gcc9.patch
+  ];
+
+  preConfigure = ''
+    mkdir fake-tools
+    echo "echo 'Nix-build-host.localdomain'" > fake-tools/hostname
+    chmod a+x fake-tools/hostname
+    export PATH="$PATH:$PWD/fake-tools"
+
+    (
+      cd picosat-*
+      ./configure
+      make
+    )
+    export PATH="$PATH:$PWD/libexec/satallax"
+
+    mkdir -p "$out/libexec/satallax"
+    cp picosat-*/picosat picosat-*/picomus "$out/libexec/satallax"
+
+    (
+      cd minisat
+      export MROOT=$PWD
+      cd core
+      make
+      cd ../simp
+      make
+    )
+  '';
+
+  postBuild = "echo testing; ! (bash ./test | grep ERROR)";
+
+  installPhase = ''
+    mkdir -p "$out/share/doc/satallax" "$out/bin" "$out/lib" "$out/lib/satallax"
+    cp bin/satallax.opt "$out/bin/satallax"
+    wrapProgram "$out/bin/satallax" \
+      --suffix PATH : "${lib.makeBinPath [ coq eprover ]}:$out/libexec/satallax" \
+      --add-flags "-M" --add-flags "$out/lib/satallax/modes"
+
+    cp LICENSE README "$out/share/doc/satallax"
+
+    cp bin/*.so "$out/lib"
+
+    cp -r modes "$out/lib/satallax/"
+    cp -r problems "$out/lib/satallax/"
+    cp -r coq* "$out/lib/satallax/"
+  '';
+
+  meta = {
+    description = "Automated theorem prover for higher-order logic";
+    license = lib.licenses.mit ;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.linux;
+    downloadPage = "http://www.ps.uni-saarland.de/~cebrown/satallax/downloads.php";
+    homepage = "http://www.ps.uni-saarland.de/~cebrown/satallax/index.php";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/satallax/fix-declaration-gcc9.patch b/nixpkgs/pkgs/applications/science/logic/satallax/fix-declaration-gcc9.patch
new file mode 100644
index 000000000000..1933fc25c4da
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/satallax/fix-declaration-gcc9.patch
@@ -0,0 +1,21 @@
+diff --git i/minisat/core/SolverTypes.h w/minisat/core/SolverTypes.h
+--- i/minisat/core/SolverTypes.h
++++ w/minisat/core/SolverTypes.h
+@@ -47,7 +47,7 @@ struct Lit {
+     int     x;
+ 
+     // Use this as a constructor:
+-    friend Lit mkLit(Var var, bool sign = false);
++    friend Lit mkLit(Var var, bool sign);
+ 
+     bool operator == (Lit p) const { return x == p.x; }
+     bool operator != (Lit p) const { return x != p.x; }
+@@ -55,7 +55,7 @@ struct Lit {
+ };
+ 
+ 
+-inline  Lit  mkLit     (Var var, bool sign) { Lit p; p.x = var + var + (int)sign; return p; }
++inline  Lit  mkLit     (Var var, bool sign = false) { Lit p; p.x = var + var + (int)sign; return p; }
+ inline  Lit  operator ~(Lit p)              { Lit q; q.x = p.x ^ 1; return q; }
+ inline  Lit  operator ^(Lit p, bool b)      { Lit q; q.x = p.x ^ (unsigned int)b; return q; }
+ inline  bool sign      (Lit p)              { return p.x & 1; }
diff --git a/nixpkgs/pkgs/applications/science/logic/saw-tools/default.nix b/nixpkgs/pkgs/applications/science/logic/saw-tools/default.nix
new file mode 100644
index 000000000000..df99d067f08c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/saw-tools/default.nix
@@ -0,0 +1,58 @@
+{ lib, stdenv, fetchurl, gmp4, ncurses, zlib, clang }:
+
+let
+  libPath = lib.makeLibraryPath
+    [ stdenv.cc.libc
+      stdenv.cc.cc
+      gmp4
+      ncurses
+      zlib
+    ] + ":${stdenv.cc.cc.lib}/lib64";
+
+  url = "https://github.com/GaloisInc/saw-script/releases/download";
+
+  saw-bin =
+    if stdenv.hostPlatform.system == "i686-linux"
+    then fetchurl {
+      url    = url + "/v0.1.1-dev/saw-0.1.1-dev-2015-07-31-CentOS6-32.tar.gz";
+      sha256 = "126iag5nnvndi78c921z7vjrjfwcspn1hlxwwhzmqm4rvbhhr9v9";
+    }
+    else fetchurl {
+      url    = url + "/v0.1.1-dev/saw-0.1.1-dev-2015-07-31-CentOS6-64.tar.gz";
+      sha256 = "07gyf319v6ama6n1aj96403as04bixi8mbisfy7f7va689zklflr";
+    };
+in
+stdenv.mkDerivation {
+  pname = "saw-tools";
+  version = "0.1.1-20150731";
+
+  src = saw-bin;
+
+  installPhase = ''
+    mkdir -p $out/lib $out/share
+
+    mv bin $out/bin
+    mv doc $out/share
+
+    ln -s ${ncurses.out}/lib/libtinfo.so.5       $out/lib/libtinfo.so.5
+    ln -s ${stdenv.cc.libc}/lib/libpthread.so.0 $out/lib/libpthread.so.0
+
+    # Add a clang symlink for easy building with a suitable compiler.
+    ln -s ${clang}/bin/clang $out/bin/saw-clang
+  '';
+
+  fixupPhase = ''
+    for x in bin/bcdump bin/extcore-info bin/jss bin/llvm-disasm bin/lss bin/saw; do
+      patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+        --set-rpath "$out/lib:${libPath}" $out/$x;
+    done
+  '';
+
+  meta = {
+    description = "Tools for software verification and analysis";
+    homepage    = "https://saw.galois.com";
+    license     = lib.licenses.bsd3;
+    platforms   = lib.platforms.linux;
+    maintainers = [ lib.maintainers.thoughtpolice ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/spass/default.nix b/nixpkgs/pkgs/applications/science/logic/spass/default.nix
new file mode 100644
index 000000000000..77b297b4fbbb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/spass/default.nix
@@ -0,0 +1,42 @@
+{ lib, stdenv, fetchurl, bison, flex }:
+
+let
+  baseVersion="3";
+  minorVersion="9";
+
+  extraTools = "FLOTTER prolog2dfg dfg2otter dfg2dimacs dfg2tptp"
+    + " dfg2ascii dfg2dfg tptp2dfg dimacs2dfg pgen rescmp";
+in
+
+stdenv.mkDerivation {
+  pname = "spass";
+  version = "${baseVersion}.${minorVersion}";
+
+  src = fetchurl {
+    url = "http://www.spass-prover.org/download/sources/spass${baseVersion}${minorVersion}.tgz";
+    sha256 = "11cyn3kcff4r79rsw2s0xm6rdb8bi0kpkazv2b48jhcms7xw75qp";
+  };
+
+  sourceRoot = ".";
+
+  nativeBuildInputs = [ bison flex ];
+
+  buildPhase = ''
+    make RM="rm -f" proparser.c ${extraTools} opt
+  '';
+  installPhase = ''
+    mkdir -p $out/bin
+    install -m0755 SPASS ${extraTools} $out/bin/
+  '';
+
+  meta = with lib; {
+    description = "Automated theorem prover for first-order logic";
+    maintainers = with maintainers;
+    [
+      raskin
+    ];
+    platforms = platforms.unix;
+    license = licenses.bsd2;
+    downloadPage = "http://www.spass-prover.org/download/index.html";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/statverif/default.nix b/nixpkgs/pkgs/applications/science/logic/statverif/default.nix
new file mode 100644
index 000000000000..07365eef33fa
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/statverif/default.nix
@@ -0,0 +1,34 @@
+{ lib, stdenv, fetchurl, ocaml }:
+
+stdenv.mkDerivation rec {
+  pname = "statverif";
+  version = "1.86pl4";
+
+  src = fetchurl {
+    url    = "http://prosecco.gforge.inria.fr/personal/bblanche/proverif/proverif${version}.tar.gz";
+    sha256 = "163vdcixs764jj8xa08w80qm4kcijf7xj911yp8jvz6pi1q5g13i";
+  };
+
+  pf-patch = fetchurl {
+    url    = "http://markryan.eu/research/statverif/files/proverif-${version}-statverif-2657ab4.patch";
+    sha256 = "113jjhi1qkcggbsmbw8fa9ln8vs7vy2r288szks7rn0jjn0wxmbw";
+  };
+
+  buildInputs = [ ocaml ];
+
+  patchPhase = "patch -p1 < ${pf-patch}";
+  buildPhase = "./build";
+  installPhase = ''
+    mkdir -p $out/bin
+    cp ./proverif      $out/bin/statverif
+    cp ./proveriftotex $out/bin/statveriftotex
+  '';
+
+  meta = {
+    description = "Verification of stateful processes (via Proverif)";
+    homepage    = "https://markryan.eu/research/statverif/";
+    license     = lib.licenses.gpl2;
+    platforms   = lib.platforms.unix;
+    maintainers = [ lib.maintainers.thoughtpolice ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/stp/default.nix b/nixpkgs/pkgs/applications/science/logic/stp/default.nix
new file mode 100644
index 000000000000..42926a870816
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/stp/default.nix
@@ -0,0 +1,33 @@
+{ lib, stdenv, cmake, boost, bison, flex, fetchFromGitHub, perl
+, python3, python3Packages, zlib, minisat, cryptominisat }:
+
+stdenv.mkDerivation rec {
+  pname = "stp";
+  version = "2.3.3";
+
+  src = fetchFromGitHub {
+    owner = "stp";
+    repo = "stp";
+    rev    = version;
+    sha256 = "1yg2v4wmswh1sigk47drwsxyayr472mf4i47lqmlcgn9hhbx1q87";
+  };
+
+  buildInputs = [ boost zlib minisat cryptominisat python3 ];
+  nativeBuildInputs = [ cmake bison flex perl ];
+  preConfigure = ''
+    python_install_dir=$out/${python3Packages.python.sitePackages}
+    mkdir -p $python_install_dir
+    cmakeFlagsArray=(
+      $cmakeFlagsArray
+      "-DBUILD_SHARED_LIBS=ON"
+      "-DPYTHON_LIB_INSTALL_DIR=$python_install_dir"
+    )
+  '';
+
+  meta = with lib; {
+    description = "Simple Theorem Prover";
+    maintainers = with maintainers; [ ];
+    platforms = platforms.linux;
+    license = licenses.mit;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/symbiyosys/default.nix b/nixpkgs/pkgs/applications/science/logic/symbiyosys/default.nix
new file mode 100644
index 000000000000..b9bf480f7e6d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/symbiyosys/default.nix
@@ -0,0 +1,61 @@
+{ lib, stdenv, fetchFromGitHub
+, bash, python3, yosys
+, yices, boolector, z3, aiger
+}:
+
+stdenv.mkDerivation {
+  pname = "symbiyosys";
+  version = "2021.11.30";
+
+  src = fetchFromGitHub {
+    owner = "YosysHQ";
+    repo  = "SymbiYosys";
+    rev   = "b409b1179e36d2a3fff66c85b7d4e271769a2d9e";
+    hash  = "sha256-S7of2upntiMkSdh4kf1RsrjriS31Eh8iEcVvG36isQg=";
+  };
+
+  buildInputs = [ ];
+  patchPhase = ''
+    patchShebangs .
+
+    # Fix up Yosys imports
+    substituteInPlace sbysrc/sby.py \
+      --replace "##yosys-sys-path##" \
+                "sys.path += [p + \"/share/yosys/python3/\" for p in [\"$out\", \"${yosys}\"]]"
+
+    # Fix various executable references
+    substituteInPlace sbysrc/sby_core.py \
+      --replace '"/usr/bin/env", "bash"' '"${bash}/bin/bash"' \
+      --replace ', "btormc"'             ', "${boolector}/bin/btormc"' \
+      --replace ', "aigbmc"'             ', "${aiger}/bin/aigbmc"'
+
+    substituteInPlace sbysrc/sby_core.py \
+      --replace '##yosys-program-prefix##' '"${yosys}/bin/"'
+
+    substituteInPlace sbysrc/sby.py \
+      --replace '/usr/bin/env python3' '${python3}/bin/python'
+  '';
+
+  buildPhase = "true";
+
+  installPhase = ''
+    mkdir -p $out/bin $out/share/yosys/python3
+
+    cp sbysrc/sby_*.py $out/share/yosys/python3/
+    cp sbysrc/sby.py $out/bin/sby
+
+    chmod +x $out/bin/sby
+  '';
+
+  doCheck = false; # not all provers are yet packaged...
+  checkInputs = [ python3 yosys boolector yices z3 aiger ];
+  checkPhase = "make test";
+
+  meta = {
+    description = "Tooling for Yosys-based verification flows";
+    homepage    = "https://symbiyosys.readthedocs.io/";
+    license     = lib.licenses.isc;
+    maintainers = with lib.maintainers; [ thoughtpolice emily ];
+    platforms   = lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/tamarin-prover/default.nix b/nixpkgs/pkgs/applications/science/logic/tamarin-prover/default.nix
new file mode 100644
index 000000000000..08b8a681b2d5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/tamarin-prover/default.nix
@@ -0,0 +1,97 @@
+{ haskellPackages, mkDerivation, fetchFromGitHub, lib
+# the following are non-haskell dependencies
+, makeWrapper, which, maude, graphviz
+}:
+
+let
+  version = "1.6.1";
+  src = fetchFromGitHub {
+    owner  = "tamarin-prover";
+    repo   = "tamarin-prover";
+    rev    = version;
+    sha256 = "sha256:0cz1v7k4d0im749ag632nc34n91b51b0pq4z05rzw1p59a5lza92";
+  };
+
+  # tamarin has its own dependencies, but they're kept inside the repo,
+  # no submodules. this factors out the common metadata among all derivations
+  common = pname: src: {
+    inherit pname version src;
+
+    license     = lib.licenses.gpl3;
+    homepage    = "https://tamarin-prover.github.io";
+    description = "Security protocol verification in the symbolic model";
+    maintainers = [ lib.maintainers.thoughtpolice ];
+  };
+
+  # tamarin use symlinks to the LICENSE and Setup.hs files, so for these sublibraries
+  # we set the patchPhase to fix that. otherwise, cabal cries a lot.
+  replaceSymlinks = ''
+    cp --remove-destination ${src}/LICENSE .;
+    cp --remove-destination ${src}/Setup.hs .;
+  '';
+
+  tamarin-prover-utils = mkDerivation (common "tamarin-prover-utils" (src + "/lib/utils") // {
+    postPatch = replaceSymlinks;
+    libraryHaskellDepends = with haskellPackages; [
+      base64-bytestring blaze-builder
+      dlist exceptions fclabels safe SHA syb
+    ];
+  });
+
+  tamarin-prover-term = mkDerivation (common "tamarin-prover-term" (src + "/lib/term") // {
+    postPatch = replaceSymlinks;
+    libraryHaskellDepends = (with haskellPackages; [
+      attoparsec HUnit
+    ]) ++ [ tamarin-prover-utils ];
+  });
+
+  tamarin-prover-theory = mkDerivation (common "tamarin-prover-theory" (src + "/lib/theory") // {
+    postPatch = replaceSymlinks;
+    doHaddock = false; # broken
+    libraryHaskellDepends = (with haskellPackages; [
+      aeson aeson-pretty parallel uniplate
+    ]) ++ [ tamarin-prover-utils tamarin-prover-term ];
+  });
+
+  tamarin-prover-sapic = mkDerivation (common "tamarin-prover-sapic" (src + "/lib/sapic") // {
+    postPatch = "cp --remove-destination ${src}/LICENSE .";
+    doHaddock = false; # broken
+    libraryHaskellDepends = (with haskellPackages; [
+      raw-strings-qq
+    ]) ++ [ tamarin-prover-theory ];
+  });
+
+in
+mkDerivation (common "tamarin-prover" src // {
+  isLibrary = false;
+  isExecutable = true;
+
+  # strip out unneeded deps manually
+  doHaddock = false;
+  enableSharedExecutables = false;
+  postFixup = "rm -rf $out/lib $out/nix-support $out/share/doc";
+
+  # wrap the prover to be sure it can find maude, sapic, etc
+  executableToolDepends = [ makeWrapper which maude graphviz ];
+  postInstall = ''
+    wrapProgram $out/bin/tamarin-prover \
+      --prefix PATH : ${lib.makeBinPath [ which maude graphviz ]}
+    # so that the package can be used as a vim plugin to install syntax coloration
+    install -Dt $out/share/vim-plugins/tamarin-prover/syntax/ etc/syntax/spthy.vim
+    install etc/filetype.vim -D $out/share/vim-plugins/tamarin-prover/ftdetect/tamarin.vim
+    # Emacs SPTHY major mode
+    install -Dt $out/share/emacs/site-lisp etc/spthy-mode.el
+  '';
+
+  checkPhase = "./dist/build/tamarin-prover/tamarin-prover test";
+
+  executableHaskellDepends = (with haskellPackages; [
+    binary-instances binary-orphans blaze-html conduit file-embed
+    gitrev http-types lifted-base monad-control
+    resourcet shakespeare threads wai warp yesod-core yesod-static
+  ]) ++ [ tamarin-prover-utils
+          tamarin-prover-sapic
+          tamarin-prover-term
+          tamarin-prover-theory
+        ];
+})
diff --git a/nixpkgs/pkgs/applications/science/logic/tlaplus/default.nix b/nixpkgs/pkgs/applications/science/logic/tlaplus/default.nix
new file mode 100644
index 000000000000..8b9f64a8f5b9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/tlaplus/default.nix
@@ -0,0 +1,37 @@
+{ lib, stdenv, fetchurl, makeWrapper, adoptopenjdk-bin, jre }:
+
+stdenv.mkDerivation rec {
+  pname = "tlaplus";
+  version = "1.7.2";
+
+  src = fetchurl {
+    url = "https://github.com/tlaplus/tlaplus/releases/download/v${version}/tla2tools.jar";
+    sha256 = "sha256-+hhUPkTtWXSoW9LGDA3BZiCuEXaA6o5pPSaRmZ7ZCyI=";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ adoptopenjdk-bin ];
+
+  dontUnpack = true;
+  installPhase = ''
+    mkdir -p $out/share/java $out/bin
+    cp $src $out/share/java/tla2tools.jar
+
+    makeWrapper ${jre}/bin/java $out/bin/tlc \
+      --add-flags "-XX:+UseParallelGC -cp $out/share/java/tla2tools.jar tlc2.TLC"
+    makeWrapper ${jre}/bin/java $out/bin/tlasany \
+      --add-flags "-XX:+UseParallelGC -cp $out/share/java/tla2tools.jar tla2sany.SANY"
+    makeWrapper ${jre}/bin/java $out/bin/pcal \
+      --add-flags "-XX:+UseParallelGC -cp $out/share/java/tla2tools.jar pcal.trans"
+    makeWrapper ${jre}/bin/java $out/bin/tlatex \
+      --add-flags "-XX:+UseParallelGC -cp $out/share/java/tla2tools.jar tla2tex.TLA"
+  '';
+
+  meta = {
+    description = "An algorithm specification language with model checking tools";
+    homepage    = "http://lamport.azurewebsites.net/tla/tla.html";
+    license     = lib.licenses.mit;
+    platforms   = lib.platforms.unix;
+    maintainers = with lib.maintainers; [ florentc thoughtpolice ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/tlaplus/tlaps.nix b/nixpkgs/pkgs/applications/science/logic/tlaplus/tlaps.nix
new file mode 100644
index 000000000000..14b3055ab36b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/tlaplus/tlaps.nix
@@ -0,0 +1,58 @@
+{ fetchurl
+, lib
+, stdenv
+, ocaml
+, isabelle
+, cvc3
+, perl
+, wget
+, which
+}:
+
+stdenv.mkDerivation rec {
+  pname = "tlaps";
+  version = "1.4.5";
+  src = fetchurl {
+    url = "https://tla.msr-inria.inria.fr/tlaps/dist/${version}/tlaps-${version}.tar.gz";
+    sha256 = "c296998acd14d5b93a8d5be7ee178007ef179957465966576bda26944b1b7fca";
+  };
+
+  buildInputs = [ ocaml isabelle cvc3 perl wget which ];
+
+  installPhase = ''
+    mkdir -pv "$out"
+    export HOME="$out"
+    export PATH=$out/bin:$PATH
+
+    pushd zenon
+    ./configure --prefix $out
+    make
+    make install
+    popd
+
+    pushd isabelle
+    isabelle build -b Pure
+    popd
+
+    pushd tlapm
+    ./configure --prefix $out
+    make all
+    make install
+  '';
+
+  meta = {
+    description = "Mechanically check TLA+ proofs";
+    longDescription = ''
+      TLA+ is a general-purpose formal specification language that is
+      particularly useful for describing concurrent and distributed
+      systems. The TLA+ proof language is declarative, hierarchical,
+      and scalable to large system specifications. It provides a
+      consistent abstraction over the various “backend” verifiers.
+    '';
+    homepage = "https://tla.msr-inria.inria.fr/tlaps/content/Home.html";
+    license = lib.licenses.bsd2;
+    platforms = lib.platforms.unix;
+    maintainers = with lib.maintainers; [ florentc ];
+  };
+
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/tlaplus/toolbox.nix b/nixpkgs/pkgs/applications/science/logic/tlaplus/toolbox.nix
new file mode 100644
index 000000000000..7b1ee4384c9e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/tlaplus/toolbox.nix
@@ -0,0 +1,100 @@
+{ lib
+, fetchzip
+, makeWrapper
+, makeDesktopItem
+, stdenv
+, gtk3
+, libXtst
+, glib
+, zlib
+, wrapGAppsHook
+}:
+
+let
+  desktopItem = makeDesktopItem rec {
+    name = "TLA+Toolbox";
+    exec = "tla-toolbox";
+    icon = "tla-toolbox";
+    comment = "IDE for TLA+";
+    desktopName = name;
+    genericName = comment;
+    categories = [ "Development" ];
+    startupWMClass = "TLA+ Toolbox";
+  };
+
+
+in
+stdenv.mkDerivation rec {
+  pname = "tla-toolbox";
+  version = "1.7.1";
+  src = fetchzip {
+    url = "https://tla.msr-inria.inria.fr/tlatoolbox/products/TLAToolbox-${version}-linux.gtk.x86_64.zip";
+    sha256 = "02a2y2mkfab5cczw8g604m61h4xr0apir49zbd1aq6mmgcgngw80";
+  };
+
+  buildInputs = [ gtk3 ];
+
+  nativeBuildInputs = [ makeWrapper wrapGAppsHook ];
+
+  dontWrapGApps = true;
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p "$out/bin"
+    cp -r "$src" "$out/toolbox"
+    chmod -R +w "$out/toolbox"
+
+    fixupPhase
+    gappsWrapperArgsHook
+
+    patchelf \
+      --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
+      "$out/toolbox/toolbox"
+
+    patchelf \
+      --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
+      --set-rpath "${lib.makeLibraryPath [ zlib ]}:$(patchelf --print-rpath $(find "$out/toolbox" -name java))" \
+      "$(find "$out/toolbox" -name java)"
+
+    patchelf \
+      --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
+      "$(find "$out/toolbox" -name jspawnhelper)"
+
+    makeWrapper $out/toolbox/toolbox $out/bin/tla-toolbox \
+      --run "set -x; cd $out/toolbox" \
+      --add-flags "-data ~/.tla-toolbox" \
+      --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ gtk3 libXtst glib zlib ]}"  \
+      "''${gappsWrapperArgs[@]}"
+
+    echo -e "\nCreating TLA Toolbox icons..."
+    pushd "$src"
+    for icon_in in $(find . -path "./plugins/*/icons/full/etool16/tla_launch_check_wiz_*.png")
+    do
+      icon_size=$(echo $icon_in | grep -Po "wiz_\K[0-9]+")
+      icon_out="$out/share/icons/hicolor/$icon_size""x$icon_size/apps/tla-toolbox.png"
+      mkdir -p "$(dirname $icon_out)"
+      cp "$icon_in" "$icon_out"
+    done
+    popd
+
+    echo -e "\nCreating TLA Toolbox desktop entry..."
+    cp -r "${desktopItem}/share/applications"* "$out/share/applications"
+
+    runHook postInstall
+  '';
+
+  meta = {
+    homepage = "http://research.microsoft.com/en-us/um/people/lamport/tla/toolbox.html";
+    description = "IDE for the TLA+ tools";
+    longDescription = ''
+      Integrated development environment for the TLA+ tools, based on Eclipse. You can use it
+      to create and edit your specs, run the PlusCal translator, view the pretty-printed
+      versions of your modules, run the TLC model checker, and run TLAPS, the TLA+ proof system.
+    '';
+    # http://lamport.azurewebsites.net/tla/license.html
+    license = with lib.licenses; [ mit ];
+    platforms = [ "x86_64-linux" ];
+    maintainers = [ ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/tptp/default.nix b/nixpkgs/pkgs/applications/science/logic/tptp/default.nix
new file mode 100644
index 000000000000..9c91eaddfc47
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/tptp/default.nix
@@ -0,0 +1,49 @@
+{ lib, stdenv, fetchurl, yap, tcsh, perl, patchelf }:
+
+stdenv.mkDerivation rec {
+  pname = "TPTP";
+  version = "7.2.0";
+
+  src = fetchurl {
+    urls = [
+      "http://tptp.cs.miami.edu/TPTP/Distribution/TPTP-v${version}.tgz"
+      "http://tptp.cs.miami.edu/TPTP/Archive/TPTP-v${version}.tgz"
+    ];
+    sha256 = "0yq8452b6mym4yscy46pshg0z2my8xi74b5bp2qlxd5bjwcrg6rl";
+  };
+
+  nativeBuildInputs = [ patchelf ];
+  buildInputs = [ tcsh yap perl ];
+
+  installPhase = ''
+    sharedir=$out/share/tptp
+
+    mkdir -p $sharedir
+    cp -r ./ $sharedir
+
+    export TPTP=$sharedir
+
+    tcsh $sharedir/Scripts/tptp2T_install -default
+
+    substituteInPlace $sharedir/TPTP2X/tptp2X_install --replace /bin/mv mv
+    tcsh $sharedir/TPTP2X/tptp2X_install -default
+
+    patchelf --interpreter $(cat $NIX_CC/nix-support/dynamic-linker) $sharedir/Scripts/tptp4X
+
+    mkdir -p $out/bin
+    ln -s $sharedir/TPTP2X/tptp2X $out/bin
+    ln -s $sharedir/Scripts/tptp2T $out/bin
+    ln -s $sharedir/Scripts/tptp4X $out/bin
+  '';
+
+  meta = with lib; {
+    description = "Thousands of problems for theorem provers and tools";
+    maintainers = with maintainers; [ raskin gebner ];
+    # 6.3 GiB of data. Installation is unpacking and editing a few files.
+    # No sense in letting Hydra build it.
+    # Also, it is unclear what is covered by "verbatim" - we will edit configs
+    hydraPlatforms = [];
+    platforms = platforms.all;
+    license = licenses.unfreeRedistributable;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/twelf/default.nix b/nixpkgs/pkgs/applications/science/logic/twelf/default.nix
new file mode 100644
index 000000000000..67779b2b5722
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/twelf/default.nix
@@ -0,0 +1,51 @@
+{ lib, stdenv, fetchurl, pkg-config, smlnj, rsync }:
+
+stdenv.mkDerivation rec {
+  pname = "twelf";
+  version = "1.7.1";
+
+  src = fetchurl {
+    url = "http://twelf.plparty.org/releases/twelf-src-${version}.tar.gz";
+    sha256 = "0fi1kbs9hrdrm1x4k13angpjasxlyd1gc3ys8ah54i75qbcd9c4i";
+  };
+
+  nativeBuildInputs = [ pkg-config ];
+  buildInputs = [ smlnj rsync ];
+
+  buildPhase = ''
+    export SMLNJ_HOME=${smlnj}
+    make smlnj
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    rsync -av bin/{*,.heap} $out/bin/
+    bin/.mkexec ${smlnj}/bin/sml $out/ twelf-server twelf-server
+
+    substituteInPlace emacs/twelf-init.el \
+      --replace '(concat twelf-root "emacs")' '(concat twelf-root "share/emacs/site-lisp/twelf")'
+
+    mkdir -p $out/share/emacs/site-lisp/twelf/
+    rsync -av emacs/ $out/share/emacs/site-lisp/twelf/
+
+    mkdir -p $out/share/twelf/examples
+    rsync -av examples/ $out/share/twelf/examples/
+    mkdir -p $out/share/twelf/vim
+    rsync -av vim/ $out/share/twelf/vim/
+  '';
+
+  meta = {
+    description = "Logic proof assistant";
+    longDescription = ''
+      Twelf is a language used to specify, implement, and prove properties of
+      deductive systems such as programming languages and logics. Large
+      research projects using Twelf include the TALT typed assembly language,
+      a foundational proof-carrying-code system, and a type safety proof for
+      Standard ML.
+    '';
+    homepage = "http://twelf.org/wiki/Main_Page";
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ jwiegley ];
+    platforms = lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/vampire/default.nix b/nixpkgs/pkgs/applications/science/logic/vampire/default.nix
new file mode 100644
index 000000000000..307c75b272bc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/vampire/default.nix
@@ -0,0 +1,56 @@
+{ lib, stdenv, fetchFromGitHub, fetchpatch, z3, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "vampire";
+  version = "4.6.1";
+
+  src = fetchFromGitHub {
+    owner = "vprover";
+    repo = "vampire";
+    rev = "v${version}";
+    sha256 = "0z71nxjak3ibp842r8iv37w1x3cbkrmjs88lpvxqb4sgrbyk38zd";
+  };
+
+  buildInputs = [ z3 zlib ];
+
+  makeFlags = [ "vampire_z3_rel" "CC:=$(CC)" "CXX:=$(CXX)" ];
+
+  patches = [
+    # https://github.com/vprover/vampire/pull/54
+    (fetchpatch {
+      name = "fix-apple-cygwin-defines.patch";
+      url = "https://github.com/vprover/vampire/pull/54.patch";
+      sha256 = "0i6nrc50wlg1dqxq38lkpx4rmfb3lf7s8f95l4jkvqp0nxa20cza";
+    })
+    # https://github.com/vprover/vampire/pull/55
+    (fetchpatch {
+      name = "fix-wait-any.patch";
+      url = "https://github.com/vprover/vampire/pull/55.patch";
+      sha256 = "1pwfpwpl23bqsgkmmvw6bnniyvp5j9v8l3z9s9pllfabnfcrcz9l";
+    })
+    # https://github.com/vprover/vampire/pull/56
+    (fetchpatch {
+      name = "fenv.patch";
+      url = "https://github.com/vprover/vampire/pull/56.patch";
+      sha256 = "0xl3jcyqmk146mg3qj5hdd0pbja6wbq3250zmfhbxqrjh40mm40g";
+    })
+  ];
+
+  enableParallelBuilding = true;
+
+  fixupPhase = ''
+    rm -rf z3
+  '';
+
+  installPhase = ''
+    install -m0755 -D vampire_z3_rel* $out/bin/vampire
+  '';
+
+  meta = with lib; {
+    homepage = "https://vprover.github.io/";
+    description = "The Vampire Theorem Prover";
+    platforms = platforms.unix;
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ gebner ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/verifast/default.nix b/nixpkgs/pkgs/applications/science/logic/verifast/default.nix
new file mode 100644
index 000000000000..c610256ccaef
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/verifast/default.nix
@@ -0,0 +1,50 @@
+{ lib, stdenv, fetchurl, gtk2, gdk-pixbuf, atk, pango, glib, cairo, freetype
+, fontconfig, libxml2, gnome2 }:
+
+let
+
+  libPath = lib.makeLibraryPath
+    [ stdenv.cc.libc stdenv.cc.cc gtk2 gdk-pixbuf atk pango glib cairo
+      freetype fontconfig libxml2 gnome2.gtksourceview
+    ] + ":${stdenv.cc.cc.lib}/lib64:$out/libexec";
+
+  patchExe = x: ''
+    patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+      --set-rpath ${libPath} ${x}
+  '';
+
+  patchLib = x: ''
+    patchelf --set-rpath ${libPath} ${x}
+  '';
+
+in
+stdenv.mkDerivation rec {
+  pname = "verifast";
+  version = "21.04";
+
+  src = fetchurl {
+    url    = "https://github.com/verifast/verifast/releases/download/${version}/${pname}-${version}-linux.tar.gz";
+    sha256 = "sha256-PlRsf4wFXoM+E+60SbeKzs/RZK0HNVirX47AnI6NeYM=";
+  };
+
+  dontConfigure = true;
+  dontStrip = true;
+  installPhase = ''
+    mkdir -p $out/bin
+    cp -R bin $out/libexec
+
+    ${patchExe "$out/libexec/verifast"}
+    ${patchExe "$out/libexec/vfide"}
+    ${patchLib "$out/libexec/libz3.so"}
+    ln -s $out/libexec/verifast $out/bin/verifast
+    ln -s $out/libexec/vfide    $out/bin/vfide
+  '';
+
+  meta = {
+    description = "Verification for C and Java programs via separation logic";
+    homepage    = "https://people.cs.kuleuven.be/~bart.jacobs/verifast/";
+    license     = lib.licenses.mit;
+    platforms   = [ "x86_64-linux" ];
+    maintainers = [ lib.maintainers.thoughtpolice ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/verit/default.nix b/nixpkgs/pkgs/applications/science/logic/verit/default.nix
new file mode 100644
index 000000000000..6c0d1061dcab
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/verit/default.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchurl, autoreconfHook, gmp, flex, bison }:
+
+stdenv.mkDerivation {
+  pname = "veriT";
+  version = "2021.06.2";
+
+  src = fetchurl {
+    url = "https://verit.loria.fr/download/2021.06.2/verit-2021.06.2-rmx.tar.gz";
+    sha256 = "1yjvvxnsix0rhilc81ycx1s85dymq366c6zh1hwwd8qxp7k1zca2";
+  };
+
+  nativeBuildInputs = [ autoreconfHook flex bison ];
+  buildInputs = [ gmp ];
+
+  # --disable-static actually enables static linking here...
+  dontDisableStatic = true;
+
+  makeFlags = [ "LEX=${flex}/bin/flex" ];
+
+  preInstall = ''
+    mkdir -p $out/bin
+  '';
+
+  meta = with lib; {
+    description = "An open, trustable and efficient SMT-solver";
+    homepage = "https://verit.loria.fr/";
+    license = licenses.bsd3;
+    platforms = platforms.unix;
+    maintainers = [ maintainers.gebner ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/why3/default.nix b/nixpkgs/pkgs/applications/science/logic/why3/default.nix
new file mode 100644
index 000000000000..0f3dab8038ee
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/why3/default.nix
@@ -0,0 +1,46 @@
+{ callPackage, fetchurl, fetchpatch, lib, stdenv
+, ocamlPackages, coqPackages, rubber, hevea, emacs }:
+
+stdenv.mkDerivation rec {
+  pname = "why3";
+  version = "1.4.1";
+
+  src = fetchurl {
+    url = "https://why3.gitlabpages.inria.fr/releases/${pname}-${version}.tar.gz";
+    sha256 = "sha256:1rqyypzlvagrn43ykl0c5wxyvnry5fl1ykn3xcvlzgghk96yq3jq";
+  };
+
+  buildInputs = with ocamlPackages; [
+    ocaml findlib ocamlgraph zarith menhir
+    # Emacs compilation of why3.el
+    emacs
+    # Documentation
+    rubber hevea
+    # GUI
+    lablgtk3-sourceview3
+    # WebIDE
+    js_of_ocaml js_of_ocaml-ppx
+    # S-expression output for why3pp
+    ppx_deriving ppx_sexp_conv
+    # Coq Support
+    coqPackages.coq coqPackages.flocq
+  ];
+
+  propagatedBuildInputs = with ocamlPackages; [ camlzip menhirLib num re sexplib ];
+
+  enableParallelBuilding = true;
+
+  configureFlags = [ "--enable-verbose-make" ];
+
+  installTargets = [ "install" "install-lib" ];
+
+  passthru.withProvers = callPackage ./with-provers.nix {};
+
+  meta = with lib; {
+    description = "A platform for deductive program verification";
+    homepage    = "http://why3.lri.fr/";
+    license     = licenses.lgpl21;
+    platforms   = platforms.unix;
+    maintainers = with maintainers; [ thoughtpolice vbgl ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/why3/with-provers.nix b/nixpkgs/pkgs/applications/science/logic/why3/with-provers.nix
new file mode 100644
index 000000000000..826473b38e9f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/why3/with-provers.nix
@@ -0,0 +1,32 @@
+{ stdenv, makeWrapper, runCommand, symlinkJoin, why3 }:
+provers:
+let configAwkScript = runCommand "why3-conf.awk" { inherit provers; }
+  ''
+    for p in $provers; do
+      for b in $p/bin/*; do
+        BASENAME=$(basename $b)
+        echo "/^command =/{ gsub(\"$BASENAME\", \"$b\") }" >> $out
+      done
+    done
+    echo '{ print }' >> $out
+  '';
+in
+stdenv.mkDerivation {
+  name = "${why3.name}-with-provers";
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ why3 ] ++ provers;
+
+  dontUnpack = true;
+
+  buildPhase = ''
+    mkdir -p $out/share/why3/
+    why3 config detect -C $out/share/why3/why3.conf
+    awk -i inplace -f ${configAwkScript} $out/share/why3/why3.conf
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    makeWrapper ${why3}/bin/why3 $out/bin/why3 --add-flags "--extra-config $out/share/why3/why3.conf"
+  '';
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/workcraft/default.nix b/nixpkgs/pkgs/applications/science/logic/workcraft/default.nix
new file mode 100644
index 000000000000..0c20faceb54e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/workcraft/default.nix
@@ -0,0 +1,32 @@
+{ lib, stdenv, fetchurl, jre, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  pname = "workcraft";
+  version = "3.3.6";
+
+  src = fetchurl {
+    url = "https://github.com/workcraft/workcraft/releases/download/v${version}/workcraft-v${version}-linux.tar.gz";
+    sha256 = "sha256-5J4HOTz92ALUcZZr15jJ6vplc3KDwbFCXqjEhlOV4kE=";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  dontConfigure = true;
+
+  installPhase = ''
+  mkdir -p $out/share
+  cp -r * $out/share
+  mkdir $out/bin
+  makeWrapper $out/share/workcraft $out/bin/workcraft \
+    --set JAVA_HOME "${jre}" \
+    --set _JAVA_OPTIONS '-Dawt.useSystemAAFontSettings=gasp';
+  '';
+
+  meta = {
+    homepage = "https://workcraft.org/";
+    description = "Framework for interpreted graph modeling, verification and synthesis";
+    platforms = lib.platforms.linux;
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ timor ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/yices/default.nix b/nixpkgs/pkgs/applications/science/logic/yices/default.nix
new file mode 100644
index 000000000000..fb14723241b8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/yices/default.nix
@@ -0,0 +1,39 @@
+{ lib, stdenv, fetchFromGitHub, cudd, gmp-static, gperf, autoreconfHook, libpoly }:
+
+stdenv.mkDerivation rec {
+  pname = "yices";
+  # We never want X.Y.${odd} versions as they are moving development tags.
+  version = "2.6.4";
+
+  src = fetchFromGitHub {
+    owner  = "SRI-CSL";
+    repo   = "yices2";
+    rev    = "Yices-${version}";
+    sha256 = "sha256-qdxh86CkKdm65oHcRgaafTG9GUOoIgTDjeWmRofIpNE=";
+  };
+
+  patches = [
+    # musl las no ldconfig, create symlinks explicitly
+    ./linux-no-ldconfig.patch
+  ];
+  postPatch = "patchShebangs tests/regress/check.sh";
+
+  nativeBuildInputs = [ autoreconfHook ];
+  buildInputs = [ cudd gmp-static gperf libpoly ];
+  configureFlags =
+    [ "--with-static-gmp=${gmp-static.out}/lib/libgmp.a"
+      "--with-static-gmp-include-dir=${gmp-static.dev}/include"
+      "--enable-mcsat"
+    ];
+
+  enableParallelBuilding = true;
+  doCheck = true;
+
+  meta = with lib; {
+    description = "A high-performance theorem prover and SMT solver";
+    homepage    = "http://yices.csl.sri.com";
+    license     = licenses.gpl3;
+    platforms   = with platforms; linux ++ darwin;
+    maintainers = with maintainers; [ thoughtpolice ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/yices/linux-no-ldconfig.patch b/nixpkgs/pkgs/applications/science/logic/yices/linux-no-ldconfig.patch
new file mode 100644
index 000000000000..bad3da6ad4a2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/yices/linux-no-ldconfig.patch
@@ -0,0 +1,13 @@
+--- a/Makefile.build
++++ b/Makefile.build
+@@ -474,8 +474,9 @@ install-darwin: install-default
+ install-solaris: install-default
+ 	$(LDCONFIG) -n $(DESTDIR)$(libdir) && (cd $(DESTDIR)$(libdir) && $(LN_S) -f libyices.so.$(YICES_VERSION) libyices.so)
+ 
++# avoid ldconfig as it's not present on musl
+ install-linux install-unix: install-default
+-	$(LDCONFIG) -n $(DESTDIR)$(libdir) && (cd $(DESTDIR)$(libdir) && $(LN_S) -f libyices.so.$(YICES_VERSION) libyices.so)
++	(cd $(DESTDIR)$(libdir) && $(LN_S) -f libyices.so.$(YICES_VERSION) libyices.so.$(MAJOR).$(MINOR) && $(LN_S) -f libyices.so.$(MAJOR).$(MINOR) libyices.so)
+ 
+ # on FreeBSD: the library file is libyices.so.X.Y and ldconfig does not take -n
+ # TODO: fix this. We must also create a symbolic link: libyices.so.X in libdir
diff --git a/nixpkgs/pkgs/applications/science/logic/z3/4.4.0.nix b/nixpkgs/pkgs/applications/science/logic/z3/4.4.0.nix
new file mode 100644
index 000000000000..2fbaa0a28caf
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/z3/4.4.0.nix
@@ -0,0 +1,41 @@
+{ lib, stdenv, fetchFromGitHub, python }:
+
+stdenv.mkDerivation rec {
+  name = "z3-${version}";
+  version = "4.4.0";
+
+  src = fetchFromGitHub {
+    owner  = "Z3Prover";
+    repo   = "z3";
+    rev    = "7f6ef0b6c0813f2e9e8f993d45722c0e5b99e152";
+    sha256 = "1xllvq9fcj4cz34biq2a9dn2sj33bdgrzyzkj26hqw70wkzv1kzx";
+  };
+
+  buildInputs = [ python ];
+  enableParallelBuilding = true;
+
+  configurePhase = "python scripts/mk_make.py --prefix=$out && cd build";
+
+  # z3's install phase is stupid because it tries to calculate the
+  # python package store location itself, meaning it'll attempt to
+  # write files into the nix store, and fail.
+  soext = stdenv.hostPlatform.extensions.sharedLibrary;
+  installPhase = ''
+    mkdir -p $out/bin $out/lib/${python.libPrefix}/site-packages $out/include
+    cp ../src/api/z3*.h       $out/include
+    cp ../src/api/c++/z3*.h   $out/include
+    cp z3                     $out/bin
+    cp libz3${soext}          $out/lib
+    cp libz3${soext}          $out/lib/${python.libPrefix}/site-packages
+    cp z3*.pyc                $out/lib/${python.libPrefix}/site-packages
+    cp ../src/api/python/*.py $out/lib/${python.libPrefix}/site-packages
+  '';
+
+  meta = {
+    description = "A high-performance theorem prover and SMT solver";
+    homepage    = "https://github.com/Z3Prover/z3";
+    license     = lib.licenses.mit;
+    platforms   = lib.platforms.x86_64;
+    maintainers = with lib.maintainers; [ thoughtpolice ttuegel ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/z3/default.nix b/nixpkgs/pkgs/applications/science/logic/z3/default.nix
new file mode 100644
index 000000000000..a820539eb9a3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/z3/default.nix
@@ -0,0 +1,95 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, python
+, fixDarwinDylibNames
+, javaBindings ? false
+, ocamlBindings ? false
+, pythonBindings ? true
+, jdk ? null
+, ocaml ? null
+, findlib ? null
+, zarith ? null
+, writeScript
+}:
+
+assert javaBindings -> jdk != null;
+assert ocamlBindings -> ocaml != null && findlib != null && zarith != null;
+
+with lib;
+
+stdenv.mkDerivation rec {
+  pname = "z3";
+  version = "4.8.14";
+
+  src = fetchFromGitHub {
+    owner = "Z3Prover";
+    repo = pname;
+    rev = "z3-${version}";
+    sha256 = "jPSTVSndp/T7n+VxZ/g9Rjco00Up+9xeDIVkeLl1MTw=";
+  };
+
+  nativeBuildInputs = optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+  buildInputs = [ python ]
+    ++ optional javaBindings jdk
+    ++ optionals ocamlBindings [ ocaml findlib zarith ]
+  ;
+  propagatedBuildInputs = [ python.pkgs.setuptools ];
+  enableParallelBuilding = true;
+
+  postPatch = optionalString ocamlBindings ''
+    export OCAMLFIND_DESTDIR=$ocaml/lib/ocaml/${ocaml.version}/site-lib
+    mkdir -p $OCAMLFIND_DESTDIR/stublibs
+  '';
+
+  configurePhase = concatStringsSep " "
+    (
+      [ "${python.interpreter} scripts/mk_make.py --prefix=$out" ]
+        ++ optional javaBindings "--java"
+        ++ optional ocamlBindings "--ml"
+        ++ optional pythonBindings "--python --pypkgdir=$out/${python.sitePackages}"
+    ) + "\n" + "cd build";
+
+  postInstall = ''
+    mkdir -p $dev $lib
+    mv $out/lib $lib/lib
+    mv $out/include $dev/include
+  '' + optionalString pythonBindings ''
+    mkdir -p $python/lib
+    mv $lib/lib/python* $python/lib/
+    ln -sf $lib/lib/libz3${stdenv.hostPlatform.extensions.sharedLibrary} $python/${python.sitePackages}/z3/lib/libz3${stdenv.hostPlatform.extensions.sharedLibrary}
+  '' + optionalString javaBindings ''
+    mkdir -p $java/share/java
+    mv com.microsoft.z3.jar $java/share/java
+    moveToOutput "lib/libz3java.${stdenv.hostPlatform.extensions.sharedLibrary}" "$java"
+  '';
+
+  outputs = [ "out" "lib" "dev" "python" ]
+    ++ optional javaBindings "java"
+    ++ optional ocamlBindings "ocaml";
+
+   passthru = {
+    updateScript = writeScript "update-z3" ''
+      #!/usr/bin/env nix-shell
+      #!nix-shell -i bash -p common-updater-scripts curl jq
+
+      set -eu -o pipefail
+
+      # Expect tags in format
+      #    [{name: "Nightly", ..., {name: "z3-vv.vv.vv", ...].
+      # Below we extract frst "z3-vv.vv" and drop "z3-" prefix.
+      newVersion="$(curl -s https://api.github.com/repos/Z3Prover/z3/releases |
+          jq 'first(.[].name|select(startswith("z3-"))|ltrimstr("z3-"))' --raw-output
+      )"
+      update-source-version ${pname} "$newVersion"
+    '';
+   };
+
+  meta = with lib; {
+    description = "A high-performance theorem prover and SMT solver";
+    homepage = "https://github.com/Z3Prover/z3";
+    license = licenses.mit;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ thoughtpolice ttuegel ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/z3/tptp.nix b/nixpkgs/pkgs/applications/science/logic/z3/tptp.nix
new file mode 100644
index 000000000000..23136ddf7a70
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/z3/tptp.nix
@@ -0,0 +1,30 @@
+{lib, stdenv, z3, cmake}:
+stdenv.mkDerivation rec {
+  pname = "z3-tptp";
+  version = z3.version;
+
+  src = z3.src;
+
+  sourceRoot = "source/examples/tptp";
+
+  nativeBuildInputs = [cmake];
+  buildInputs = [z3];
+
+  preConfigure = ''
+    echo 'set(Z3_LIBRARIES "-lz3")' >> CMakeLists.new
+    cat CMakeLists.txt | grep -E 'add_executable|project|link_libraries' >> CMakeLists.new
+    mv CMakeLists.new CMakeLists.txt
+  '';
+
+  installPhase = ''
+    mkdir -p "$out/bin"
+    cp "z3_tptp5" "$out/bin/"
+    ln -s "z3_tptp5" "$out/bin/z3-tptp"
+  '';
+
+  meta = {
+    inherit (z3.meta) license homepage platforms;
+    description = "TPTP wrapper for Z3 prover";
+    maintainers = [lib.maintainers.raskin];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/machine-learning/fasttext/default.nix b/nixpkgs/pkgs/applications/science/machine-learning/fasttext/default.nix
new file mode 100644
index 000000000000..a04ac5a6945e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/fasttext/default.nix
@@ -0,0 +1,23 @@
+{lib, stdenv, fetchFromGitHub, cmake}:
+
+stdenv.mkDerivation rec {
+  pname = "fasttext";
+  version = "0.9.2";
+
+  src = fetchFromGitHub {
+    owner = "facebookresearch";
+    repo = "fastText";
+    rev = "v${version}";
+    sha256 = "07cz2ghfq6amcljaxpdr5chbd64ph513y8zqmibfx2xwfp74xkhn";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  meta = with lib; {
+    description = "Library for text classification and representation learning";
+    homepage = "https://fasttext.cc/";
+    license = licenses.mit;
+    platforms = platforms.unix;
+    maintainers = [ ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/machine-learning/finalfrontier/default.nix b/nixpkgs/pkgs/applications/science/machine-learning/finalfrontier/default.nix
new file mode 100644
index 000000000000..1644ca3d1433
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/finalfrontier/default.nix
@@ -0,0 +1,51 @@
+{ lib
+, stdenv
+, rustPlatform
+, fetchFromGitHub
+, installShellFiles
+, pkg-config
+, libiconv
+, openssl
+, Security
+}:
+
+rustPlatform.buildRustPackage rec {
+  pname = "finalfrontier";
+  version = "0.9.4";
+
+  src = fetchFromGitHub {
+    owner = "finalfusion";
+    repo = pname;
+    rev = version;
+    sha256 = "1lvwv238p8hrl4sc5pmnvaargl2dd25p44gxl3kibq5ng03afd0n";
+  };
+
+  cargoSha256 = "0lhcazcih48gc23q484h344bzz7p3lh189ljhswdyph2i11caarp";
+
+  nativeBuildInputs = [
+    installShellFiles
+    pkg-config
+  ];
+
+  buildInputs = [ openssl ] ++ lib.optionals stdenv.isDarwin [
+    libiconv
+    Security
+  ];
+
+  postInstall = ''
+    installManPage man/*.1
+
+    # Install shell completions
+    for shell in bash fish zsh; do
+      $out/bin/finalfrontier completions $shell > finalfrontier.$shell
+    done
+    installShellCompletion finalfrontier.{bash,fish,zsh}
+  '';
+
+  meta = with lib; {
+    description = "Utility for training word and subword embeddings";
+    homepage = "https://github.com/finalfusion/finalfrontier/";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/machine-learning/finalfusion-utils/default.nix b/nixpkgs/pkgs/applications/science/machine-learning/finalfusion-utils/default.nix
new file mode 100644
index 000000000000..dbb187dc35ee
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/finalfusion-utils/default.nix
@@ -0,0 +1,54 @@
+{ lib
+, stdenv
+, rustPlatform
+, fetchFromGitHub
+, installShellFiles
+, blas
+, gfortran
+, lapack
+, openssl
+, Security
+}:
+
+rustPlatform.buildRustPackage rec {
+  pname = "finalfusion-utils";
+  version = "0.14.1";
+
+  src = fetchFromGitHub {
+    owner = "finalfusion";
+    repo = pname;
+    rev = version;
+    sha256 = "sha256-suzivynlgk4VvDOC2dQR40n5IJHoJ736+ObdrM9dIqE=";
+  };
+
+  cargoSha256 = "sha256-HekjmctuzOWs5k/ihhsV8vVkm6906jEnFf3yvhkrA5Y=";
+
+  nativeBuildInputs = [ installShellFiles ];
+
+  buildInputs = [
+    blas
+    gfortran.cc.lib
+    lapack
+    openssl
+  ] ++ lib.optionals stdenv.isDarwin [
+    Security
+  ];
+
+  # Enables build against a generic BLAS.
+  buildFeatures = [ "netlib" ];
+
+  postInstall = ''
+    # Install shell completions
+    for shell in bash fish zsh; do
+      $out/bin/finalfusion completions $shell > finalfusion.$shell
+    done
+    installShellCompletion finalfusion.{bash,fish,zsh}
+  '';
+
+  meta = with lib; {
+    description = "Utility for converting, quantizing, and querying word embeddings";
+    homepage = "https://github.com/finalfusion/finalfusion-utils/";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/machine-learning/labelimg/default.nix b/nixpkgs/pkgs/applications/science/machine-learning/labelimg/default.nix
new file mode 100644
index 000000000000..620ccfb084ef
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/labelimg/default.nix
@@ -0,0 +1,37 @@
+{ lib, python3Packages, fetchFromGitHub, qt5 }:
+  python3Packages.buildPythonApplication rec {
+    pname = "labelImg";
+    version = "1.8.3";
+    src = fetchFromGitHub {
+      owner = "tzutalin";
+      repo = "labelImg";
+      rev = "v${version}";
+      sha256 = "07v106fzlmxrbag4xm06m4mx9m0gckb27vpwsn7sap1bbgc1pap5";
+    };
+    nativeBuildInputs = with python3Packages; [
+      pyqt5
+      qt5.wrapQtAppsHook
+    ];
+    propagatedBuildInputs = with python3Packages; [
+      pyqt5
+      lxml
+      sip_4
+    ];
+    preBuild = ''
+      make qt5py3
+    '';
+    postInstall = ''
+      cp libs/resources.py $out/${python3Packages.python.sitePackages}/libs
+    '';
+    dontWrapQtApps = true;
+    preFixup = ''
+      makeWrapperArgs+=("''${qtWrapperArgs[@]}")
+    '';
+    meta = with lib; {
+      description = "A graphical image annotation tool and label object bounding boxes in images";
+      homepage = "https://github.com/tzutalin/labelImg";
+      license = licenses.mit;
+      platforms = platforms.linux;
+      maintainers = [ maintainers.cmcdragonkai ];
+    };
+  }
diff --git a/nixpkgs/pkgs/applications/science/machine-learning/nengo-gui/default.nix b/nixpkgs/pkgs/applications/science/machine-learning/nengo-gui/default.nix
new file mode 100644
index 000000000000..6380f25177cb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/nengo-gui/default.nix
@@ -0,0 +1,26 @@
+{ lib, fetchFromGitHub, python3Packages }:
+
+python3Packages.buildPythonPackage rec {
+  pname = "nengo-gui";
+  version = "0.4.8";
+
+  src = fetchFromGitHub {
+    owner = "nengo";
+    repo = "nengo-gui";
+    rev = "v${version}";
+    sha256 = "1awb0h2l6yifb77zah7a4qzxqvkk4ac5fynangalidr10sk9rzk3";
+  };
+
+  propagatedBuildInputs = with python3Packages; [ nengo ];
+
+  # checks req missing:
+  #   pyimgur
+  doCheck = false;
+
+  meta = with lib; {
+    description = "Nengo interactive visualizer";
+    homepage    = "https://nengo.ai/";
+    license     = licenses.unfreeRedistributable;
+    maintainers = with maintainers; [ arjix ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/machine-learning/sc2-headless/default.nix b/nixpkgs/pkgs/applications/science/machine-learning/sc2-headless/default.nix
new file mode 100644
index 000000000000..9438cd972f95
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/sc2-headless/default.nix
@@ -0,0 +1,61 @@
+{ config, stdenv
+, callPackage
+, lib
+, fetchurl
+, unzip
+, licenseAccepted ? config.sc2-headless.accept_license or false
+}:
+
+if !licenseAccepted then throw ''
+    You must accept the Blizzard® Starcraft® II AI and Machine Learning License at
+    https://blzdistsc2-a.akamaihd.net/AI_AND_MACHINE_LEARNING_LICENSE.html
+    by setting nixpkgs config option 'sc2-headless.accept_license = true;'
+  ''
+else assert licenseAccepted;
+let maps = callPackage ./maps.nix {};
+in stdenv.mkDerivation rec {
+  version = "4.7.1";
+  pname = "sc2-headless";
+
+  src = fetchurl {
+    url = "https://blzdistsc2-a.akamaihd.net/Linux/SC2.${version}.zip";
+    sha256 = "0q1ry9bd3dm8y4hvh57yfq7s05hl2k2sxi2wsl6h0r3w690v1kdd";
+  };
+
+  unpackCmd = ''
+    unzip -P 'iagreetotheeula' $curSrc
+  '';
+
+  nativeBuildInputs = [ unzip ];
+
+  installPhase = ''
+    mkdir -p $out
+    cp -r . "$out"
+    rm -r $out/Libs
+
+    cp -ur "${maps.minigames}"/* "${maps.melee}"/* "${maps.ladder2017season1}"/* "${maps.ladder2017season2}"/* "${maps.ladder2017season3}"/* \
+      "${maps.ladder2017season4}"/* "${maps.ladder2018season1}"/* "${maps.ladder2018season2}"/* \
+      "${maps.ladder2018season3}"/*  "${maps.ladder2018season4}"/* "${maps.ladder2019season1}"/* "$out"/Maps/
+  '';
+
+  preFixup = ''
+    find $out -type f -print0 | while IFS=''' read -d ''' -r file; do
+      isELF "$file" || continue
+      patchelf \
+        --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+        --set-rpath ${lib.makeLibraryPath [stdenv.cc.cc stdenv.cc.libc]} \
+        "$file"
+    done
+  '';
+
+  meta = {
+    platforms = lib.platforms.linux;
+    description = "Starcraft II headless linux client for machine learning research";
+    license = {
+      fullName = "BLIZZARD® STARCRAFT® II AI AND MACHINE LEARNING LICENSE";
+      url = "https://blzdistsc2-a.akamaihd.net/AI_AND_MACHINE_LEARNING_LICENSE.html";
+      free = false;
+    };
+    maintainers = with lib.maintainers; [ danharaj ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/machine-learning/sc2-headless/maps.nix b/nixpkgs/pkgs/applications/science/machine-learning/sc2-headless/maps.nix
new file mode 100644
index 000000000000..47e14108e37c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/sc2-headless/maps.nix
@@ -0,0 +1,63 @@
+{ fetchzip
+}:
+let
+  fetchzip' = args: (fetchzip args).overrideAttrs (old: { UNZIP = "-j -P iagreetotheeula"; });
+in
+{
+  minigames = fetchzip {
+    url = "https://github.com/deepmind/pysc2/releases/download/v1.2/mini_games.zip";
+    sha256 = "19f873ilcdsf50g2v0s2zzmxil1bqncsk8nq99bzy87h0i7khkla";
+    stripRoot = false;
+  };
+
+  melee = fetchzip' {
+    url = "http://blzdistsc2-a.akamaihd.net/MapPacks/Melee.zip";
+    sha256 = "0z44pgy10jklsvgpr0kcn4c2mz3hw7nlcmvsy6a6lzpi3dvzf33i";
+    stripRoot = false;
+  };
+  ladder2017season1 = fetchzip' {
+    url = "http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2017Season1.zip";
+    sha256 = "0ngg4g74s2ryhylny93fm8yq9rlrhphwnjg2s6f3qr85a2b3zdpd";
+    stripRoot = false;
+  };
+  ladder2017season2 = fetchzip' {
+    url = "http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2017Season2.zip";
+    sha256 = "01kycnvqagql9pkjkcgngfcnry2pc4kcygdkk511m0qr34909za5";
+    stripRoot = false;
+  };
+  ladder2017season3 = fetchzip' {
+    url = "http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2017Season3_Updated.zip";
+    sha256 = "0wix3lwmbyxfgh8ldg0n66i21p0dbavk2dxjngz79rx708m8qvld";
+    stripRoot = false;
+  };
+  ladder2017season4 = fetchzip' {
+    url = "http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2017Season4.zip";
+    sha256 = "1sidnmk2rc9j5fd3a4623pvaika1mm1rwhznb2qklsqsq1x2qckp";
+    stripRoot = false;
+  };
+  ladder2018season1 = fetchzip' {
+    url = "http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2018Season1.zip";
+    sha256 = "0mp0ilcq0gmd7ahahc5i8c7bdr3ivk6skx0b2cgb1z89l5d76irq";
+    stripRoot = false;
+  };
+  ladder2018season2 = fetchzip' {
+    url = "http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2018Season2_Updated.zip";
+    sha256 = "176rs848cx5src7qbr6dnn81bv1i86i381fidk3v81q9bxlmc2rv";
+    stripRoot = false;
+  };
+  ladder2018season3 = fetchzip' {
+    url = "http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2018Season3.zip";
+    sha256 = "1r3wv4w53g9zq6073ajgv74prbdsd1x3zfpyhv1kpxbffyr0x0zp";
+    stripRoot = false;
+  };
+  ladder2018season4 = fetchzip' {
+    url = "http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2018Season4.zip";
+    sha256 = "0k47rr6pzxbanlqnhliwywkvf0w04c8hxmbanksbz6aj5wpkcn1s";
+    stripRoot = false;
+  };
+  ladder2019season1 = fetchzip' {
+    url = "http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2019Season1.zip";
+    sha256 = "1dlk9zza8h70lbjvg2ykc5wr9vsvvdk02szwrkgdw26mkssl2rg9";
+    stripRoot = false;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/machine-learning/shogun/default.nix b/nixpkgs/pkgs/applications/science/machine-learning/shogun/default.nix
new file mode 100644
index 000000000000..b715c2fc33b3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/shogun/default.nix
@@ -0,0 +1,192 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, fetchpatch
+, fetchurl
+  # build
+, cmake
+, ctags
+, python3Packages
+, swig
+  # math
+, eigen
+, blas
+, lapack
+, glpk
+  # data
+, protobuf
+, json_c
+, libxml2
+, hdf5
+, curl
+  # compression
+, libarchive
+, bzip2
+, xz
+, snappy
+, lzo
+  # more math
+, nlopt
+, lp_solve
+, colpack
+  # extra support
+, pythonSupport ? false
+, opencvSupport ? false
+, opencv ? null
+, withSvmLight ? false
+}:
+
+assert pythonSupport -> python3Packages != null;
+assert opencvSupport -> opencv != null;
+
+assert (!blas.isILP64) && (!lapack.isILP64);
+
+let
+  pname = "shogun";
+  version = "6.1.4";
+
+  rxcppVersion = "4.0.0";
+  gtestVersion = "1.8.0";
+
+  srcs = {
+    toolbox = fetchFromGitHub {
+      owner = pname + "-toolbox";
+      repo = pname;
+      rev = pname + "_" + version;
+      sha256 = "05s9dclmk7x5d7wnnj4qr6r6c827m72a44gizcv09lxr28pr9inz";
+      fetchSubmodules = true;
+    };
+
+    # The CMake external projects expect the packed archives
+    rxcpp = fetchurl {
+      url = "https://github.com/Reactive-Extensions/RxCpp/archive/v${rxcppVersion}.tar.gz";
+      sha256 = "0y2isr8dy2n1yjr9c5570kpc9lvdlch6jv0jvw000amwn5d3krsh";
+    };
+    gtest = fetchurl {
+      url = "https://github.com/google/googletest/archive/release-${gtestVersion}.tar.gz";
+      sha256 = "1n5p1m2m3fjrjdj752lf92f9wq3pl5cbsfrb49jqbg52ghkz99jq";
+    };
+  };
+in
+
+stdenv.mkDerivation rec {
+  inherit pname version;
+
+  outputs = [ "out" "dev" "doc" ];
+
+  src = srcs.toolbox;
+
+  patches = [
+    # Fix compile errors with json-c
+    # https://github.com/shogun-toolbox/shogun/pull/4104
+    (fetchpatch {
+      url = "https://github.com/shogun-toolbox/shogun/commit/365ce4c4c700736d2eec8ba6c975327a5ac2cd9b.patch";
+      sha256 = "158hqv4xzw648pmjbwrhxjp7qcppqa7kvriif87gn3zdn711c49s";
+    })
+
+    # Fix compile errors with GCC 9+
+    # https://github.com/shogun-toolbox/shogun/pull/4811
+    (fetchpatch {
+      url = "https://github.com/shogun-toolbox/shogun/commit/c8b670be4790e0f06804b048a6f3d77c17c3ee95.patch";
+      sha256 = "sha256-MxsR3Y2noFQevfqWK3nmX5iK4OVWeKBl5tfeDNgjcXk=";
+    })
+    (fetchpatch {
+      url = "https://github.com/shogun-toolbox/shogun/commit/5aceefd9fb0e2132c354b9a0c0ceb9160cc9b2f7.patch";
+      sha256 = "sha256-AgJJKQA8vc5oKaTQDqMdwBR4hT4sn9+uW0jLe7GteJw=";
+    })
+
+    # Fix compile errors with Eigen 3.4
+    ./eigen-3.4.patch
+
+  ] ++ lib.optional (!withSvmLight) ./svmlight-scrubber.patch;
+
+  nativeBuildInputs = [ cmake swig ctags ]
+    ++ (with python3Packages; [ python jinja2 ply ]);
+
+  buildInputs = [
+    eigen
+    blas
+    lapack
+    glpk
+    protobuf
+    json_c
+    libxml2
+    hdf5
+    curl
+    libarchive
+    bzip2
+    xz
+    snappy
+    lzo
+    nlopt
+    lp_solve
+    colpack
+  ] ++ lib.optionals pythonSupport (with python3Packages; [ python numpy ])
+    ++ lib.optional opencvSupport opencv;
+
+  cmakeFlags = let
+    enableIf = cond: if cond then "ON" else "OFF";
+  in [
+    "-DBUILD_META_EXAMPLES=ON"
+    "-DCMAKE_DISABLE_FIND_PACKAGE_ARPACK=ON"
+    "-DCMAKE_DISABLE_FIND_PACKAGE_ARPREC=ON"
+    "-DCMAKE_DISABLE_FIND_PACKAGE_CPLEX=ON"
+    "-DCMAKE_DISABLE_FIND_PACKAGE_Mosek=ON"
+    "-DCMAKE_DISABLE_FIND_PACKAGE_TFLogger=ON"
+    "-DCMAKE_DISABLE_FIND_PACKAGE_ViennaCL=ON"
+    "-DCMAKE_SKIP_BUILD_RPATH=OFF"
+    "-DCMAKE_CTEST_ARGUMENTS='--exclude-regex;TrainedModelSerialization'"  # Sporadic segfault
+    "-DENABLE_TESTING=${enableIf doCheck}"
+    "-DDISABLE_META_INTEGRATION_TESTS=ON"
+    "-DTRAVIS_DISABLE_META_CPP=ON"
+    "-DINTERFACE_PYTHON=${enableIf pythonSupport}"
+    "-DOpenCV=${enableIf opencvSupport}"
+    "-DUSE_SVMLIGHT=${enableIf withSvmLight}"
+  ];
+
+  CXXFLAGS = "-faligned-new";
+
+  doCheck = true;
+
+  postUnpack = ''
+    mkdir -p $sourceRoot/third_party/{rxcpp,GoogleMock}
+    ln -s ${srcs.rxcpp} $sourceRoot/third_party/rxcpp/v${rxcppVersion}.tar.gz
+    ln -s ${srcs.gtest} $sourceRoot/third_party/GoogleMock/release-${gtestVersion}.tar.gz
+  '';
+
+  postPatch = ''
+    # Fix preprocessing SVMlight code
+    sed -i \
+        -e 's@#ifdef SVMLIGHT@#ifdef USE_SVMLIGHT@' \
+        -e '/^#ifdef USE_SVMLIGHT/,/^#endif/ s@#endif@#endif //USE_SVMLIGHT@' \
+        src/shogun/kernel/string/CommUlongStringKernel.cpp
+    sed -i -e 's/#if USE_SVMLIGHT/#ifdef USE_SVMLIGHT/' src/interfaces/swig/Machine.i
+    sed -i -e 's@// USE_SVMLIGHT@//USE_SVMLIGHT@' src/interfaces/swig/Transfer.i
+    sed -i -e 's@/\* USE_SVMLIGHT \*/@//USE_SVMLIGHT@' src/interfaces/swig/Transfer_includes.i
+  '' + lib.optionalString (!withSvmLight) ''
+    # Run SVMlight scrubber
+    patchShebangs scripts/light-scrubber.sh
+    echo "removing SVMlight code"
+    ./scripts/light-scrubber.sh
+  '';
+
+  postInstall = ''
+    mkdir -p $doc/share/doc/shogun/examples
+    mv $out/share/shogun/examples/cpp $doc/share/doc/shogun/examples
+    cp ../examples/undocumented/libshogun/*.cpp $doc/share/doc/shogun/examples/cpp
+    rm -r $out/share
+  '';
+
+  postFixup = ''
+    # CMake incorrectly calculates library path from dev prefix
+    substituteInPlace $dev/lib/cmake/shogun/ShogunTargets-release.cmake \
+      --replace "\''${_IMPORT_PREFIX}/lib/" "$out/lib/"
+  '';
+
+  meta = with lib; {
+    description = "A toolbox which offers a wide range of efficient and unified machine learning methods";
+    homepage = "http://shogun-toolbox.org/";
+    license = if withSvmLight then licenses.unfree else licenses.gpl3Plus;
+    maintainers = with maintainers; [ edwtjo smancill ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/machine-learning/shogun/eigen-3.4.patch b/nixpkgs/pkgs/applications/science/machine-learning/shogun/eigen-3.4.patch
new file mode 100644
index 000000000000..863bd75918b0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/shogun/eigen-3.4.patch
@@ -0,0 +1,74 @@
+From: Sebastián Mancilla <smancill@smancill.dev>
+Subject: [PATCH] Fix compile errors when using Eigen 3.4
+
+---
+ .../machine/gp/MultiLaplaceInferenceMethod.cpp | 18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/src/shogun/machine/gp/MultiLaplaceInferenceMethod.cpp b/src/shogun/machine/gp/MultiLaplaceInferenceMethod.cpp
+index 2e27678d2..60050afea 100644
+--- a/src/shogun/machine/gp/MultiLaplaceInferenceMethod.cpp
++++ b/src/shogun/machine/gp/MultiLaplaceInferenceMethod.cpp
+@@ -84,9 +84,9 @@ class CMultiPsiLine : public func_base
+ 		float64_t result=0;
+ 		for(index_t bl=0; bl<C; bl++)
+ 		{
+-			eigen_f.block(bl*n,0,n,1)=K*alpha->block(bl*n,0,n,1)*CMath::exp(log_scale*2.0);
+-			result+=alpha->block(bl*n,0,n,1).dot(eigen_f.block(bl*n,0,n,1))/2.0;
+-			eigen_f.block(bl*n,0,n,1)+=eigen_m;
++			eigen_f.segment(bl*n,n)=K*alpha->segment(bl*n,n)*CMath::exp(log_scale*2.0);
++			result+=alpha->segment(bl*n,n).dot(eigen_f.segment(bl*n,n))/2.0;
++			eigen_f.segment(bl*n,n)+=eigen_m;
+ 		}
+ 
+ 		// get first and second derivatives of log likelihood
+@@ -272,7 +272,7 @@ void CMultiLaplaceInferenceMethod::update_alpha()
+ 	{
+ 		Map<VectorXd> alpha(m_alpha.vector, m_alpha.vlen);
+ 		for(index_t bl=0; bl<C; bl++)
+-			eigen_mu.block(bl*n,0,n,1)=eigen_ktrtr*CMath::exp(m_log_scale*2.0)*alpha.block(bl*n,0,n,1);
++			eigen_mu.segment(bl*n,n)=eigen_ktrtr*CMath::exp(m_log_scale*2.0)*alpha.segment(bl*n,n);
+ 
+ 		//alpha'*(f-m)/2.0
+ 		Psi_New=alpha.dot(eigen_mu)/2.0;
+@@ -316,7 +316,7 @@ void CMultiLaplaceInferenceMethod::update_alpha()
+ 
+ 		for(index_t bl=0; bl<C; bl++)
+ 		{
+-			VectorXd eigen_sD=eigen_dpi.block(bl*n,0,n,1).cwiseSqrt();
++			VectorXd eigen_sD=eigen_dpi.segment(bl*n,n).cwiseSqrt();
+ 			LLT<MatrixXd> chol_tmp((eigen_sD*eigen_sD.transpose()).cwiseProduct(eigen_ktrtr*CMath::exp(m_log_scale*2.0))+
+ 				MatrixXd::Identity(m_ktrtr.num_rows, m_ktrtr.num_cols));
+ 			MatrixXd eigen_L_tmp=chol_tmp.matrixU();
+@@ -341,11 +341,11 @@ void CMultiLaplaceInferenceMethod::update_alpha()
+ 		VectorXd tmp2=m_tmp.array().rowwise().sum();
+ 
+ 		for(index_t bl=0; bl<C; bl++)
+-			eigen_b.block(bl*n,0,n,1)+=eigen_dpi.block(bl*n,0,n,1).cwiseProduct(eigen_mu.block(bl*n,0,n,1)-eigen_mean_bl-tmp2);
++			eigen_b.segment(bl*n,n)+=eigen_dpi.segment(bl*n,n).cwiseProduct(eigen_mu.segment(bl*n,n)-eigen_mean_bl-tmp2);
+ 
+ 		Map<VectorXd> &eigen_c=eigen_W;
+ 		for(index_t bl=0; bl<C; bl++)
+-			eigen_c.block(bl*n,0,n,1)=eigen_E.block(0,bl*n,n,n)*(eigen_ktrtr*CMath::exp(m_log_scale*2.0)*eigen_b.block(bl*n,0,n,1));
++			eigen_c.segment(bl*n,n)=eigen_E.block(0,bl*n,n,n)*(eigen_ktrtr*CMath::exp(m_log_scale*2.0)*eigen_b.segment(bl*n,n));
+ 
+ 		Map<MatrixXd> c_tmp(eigen_c.data(),n,C);
+ 
+@@ -409,7 +409,7 @@ float64_t CMultiLaplaceInferenceMethod::get_derivative_helper(SGMatrix<float64_t
+ 	{
+ 		result+=((eigen_E.block(0,bl*n,n,n)-eigen_U.block(0,bl*n,n,n).transpose()*eigen_U.block(0,bl*n,n,n)).array()
+ 			*eigen_dK.array()).sum();
+-		result-=(eigen_dK*eigen_alpha.block(bl*n,0,n,1)).dot(eigen_alpha.block(bl*n,0,n,1));
++		result-=(eigen_dK*eigen_alpha.segment(bl*n,n)).dot(eigen_alpha.segment(bl*n,n));
+ 	}
+ 
+ 	return result/2.0;
+@@ -489,7 +489,7 @@ SGVector<float64_t> CMultiLaplaceInferenceMethod::get_derivative_wrt_mean(
+ 		result[i]=0;
+ 		//currently only compute the explicit term
+ 		for(index_t bl=0; bl<C; bl++)
+-			result[i]-=eigen_alpha.block(bl*n,0,n,1).dot(eigen_dmu);
++			result[i]-=eigen_alpha.segment(bl*n,n).dot(eigen_dmu);
+ 	}
+ 
+ 	return result;
diff --git a/nixpkgs/pkgs/applications/science/machine-learning/shogun/svmlight-scrubber.patch b/nixpkgs/pkgs/applications/science/machine-learning/shogun/svmlight-scrubber.patch
new file mode 100644
index 000000000000..2958e6ce5dae
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/shogun/svmlight-scrubber.patch
@@ -0,0 +1,76 @@
+From: Sebastián Mancilla <smancill@smancill.dev>
+Subject: Update SVMlight scrubber script
+
+This requires previously fixing a few wrong preprocessor directives that
+are supposed to fence code using SVMlight.
+
+- The script was too eager and removing *.light files in SVMlight format
+  that are used by other tests. The code reading those files doesn't use
+  any SVMlight code so it should be fine to keep it and run the tests.
+
+- The Python test *domainadaptationsvm.py was not removed because of
+  wrong globbing.
+
+- Remove a couple of examples using SVMlight that were missed.
+
+- The script is actually modifying (and breaking) itself because the
+  grep for the USE_SVMLIGHT macro is too eager again and matches itself
+  (and the version stored in upstream's Debian package control tarball
+  is broken because of it). Just fix it by grepping for preprocessor
+  directives only.
+
+- No need to fix the Transfer_includes.i file in the script with a final
+  %} when its preprocessor directives have been fixed.
+
+- The Swig files were moved to a new directory at some point but the
+  script was not updated accordingly.
+---
+ scripts/light-scrubber.sh | 16 ++++++----------
+ 1 file changed, 6 insertions(+), 10 deletions(-)
+
+diff a/scripts/light-scrubber.sh b/scripts/light-scrubber.sh
+--- a/scripts/light-scrubber.sh
++++ b/scripts/light-scrubber.sh
+@@ -26,14 +26,16 @@
+ # You should have received a copy of the GNU General Public License
+ # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ #
+-rm -rf	examples/*/*/{*light*,*_domainadaptationsvm_*}				\
++rm -rf	examples/*/*/{*light*.*,*domainadaptationsvm*}				\
+ 	examples/undocumented/matlab_and_octave/tests/*light*			\
++	examples/undocumented/python/serialization_string_kernels.py		\
++	examples/undocumented/python/mkl_binclass.py				\
+ 	src/shogun/classifier/svm/SVMLight.*					\
+ 	src/shogun/classifier/svm/SVMLightOneClass.*				\
+ 	src/shogun/regression/svr/SVRLight.*					\
+ 	doc/md/LICENSE_SVMlight*
+ 
+-for _file in `grep -rl USE_SVMLIGHT .`
++grep -rl '^#ifdef USE_SVMLIGHT' . | while read -r _file
+ do
+   sed -i.orig -e								\
+ 	'/\#ifdef USE_SVMLIGHT/,/\#endif \/\/USE_SVMLIGHT/c \\' ${_file} &&	\
+@@ -41,7 +43,7 @@ do
+   rm -rf ${_file}.orig
+ done
+ 
+-for _file in `find . -depth -name 'CMakeLists.txt'`
++find . -depth -name 'CMakeLists.txt' | while read -r _file
+ do
+   sed -i.orig -e 's!.*_sv[mr]light_.*!!g' ${_file} &&				\
+   touch -r ${_file}.orig ${_file} &&						\
+@@ -56,13 +58,7 @@ do
+   rm -rf ${_file}.orig
+ done
+ 
+-_file="src/interfaces/modular/Transfer_includes.i" &&				\
+-cp -a ${_file} ${_file}.orig &&							\
+-echo '%}' >> ${_file} &&							\
+-touch -r ${_file}.orig ${_file} &&						\
+-rm -rf ${_file}.orig
+-
+-_file="src/interfaces/modular/Machine.i" &&					\
++_file="src/interfaces/swig/Machine.i" &&					\
+ sed -i.orig -e '/.*CSVRLight.*/d' ${_file} &&					\
+ touch -r ${_file}.orig ${_file} &&						\
+ rm -rf ${_file}.orig
diff --git a/nixpkgs/pkgs/applications/science/machine-learning/starspace/default.nix b/nixpkgs/pkgs/applications/science/machine-learning/starspace/default.nix
new file mode 100644
index 000000000000..81e0ccc71d66
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/starspace/default.nix
@@ -0,0 +1,37 @@
+{ lib, stdenv, fetchFromGitHub, boost165, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "starspace";
+  version = "unstable-2021-01-17";
+
+  src = fetchFromGitHub {
+    owner = "facebookresearch";
+    repo = pname;
+    rev = "8aee0a950aa607c023e5c91cff518bec335b5df5";
+    sha256 = "0sc7a37z1skb9377a1qs8ggwrkz0nmpybx7sms38xj05b702kbvj";
+  };
+
+  buildInputs = [ boost165 zlib ];
+
+  makeFlags = [
+    "CXX=${stdenv.cc.targetPrefix}c++"
+    "BOOST_DIR=${boost165.dev}/include"
+  ];
+
+  preBuild = ''
+    cp makefile_compress makefile
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mv starspace $out/bin
+  '';
+
+  meta = with lib; {
+    description = "General-purpose neural model for efficient learning of entity embeddings";
+    homepage = "https://ai.facebook.com/tools/starspace/";
+    license = licenses.mit;
+    platforms = platforms.unix;
+    maintainers = [ maintainers.mausch ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/machine-learning/streamlit/default.nix b/nixpkgs/pkgs/applications/science/machine-learning/streamlit/default.nix
new file mode 100755
index 000000000000..f439b113d1ab
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/streamlit/default.nix
@@ -0,0 +1,89 @@
+{
+  # Nix
+  lib,
+  buildPythonApplication,
+  fetchPypi,
+
+  # Build inputs
+  altair,
+  astor,
+  base58,
+  blinker,
+  boto3,
+  botocore,
+  click,
+  cachetools,
+  enum-compat,
+  future,
+  GitPython,
+  jinja2,
+  pillow,
+  pyarrow,
+  pydeck,
+  pympler,
+  protobuf,
+  requests,
+  setuptools,
+  toml,
+  tornado,
+  tzlocal,
+  validators,
+  watchdog,
+}:
+
+let
+  click_7 = click.overridePythonAttrs(old: rec {
+    version = "7.1.2";
+    src = old.src.override {
+      inherit version;
+      sha256 = "d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a";
+    };
+  });
+in buildPythonApplication rec {
+  pname = "streamlit";
+  version = "1.2.0";
+  format = "wheel"; # the only distribution available
+
+  src = fetchPypi {
+    inherit pname version format;
+    sha256 = "1dzb68a8n8wvjppcmqdaqnh925b2dg6rywv51ac9q09zjxb6z11n";
+  };
+
+  propagatedBuildInputs = [
+    altair
+    astor
+    base58
+    blinker
+    boto3
+    botocore
+    cachetools
+    click_7
+    enum-compat
+    future
+    GitPython
+    jinja2
+    pillow
+    protobuf
+    pyarrow
+    pydeck
+    pympler
+    requests
+    setuptools
+    toml
+    tornado
+    tzlocal
+    validators
+    watchdog
+  ];
+
+  postInstall = ''
+      rm $out/bin/streamlit.cmd # remove windows helper
+  '';
+
+  meta = with lib; {
+    homepage = "https://streamlit.io/";
+    description = "The fastest way to build custom ML tools";
+    maintainers = with maintainers; [ yrashk ];
+    license = licenses.asl20;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/machine-learning/vowpal-wabbit/default.nix b/nixpkgs/pkgs/applications/science/machine-learning/vowpal-wabbit/default.nix
new file mode 100644
index 000000000000..8dd55efaeb52
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/vowpal-wabbit/default.nix
@@ -0,0 +1,53 @@
+{ lib, stdenv, fetchFromGitHub, cmake, boost, flatbuffers, rapidjson, spdlog, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "vowpal-wabbit";
+  version = "9.0.1";
+
+  src = fetchFromGitHub {
+    owner = "VowpalWabbit";
+    repo = "vowpal_wabbit";
+    rev = version;
+    sha256 = "sha256-ZUurY2bmTKKIW4GR4oiIpLxb6DSRUNJI/EyNSOu9D9c=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  buildInputs = [
+    boost
+    flatbuffers
+    rapidjson
+    spdlog
+    zlib
+  ];
+
+  # -DBUILD_TESTS=OFF is set as both it saves time in the build and the default
+  # cmake flags appended by the builder include -DBUILD_TESTING=OFF for which
+  # this is the equivalent flag.
+  # Flatbuffers are an optional feature.
+  # BUILD_FLATBUFFERS=ON turns it on. This will still consume Flatbuffers as a
+  # system dependency
+  cmakeFlags = [
+    "-DVW_INSTALL=ON"
+    "-DBUILD_TESTS=OFF"
+    "-DBUILD_JAVA=OFF"
+    "-DBUILD_PYTHON=OFF"
+    "-DUSE_LATEST_STD=ON"
+    "-DRAPIDJSON_SYS_DEP=ON"
+    "-DFMT_SYS_DEP=ON"
+    "-DSPDLOG_SYS_DEP=ON"
+    "-DBUILD_FLATBUFFERS=ON"
+  ];
+
+  meta = with lib; {
+    description = "Machine learning system focused on online reinforcement learning";
+    homepage = "https://github.com/VowpalWabbit/vowpal_wabbit/";
+    license = licenses.bsd3;
+    longDescription = ''
+      Machine learning system which pushes the frontier of machine learning with techniques such as online,
+      hashing, allreduce, reductions, learning2search, active, and interactive and reinforcement learning
+    '';
+    maintainers = with maintainers; [ jackgerrits ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/4ti2/default.nix b/nixpkgs/pkgs/applications/science/math/4ti2/default.nix
new file mode 100644
index 000000000000..bb6a89385ce0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/4ti2/default.nix
@@ -0,0 +1,38 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, autoreconfHook
+, glpk
+, gmp
+}:
+
+stdenv.mkDerivation rec{
+  pname = "4ti2";
+  version = "1.6.9";
+
+  src = fetchFromGitHub {
+    owner = pname;
+    repo = pname;
+    rev = "Release_${builtins.replaceStrings ["."] ["_"] version}";
+    hash = "sha256-cywneIM0sHt1iQsNfjyQDoDfdRjxpz4l3rfysi9YN20=";
+  };
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  buildInputs = [
+    glpk
+    gmp
+  ];
+
+  installFlags = [ "install-exec" ];
+
+  meta = with lib;{
+    homepage = "https://4ti2.github.io/";
+    description = "A software package for algebraic, geometric and combinatorial problems on linear spaces";
+    license = with licenses; [ gpl2Plus ];
+    maintainers = with maintainers; [ AndersonTorres ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/LiE/default.nix b/nixpkgs/pkgs/applications/science/math/LiE/default.nix
new file mode 100644
index 000000000000..9b16fc1d67f6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/LiE/default.nix
@@ -0,0 +1,47 @@
+{ lib, stdenv, fetchurl
+, bison, readline }:
+
+stdenv.mkDerivation {
+  version = "2.2.2";
+     # The current version of LiE is 2.2.2, which is more or less unchanged
+     # since about the year 2000. Minor bugfixes do get applied now and then.
+  pname = "lie";
+
+  meta = {
+    description = "A Computer algebra package for Lie group computations";
+    homepage = "http://wwwmathlabo.univ-poitiers.fr/~maavl/LiE/";
+    license = lib.licenses.lgpl3; # see the website
+
+    longDescription = ''
+      LiE is a computer algebra system that is specialised in computations
+      involving (reductive) Lie groups and their representations. It is
+      publically available for free in source code. For a description of its
+      characteristics, we refer to the following sources of information.
+    ''; # take from the website
+
+    platforms = lib.platforms.linux;
+    maintainers = [ ]; # this package is probably not going to change anyway
+  };
+
+  src = fetchurl {
+    url = "http://wwwmathlabo.univ-poitiers.fr/~maavl/LiE/conLiE.tar.gz";
+    sha256 = "07lbj75qqr4pq1j1qz8fyfnmrz1gnk92lnsshxycfavxl5zzdmn4";
+  };
+
+  buildInputs = [ bison readline ];
+
+  patchPhase = ''
+    substituteInPlace make_lie \
+      --replace \`/bin/pwd\` $out
+  '';
+
+  installPhase = ''
+    mkdir -vp $out/bin
+
+    cp -v Lie.exe $out
+    cp -v lie $out/bin
+
+    cp -v LEARN* $out
+    cp -v INFO* $out
+  '';
+}
diff --git a/nixpkgs/pkgs/applications/science/math/R/default.nix b/nixpkgs/pkgs/applications/science/math/R/default.nix
new file mode 100644
index 000000000000..4bd237f87834
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/R/default.nix
@@ -0,0 +1,132 @@
+{ lib, stdenv, fetchurl, bzip2, gfortran, libX11, libXmu, libXt, libjpeg, libpng
+, libtiff, ncurses, pango, pcre2, perl, readline, tcl, texLive, tk, xz, zlib
+, less, texinfo, graphviz, icu, pkg-config, bison, imake, which, jdk, blas, lapack
+, curl, Cocoa, Foundation, libobjc, libcxx, tzdata
+, withRecommendedPackages ? true
+, enableStrictBarrier ? false
+, enableMemoryProfiling ? false
+# R as of writing does not support outputting both .so and .a files; it outputs:
+#     --enable-R-static-lib conflicts with --enable-R-shlib and will be ignored
+, static ? false
+}:
+
+assert (!blas.isILP64) && (!lapack.isILP64);
+
+stdenv.mkDerivation rec {
+  pname = "R";
+  version = "4.1.2";
+
+  src = fetchurl {
+    url = "https://cran.r-project.org/src/base/R-${lib.versions.major version}/${pname}-${version}.tar.gz";
+    sha256 = "sha256-IDYiXp9yB9TOCX5Ulyrs2qi0DX2ZEc0mSR+sWg+rOK8=";
+  };
+
+  dontUseImakeConfigure = true;
+
+  buildInputs = [
+    bzip2 gfortran libX11 libXmu libXt libXt libjpeg libpng libtiff ncurses
+    pango pcre2 perl readline texLive xz zlib less texinfo graphviz icu
+    pkg-config bison imake which blas lapack curl tcl tk jdk
+  ] ++ lib.optionals stdenv.isDarwin [ Cocoa Foundation libobjc libcxx ];
+
+  patches = [
+    ./no-usr-local-search-paths.patch
+  ];
+
+  # Test of the examples for package 'tcltk' fails in Darwin sandbox. See:
+  # https://github.com/NixOS/nixpkgs/issues/146131
+  postPatch = lib.optionalString stdenv.isDarwin ''
+    substituteInPlace configure \
+      --replace "-install_name libRblas.dylib" "-install_name $out/lib/R/lib/libRblas.dylib" \
+      --replace "-install_name libRlapack.dylib" "-install_name $out/lib/R/lib/libRlapack.dylib" \
+      --replace "-install_name libR.dylib" "-install_name $out/lib/R/lib/libR.dylib"
+    substituteInPlace tests/Examples/Makefile.in \
+      --replace "test-Examples: test-Examples-Base" "test-Examples:" # do not test the examples
+  '';
+
+  dontDisableStatic = static;
+
+  preConfigure = ''
+    configureFlagsArray=(
+      --disable-lto
+      --with${lib.optionalString (!withRecommendedPackages) "out"}-recommended-packages
+      --with-blas="-L${blas}/lib -lblas"
+      --with-lapack="-L${lapack}/lib -llapack"
+      --with-readline
+      --with-tcltk --with-tcl-config="${tcl}/lib/tclConfig.sh" --with-tk-config="${tk}/lib/tkConfig.sh"
+      --with-cairo
+      --with-libpng
+      --with-jpeglib
+      --with-libtiff
+      --with-ICU
+      ${lib.optionalString enableStrictBarrier "--enable-strict-barrier"}
+      ${lib.optionalString enableMemoryProfiling "--enable-memory-profiling"}
+      ${if static then "--enable-R-static-lib" else "--enable-R-shlib"}
+      AR=$(type -p ar)
+      AWK=$(type -p gawk)
+      CC=$(type -p cc)
+      CXX=$(type -p c++)
+      FC="${gfortran}/bin/gfortran" F77="${gfortran}/bin/gfortran"
+      JAVA_HOME="${jdk}"
+      RANLIB=$(type -p ranlib)
+      R_SHELL="${stdenv.shell}"
+  '' + lib.optionalString stdenv.isDarwin ''
+      --disable-R-framework
+      --without-x
+      OBJC="clang"
+      CPPFLAGS="-isystem ${lib.getDev libcxx}/include/c++/v1"
+      LDFLAGS="-L${lib.getLib libcxx}/lib"
+  '' + ''
+    )
+    echo >>etc/Renviron.in "TCLLIBPATH=${tk}/lib"
+    echo >>etc/Renviron.in "TZDIR=${tzdata}/share/zoneinfo"
+  '';
+
+  installTargets = [ "install" "install-info" "install-pdf" ];
+
+  # The store path to "which" is baked into src/library/base/R/unix/system.unix.R,
+  # but Nix cannot detect it as a run-time dependency because the installed file
+  # is compiled and compressed, which hides the store path.
+  postFixup = "echo ${which} > $out/nix-support/undetected-runtime-dependencies";
+
+  doCheck = true;
+  preCheck = "export TZ=CET; bin/Rscript -e 'sessionInfo()'";
+
+  enableParallelBuilding = true;
+
+  # disable stackprotector on aarch64-darwin for now
+  # https://github.com/NixOS/nixpkgs/issues/158730
+  # see https://github.com/NixOS/nixpkgs/issues/127608 for a similar issue
+  hardeningDisable = lib.optionals (stdenv.isAarch64 && stdenv.isDarwin) [ "stackprotector" ];
+
+  setupHook = ./setup-hook.sh;
+
+  meta = with lib; {
+    homepage = "http://www.r-project.org/";
+    description = "Free software environment for statistical computing and graphics";
+    license = licenses.gpl2Plus;
+
+    longDescription = ''
+      GNU R is a language and environment for statistical computing and
+      graphics that provides a wide variety of statistical (linear and
+      nonlinear modelling, classical statistical tests, time-series
+      analysis, classification, clustering, ...) and graphical
+      techniques, and is highly extensible. One of R's strengths is the
+      ease with which well-designed publication-quality plots can be
+      produced, including mathematical symbols and formulae where
+      needed. R is an integrated suite of software facilities for data
+      manipulation, calculation and graphical display. It includes an
+      effective data handling and storage facility, a suite of operators
+      for calculations on arrays, in particular matrices, a large,
+      coherent, integrated collection of intermediate tools for data
+      analysis, graphical facilities for data analysis and display
+      either on-screen or on hardcopy, and a well-developed, simple and
+      effective programming language which includes conditionals, loops,
+      user-defined recursive functions and input and output facilities.
+    '';
+
+    platforms = platforms.all;
+
+    maintainers = with maintainers; [ jbedo ] ++ teams.sage.members;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/R/no-usr-local-search-paths.patch b/nixpkgs/pkgs/applications/science/math/R/no-usr-local-search-paths.patch
new file mode 100644
index 000000000000..6c7f6d4ee02a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/R/no-usr-local-search-paths.patch
@@ -0,0 +1,24 @@
+diff -ubr R-3.0.1-orig/configure R-3.0.1/configure
+--- R-3.0.1-orig/configure	2013-07-04 10:46:42.336133947 +0200
++++ R-3.0.1/configure	2013-07-04 10:46:17.181919960 +0200
+@@ -3800,13 +3800,13 @@
+ : ${LIBnn=$libnn}
+ ## We provide these defaults so that headers and libraries in
+ ## '/usr/local' are found (by the native tools, mostly).
+-if test -f "/sw/etc/fink.conf"; then
+-  : ${CPPFLAGS="-I/sw/include -I/usr/local/include"}
+-  : ${LDFLAGS="-L/sw/lib -L/usr/local/lib"}
+-else
+-  : ${CPPFLAGS="-I/usr/local/include"}
+-  : ${LDFLAGS="-L/usr/local/${LIBnn}"}
+-fi
++# if test -f "/sw/etc/fink.conf"; then
++#   : ${CPPFLAGS="-I/sw/include -I/usr/local/include"}
++#   : ${LDFLAGS="-L/sw/lib -L/usr/local/lib"}
++# else
++#   : ${CPPFLAGS="-I/usr/local/include"}
++#   : ${LDFLAGS="-L/usr/local/${LIBnn}"}
++# fi
+ 
+ ## take care not to  override the command-line setting
+ if test "${libdir}" = '${exec_prefix}/lib'; then
diff --git a/nixpkgs/pkgs/applications/science/math/R/setup-hook.sh b/nixpkgs/pkgs/applications/science/math/R/setup-hook.sh
new file mode 100644
index 000000000000..6951e2a4b61b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/R/setup-hook.sh
@@ -0,0 +1,7 @@
+addRLibPath () {
+    if [[ -d "$1/library" ]]; then
+        addToSearchPath R_LIBS_SITE "$1/library"
+    fi
+}
+
+addEnvHooks "$targetOffset" addRLibPath
diff --git a/nixpkgs/pkgs/applications/science/math/almonds/default.nix b/nixpkgs/pkgs/applications/science/math/almonds/default.nix
new file mode 100644
index 000000000000..ec3891667c58
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/almonds/default.nix
@@ -0,0 +1,26 @@
+{ lib, python3, fetchFromGitHub, ncurses }:
+
+with python3.pkgs; buildPythonApplication rec {
+  pname = "almonds";
+  version = "1.25b";
+
+  src = fetchFromGitHub {
+    owner = "Tenchi2xh";
+    repo = "Almonds";
+    rev = version;
+    sha256 = "0j8d8jizivnfx8lpc4w6sbqj5hq35nfz0vdg7ld80sc5cs7jr3ws";
+  };
+
+  nativeBuildInputs = [ pytest ];
+  buildInputs = [ ncurses ];
+  propagatedBuildInputs = [ pillow ];
+
+  checkPhase = "py.test";
+
+  meta = with lib; {
+    description = "Terminal Mandelbrot fractal viewer";
+    homepage = "https://github.com/Tenchi2xh/Almonds";
+    license = licenses.mit;
+    maintainers = with maintainers; [ infinisil ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/bcal/default.nix b/nixpkgs/pkgs/applications/science/math/bcal/default.nix
new file mode 100644
index 000000000000..b23b433becd3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/bcal/default.nix
@@ -0,0 +1,37 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, readline
+, bc
+, python3Packages
+}:
+
+stdenv.mkDerivation rec {
+  pname = "bcal";
+  version = "2.4";
+
+  src = fetchFromGitHub {
+    owner = "jarun";
+    repo = "bcal";
+    rev = "v${version}";
+    sha256 = "sha256-PleWU2yyJzkUAZEvEYoCGdpEXqOgRvZK9zXTYrxRtQU=";
+  };
+
+  buildInputs = [ readline ];
+
+  installFlags = [ "PREFIX=$(out)" ];
+
+  doCheck = true;
+
+  checkInputs = [ bc python3Packages.pytestCheckHook ];
+
+  pytestFlagsArray = [ "test.py" ];
+
+  meta = with lib; {
+    description = "Storage conversion and expression calculator";
+    homepage = "https://github.com/jarun/bcal";
+    license = licenses.gpl3Only;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ jfrankenau ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/bliss/default.nix b/nixpkgs/pkgs/applications/science/math/bliss/default.nix
new file mode 100644
index 000000000000..fe68d9d245c5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/bliss/default.nix
@@ -0,0 +1,37 @@
+{ lib, stdenv, fetchurl, unzip, doxygen }:
+
+stdenv.mkDerivation rec {
+  pname = "bliss";
+  version = "0.73";
+
+  src = fetchurl {
+    url = "http://www.tcs.hut.fi/Software/bliss/${pname}-${version}.zip";
+    sha256 = "f57bf32804140cad58b1240b804e0dbd68f7e6bf67eba8e0c0fa3a62fd7f0f84";
+  };
+
+  patches = fetchurl {
+    url = "http://scip.zib.de/download/bugfixes/scip-5.0.1/bliss-0.73.patch";
+    sha256 = "815868d6586bcd49ff3c28e14ccb536d38b2661151088fe08187c13909c5dab0";
+  };
+
+  nativeBuildInputs = [ unzip doxygen ];
+
+  preBuild = ''
+    doxygen Doxyfile
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin $out/share/doc/bliss $out/lib $out/include/bliss
+    mv bliss $out/bin
+    mv html/* COPYING* $out/share/doc/bliss
+    mv *.a $out/lib
+    mv *.h *.hh $out/include/bliss
+  '';
+
+  meta = with lib; {
+    description = "An open source tool for computing automorphism groups and canonical forms of graphs. It has both a command line user interface as well as C++ and C programming language APIs";
+    homepage = "http://www.tcs.hut.fi/Software/bliss/";
+    license = licenses.lgpl3;
+    platforms = [ "i686-linux" "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/caffe/darwin.patch b/nixpkgs/pkgs/applications/science/math/caffe/darwin.patch
new file mode 100644
index 000000000000..e8fa6a683f73
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/caffe/darwin.patch
@@ -0,0 +1,47 @@
+diff --git a/Makefile b/Makefile
+index c823f66e..65b90c5e 100644
+--- a/Makefile
++++ b/Makefile
+@@ -32,9 +32,9 @@ SRC_DIRS := $(shell find * -type d -exec bash -c "find {} -maxdepth 1 \
+ LIBRARY_NAME := $(PROJECT)
+ LIB_BUILD_DIR := $(BUILD_DIR)/lib
+ STATIC_NAME := $(LIB_BUILD_DIR)/lib$(LIBRARY_NAME).a
+-DYNAMIC_VERSION_MAJOR 		:= 1
+-DYNAMIC_VERSION_MINOR 		:= 0
+-DYNAMIC_VERSION_REVISION 	:= 0
++DYNAMIC_VERSION_MAJOR		:= 1
++DYNAMIC_VERSION_MINOR		:= 0
++DYNAMIC_VERSION_REVISION	:= 0
+ DYNAMIC_NAME_SHORT := lib$(LIBRARY_NAME).so
+ #DYNAMIC_SONAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR)
+ DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)
+diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
+index c48255c8..cf4c580e 100644
+--- a/cmake/Dependencies.cmake
++++ b/cmake/Dependencies.cmake
+@@ -105,7 +105,6 @@ if(USE_OPENCV)
+ endif()
+ 
+ # ---[ BLAS
+-if(NOT APPLE)
+   set(BLAS "Atlas" CACHE STRING "Selected BLAS library")
+   set_property(CACHE BLAS PROPERTY STRINGS "Atlas;Open;MKL")
+ 
+@@ -123,17 +122,6 @@ if(NOT APPLE)
+     list(APPEND Caffe_LINKER_LIBS PUBLIC ${MKL_LIBRARIES})
+     list(APPEND Caffe_DEFINITIONS PUBLIC -DUSE_MKL)
+   endif()
+-elseif(APPLE)
+-  find_package(vecLib REQUIRED)
+-  list(APPEND Caffe_INCLUDE_DIRS PUBLIC ${vecLib_INCLUDE_DIR})
+-  list(APPEND Caffe_LINKER_LIBS PUBLIC ${vecLib_LINKER_LIBS})
+-
+-  if(VECLIB_FOUND)
+-    if(NOT vecLib_INCLUDE_DIR MATCHES "^/System/Library/Frameworks/vecLib.framework.*")
+-      list(APPEND Caffe_DEFINITIONS PUBLIC -DUSE_ACCELERATE)
+-    endif()
+-  endif()
+-endif()
+ 
+ # ---[ Python
+ if(BUILD_python)
diff --git a/nixpkgs/pkgs/applications/science/math/caffe/default.nix b/nixpkgs/pkgs/applications/science/math/caffe/default.nix
new file mode 100644
index 000000000000..462a05d300ce
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/caffe/default.nix
@@ -0,0 +1,144 @@
+{ config, stdenv, lib
+, fetchFromGitHub
+, fetchurl
+, cmake
+, boost
+, gflags
+, glog
+, hdf5-cpp
+, opencv3
+, protobuf
+, doxygen
+, blas
+, Accelerate, CoreGraphics, CoreVideo
+, lmdbSupport ? true, lmdb
+, leveldbSupport ? true, leveldb, snappy
+, cudaSupport ? config.cudaSupport or false, cudatoolkit
+, cudnnSupport ? cudaSupport, cudnn ? null
+, ncclSupport ? false, nccl ? null
+, pythonSupport ? false, python ? null, numpy ? null
+, substituteAll
+}:
+
+assert leveldbSupport -> (leveldb != null && snappy != null);
+assert cudnnSupport -> cudaSupport;
+assert ncclSupport -> cudaSupport;
+assert pythonSupport -> (python != null && numpy != null);
+
+let
+  toggle = bool: if bool then "ON" else "OFF";
+
+  test_model_weights = fetchurl {
+    url = "http://dl.caffe.berkeleyvision.org/bvlc_reference_caffenet.caffemodel";
+    sha256 = "472d4a06035497b180636d8a82667129960371375bd10fcb6df5c6c7631f25e0";
+  };
+
+in
+
+stdenv.mkDerivation rec {
+  pname = "caffe";
+  version = "1.0";
+
+  src = fetchFromGitHub {
+    owner = "BVLC";
+    repo = "caffe";
+    rev = version;
+    sha256 = "104jp3cm823i3cdph7hgsnj6l77ygbwsy35mdmzhmsi4jxprd9j3";
+  };
+
+  nativeBuildInputs = [ cmake doxygen ];
+
+  cmakeFlags =
+    # It's important that caffe is passed the major and minor version only because that's what
+    # boost_python expects
+    [ (if pythonSupport then "-Dpython_version=${python.pythonVersion}" else "-DBUILD_python=OFF")
+      "-DBLAS=open"
+    ] ++ (if cudaSupport then [
+           "-DCUDA_ARCH_NAME=All"
+           "-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/cc"
+         ] else [ "-DCPU_ONLY=ON" ])
+      ++ ["-DUSE_NCCL=${toggle ncclSupport}"]
+      ++ ["-DUSE_LEVELDB=${toggle leveldbSupport}"]
+      ++ ["-DUSE_LMDB=${toggle lmdbSupport}"];
+
+  buildInputs = [ boost gflags glog protobuf hdf5-cpp opencv3 blas ]
+                ++ lib.optional cudaSupport cudatoolkit
+                ++ lib.optional cudnnSupport cudnn
+                ++ lib.optional lmdbSupport lmdb
+                ++ lib.optional ncclSupport nccl
+                ++ lib.optionals leveldbSupport [ leveldb snappy ]
+                ++ lib.optionals pythonSupport [ python numpy ]
+                ++ lib.optionals stdenv.isDarwin [ Accelerate CoreGraphics CoreVideo ]
+                ;
+
+  propagatedBuildInputs = lib.optionals pythonSupport (
+    # requirements.txt
+    let pp = python.pkgs; in ([
+      pp.numpy pp.scipy pp.scikitimage pp.h5py
+      pp.matplotlib pp.ipython pp.networkx pp.nose
+      pp.pandas pp.python-dateutil pp.protobuf pp.gflags
+      pp.pyyaml pp.pillow pp.six
+    ] ++ lib.optional leveldbSupport pp.leveldb)
+  );
+
+  outputs = [ "bin" "out" ];
+  propagatedBuildOutputs = []; # otherwise propagates out -> bin cycle
+
+  patches = [
+    ./darwin.patch
+  ] ++ lib.optional pythonSupport (substituteAll {
+    src = ./python.patch;
+    inherit (python.sourceVersion) major minor;  # Should be changed in case of PyPy
+  });
+
+  postPatch = ''
+    substituteInPlace src/caffe/util/io.cpp --replace \
+      'SetTotalBytesLimit(kProtoReadBytesLimit, 536870912)' \
+      'SetTotalBytesLimit(kProtoReadBytesLimit)'
+  '' + lib.optionalString (cudaSupport && lib.versionAtLeast cudatoolkit.version "9.0") ''
+    # CUDA 9.0 doesn't support sm_20
+    sed -i 's,20 21(20) ,,' cmake/Cuda.cmake
+  '';
+
+  preConfigure = lib.optionalString pythonSupport ''
+    # We need this when building with Python bindings
+    export BOOST_LIBRARYDIR="${boost.out}/lib";
+  '';
+
+  postInstall = ''
+    # Internal static library.
+    rm $out/lib/libproto.a
+
+    # Install models
+    cp -a ../models $out/share/Caffe/models
+
+    moveToOutput "bin" "$bin"
+  '' + lib.optionalString pythonSupport ''
+    mkdir -p $out/${python.sitePackages}
+    mv $out/python/caffe $out/${python.sitePackages}
+    rm -rf $out/python
+  '';
+
+  doInstallCheck = false; # build takes more than 30 min otherwise
+  installCheckPhase = ''
+    model=bvlc_reference_caffenet
+    m_path="$out/share/Caffe/models/$model"
+    $bin/bin/caffe test \
+      -model "$m_path/deploy.prototxt" \
+      -solver "$m_path/solver.prototxt" \
+      -weights "${test_model_weights}"
+  '';
+
+  meta = with lib; {
+    description = "Deep learning framework";
+    longDescription = ''
+      Caffe is a deep learning framework made with expression, speed, and
+      modularity in mind. It is developed by the Berkeley Vision and Learning
+      Center (BVLC) and by community contributors.
+    '';
+    homepage = "http://caffe.berkeleyvision.org/";
+    maintainers = with maintainers; [ jb55 ];
+    license = licenses.bsd2;
+    platforms = platforms.linux ++ platforms.darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/caffe/python.patch b/nixpkgs/pkgs/applications/science/math/caffe/python.patch
new file mode 100644
index 000000000000..dac5071aa08c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/caffe/python.patch
@@ -0,0 +1,70 @@
+commit b14ca23651d390fcae4a929dedc7c33a83453a66
+Author: Frederik Rietdijk <fridh@fridh.nl>
+Date:   Sun Feb 17 08:41:27 2019 +0100
+
+    Find boost_pythonXX
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 08f56a33..0a04592a 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -99,10 +99,10 @@ add_subdirectory(docs)
+ add_custom_target(lint COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/cmake/lint.cmake)
+ 
+ # ---[ pytest target
+-if(BUILD_python)
+-  add_custom_target(pytest COMMAND python${python_version} -m unittest discover -s caffe/test WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/python )
+-  add_dependencies(pytest pycaffe)
+-endif()
++# if(BUILD_python)
++#   add_custom_target(pytest COMMAND python${python_version} -m unittest discover -s caffe/test WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/python )
++#   add_dependencies(pytest pycaffe)
++# endif()
+ 
+ # ---[ uninstall target
+ configure_file(
+diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
+index 4a5bac47..be026d43 100644
+--- a/cmake/Dependencies.cmake
++++ b/cmake/Dependencies.cmake
+@@ -141,37 +141,14 @@ if(BUILD_python)
+     # use python3
+     find_package(PythonInterp 3.0)
+     find_package(PythonLibs 3.0)
+-    find_package(NumPy 1.7.1)
+-    # Find the matching boost python implementation
+-    set(version ${PYTHONLIBS_VERSION_STRING})
+-
+-    STRING( REGEX REPLACE "[^0-9]" "" boost_py_version ${version} )
+-    find_package(Boost 1.46 COMPONENTS "python-py${boost_py_version}")
+-    set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND})
+-
+-    while(NOT "${version}" STREQUAL "" AND NOT Boost_PYTHON_FOUND)
+-      STRING( REGEX REPLACE "([0-9.]+).[0-9]+" "\\1" version ${version} )
+-
+-      STRING( REGEX REPLACE "[^0-9]" "" boost_py_version ${version} )
+-      find_package(Boost 1.46 COMPONENTS "python-py${boost_py_version}")
+-      set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND})
+-
+-      STRING( REGEX MATCHALL "([0-9.]+).[0-9]+" has_more_version ${version} )
+-      if("${has_more_version}" STREQUAL "")
+-        break()
+-      endif()
+-    endwhile()
+-    if(NOT Boost_PYTHON_FOUND)
+-      find_package(Boost 1.46 COMPONENTS python)
+-    endif()
+   else()
+     # disable Python 3 search
+     find_package(PythonInterp 2.7)
+     find_package(PythonLibs 2.7)
+-    find_package(NumPy 1.7.1)
+-    find_package(Boost 1.46 COMPONENTS python)
+   endif()
+-  if(PYTHONLIBS_FOUND AND NUMPY_FOUND AND Boost_PYTHON_FOUND)
++  find_package(NumPy 1.7.1)
++  find_package(Boost 1.46 REQUIRED COMPONENTS python@major@@minor@)
++  if(PYTHONLIBS_FOUND AND NUMPY_FOUND AND Boost_PYTHON@major@@minor@_FOUND)
+     set(HAVE_PYTHON TRUE)
+     if(BUILD_python_layer)
+       list(APPEND Caffe_DEFINITIONS PRIVATE -DWITH_PYTHON_LAYER)
diff --git a/nixpkgs/pkgs/applications/science/math/calc/default.nix b/nixpkgs/pkgs/applications/science/math/calc/default.nix
new file mode 100644
index 000000000000..f9931c7d4c96
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/calc/default.nix
@@ -0,0 +1,51 @@
+{ stdenv, lib, fetchurl, util-linux, makeWrapper
+, enableReadline ? true, readline, ncurses }:
+
+stdenv.mkDerivation rec {
+  pname = "calc";
+  version = "2.14.0.14";
+
+  src = fetchurl {
+    urls = [
+      "https://github.com/lcn2/calc/releases/download/${version}/${pname}-${version}.tar.bz2"
+      "http://www.isthe.com/chongo/src/calc/${pname}-${version}.tar.bz2"
+    ];
+    sha256 = "sha256-93J4NaED2XEsVxlY6STpwlS9FI8I60NIAZvDT45xxV0=";
+  };
+
+  postPatch = ''
+    substituteInPlace Makefile \
+      --replace '-install_name ''${LIBDIR}/libcalc''${LIB_EXT_VERSION}' '-install_name ''${T}''${LIBDIR}/libcalc''${LIB_EXT_VERSION}' \
+      --replace '-install_name ''${LIBDIR}/libcustcalc''${LIB_EXT_VERSION}' '-install_name ''${T}''${LIBDIR}/libcustcalc''${LIB_EXT_VERSION}'
+  '';
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ util-linux ]
+             ++ lib.optionals enableReadline [ readline ncurses ];
+
+  makeFlags = [
+    "T=$(out)"
+    "INCDIR="
+    "BINDIR=/bin"
+    "LIBDIR=/lib"
+    "CALC_SHAREDIR=/share/calc"
+    "CALC_INCDIR=/include"
+    "MANDIR=/share/man/man1"
+
+    # Handle LDFLAGS defaults in calc
+    "DEFAULT_LIB_INSTALL_PATH=$(out)/lib"
+  ] ++ lib.optionals enableReadline [
+    "READLINE_LIB=-lreadline"
+    "USE_READLINE=-DUSE_READLINE"
+  ];
+
+  meta = with lib; {
+    description = "C-style arbitrary precision calculator";
+    homepage = "http://www.isthe.com/chongo/tech/comp/calc/";
+    # The licensing situation depends on readline (see section 3 of the LGPL)
+    # If linked against readline then GPLv2 otherwise LGPLv2.1
+    license = with licenses; if enableReadline then gpl2Only else lgpl21Only;
+    maintainers = with maintainers; [ matthewbauer ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/calculix/calculix.patch b/nixpkgs/pkgs/applications/science/math/calculix/calculix.patch
new file mode 100644
index 000000000000..2334d54711e5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/calculix/calculix.patch
@@ -0,0 +1,22 @@
+diff -Naur a/ccx_2.17/src/Makefile b/ccx_2.17/src/Makefile
+--- a/ccx_2.17/src/Makefile	2020-07-23 21:41:38.507761972 +0200
++++ b/ccx_2.17/src/Makefile	2020-08-22 16:53:50.004938281 +0200
+@@ -18,15 +18,10 @@
+ OCCXC = $(SCCXC:.c=.o)
+ OCCXMAIN = $(SCCXMAIN:.c=.o)
+ 
+-DIR=../../../SPOOLES.2.2
++LIBS = -lpthread -lm -lc -lspooles -larpack -lblas -llapack
+ 
+-LIBS = \
+-       $(DIR)/spooles.a \
+-	../../../ARPACK/libarpack_INTEL.a \
+-       -lpthread -lm -lc
+-
+-ccx_2.17: $(OCCXMAIN) ccx_2.17.a  $(LIBS)
+-	./date.pl; $(CC) $(CFLAGS) -c ccx_2.17.c; $(FC)  -Wall -O2 -o $@ $(OCCXMAIN) ccx_2.17.a $(LIBS)
++ccx_2.17: $(OCCXMAIN) ccx_2.17.a
++	$(CC) $(CFLAGS) -c ccx_2.17.c; $(FC)  -Wall -O2 -o $@ $(OCCXMAIN) ccx_2.17.a $(LIBS)
+ 
+ ccx_2.17.a: $(OCCXF) $(OCCXC)
+ 	ar vr $@ $?
diff --git a/nixpkgs/pkgs/applications/science/math/calculix/default.nix b/nixpkgs/pkgs/applications/science/math/calculix/default.nix
new file mode 100644
index 000000000000..e9766b32c2a4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/calculix/default.nix
@@ -0,0 +1,37 @@
+{ lib, stdenv, fetchurl, gfortran, arpack, spooles, blas, lapack }:
+
+stdenv.mkDerivation rec {
+  pname = "calculix";
+  version = "2.17";
+
+  src = fetchurl {
+    url = "http://www.dhondt.de/ccx_${version}.src.tar.bz2";
+    sha256 = "0l3fizxfdj2mpdp62wnk9v47q2yc3cy39fpsm629z7bjmba8lw6a";
+  };
+
+  nativeBuildInputs = [ gfortran ];
+
+  buildInputs = [ arpack spooles blas lapack ];
+
+  NIX_CFLAGS_COMPILE = "-I${spooles}/include/spooles";
+
+  patches = [
+    ./calculix.patch
+  ];
+
+  postPatch = ''
+    cd ccx*/src
+  '';
+
+  installPhase = ''
+    install -Dm0755 ccx_${version} $out/bin/ccx
+  '';
+
+  meta = with lib; {
+    homepage = "http://www.calculix.de/";
+    description = "Three-dimensional structural finite element program";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ gebner ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/cbc/default.nix b/nixpkgs/pkgs/applications/science/math/cbc/default.nix
new file mode 100644
index 000000000000..1909e4bb1d04
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/cbc/default.nix
@@ -0,0 +1,33 @@
+{ lib, stdenv, fetchurl, zlib, bzip2 }:
+
+stdenv.mkDerivation rec {
+  pname = "cbc";
+  version = "2.10.4";
+
+  # Note: Cbc 2.10.5 contains Clp 1.17.5 which hits this bug
+  # that breaks or-tools https://github.com/coin-or/Clp/issues/130
+
+  src = fetchurl {
+    url = "https://www.coin-or.org/download/source/Cbc/Cbc-${version}.tgz";
+    sha256 = "0zq66j1vvpslswhzi9yfgkv6vmg7yry4pdmfgqaqw2vhyqxnsy39";
+  };
+
+  # or-tools has a hard dependency on Cbc static libraries, so we build both
+  configureFlags = [ "-C" "--enable-static" ];
+
+  enableParallelBuilding = true;
+
+  hardeningDisable = [ "format" ];
+
+  buildInputs = [ zlib bzip2 ];
+
+  # FIXME: move share/coin/Data to a separate output?
+
+  meta = {
+    homepage = "https://projects.coin-or.org/Cbc";
+    license = lib.licenses.epl10;
+    maintainers = [ lib.maintainers.eelco ];
+    platforms = lib.platforms.linux ++ lib.platforms.darwin;
+    description = "A mixed integer programming solver";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/cemu/default.nix b/nixpkgs/pkgs/applications/science/math/cemu/default.nix
new file mode 100644
index 000000000000..35b9200a4774
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/cemu/default.nix
@@ -0,0 +1,57 @@
+{ fetchFromGitHub
+, lib
+, SDL2
+, libGL
+, libarchive
+, libusb-compat-0_1
+, qtbase
+, qmake
+, git
+, libpng_apng
+, pkg-config
+, wrapQtAppsHook
+, stdenv
+}:
+
+stdenv.mkDerivation rec {
+  pname = "CEmu";
+  version = "1.3";
+  src = fetchFromGitHub {
+    owner = "CE-Programming";
+    repo = "CEmu";
+    rev = "v${version}";
+    sha256 = "1wcdnzcqscawj6jfdj5wwmw9g9vsd6a1rx0rrramakxzf8b7g47r";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [
+    qmake
+    git
+    wrapQtAppsHook
+    pkg-config
+  ];
+
+  buildInputs = [
+    SDL2
+    libGL
+    libarchive
+    libusb-compat-0_1
+    qtbase
+    libpng_apng
+  ];
+
+  qmakeFlags = [
+    "gui/qt"
+    "CONFIG+=ltcg"
+  ];
+
+  meta = with lib; {
+    changelog = "https://github.com/CE-Programming/CEmu/releases/tag/v${version}";
+    description = "Third-party TI-84 Plus CE / TI-83 Premium CE emulator, focused on developer features";
+    homepage = "https://ce-programming.github.io/CEmu";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ luc65r ];
+    platforms = [ "x86_64-linux" "x86_64-darwin" ];
+    broken = stdenv.isDarwin;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/clp/default.nix b/nixpkgs/pkgs/applications/science/math/clp/default.nix
new file mode 100644
index 000000000000..26c277c2685f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/clp/default.nix
@@ -0,0 +1,22 @@
+{ lib, stdenv, fetchurl, zlib }:
+
+stdenv.mkDerivation rec {
+  version = "1.17.6";
+  pname = "clp";
+  src = fetchurl {
+    url = "https://www.coin-or.org/download/source/Clp/Clp-${version}.tgz";
+    sha256 = "0ap1f0lxppa6pnbc4bg7ih7a96avwaki482nig8w5fr3vg9wvkzr";
+  };
+
+  propagatedBuildInputs = [ zlib ];
+
+  doCheck = true;
+
+  meta = with lib; {
+    license = licenses.epl10;
+    homepage = "https://github.com/coin-or/Clp";
+    description = "An open-source linear programming solver written in C++";
+    platforms = platforms.darwin ++ [ "x86_64-linux" ];
+    maintainers = [ maintainers.vbgl ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/cntk/default.nix b/nixpkgs/pkgs/applications/science/math/cntk/default.nix
new file mode 100644
index 000000000000..ba2225b903fa
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/cntk/default.nix
@@ -0,0 +1,127 @@
+{ lib, stdenv, fetchgit, fetchFromGitHub, cmake
+, fetchpatch
+, openblas, blas, lapack, opencv3, libzip, boost, protobuf, mpi
+, onebitSGDSupport ? false
+, cudaSupport ? false, addOpenGLRunpath, cudatoolkit, nvidia_x11
+, cudnnSupport ? cudaSupport, cudnn
+}:
+
+assert cudnnSupport -> cudaSupport;
+assert blas.implementation == "openblas" && lapack.implementation == "openblas";
+
+let
+  # Old specific version required for CNTK.
+  cub = fetchFromGitHub {
+    owner = "NVlabs";
+    repo = "cub";
+    rev = "1.7.4";
+    sha256 = "0ksd5n1lxqhm5l5cd2lps4cszhjkf6gmzahaycs7nxb06qci8c66";
+  };
+
+in stdenv.mkDerivation rec {
+  pname = "CNTK";
+  version = "2.7";
+
+  # Submodules
+  src = fetchgit {
+    url = "https://github.com/Microsoft/CNTK";
+    rev = "v${version}";
+    sha256 = "18l9k7s966a26ywcf7flqyhm61788pcb9fj3wk61jrmgkhy2pcns";
+  };
+
+  patches = [
+    # Fix build with protobuf 3.18+
+    # Remove with onnx submodule bump to 1.9+
+    (fetchpatch {
+      url = "https://github.com/onnx/onnx/commit/d3bc82770474761571f950347560d62a35d519d7.patch";
+      extraPrefix = "Source/CNTKv2LibraryDll/proto/onnx/onnx_repo/";
+      stripLen = 1;
+      sha256 = "00raqj8wx30b06ky6cdp5vvc1mrzs7hglyi6h58hchw5lhrwkzxp";
+    })
+  ];
+
+  postPatch = ''
+    # Fix build with protobuf 3.18+
+    substituteInPlace Source/CNTKv2LibraryDll/Serialization.cpp \
+      --replace 'SetTotalBytesLimit(INT_MAX, INT_MAX)' \
+                'SetTotalBytesLimit(INT_MAX)' \
+      --replace 'SetTotalBytesLimit(limit, limit)' \
+                'SetTotalBytesLimit(limit)'
+  '';
+
+  nativeBuildInputs = [ cmake ] ++ lib.optional cudaSupport addOpenGLRunpath;
+
+  # Force OpenMPI to use g++ in PATH.
+  OMPI_CXX = "g++";
+
+  # Uses some deprecated tensorflow functions
+  NIX_CFLAGS_COMPILE = "-Wno-error=deprecated-declarations";
+
+  buildInputs = [ openblas opencv3 libzip boost protobuf mpi ]
+             ++ lib.optional cudaSupport cudatoolkit
+             ++ lib.optional cudnnSupport cudnn;
+
+  configureFlags = [
+    "--with-opencv=${opencv3}"
+    "--with-libzip=${libzip.dev}"
+    "--with-openblas=${openblas.dev}"
+    "--with-boost=${boost.dev}"
+    "--with-protobuf=${protobuf}"
+    "--with-mpi=${mpi}"
+    "--cuda=${if cudaSupport then "yes" else "no"}"
+    # FIXME
+    "--asgd=no"
+  ] ++ lib.optionals cudaSupport [
+    "--with-cuda=${cudatoolkit}"
+    "--with-gdk-include=${cudatoolkit}/include"
+    "--with-gdk-nvml-lib=${nvidia_x11}/lib"
+    "--with-cub=${cub}"
+  ] ++ lib.optional onebitSGDSupport "--1bitsgd=yes";
+
+  configurePhase = ''
+    sed -i \
+      -e 's,^GIT_STATUS=.*,GIT_STATUS=,' \
+      -e 's,^GIT_COMMIT=.*,GIT_COMMIT=v${version},' \
+      -e 's,^GIT_BRANCH=.*,GIT_BRANCH=v${version},' \
+      -e 's,^BUILDER=.*,BUILDER=nixbld,' \
+      -e 's,^BUILDMACHINE=.*,BUILDMACHINE=machine,' \
+      -e 's,^BUILDPATH=.*,BUILDPATH=/homeless-shelter,' \
+      -e '/git does not exist/d' \
+      Tools/generate_build_info
+
+    patchShebangs .
+    mkdir build
+    cd build
+    ${lib.optionalString cudnnSupport ''
+      mkdir cuda
+      ln -s ${cudnn}/include cuda
+      export configureFlags="$configureFlags --with-cudnn=$PWD"
+    ''}
+
+    ../configure $configureFlags
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    # Moving to make patchelf remove references later.
+    mv lib $out
+    cp bin/cntk $out/bin
+  '';
+
+  postFixup = lib.optionalString cudaSupport ''
+    for lib in $out/lib/*; do
+      addOpenGLRunpath "$lib"
+    done
+  '';
+
+  meta = with lib; {
+    # Newer cub is included with cudatoolkit now and it breaks the build.
+    # https://github.com/Microsoft/CNTK/issues/3191
+    broken = cudaSupport;
+    homepage = "https://github.com/Microsoft/CNTK";
+    description = "An open source deep-learning toolkit";
+    license = if onebitSGDSupport then licenses.unfreeRedistributable else licenses.mit;
+    platforms = [ "x86_64-linux" ];
+    maintainers = with maintainers; [ abbradar ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/colpack/default.nix b/nixpkgs/pkgs/applications/science/math/colpack/default.nix
new file mode 100644
index 000000000000..3cc9290a7626
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/colpack/default.nix
@@ -0,0 +1,43 @@
+{ lib, stdenv, fetchFromGitHub, autoreconfHook }:
+
+stdenv.mkDerivation rec {
+
+  pname = "ColPack";
+  version = "1.0.10";
+
+  src = fetchFromGitHub {
+    owner = "CSCsw";
+    repo = pname;
+    rev = "v" + version;
+    sha256 = "1p05vry940mrjp6236c0z83yizmw9pk6ly2lb7d8rpb7j9h03glr";
+  };
+
+  nativeBuildInputs = [ autoreconfHook ];
+
+  configureFlags = [
+    "--enable-openmp=${if stdenv.isLinux then "yes" else "no"}"
+    "--enable-examples=no"
+  ];
+
+  postInstall = ''
+    # Remove libtool archive
+    rm $out/lib/*.la
+
+    # Remove compiled examples (Basic examples get compiled anyway)
+    rm -r $out/examples
+
+    # Copy the example sources (Basic tree contains scripts and object files)
+    mkdir -p $out/share/ColPack/examples/Basic
+    cp SampleDrivers/Basic/*.cpp $out/share/ColPack/examples/Basic
+    cp -r SampleDrivers/Matrix* $out/share/ColPack/examples
+  '';
+
+  meta = with lib; {
+    description = "A package comprising of implementations of algorithms for
+    vertex coloring and derivative computation";
+    homepage = "http://cscapes.cs.purdue.edu/coloringpage/software.htm#functionalities";
+    license = licenses.lgpl3Plus;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ edwtjo ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/cplex/default.nix b/nixpkgs/pkgs/applications/science/math/cplex/default.nix
new file mode 100644
index 000000000000..068f9f0ea3c1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/cplex/default.nix
@@ -0,0 +1,87 @@
+{ lib, stdenv, makeWrapper, openjdk, gtk2, xorg, glibcLocales, releasePath ? null }:
+
+# To use this package, you need to download your own cplex installer from IBM
+# and override the releasePath attribute to point to the location of the file.
+#
+# Note: cplex creates an individual build for each license which screws
+# somewhat with the use of functions like requireFile as the hash will be
+# different for every user.
+
+stdenv.mkDerivation rec {
+  pname = "cplex";
+  version = "128";
+
+  src =
+    if releasePath == null then
+      throw ''
+        This nix expression requires that the cplex installer is already
+        downloaded to your machine. Get it from IBM:
+        https://developer.ibm.com/docloud/blog/2017/12/20/cplex-optimization-studio-12-8-now-available/
+
+        Set `cplex.releasePath = /path/to/download;` in your
+        ~/.config/nixpkgs/config.nix for `nix-*` commands, or
+        `config.cplex.releasePath = /path/to/download;` in your
+        `configuration.nix` for NixOS.
+      ''
+    else
+      releasePath;
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ openjdk gtk2 xorg.libXtst glibcLocales ];
+
+  unpackPhase = "cp $src $name";
+
+  patchPhase = ''
+    sed -i -e 's|/usr/bin/tr"|tr"         |' $name
+  '';
+
+  buildPhase = ''
+    sh $name -i silent -DLICENSE_ACCEPTED=TRUE -DUSER_INSTALL_DIR=$out
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    ln -s $out/opl/bin/x86-64_linux/oplrun\
+      $out/opl/bin/x86-64_linux/oplrunjava\
+      $out/opl/oplide/oplide\
+      $out/cplex/bin/x86-64_linux/cplex\
+      $out/cpoptimizer/bin/x86-64_linux/cpoptimizer\
+      $out/bin
+  '';
+
+  fixupPhase =
+  let
+    libraryPath = lib.makeLibraryPath [ stdenv.cc.cc gtk2 xorg.libXtst ];
+  in ''
+    interpreter=${stdenv.glibc}/lib/ld-linux-x86-64.so.2
+
+    for pgm in $out/opl/bin/x86-64_linux/oplrun $out/opl/bin/x86-64_linux/oplrunjava $out/opl/oplide/oplide;
+    do
+      patchelf --set-interpreter "$interpreter" $pgm;
+      wrapProgram $pgm \
+        --prefix LD_LIBRARY_PATH : $out/opl/bin/x86-64_linux:${libraryPath} \
+        --set LOCALE_ARCHIVE ${glibcLocales}/lib/locale/locale-archive;
+    done
+
+    for pgm in $out/cplex/bin/x86-64_linux/cplex $out/cpoptimizer/bin/x86-64_linux/cpoptimizer $out/opl/oplide/jre/bin/*;
+    do
+      if grep ELF $pgm > /dev/null;
+      then
+        patchelf --set-interpreter "$interpreter" $pgm;
+      fi
+    done
+  '';
+
+  passthru = {
+    libArch = "x86-64_linux";
+    libSuffix = "${version}0";
+  };
+
+  meta = with lib; {
+    description = "Optimization solver for mathematical programming";
+    homepage = "https://www.ibm.com/be-en/marketplace/ibm-ilog-cplex";
+    license = licenses.unfree;
+    platforms = [ "x86_64-linux" ];
+    maintainers = with maintainers; [ bfortz ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/csdp/default.nix b/nixpkgs/pkgs/applications/science/math/csdp/default.nix
new file mode 100644
index 000000000000..6ce03008d3a9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/csdp/default.nix
@@ -0,0 +1,30 @@
+{ lib, stdenv, fetchurl, blas, gfortran, lapack }:
+
+stdenv.mkDerivation rec {
+  pname = "csdp";
+  version = "6.1.1";
+
+  src = fetchurl {
+    url = "https://www.coin-or.org/download/source/Csdp/Csdp-${version}.tgz";
+    sha256 = "1f9ql6cjy2gwiyc51ylfan24v1ca9sjajxkbhszlds1lqmma8n05";
+  };
+
+  buildInputs = [ blas gfortran.cc.lib lapack ];
+
+  postPatch = ''
+    substituteInPlace Makefile --replace /usr/local/bin $out/bin
+  '';
+
+  preInstall = ''
+    rm -f INSTALL
+    mkdir -p $out/bin
+  '';
+
+  meta = {
+    homepage = "https://projects.coin-or.org/Csdp";
+    license = lib.licenses.cpl10;
+    maintainers = [ lib.maintainers.roconnor ];
+    description = "A C Library for Semidefinite Programming";
+    platforms = lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/dap/default.nix b/nixpkgs/pkgs/applications/science/math/dap/default.nix
new file mode 100644
index 000000000000..ed3290f6c27d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/dap/default.nix
@@ -0,0 +1,37 @@
+{ lib
+, stdenv
+, fetchurl
+}:
+
+stdenv.mkDerivation rec {
+  pname = "dap";
+  version = "3.10";
+
+  src = fetchurl {
+    url = "mirror://gnu/${pname}/${pname}-${version}.tar.gz";
+    sha256 = "Bk5sty/438jLb1PpurMQ5OqMbr6JqUuuQjcg2bejh2Y=";
+  };
+
+  hardeningDisable = [ "format" ];
+
+  meta = with lib; {
+    homepage = "https://www.gnu.org/software/dap";
+    description = "A small statistics and graphics package based on C";
+    longDescription = ''
+      Dap is a small statistics and graphics package based on C. Version 3.0 and
+      later of Dap can read SBS programs (based on the utterly famous, industry
+      standard statistics system with similar initials - you know the one I
+      mean)! The user wishing to perform basic statistical analyses is now freed
+      from learning and using C syntax for straightforward tasks, while
+      retaining access to the C-style graphics and statistics features provided
+      by the original implementation. Dap provides core methods of data
+      management, analysis, and graphics that are commonly used in statistical
+      consulting practice (univariate statistics, correlations and regression,
+      ANOVA, categorical data analysis, logistic regression, and nonparametric
+      analyses).
+    '';
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ AndersonTorres ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/ecm/default.nix b/nixpkgs/pkgs/applications/science/math/ecm/default.nix
new file mode 100644
index 000000000000..c59b1a8729a2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/ecm/default.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchurl, gmp, m4 }:
+
+let
+  pname = "ecm";
+  version = "7.0.4";
+  name = "${pname}-${version}";
+in
+
+stdenv.mkDerivation {
+  inherit name;
+
+  src = fetchurl {
+    url = "http://gforge.inria.fr/frs/download.php/file/36224/ecm-${version}.tar.gz";
+    sha256 = "0hxs24c2m3mh0nq1zz63z3sb7dhy1rilg2s1igwwcb26x3pb7xqc";
+  };
+
+  # See https://trac.sagemath.org/ticket/19233
+  configureFlags = lib.optional stdenv.isDarwin "--disable-asm-redc";
+
+  buildInputs = [ m4 gmp ];
+
+  doCheck = true;
+
+  meta = {
+    description = "Elliptic Curve Method for Integer Factorization";
+    license = lib.licenses.gpl2Plus;
+    homepage = "http://ecm.gforge.inria.fr/";
+    maintainers = [ lib.maintainers.roconnor ];
+    platforms = with lib.platforms; linux ++ darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/engauge-digitizer/default.nix b/nixpkgs/pkgs/applications/science/math/engauge-digitizer/default.nix
new file mode 100644
index 000000000000..4c26dc2887c8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/engauge-digitizer/default.nix
@@ -0,0 +1,60 @@
+{ lib, stdenv, fetchFromGitHub, fftw, libjpeg, log4cpp, openjpeg
+, libpng12, poppler, qtbase, qt5, qmake, wrapQtAppsHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "engauge-digitizer";
+  version = "12.2.2";
+
+  src = fetchFromGitHub {
+    owner = "markummitchell";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "sha256-Wj9o3wWbtHsEi6LFH4xDpwVR9BwcWc472jJ/QFDQZvY=";
+  };
+
+  nativeBuildInputs = [ qmake wrapQtAppsHook ];
+
+  buildInputs = [
+    qtbase
+    qt5.qttools
+    poppler
+    libpng12
+    openjpeg
+    openjpeg.dev
+    log4cpp
+    libjpeg
+    fftw
+  ];
+
+  qmakeFlags = [
+    "CONFIG+=jpeg2000"
+    "CONFIG+=pdf"
+    "CONFIG+=log4cpp_null"
+  ];
+
+  POPPLER_INCLUDE = "${poppler.dev}/include/poppler/qt5";
+
+  POPPLER_LIB = "${poppler}/lib";
+
+  OPENJPEG_INCLUDE = "${openjpeg.dev}/include/${openjpeg.pname}-${lib.versions.majorMinor openjpeg.version}";
+
+  OPENJPEG_LIB = "${openjpeg}/lib";
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out/bin
+    cp bin/engauge $out/bin/
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Engauge Digitizer is a tool for recovering graph data from an image file";
+    homepage = "https://markummitchell.github.io/engauge-digitizer";
+    license = with licenses; [ gpl2Only ];
+    platforms = platforms.linux;
+    maintainers = [ maintainers.sheepforce ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/eukleides/default.nix b/nixpkgs/pkgs/applications/science/math/eukleides/default.nix
new file mode 100644
index 000000000000..0c3ef25909bb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/eukleides/default.nix
@@ -0,0 +1,67 @@
+{ lib, stdenv, fetchurl, bison, flex, makeWrapper, texinfo4, getopt, readline, texlive }:
+
+lib.fix (eukleides: stdenv.mkDerivation rec {
+  pname = "eukleides";
+  version = "1.5.4";
+
+  src = fetchurl {
+    url = "http://www.eukleides.org/files/${pname}-${version}.tar.bz2";
+    sha256 = "0s8cyh75hdj89v6kpm3z24i48yzpkr8qf0cwxbs9ijxj1i38ki0q";
+  };
+
+  patches = [
+    # use $CC instead of hardcoded gcc
+    ./use-CC.patch
+    # allow PostScript transparency in epstopdf call
+    ./gs-allowpstransparency.patch
+  ];
+
+  nativeBuildInputs = [ bison flex texinfo4 makeWrapper ];
+
+  buildInputs = [ getopt readline ];
+
+  preConfigure = ''
+    substituteInPlace Makefile \
+      --replace mktexlsr true
+
+    substituteInPlace doc/Makefile \
+      --replace ginstall-info install-info
+
+    substituteInPlace Config \
+      --replace '/usr/local' "$out" \
+      --replace '$(SHARE_DIR)/texmf' "$tex"
+  '';
+
+  preInstall = ''
+    mkdir -p $out/bin
+  '';
+
+  postInstall = ''
+    wrapProgram $out/bin/euktoeps \
+      --prefix PATH : ${lib.makeBinPath [ getopt ]}
+  '';
+
+  outputs = [ "out" "doc" "tex" ];
+
+  passthru.tlType = "run";
+  passthru.pkgs = [ eukleides.tex ]
+    # packages needed by euktoeps, euktopdf and eukleides.sty
+    ++ (with texlive; collection-pstricks.pkgs ++ epstopdf.pkgs ++ iftex.pkgs ++ moreverb.pkgs);
+
+  meta = {
+    description = "Geometry Drawing Language";
+    homepage = "http://www.eukleides.org/";
+    license = lib.licenses.gpl3Plus;
+
+    longDescription = ''
+      Eukleides is a computer language devoted to elementary plane
+      geometry. It aims to be a fairly comprehensive system to create
+      geometric figures, either static or dynamic. Eukleides allows to
+      handle basic types of data: numbers and strings, as well as
+      geometric types of data: points, vectors, sets (of points), lines,
+      circles and conics.
+    '';
+
+    platforms = lib.platforms.unix;
+  };
+})
diff --git a/nixpkgs/pkgs/applications/science/math/eukleides/gs-allowpstransparency.patch b/nixpkgs/pkgs/applications/science/math/eukleides/gs-allowpstransparency.patch
new file mode 100644
index 000000000000..aa92e6cc9fa7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/eukleides/gs-allowpstransparency.patch
@@ -0,0 +1,10 @@
+--- a/bash/euktopdf
++++ b/bash/euktopdf
+@@ -55,6 +55,6 @@ do
+     exit 1
+   fi
+   dvips -q -E -o $base.eps $base.dvi &&
+-  epstopdf $base.eps &&
++  epstopdf --gsopt=-dALLOWPSTRANSPARENCY $base.eps &&
+   rm -f $base.{tex,log,dvi,eps}
+ done
diff --git a/nixpkgs/pkgs/applications/science/math/eukleides/use-CC.patch b/nixpkgs/pkgs/applications/science/math/eukleides/use-CC.patch
new file mode 100644
index 000000000000..08bd71ec9dc5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/eukleides/use-CC.patch
@@ -0,0 +1,11 @@
+--- a/build/Makefile
++++ b/build/Makefile
+@@ -11,7 +11,7 @@ LEX = flex
+ LFLAGS = -8
+ YACC = bison
+ YFLAGS = -d
+-CC = gcc
++CC ?= gcc
+ IFLAGS = -I$(COMMON_DIR) -I$(MAIN_DIR) -I$(BUILD_DIR) 
+ ifneq ($(strip $(LOCALES)),)
+ MOFLAGS = -DMO_DIR=\"$(MO_DIR)\" 
diff --git a/nixpkgs/pkgs/applications/science/math/form/default.nix b/nixpkgs/pkgs/applications/science/math/form/default.nix
new file mode 100644
index 000000000000..00f7d7e45365
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/form/default.nix
@@ -0,0 +1,22 @@
+{ lib, stdenv, fetchurl, gmp, zlib }:
+
+stdenv.mkDerivation {
+  version = "4.2.1";
+  pname = "form";
+
+  # This tarball is released by author, it is not downloaded from tag, so can't use fetchFromGitHub
+  src = fetchurl {
+    url = "https://github.com/vermaseren/form/releases/download/v4.2.1/form-4.2.1.tar.gz";
+    sha256 = "0a0smc10gm85vxd85942n5azy88w5qs5avbqrw0lw0yb9injswpj";
+  };
+
+  buildInputs = [ gmp zlib ];
+
+  meta = with lib; {
+    description = "The FORM project for symbolic manipulation of very big expressions";
+    homepage = "https://www.nikhef.nl/~form/";
+    license = licenses.gpl3;
+    maintainers = [ maintainers.veprbl ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/fricas/default.nix b/nixpkgs/pkgs/applications/science/math/fricas/default.nix
new file mode 100644
index 000000000000..79d5664426be
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/fricas/default.nix
@@ -0,0 +1,27 @@
+{ lib, stdenv, fetchurl, sbcl, libX11, libXpm, libICE, libSM, libXt, libXau, libXdmcp }:
+
+let
+  version = "1.3.7";
+  name = "fricas-" + version;
+in
+stdenv.mkDerivation {
+  inherit name;
+
+  src = fetchurl {
+    url = "mirror://sourceforge/fricas/fricas/${version}/${name}-full.tar.bz2";
+    sha256 = "sha256-cOqMvSe3ef/ZeVy5cj/VU/aTRtxgfxZfRbE4lWE5TU4=";
+  };
+
+  buildInputs = [ sbcl libX11 libXpm libICE libSM libXt libXau libXdmcp ];
+
+  dontStrip = true;
+
+  meta = {
+    homepage = "http://fricas.sourceforge.net/";
+    description = "An advanced computer algebra system";
+    license = lib.licenses.bsd3;
+
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.sprock ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/gap/default.nix b/nixpkgs/pkgs/applications/science/math/gap/default.nix
new file mode 100644
index 000000000000..c309423f142a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/gap/default.nix
@@ -0,0 +1,159 @@
+{ stdenv
+, lib
+, fetchurl
+, makeWrapper
+, readline
+, gmp
+, zlib
+# one of
+# - "minimal" (~400M):
+#     Install the bare minimum of packages required by gap to start.
+#     This is likely to break a lot of stuff. Do not expect upstream support with
+#     this configuration.
+# - "standard" (~700M):
+#     Install the "standard packages" which gap autoloads by default. These
+#     packages are effectively considered a part of gap.
+# - "full" (~1.7G):
+#     Install all available packages. This takes a lot of space.
+, packageSet ? "standard"
+# Kept for backwards compatibility. Overrides packageSet to "full".
+, keepAllPackages ? false
+}:
+let
+  # packages absolutely required for gap to start
+  # `*` represents the version where applicable
+  requiredPackages = [
+    "GAPDoc-*"
+    "primgrp-*"
+    "SmallGrp-*"
+    "transgrp"
+  ];
+  # packages autoloaded by default if available
+  autoloadedPackages = [
+    "atlasrep"
+    "autpgrp-*"
+    "alnuth-*"
+    "crisp-*"
+    "ctbllib-*"
+    "FactInt-*"
+    "fga"
+    "irredsol-*"
+    "laguna-*"
+    "polenta-*"
+    "polycyclic-*"
+    "resclasses-*"
+    "sophus-*"
+    "tomlib-*"
+  ];
+  keepAll = keepAllPackages || (packageSet == "full");
+  packagesToKeep = requiredPackages ++ lib.optionals (packageSet == "standard") autoloadedPackages;
+
+  # Generate bash script that removes all packages from the `pkg` subdirectory
+  # that are not on the whitelist. The whitelist consists of strings expected by
+  # `find`'s `-name`.
+  removeNonWhitelistedPkgs = whitelist: ''
+    find pkg -type d -maxdepth 1 -mindepth 1 \
+  '' + (lib.concatStringsSep "\n" (map (str: "-not -name '${str}' \\") whitelist)) + ''
+    -exec echo "Removing package {}" \; \
+    -exec rm -r '{}' \;
+  '';
+in
+stdenv.mkDerivation rec {
+  pname = "gap";
+  # https://www.gap-system.org/Releases/
+  version = "4.11.1";
+
+  src = fetchurl {
+    url = "https://github.com/gap-system/gap/releases/download/v${version}/gap-${version}.tar.gz";
+    sha256 = "sha256-ZjXF2n2CdV+DOUhrnKwzdm9YcS8pfoI0+6QIGJAuowQ=";
+  };
+
+  # remove all non-essential packages (which take up a lot of space)
+  preConfigure = lib.optionalString (!keepAll) (removeNonWhitelistedPkgs packagesToKeep) + ''
+    patchShebangs .
+  '';
+
+  buildInputs = [
+    readline
+    gmp
+    zlib
+  ];
+
+  nativeBuildInputs = [
+    makeWrapper
+  ];
+
+  # "teststandard" is a superset of testinstall. It takes ~1h instead of ~1min.
+  # tests are run twice, once with all packages loaded and once without
+  # checkTarget = "teststandard";
+
+  doInstallCheck = true;
+  installCheckTarget = "check";
+
+  preInstallCheck = ''
+    # gap tests check that the home directory exists
+    export HOME="$TMP/gap-home"
+    mkdir -p "$HOME"
+
+    # make sure gap is in PATH
+    export PATH="$out/bin:$PATH"
+
+    # make sure we don't accidentally use the wrong gap binary
+    rm -r bin
+
+    # like the defaults the Makefile, but use gap from PATH instead of the
+    # one from builddir
+    installCheckFlagsArray+=(
+      "TESTGAP=gap --quitonbreak -b -m 100m -o 1g -q -x 80 -r -A"
+      "TESTGAPauto=gap --quitonbreak -b -m 100m -o 1g -q -x 80 -r"
+    )
+  '';
+
+  postBuild = ''
+    pushd pkg
+    bash ../bin/BuildPackages.sh
+    popd
+  '';
+
+  installTargets = [
+    "install-libgap"
+    "install-headers"
+  ];
+
+  # full `make install` is not yet implemented, just for libgap and headers
+  postInstall = ''
+    # Install config.h, which is not currently handled by `make install-headers`
+    cp gen/config.h "$out/include/gap"
+
+    mkdir -p "$out/bin" "$out/share/gap/"
+
+    echo "Copying files to target directory"
+    cp -ar . "$out/share/gap/build-dir"
+
+    makeWrapper "$out/share/gap/build-dir/bin/gap.sh" "$out/bin/gap" \
+      --set GAP_DIR $out/share/gap/build-dir
+  '';
+
+  preFixup = ''
+    # patchelf won't strip references to the build dir if it still exists
+    rm -rf pkg
+  '';
+
+  meta = with lib; {
+    description = "Computational discrete algebra system";
+    maintainers = with maintainers;
+    [
+      raskin
+      chrisjefferson
+      timokau
+    ];
+    platforms = platforms.all;
+    broken = stdenv.isDarwin;
+    # keeping all packages increases the package size considerably, which is
+    # why a local build is preferable in that situation. The timeframe is
+    # reasonable and that way the binary cache doesn't get overloaded.
+    hydraPlatforms = lib.optionals (!keepAllPackages) meta.platforms;
+    license = licenses.gpl2;
+    homepage = "https://www.gap-system.org";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/geogebra/default.nix b/nixpkgs/pkgs/applications/science/math/geogebra/default.nix
new file mode 100644
index 000000000000..8ab498c61d93
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/geogebra/default.nix
@@ -0,0 +1,92 @@
+{ lib, stdenv, fetchurl, jre, makeDesktopItem, makeWrapper, unzip, language ? "en_US" }:
+let
+  pname = "geogebra";
+  version = "5-0-680-0";
+
+  srcIcon = fetchurl {
+    url = "http://static.geogebra.org/images/geogebra-logo.svg";
+    sha256 = "01sy7ggfvck350hwv0cla9ynrvghvssqm3c59x4q5lwsxjsxdpjm";
+  };
+
+  desktopItem = makeDesktopItem {
+    name = "geogebra";
+    exec = "geogebra";
+    icon = "geogebra";
+    desktopName = "Geogebra";
+    genericName = "Geogebra";
+    comment = meta.description;
+    categories = [ "Education" "Science" "Math" ];
+    mimeTypes = [ "application/vnd.geogebra.file" "application/vnd.geogebra.tool" ];
+  };
+
+  meta = with lib; {
+    description = "Dynamic mathematics software with graphics, algebra and spreadsheets";
+    longDescription = ''
+      Dynamic mathematics software for all levels of education that brings
+      together geometry, algebra, spreadsheets, graphing, statistics and
+      calculus in one easy-to-use package.
+    '';
+    homepage = "https://www.geogebra.org/";
+    maintainers = with maintainers; [ sikmir ];
+    license = with licenses; [ gpl3 cc-by-nc-sa-30 geogebra ];
+    platforms = with platforms; linux ++ darwin;
+    hydraPlatforms = [];
+  };
+
+  linuxPkg = stdenv.mkDerivation {
+    inherit pname version meta srcIcon desktopItem;
+
+    preferLocalBuild = true;
+
+    src = fetchurl {
+      urls = [
+        "https://download.geogebra.org/installers/5.0/GeoGebra-Linux-Portable-${version}.tar.bz2"
+        "https://web.archive.org/web/20210910014320/https://download.geogebra.org/installers/5.0/GeoGebra-Linux-Portable-${version}.tar.bz2"
+      ];
+      sha256 = "0gdvajf220pm1w3nxi2fymxjx2vl978pz7ffn5gr72cx8f2956lm";
+    };
+
+    nativeBuildInputs = [ makeWrapper ];
+
+    installPhase = ''
+      install -D geogebra/* -t "$out/libexec/geogebra/"
+
+      makeWrapper "$out/libexec/geogebra/geogebra" "$out/bin/geogebra" \
+        --set JAVACMD "${jre}/bin/java" \
+        --set GG_PATH "$out/libexec/geogebra" \
+        --add-flags "--language=${language}"
+
+      install -Dm644 "${desktopItem}/share/applications/"* \
+        -t $out/share/applications/
+
+      install -Dm644 "${srcIcon}" \
+        "$out/share/icons/hicolor/scalable/apps/geogebra.svg"
+    '';
+  };
+
+  darwinPkg = stdenv.mkDerivation {
+    inherit pname version meta;
+
+    preferLocalBuild = true;
+
+    src = fetchurl {
+      urls = [
+        "https://download.geogebra.org/installers/5.0/GeoGebra-MacOS-Installer-withJava-${version}.zip"
+        "https://web.archive.org/web/20210101213641/https://download.geogebra.org/installers/5.0/GeoGebra-MacOS-Installer-withJava-${version}.zip"
+      ];
+      sha256 = "02sbxrns9zvhcfrr68ygv766and6f6b2a3dfarljxszwsviv6ljf";
+    };
+
+    dontUnpack = true;
+
+    nativeBuildInputs = [ unzip ];
+
+    installPhase = ''
+      install -dm755 $out/Applications
+      unzip $src -d $out/Applications
+    '';
+  };
+in
+if stdenv.isDarwin
+then darwinPkg
+else linuxPkg
diff --git a/nixpkgs/pkgs/applications/science/math/geogebra/geogebra6.nix b/nixpkgs/pkgs/applications/science/math/geogebra/geogebra6.nix
new file mode 100644
index 000000000000..76d178b7e490
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/geogebra/geogebra6.nix
@@ -0,0 +1,73 @@
+{ lib, stdenv, unzip, fetchurl, electron, makeWrapper, geogebra }:
+let
+  pname = "geogebra";
+  version = "6-0-676-0";
+
+  srcIcon = geogebra.srcIcon;
+  desktopItem = geogebra.desktopItem;
+
+  meta = with lib; geogebra.meta // {
+    license = licenses.geogebra;
+    maintainers = with maintainers; [ voidless sikmir ];
+    platforms = with platforms; linux ++ darwin;
+  };
+
+  linuxPkg = stdenv.mkDerivation {
+    inherit pname version meta;
+
+    src = fetchurl {
+      urls = [
+        "https://download.geogebra.org/installers/6.0/GeoGebra-Linux64-Portable-${version}.zip"
+        "https://web.archive.org/web/20211123222708/https://download.geogebra.org/installers/6.0/GeoGebra-Linux64-Portable-${version}.zip"
+      ];
+      sha256 = "0wn90n2nd476rkf83gk9vvcpbjflkrvyri50pnmv52j76n023hmm";
+    };
+
+    dontConfigure = true;
+    dontBuild = true;
+
+    nativeBuildInputs = [
+      unzip
+      makeWrapper
+    ];
+
+    unpackPhase = ''
+      unzip $src
+    '';
+
+    installPhase = ''
+      mkdir -p $out/libexec/geogebra/ $out/bin
+      cp -r GeoGebra-linux-x64/{resources,locales} "$out/"
+      makeWrapper ${lib.getBin electron}/bin/electron $out/bin/geogebra --add-flags "$out/resources/app"
+      install -Dm644 "${desktopItem}/share/applications/"* \
+        -t $out/share/applications/
+
+      install -Dm644 "${srcIcon}" \
+        "$out/share/icons/hicolor/scalable/apps/geogebra.svg"
+    '';
+  };
+
+  darwinPkg = stdenv.mkDerivation {
+    inherit pname version meta;
+
+    src = fetchurl {
+      urls = [
+        "https://download.geogebra.org/installers/6.0/GeoGebra-Classic-6-MacOS-Portable-${version}.zip"
+        "https://web.archive.org/web/20211124143625/https://download.geogebra.org/installers/6.0/GeoGebra-Classic-6-MacOS-Portable-${version}.zip"
+      ];
+      sha256 = "1dwv2f94a1c2y10lmy0i66cafynalp7dkqgnpk4f0mk6pir2fdgj";
+    };
+
+    dontUnpack = true;
+
+    nativeBuildInputs = [ unzip ];
+
+    installPhase = ''
+      install -dm755 $out/Applications
+      unzip $src -d $out/Applications
+    '';
+  };
+in
+if stdenv.isDarwin
+then darwinPkg
+else linuxPkg
diff --git a/nixpkgs/pkgs/applications/science/math/getdp/default.nix b/nixpkgs/pkgs/applications/science/math/getdp/default.nix
new file mode 100644
index 000000000000..5713f84a866f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/getdp/default.nix
@@ -0,0 +1,32 @@
+{ lib, stdenv, fetchurl, cmake, gfortran, blas, lapack, mpi, petsc, python3 }:
+
+stdenv.mkDerivation rec {
+  pname = "getdp";
+  version = "3.4.0";
+  src = fetchurl {
+    url = "http://getdp.info/src/getdp-${version}-source.tgz";
+    sha256 = "sha256-d5YxJgtMf94PD6EHvIXpPBFPKC+skI/2v1K5Sad51hA=";
+  };
+
+  inherit (petsc) mpiSupport;
+  nativeBuildInputs = [ cmake python3 ];
+  buildInputs = [ gfortran blas lapack petsc ]
+    ++ lib.optional mpiSupport mpi
+  ;
+  cmakeFlags = lib.optional mpiSupport "-DENABLE_MPI=1";
+
+  meta = with lib; {
+    description = "A General Environment for the Treatment of Discrete Problems";
+    longDescription = ''
+      GetDP is a free finite element solver using mixed elements to discretize
+      de Rham-type complexes in one, two and three dimensions.  The main
+      feature of GetDP is the closeness between the input data defining
+      discrete problems (written by the user in ASCII data files) and the
+      symbolic mathematical expressions of these problems.
+    '';
+    homepage = "http://getdp.info/";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/gfan/default.nix b/nixpkgs/pkgs/applications/science/math/gfan/default.nix
new file mode 100644
index 000000000000..11a42d1cfdf8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/gfan/default.nix
@@ -0,0 +1,30 @@
+{lib, stdenv, fetchurl, gmp, mpir, cddlib}:
+stdenv.mkDerivation rec {
+  pname = "gfan";
+  version = "0.6.2";
+
+  src = fetchurl {
+    url = "http://home.math.au.dk/jensen/software/gfan/gfan${version}.tar.gz";
+    sha256 = "02pihqb1lb76a0xbfwjzs1cd6ay3ldfxsm8dvsbl6qs3vkjxax56";
+  };
+
+  patches = [
+    ./gfan-0.6.2-cddlib-prefix.patch
+  ];
+
+  postPatch = lib.optionalString stdenv.cc.isClang ''
+    substituteInPlace Makefile --replace "-fno-guess-branch-probability" ""
+  '';
+
+  buildFlags = [ "CC=${stdenv.cc.targetPrefix}cc" "CXX=${stdenv.cc.targetPrefix}c++" ];
+  installFlags = [ "PREFIX=$(out)" ];
+  buildInputs = [ gmp mpir cddlib ];
+
+  meta = {
+    description = "A software package for computing Gröbner fans and tropical varieties";
+    license = lib.licenses.gpl2 ;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.unix;
+    homepage = "http://home.math.au.dk/jensen/software/gfan/gfan.html";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/gfan/gfan-0.6.2-cddlib-prefix.patch b/nixpkgs/pkgs/applications/science/math/gfan/gfan-0.6.2-cddlib-prefix.patch
new file mode 100644
index 000000000000..8a96a991cf75
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/gfan/gfan-0.6.2-cddlib-prefix.patch
@@ -0,0 +1,55 @@
+diff -ru gfan0.6.2.orig/src/app_librarytest.cpp gfan0.6.2/src/app_librarytest.cpp
+--- gfan0.6.2.orig/src/app_librarytest.cpp	2020-10-19 08:41:27.981863500 +0900
++++ gfan0.6.2/src/app_librarytest.cpp	2020-10-19 08:42:44.551863500 +0900
+@@ -12,8 +12,8 @@
+ #include "setoper.h"
+ #include "cdd.h"
+ #else
+-#include "cdd/setoper.h"
+-#include "cdd/cdd.h"
++#include "cddlib/setoper.h"
++#include "cddlib/cdd.h"
+ #endif
+ #include <iostream>
+ #include <fstream>
+diff -ru gfan0.6.2.orig/src/gfanlib_zcone.cpp gfan0.6.2/src/gfanlib_zcone.cpp
+--- gfan0.6.2.orig/src/gfanlib_zcone.cpp	2020-10-19 08:41:27.981863500 +0900
++++ gfan0.6.2/src/gfanlib_zcone.cpp	2020-10-19 08:42:44.571863500 +0900
+@@ -16,8 +16,8 @@
+ #include "setoper.h"
+ #include "cdd.h"
+ #else
+-#include "cdd/setoper.h"
+-#include "cdd/cdd.h"
++#include "cddlib/setoper.h"
++#include "cddlib/cdd.h"
+ #endif
+ //}
+ 
+@@ -52,8 +52,8 @@
+ 				  "dd_free_global_constants()\n"
+ 				  "in your deinitialisation code (only available for cddlib version>=094d).\n"
+ 				  "This requires the header includes:\n"
+-				  "#include \"cdd/setoper.h\"\n"
+-				  "#include \"cdd/cdd.h\"\n"
++				  "#include \"cddlib/setoper.h\"\n"
++				  "#include \"cddlib/cdd.h\"\n"
+ 				  "\n"
+ 				  "Alternatively, you may call gfan:initializeCddlibIfRequired() and deinitializeCddlibIfRequired()\n"
+ 				  "if gfanlib is the only code using cddlib. If at some point cddlib is no longer required by gfanlib\n"
+diff -ru gfan0.6.2.orig/src/lp_cdd.cpp gfan0.6.2/src/lp_cdd.cpp
+--- gfan0.6.2.orig/src/lp_cdd.cpp	2020-10-19 08:41:27.991863500 +0900
++++ gfan0.6.2/src/lp_cdd.cpp	2020-10-19 08:42:44.571863500 +0900
+@@ -5,9 +5,9 @@
+ #include "cdd.h"
+ #include "cdd_f.h"
+ #else
+-#include "cdd/setoper.h"
+-#include "cdd/cdd.h"
+-#include "cdd/cdd_f.h"
++#include "cddlib/setoper.h"
++#include "cddlib/cdd.h"
++#include "cddlib/cdd_f.h"
+ #endif
+ //}
+ #include "termorder.h"
diff --git a/nixpkgs/pkgs/applications/science/math/giac/default.nix b/nixpkgs/pkgs/applications/science/math/giac/default.nix
new file mode 100644
index 000000000000..4700402ff21e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/giac/default.nix
@@ -0,0 +1,120 @@
+{ stdenv, lib, fetchurl, fetchpatch, texlive, bison, flex, lapack, blas
+, gmp, mpfr, pari, ntl, gsl, mpfi, ecm, glpk, nauty
+, readline, gettext, libpng, libao, gfortran, perl
+, enableGUI ? false, libGL, libGLU, xorg, fltk
+, enableMicroPy ? false, python3
+}:
+
+assert (!blas.isILP64) && (!lapack.isILP64);
+
+stdenv.mkDerivation rec {
+  pname = "giac${lib.optionalString enableGUI "-with-xcas"}";
+  version = "1.6.0-47"; # TODO try to remove preCheck phase on upgrade
+
+  src = fetchurl {
+    url = "https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version}.tar.gz";
+    sha256 = "sha256-c5A9/I6L/o3Y3dxEPoTKpw/fJqYMr6euLldaQ1HWT5c=";
+  };
+
+  patches = [
+    (fetchpatch {
+      name = "pari_2_11.patch";
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/giac/patches/pari_2_11.patch?id=21ba7540d385a9864b44850d6987893dfa16bfc0";
+      sha256 = "sha256-vEo/5MNzMdYRPWgLFPsDcMT1W80Qzj4EPBjx/B8j68k=";
+    })
+  ] ++ lib.optionals (!enableGUI) [
+    # when enableGui is false, giac is compiled without fltk. That
+    # means some outputs differ in the make check. Patch around this:
+    (fetchpatch {
+      name = "nofltk-check.patch";
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/giac/patches/nofltk-check.patch?id=7553a3c8dfa7bcec07241a07e6a4e7dcf5bb4f26";
+      sha256 = "0xkmfc028vg5w6va04gp2x2iv31n8v4shd6vbyvk4blzgfmpj2cw";
+    })
+  ];
+
+  postPatch = ''
+    for i in doc/*/Makefile* micropython*/xcas/Makefile*; do
+      substituteInPlace "$i" --replace "/bin/cp" "cp";
+    done;
+  '' +
+  # workaround for 1.6.0-47, should not be necessary in future versions
+  lib.optionalString (!enableMicroPy) ''
+    sed -i -e 's/micropython-[0-9.]* //' Makefile*
+  '';
+
+  nativeBuildInputs = [
+    texlive.combined.scheme-small bison flex
+  ];
+
+  # perl is only needed for patchShebangs fixup.
+  buildInputs = [
+    gmp mpfr pari ntl gsl blas mpfi glpk nauty
+    readline gettext libpng libao perl ecm
+    # gfortran.cc default output contains static libraries compiled without -fPIC
+    # we want libgfortran.so.3 instead
+    (lib.getLib gfortran.cc)
+    lapack blas
+  ] ++ lib.optionals enableGUI [
+    libGL libGLU fltk xorg.libX11
+  ] ++ lib.optional enableMicroPy python3;
+
+  /* fixes:
+  configure:16211: checking for main in -lntl
+  configure:16230: g++ -o conftest -g -O2   conftest.cpp -lntl  -llapack -lblas -lgfortran -ldl -lpng16 -lm -lmpfi -lmpfr -lgmp  >&5
+  /nix/store/y9c1v4x7y39j2rfbg17agjwqdzxpsn18-ntl-11.3.2/lib/libntl.so: undefined reference to `pthread_key_create'
+  */
+  NIX_CFLAGS_LINK="-lpthread";
+
+  # xcas Phys and Turtle menus are broken with split outputs
+  # and interactive use is likely to need docs
+  outputs = [ "out" ] ++ lib.optional (!enableGUI) "doc";
+
+  doCheck = true;
+  preCheck = lib.optionalString (!enableGUI) ''
+    # even with the nofltk patch, some changes in src/misc.cc (grep
+    # for HAVE_LIBFLTK) made it so that giac behaves differently
+    # when fltk is disabled. disable these tests for now.
+    echo > check/chk_fhan2
+    echo > check/chk_fhan9
+  '';
+
+  enableParallelBuilding = true;
+
+  configureFlags = [
+    "--enable-gc" "--enable-png" "--enable-gsl" "--enable-lapack"
+    "--enable-pari" "--enable-ntl" "--enable-gmpxx" # "--enable-cocoa"
+    "--enable-ao" "--enable-ecm" "--enable-glpk"
+  ] ++ lib.optionals enableGUI [
+    "--enable-gui" "--with-x"
+  ] ++ lib.optional (!enableMicroPy) "--disable-micropy";
+
+  postInstall = ''
+    # example Makefiles contain the full path to some commands
+    # notably texlive, and we don't want texlive to become a runtime
+    # dependency
+    for file in $(find $out -name Makefile) ; do
+      sed -i "s@/nix/store/[^/]*/bin/@@" "$file" ;
+    done;
+
+    # reference cycle
+    rm "$out/share/giac/doc/el/"{casinter,tutoriel}/Makefile
+
+    if [ -n "$doc" ]; then
+      mkdir -p "$doc/share/giac"
+      mv "$out/share/giac/doc" "$doc/share/giac"
+      mv "$out/share/giac/examples" "$doc/share/giac"
+    fi
+  '' + lib.optionalString (!enableGUI) ''
+    for i in pixmaps application-registry applications icons; do
+      rm -r "$out/share/$i";
+    done;
+  '';
+
+  meta = with lib; {
+    description = "A free computer algebra system (CAS)";
+    homepage = "https://www-fourier.ujf-grenoble.fr/~parisse/giac.html";
+    license = licenses.gpl3Plus;
+    platforms = platforms.linux ++ (optionals (!enableGUI) platforms.darwin);
+    maintainers = [ maintainers.symphorien ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/ginac/default.nix b/nixpkgs/pkgs/applications/science/math/ginac/default.nix
new file mode 100644
index 000000000000..1fff1156c1a0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/ginac/default.nix
@@ -0,0 +1,34 @@
+{ lib, stdenv, fetchurl, cln, pkg-config, readline, gmp, python3 }:
+
+stdenv.mkDerivation rec {
+  pname = "ginac";
+  version = "1.8.2";
+
+  src = fetchurl {
+    url = "https://www.ginac.de/ginac-${version}.tar.bz2";
+    sha256 = "sha256-v811Gryviv3bg5WMKtInY6deokAyVT5QPumzjj6jtsM=";
+  };
+
+  propagatedBuildInputs = [ cln ];
+
+  buildInputs = [ readline ]
+    ++ lib.optional stdenv.isDarwin gmp;
+
+  nativeBuildInputs = [ pkg-config python3 ];
+
+  strictDeps = true;
+
+  preConfigure = ''
+    patchShebangs ginsh
+  '';
+
+  configureFlags = [ "--disable-rpath" ];
+
+  meta = with lib; {
+    description = "GiNaC is Not a CAS";
+    homepage = "https://www.ginac.de/";
+    maintainers = with maintainers; [ lovek323 ];
+    license = licenses.gpl2;
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/glsurf/default.nix b/nixpkgs/pkgs/applications/science/math/glsurf/default.nix
new file mode 100644
index 000000000000..808d89ef9636
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/glsurf/default.nix
@@ -0,0 +1,67 @@
+{ lib
+, stdenv
+, fetchurl
+, ocamlPackages
+, makeWrapper
+, libGLU
+, libGL
+, freeglut
+, mpfr
+, gmp
+, pkgsHostTarget
+}:
+
+let
+  inherit (pkgsHostTarget.targetPackages.stdenv) cc;
+in
+
+stdenv.mkDerivation rec {
+  pname = "glsurf";
+  version = "3.3.1";
+
+  src = fetchurl {
+    url = "https://raffalli.eu/~christophe/glsurf/glsurf-${version}.tar.gz";
+    sha256 = "0w8xxfnw2snflz8wdr2ca9f5g91w5vbyp1hwlx1v7vg83d4bwqs7";
+  };
+
+  nativeBuildInputs = [
+    makeWrapper
+  ] ++ (with ocamlPackages; [
+    ocaml
+    findlib
+  ]);
+
+  buildInputs = [
+    freeglut
+    libGL
+    libGLU
+    mpfr
+    gmp
+  ] ++ (with ocamlPackages; [
+    camlp4
+    lablgl
+    camlimages_4_2_4
+  ]);
+
+  postPatch = ''
+    for f in callbacks*/Makefile src/Makefile; do
+      substituteInPlace "$f" --replace "+camlp4" \
+        "${ocamlPackages.camlp4}/lib/ocaml/${ocamlPackages.ocaml.version}/site-lib/camlp4"
+    done
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin $out/share/doc/glsurf
+    cp ./src/glsurf.opt $out/bin/glsurf
+    cp ./doc/doc.pdf $out/share/doc/glsurf
+    cp -r ./examples $out/share/doc/glsurf
+
+    wrapProgram "$out/bin/glsurf" --set CC "${cc}/bin/${cc.targetPrefix}cc"
+  '';
+
+  meta = {
+    homepage = "https://raffalli.eu/~christophe/glsurf/";
+    description = "A program to draw implicit surfaces and curves";
+    license = lib.licenses.gpl2Plus;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/gmsh/default.nix b/nixpkgs/pkgs/applications/science/math/gmsh/default.nix
new file mode 100644
index 000000000000..4306ae091515
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/gmsh/default.nix
@@ -0,0 +1,32 @@
+{ lib, stdenv, fetchurl, cmake, blas, lapack, gfortran, gmm, fltk, libjpeg
+, zlib, libGL, libGLU, xorg, opencascade-occt }:
+
+assert (!blas.isILP64) && (!lapack.isILP64);
+
+stdenv.mkDerivation rec {
+  pname = "gmsh";
+  version = "4.9.5";
+
+  src = fetchurl {
+    url = "https://gmsh.info/src/gmsh-${version}-source.tgz";
+    sha256 = "sha256-/9ZJAIRCCHGciNkaZsKBiJAjEyt6nigsUVSMufbzrUQ=";
+  };
+
+  buildInputs = [
+    blas lapack gmm fltk libjpeg zlib opencascade-occt
+  ] ++ lib.optionals (!stdenv.isDarwin) [
+    libGL libGLU xorg.libXrender xorg.libXcursor xorg.libXfixes
+    xorg.libXext xorg.libXft xorg.libXinerama xorg.libX11 xorg.libSM
+    xorg.libICE
+  ];
+
+  nativeBuildInputs = [ cmake gfortran ];
+
+  doCheck = true;
+
+  meta = {
+    description = "A three-dimensional finite element mesh generator";
+    homepage = "https://gmsh.info/";
+    license = lib.licenses.gpl2Plus;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/gretl/default.nix b/nixpkgs/pkgs/applications/science/math/gretl/default.nix
new file mode 100644
index 000000000000..b8b600c18748
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/gretl/default.nix
@@ -0,0 +1,43 @@
+{ lib, stdenv, fetchurl, curl, fftw, gmp, gnuplot, gtk3, gtksourceview3, json-glib
+, lapack, libxml2, mpfr, openblas, pkg-config, readline }:
+
+stdenv.mkDerivation rec {
+  pname = "gretl";
+  version = "2022a";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/gretl/${pname}-${version}.tar.xz";
+    sha256 = "sha256-J+JcuCda2xYJ5aVz6UXR+nWiid6QxpDtt4DXlb6L4UA=";
+  };
+
+  buildInputs = [
+    curl
+    fftw
+    gmp
+    gnuplot
+    gtk3
+    gtksourceview3
+    json-glib
+    lapack
+    libxml2
+    mpfr
+    openblas
+    readline
+  ];
+
+  nativeBuildInputs = [ pkg-config ];
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    description = "A software package for econometric analysis";
+    longDescription = ''
+      gretl is a cross-platform software package for econometric analysis,
+      written in the C programming language.
+    '';
+    homepage = "http://gretl.sourceforge.net";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ dmrauh ];
+    platforms = with platforms; all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/gurobi/default.nix b/nixpkgs/pkgs/applications/science/math/gurobi/default.nix
new file mode 100644
index 000000000000..dc947a94001b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/gurobi/default.nix
@@ -0,0 +1,53 @@
+{ stdenv, lib, fetchurl, autoPatchelfHook, python3 }:
+
+stdenv.mkDerivation rec {
+  pname = "gurobi";
+  version = "9.5.0";
+
+  src = fetchurl {
+    url = "https://packages.gurobi.com/${lib.versions.majorMinor version}/gurobi${version}_linux64.tar.gz";
+    sha256 = "sha256-u1QuWl0WhfbjZOrwXqbFVySF/8N6IkUWnPPLQCiLwp4=";
+  };
+
+  sourceRoot = "gurobi${builtins.replaceStrings ["."] [""] version}/linux64";
+
+  nativeBuildInputs = [ autoPatchelfHook ];
+  buildInputs = [ (python3.withPackages (ps: [ ps.gurobipy ])) ];
+
+  strictDeps = true;
+
+  makeFlags = [ "--directory=src/build" ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp bin/* $out/bin/
+    rm $out/bin/gurobi.sh
+    rm $out/bin/python*
+
+    cp lib/gurobi.py $out/bin/gurobi.sh
+
+    mkdir -p $out/include
+    cp include/gurobi*.h $out/include/
+
+    mkdir -p $out/lib
+    cp lib/*.jar $out/lib/
+    cp lib/libGurobiJni*.so $out/lib/
+    cp lib/libgurobi*.so* $out/lib/
+    cp lib/libgurobi*.a $out/lib/
+    cp src/build/*.a $out/lib/
+
+    mkdir -p $out/share/java
+    ln -s $out/lib/gurobi.jar $out/share/java/
+    ln -s $out/lib/gurobi-javadoc.jar $out/share/java/
+  '';
+
+  passthru.libSuffix = lib.replaceStrings [ "." ] [ "" ] (lib.versions.majorMinor version);
+
+  meta = with lib; {
+    description = "Optimization solver for mathematical programming";
+    homepage = "https://www.gurobi.com";
+    license = licenses.unfree;
+    platforms = [ "x86_64-linux" ];
+    maintainers = with maintainers; [ jfrankenau ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/hmetis/default.nix b/nixpkgs/pkgs/applications/science/math/hmetis/default.nix
new file mode 100644
index 000000000000..f25a0f13c7fb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/hmetis/default.nix
@@ -0,0 +1,42 @@
+{ lib, stdenv, fetchurl, ghostscript }:
+
+stdenv.mkDerivation rec {
+  pname = "hmetis";
+  version = "1.5";
+
+  src = fetchurl {
+    url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/hmetis/hmetis-${version}-linux.tar.gz";
+    sha256 = "e835a098c046e9c26cecb8addfea4d18ff25214e49585ffd87038e72819be7e1";
+  };
+
+  nativeBuildInputs = [ ghostscript ];
+
+  binaryFiles = "hmetis khmetis shmetis";
+
+  patchPhase = ''
+    for binaryfile in $binaryFiles; do
+      patchelf \
+        --set-interpreter ${stdenv.glibc}/lib/ld-linux.so.2 \
+        --set-rpath ${stdenv.glibc}/lib \
+        $binaryfile
+    done
+  '';
+
+  buildPhase = ''
+    gs -sOutputFile=manual.pdf -sDEVICE=pdfwrite -SNOPAUSE -dBATCH manual.ps
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin $out/share/doc/hmetis $out/lib
+    mv $binaryFiles $out/bin
+    mv manual.pdf $out/share/doc/hmetis
+    mv libhmetis.a $out/lib
+  '';
+
+  meta = with lib; {
+    description = "hMETIS is a set of programs for partitioning hypergraphs";
+    homepage = "http://glaros.dtc.umn.edu/gkhome/metis/hmetis/overview";
+    license = licenses.unfree;
+    platforms = [ "i686-linux" "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/jags/default.nix b/nixpkgs/pkgs/applications/science/math/jags/default.nix
new file mode 100644
index 000000000000..3ddcd6206d68
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/jags/default.nix
@@ -0,0 +1,25 @@
+{ lib, stdenv, fetchurl, gfortran, blas, lapack }:
+
+stdenv.mkDerivation rec {
+  pname = "JAGS";
+  version = "4.3.0";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/mcmc-jags/JAGS-${version}.tar.gz";
+    sha256 = "1z3icccg2ic56vmhyrpinlsvpq7kcaflk1731rgpvz9bk1bxvica";
+  };
+
+  nativeBuildInputs = [ gfortran ];
+
+  buildInputs = [ blas lapack ];
+
+  configureFlags = [ "--with-blas=-lblas" "--with-lapack=-llapack" ];
+
+  meta = with lib; {
+    description = "Just Another Gibbs Sampler";
+    license = licenses.gpl2;
+    homepage = "http://mcmc-jags.sourceforge.net";
+    maintainers = [ maintainers.andres ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/lp_solve/default.nix b/nixpkgs/pkgs/applications/science/math/lp_solve/default.nix
new file mode 100644
index 000000000000..876222772e86
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/lp_solve/default.nix
@@ -0,0 +1,52 @@
+{ lib, stdenv, fetchurl, cctools, fixDarwinDylibNames }:
+
+stdenv.mkDerivation rec {
+
+  pname = "lp_solve";
+  version = "5.5.2.11";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/project/lpsolve/lpsolve/${version}/lp_solve_${version}_source.tar.gz";
+    sha256 = "sha256-bUq/9cxqqpM66ObBeiJt8PwLZxxDj2lxXUHQn+gfkC8=";
+  };
+
+  nativeBuildInputs = lib.optionals stdenv.isDarwin [
+    cctools
+    fixDarwinDylibNames
+  ];
+
+  dontConfigure = true;
+
+  buildPhase = let
+    ccc = if stdenv.isDarwin then "ccc.osx" else "ccc";
+  in ''
+    runHook preBuild
+
+    (cd lpsolve55 && bash -x -e ${ccc})
+    (cd lp_solve  && bash -x -e ${ccc})
+
+    runHook postBuild
+  '';
+
+  installPhase = ''
+    runHook preInstall
+
+    install -d -m755 $out/bin $out/lib $out/include/lpsolve
+    install -m755 lp_solve/bin/*/lp_solve -t $out/bin
+    install -m644 lpsolve55/bin/*/liblpsolve* -t $out/lib
+    install -m644 lp_*.h -t $out/include/lpsolve
+
+    rm $out/lib/liblpsolve*.a
+    rm $out/include/lpsolve/lp_solveDLL.h  # A Windows header
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "A Mixed Integer Linear Programming (MILP) solver";
+    homepage    = "http://lpsolve.sourceforge.net";
+    license     = licenses.gpl2Plus;
+    maintainers = with maintainers; [ smironov ];
+    platforms   = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/lrcalc/default.nix b/nixpkgs/pkgs/applications/science/math/lrcalc/default.nix
new file mode 100644
index 000000000000..96eb77964516
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/lrcalc/default.nix
@@ -0,0 +1,40 @@
+{ lib, stdenv
+, fetchFromBitbucket
+, fetchpatch
+, autoreconfHook
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.2";
+  pname = "lrcalc";
+
+  src = fetchFromBitbucket {
+    owner = "asbuch";
+    repo = "lrcalc";
+    rev = "lrcalc-${version}";
+    sha256 = "1c12d04jdyxkkav4ak8d1aqrv594gzihwhpxvc6p9js0ry1fahss";
+  };
+
+  doCheck = true;
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  patches = [
+    # Fix include syntax:
+    # For private includes, use `#include "..."` instead of `#include <...>`
+    (fetchpatch {
+      url = "https://bitbucket.org/asbuch/lrcalc/commits/226981a0/raw/";
+      sha256 = "02kaqx5s3l642rhh28kn2wg9wr098vzpknxyl4pv627lqa3lv9vm";
+    })
+  ];
+
+  meta = with lib; {
+    description = "Littlewood-Richardson calculator";
+    homepage = "http://math.rutgers.edu/~asbuch/lrcalc/";
+    license = licenses.gpl2Plus;
+    maintainers = teams.sage.members;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/mathematica/10.nix b/nixpkgs/pkgs/applications/science/math/mathematica/10.nix
new file mode 100644
index 000000000000..6fed10da18bc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/mathematica/10.nix
@@ -0,0 +1,136 @@
+{ lib, stdenv
+, coreutils
+, patchelf
+, requireFile
+, alsa-lib
+, fontconfig
+, freetype
+, gcc
+, glib
+, ncurses
+, opencv2
+, openssl
+, unixODBC
+, xorg
+, libxml2
+, libuuid
+}:
+
+let
+  platform =
+    if stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux" then
+      "Linux"
+    else
+      throw "Mathematica requires i686-linux or x86_64 linux";
+in
+stdenv.mkDerivation rec {
+  version = "10.0.2";
+
+  pname = "mathematica";
+
+  src = requireFile rec {
+    name = "Mathematica_${version}_LINUX.sh";
+    message = ''
+      This nix expression requires that ${name} is
+      already part of the store. Find the file on your Mathematica CD
+      and add it to the nix store with nix-store --add-fixed sha256 <FILE>.
+    '';
+    sha256 = "1d2yaiaikzcacjamlw64g3xkk81m3pb4vz4an12cv8nb7kb20x9l";
+  };
+
+  buildInputs = [
+    coreutils
+    patchelf
+    alsa-lib
+    coreutils
+    fontconfig
+    freetype
+    gcc.cc
+    gcc.libc
+    glib
+    ncurses
+    opencv2
+    openssl
+    unixODBC
+    libxml2
+    libuuid
+  ] ++ (with xorg; [
+    libX11
+    libXext
+    libXtst
+    libXi
+    libXmu
+    libXrender
+    libxcb
+    libXcursor
+    libXfixes
+    libXrandr
+    libICE
+    libSM
+  ]);
+
+  ldpath = lib.makeLibraryPath buildInputs
+    + lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
+      (":" + lib.makeSearchPathOutput "lib" "lib64" buildInputs);
+
+  phases = "unpackPhase installPhase fixupPhase";
+
+  unpackPhase = ''
+    echo "=== Extracting makeself archive ==="
+    # find offset from file
+    offset=$(${stdenv.shell} -c "$(grep -axm1 -e 'offset=.*' $src); echo \$offset" $src)
+    dd if="$src" ibs=$offset skip=1 | tar -xf -
+    cd Unix
+  '';
+
+  installPhase = ''
+    cd Installer
+    # don't restrict PATH, that has already been done
+    sed -i -e 's/^PATH=/# PATH=/' MathInstaller
+
+    echo "=== Running MathInstaller ==="
+    ./MathInstaller -auto -createdir=y -execdir=$out/bin -targetdir=$out/libexec/Mathematica -platforms=${platform} -silent
+  '';
+
+  preFixup = ''
+    echo "=== PatchElfing away ==="
+    # This code should be a bit forgiving of errors, unfortunately
+    set +e
+    find $out/libexec/Mathematica/SystemFiles -type f -perm -0100 | while read f; do
+      type=$(readelf -h "$f" 2>/dev/null | grep 'Type:' | sed -e 's/ *Type: *\([A-Z]*\) (.*/\1/')
+      if [ -z "$type" ]; then
+        :
+      elif [ "$type" == "EXEC" ]; then
+        echo "patching $f executable <<"
+        patchelf --shrink-rpath "$f"
+        patchelf \
+    --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+          --set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
+          "$f" \
+          && patchelf --shrink-rpath "$f" \
+          || echo unable to patch ... ignoring 1>&2
+      elif [ "$type" == "DYN" ]; then
+        echo "patching $f library <<"
+        patchelf \
+          --set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
+          "$f" \
+          && patchelf --shrink-rpath "$f" \
+          || echo unable to patch ... ignoring 1>&2
+      else
+        echo "not patching $f <<: unknown elf type"
+      fi
+    done
+  '';
+
+  # all binaries are already stripped
+  dontStrip = true;
+
+  # we did this in prefixup already
+  dontPatchELF = true;
+
+  meta = {
+    description = "Wolfram Mathematica computational software system";
+    homepage = "http://www.wolfram.com/mathematica/";
+    license = lib.licenses.unfree;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/mathematica/11.nix b/nixpkgs/pkgs/applications/science/math/mathematica/11.nix
new file mode 100644
index 000000000000..f6f0046d2725
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/mathematica/11.nix
@@ -0,0 +1,150 @@
+{ lib, stdenv
+, coreutils
+, patchelf
+, requireFile
+, callPackage
+, alsa-lib
+, dbus
+, fontconfig
+, freetype
+, gcc
+, glib
+, ncurses
+, opencv2
+, openssl
+, unixODBC
+, xkeyboard_config
+, xorg
+, zlib
+, libxml2
+, libuuid
+, lang ? "en"
+, libGL
+, libGLU
+}:
+
+let
+  l10n =
+    import ./l10ns.nix {
+      lib = lib;
+      inherit requireFile lang;
+      majorVersion = "11";
+    };
+in
+stdenv.mkDerivation rec {
+  inherit (l10n) version name src;
+
+  buildInputs = [
+    coreutils
+    patchelf
+    alsa-lib
+    coreutils
+    dbus
+    fontconfig
+    freetype
+    gcc.cc
+    gcc.libc
+    glib
+    ncurses
+    opencv2
+    openssl
+    unixODBC
+    xkeyboard_config
+    libxml2
+    libuuid
+    zlib
+    libGL
+    libGLU
+  ] ++ (with xorg; [
+    libX11
+    libXext
+    libXtst
+    libXi
+    libXmu
+    libXrender
+    libxcb
+    libXcursor
+    libXfixes
+    libXrandr
+    libICE
+    libSM
+  ]);
+
+  ldpath = lib.makeLibraryPath buildInputs
+    + lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
+      (":" + lib.makeSearchPathOutput "lib" "lib64" buildInputs);
+
+  phases = "unpackPhase installPhase fixupPhase";
+
+  unpackPhase = ''
+    echo "=== Extracting makeself archive ==="
+    # find offset from file
+    offset=$(${stdenv.shell} -c "$(grep -axm1 -e 'offset=.*' $src); echo \$offset" $src)
+    dd if="$src" ibs=$offset skip=1 | tar -xf -
+    cd Unix
+  '';
+
+  installPhase = ''
+    cd Installer
+    # don't restrict PATH, that has already been done
+    sed -i -e 's/^PATH=/# PATH=/' MathInstaller
+    sed -i -e 's/\/bin\/bash/\/bin\/sh/' MathInstaller
+
+    echo "=== Running MathInstaller ==="
+    ./MathInstaller -auto -createdir=y -execdir=$out/bin -targetdir=$out/libexec/Mathematica -silent
+
+    # Fix library paths
+    cd $out/libexec/Mathematica/Executables
+    for path in mathematica MathKernel Mathematica WolframKernel wolfram math; do
+      sed -i -e 's#export LD_LIBRARY_PATH$#export LD_LIBRARY_PATH=${zlib}/lib:\''${LD_LIBRARY_PATH}#' $path
+    done
+
+    # Fix xkeyboard config path for Qt
+    for path in mathematica Mathematica; do
+      line=$(grep -n QT_PLUGIN_PATH $path | sed 's/:.*//')
+      sed -i -e "$line iexport QT_XKB_CONFIG_ROOT=\"${xkeyboard_config}/share/X11/xkb\"" $path
+    done
+  '';
+
+  preFixup = ''
+    echo "=== PatchElfing away ==="
+    # This code should be a bit forgiving of errors, unfortunately
+    set +e
+    find $out/libexec/Mathematica/SystemFiles -type f -perm -0100 | while read f; do
+      type=$(readelf -h "$f" 2>/dev/null | grep 'Type:' | sed -e 's/ *Type: *\([A-Z]*\) (.*/\1/')
+      if [ -z "$type" ]; then
+        :
+      elif [ "$type" == "EXEC" ]; then
+        echo "patching $f executable <<"
+        patchelf --shrink-rpath "$f"
+        patchelf \
+    --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+          --set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
+          "$f" \
+          && patchelf --shrink-rpath "$f" \
+          || echo unable to patch ... ignoring 1>&2
+      elif [ "$type" == "DYN" ]; then
+        echo "patching $f library <<"
+        patchelf \
+          --set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
+          "$f" \
+          && patchelf --shrink-rpath "$f" \
+          || echo unable to patch ... ignoring 1>&2
+      else
+        echo "not patching $f <<: unknown elf type"
+      fi
+    done
+  '';
+
+  # all binaries are already stripped
+  dontStrip = true;
+
+  # we did this in prefixup already
+  dontPatchELF = true;
+
+  meta = {
+    description = "Wolfram Mathematica computational software system";
+    homepage = "http://www.wolfram.com/mathematica/";
+    license = lib.licenses.unfree;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/mathematica/9.nix b/nixpkgs/pkgs/applications/science/math/mathematica/9.nix
new file mode 100644
index 000000000000..90a7ada99504
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/mathematica/9.nix
@@ -0,0 +1,123 @@
+{ lib
+, stdenv
+, coreutils
+, patchelf
+, requireFile
+, alsa-lib
+, fontconfig
+, freetype
+, gcc
+, glib
+, ncurses
+, opencv2
+, openssl
+, unixODBC
+, xorg
+}:
+
+let
+  platform =
+    if stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux" then
+      "Linux"
+    else
+      throw "Mathematica requires i686-linux or x86_64 linux";
+in
+stdenv.mkDerivation rec {
+  pname = "mathematica";
+  version = "9.0.0";
+
+  src = requireFile {
+    name = "Mathematica_${version}_LINUX.sh";
+    message = ''
+      This nix expression requires that Mathematica_9.0.0_LINUX.sh is
+      already part of the store. Find the file on your Mathematica CD
+      and add it to the nix store with nix-store --add-fixed sha256 <FILE>.
+    '';
+    sha256 = "106zfaplhwcfdl9rdgs25x83xra9zcny94gb22wncbfxvrsk3a4q";
+  };
+
+  buildInputs = [
+    coreutils
+    patchelf
+    alsa-lib
+    coreutils
+    fontconfig
+    freetype
+    gcc.cc
+    gcc.libc
+    glib
+    ncurses
+    opencv2
+    openssl
+    unixODBC
+  ] ++ (with xorg; [
+    libX11
+    libXext
+    libXtst
+    libXi
+    libXmu
+    libXrender
+    libxcb
+  ]);
+
+  ldpath = lib.makeLibraryPath buildInputs
+    + lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
+    (":" + lib.makeSearchPathOutput "lib" "lib64" buildInputs);
+
+  phases = "unpackPhase installPhase fixupPhase";
+
+  unpackPhase = ''
+    echo "=== Extracting makeself archive ==="
+    # find offset from file
+    offset=$(${stdenv.shell} -c "$(grep -axm1 -e 'offset=.*' $src); echo \$offset" $src)
+    dd if="$src" ibs=$offset skip=1 | tar -xf -
+    cd Unix
+  '';
+
+  installPhase = ''
+    cd Installer
+    # don't restrict PATH, that has already been done
+    sed -i -e 's/^PATH=/# PATH=/' MathInstaller
+
+    echo "=== Running MathInstaller ==="
+    ./MathInstaller -auto -createdir=y -execdir=$out/bin -targetdir=$out/libexec/Mathematica -platforms=${platform} -silent
+  '';
+
+  preFixup = ''
+    echo "=== PatchElfing away ==="
+    find $out/libexec/Mathematica/SystemFiles -type f -perm -0100 | while read f; do
+      type=$(readelf -h "$f" 2>/dev/null | grep 'Type:' | sed -e 's/ *Type: *\([A-Z]*\) (.*/\1/')
+      if [ -z "$type" ]; then
+        :
+      elif [ "$type" == "EXEC" ]; then
+        echo "patching $f executable <<"
+        patchelf \
+            --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+            --set-rpath "${ldpath}" \
+            "$f"
+        patchelf --shrink-rpath "$f"
+      elif [ "$type" == "DYN" ]; then
+        echo "patching $f library <<"
+        patchelf \
+          --set-rpath "$(patchelf --print-rpath "$f"):${ldpath}" \
+          "$f" \
+          && patchelf --shrink-rpath "$f" \
+          || echo unable to patch ... ignoring 1>&2
+      else
+        echo "not patching $f <<: unknown elf type"
+      fi
+    done
+  '';
+
+  # all binaries are already stripped
+  dontStrip = true;
+
+  # we did this in prefixup already
+  dontPatchELF = true;
+
+  meta = {
+    description = "Wolfram Mathematica computational software system";
+    homepage = "http://www.wolfram.com/mathematica/";
+    license = lib.licenses.unfree;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/mathematica/default.nix b/nixpkgs/pkgs/applications/science/math/mathematica/default.nix
new file mode 100644
index 000000000000..d24cff9e86ce
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/mathematica/default.nix
@@ -0,0 +1,178 @@
+{ lib
+, stdenv
+, autoPatchelfHook
+, buildEnv
+, makeWrapper
+, requireFile
+, alsa-lib
+, cups
+, dbus
+, flite
+, fontconfig
+, freetype
+, gcc-unwrapped
+, glib
+, gmpxx
+, keyutils
+, libGL
+, libGLU
+, libpcap
+, libtins
+, libuuid
+, libxkbcommon
+, libxml2
+, llvmPackages_12
+, matio
+, mpfr
+, ncurses
+, opencv4
+, openjdk11
+, openssl
+, pciutils
+, tre
+, unixODBC
+, xkeyboard_config
+, xorg
+, zlib
+, lang ? "en"
+}:
+
+let
+  l10n = import ./l10ns.nix {
+    inherit lib requireFile lang;
+  };
+in stdenv.mkDerivation {
+  inherit (l10n) version name src;
+
+  nativeBuildInputs = [
+    autoPatchelfHook
+    makeWrapper
+  ];
+
+  buildInputs = [
+    alsa-lib
+    cups.lib
+    dbus
+    flite
+    fontconfig
+    freetype
+    glib
+    gmpxx
+    keyutils.lib
+    libGL
+    libGLU
+    libpcap
+    libtins
+    libuuid
+    libxkbcommon
+    libxml2
+    llvmPackages_12.libllvm.lib
+    matio
+    mpfr
+    ncurses
+    opencv4
+    openjdk11
+    openssl
+    pciutils
+    tre
+    unixODBC
+    xkeyboard_config
+  ] ++ (with xorg; [
+    libICE
+    libSM
+    libX11
+    libXScrnSaver
+    libXcomposite
+    libXcursor
+    libXdamage
+    libXext
+    libXfixes
+    libXi
+    libXinerama
+    libXmu
+    libXrandr
+    libXrender
+    libXtst
+    libxcb
+  ]);
+
+  wrapProgramFlags = [
+    "--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ gcc-unwrapped.lib zlib ]}"
+    "--prefix PATH : ${lib.makeBinPath [ stdenv.cc ]}"
+    # Fix libQt errors - #96490
+    "--set USE_WOLFRAM_LD_LIBRARY_PATH 1"
+    # Fix xkeyboard config path for Qt
+    "--set QT_XKB_CONFIG_ROOT ${xkeyboard_config}/share/X11/xkb"
+  ];
+
+  unpackPhase = ''
+    runHook preUnpack
+
+    # Find offset from file
+    offset=$(${stdenv.shell} -c "$(grep -axm1 -e 'offset=.*' $src); echo \$offset" $src)
+    tail -c +$(($offset + 1)) $src | tar -xf -
+
+    runHook postUnpack
+  '';
+
+  installPhase = ''
+    runHook preInstall
+
+    cd "$TMPDIR/Unix/Installer"
+
+    mkdir -p "$out/lib/udev/rules.d"
+
+    # Patch MathInstaller's shebangs and udev rules dir
+    patchShebangs MathInstaller
+    substituteInPlace MathInstaller \
+      --replace /etc/udev/rules.d $out/lib/udev/rules.d
+
+    # Remove PATH restriction, root and avahi daemon checks, and hostname call
+    sed -i '
+      s/^PATH=/# &/
+      s/isRoot="false"/# &/
+      s/^checkAvahiDaemon$/# &/
+      s/`hostname`/""/
+    ' MathInstaller
+
+    # NOTE: some files placed under HOME may be useful
+    XDG_DATA_HOME="$out/share" HOME="$TMPDIR/home" vernierLink=y \
+      ./MathInstaller -execdir="$out/bin" -targetdir="$out/libexec/Mathematica" -auto -verbose -createdir=y
+
+    # Check if MathInstaller produced any errors
+    errLog="$out/libexec/Mathematica/InstallErrors"
+    if [ -f "$errLog" ]; then
+      echo "Installation errors:"
+      cat "$errLog"
+      return 1
+    fi
+
+    runHook postInstall
+  '';
+
+  preFixup = ''
+    for bin in $out/libexec/Mathematica/Executables/*; do
+      wrapProgram "$bin" ''${wrapProgramFlags[@]}
+    done
+  '';
+
+  dontConfigure = true;
+  dontBuild = true;
+
+  # This is primarily an IO bound build; there's little benefit to building remotely
+  preferLocalBuild = true;
+
+  # All binaries are already stripped
+  dontStrip = true;
+
+  # NOTE: Some deps are still not found; ignore for now
+  autoPatchelfIgnoreMissingDeps = true;
+
+  meta = with lib; {
+    description = "Wolfram Mathematica computational software system";
+    homepage = "http://www.wolfram.com/mathematica/";
+    license = licenses.unfree;
+    maintainers = with maintainers; [ herberteuler ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/mathematica/l10ns.nix b/nixpkgs/pkgs/applications/science/math/mathematica/l10ns.nix
new file mode 100644
index 000000000000..60841eaa3ee2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/mathematica/l10ns.nix
@@ -0,0 +1,106 @@
+{ lib
+, requireFile
+, lang
+, majorVersion ? null
+}:
+
+let allVersions = with lib; flip map
+  # N.B. Versions in this list should be ordered from newest to oldest.
+  [
+    {
+      version = "13.0.1";
+      lang = "en";
+      language = "English";
+      sha256 = "3672a920c1b4af1afd480733f6d67665baf8258757dfe59a6ed6d7440cf26dba";
+      installer = "Mathematica_13.0.1_BNDL_LINUX.sh";
+    }
+    {
+      version = "13.0.0";
+      lang = "en";
+      language = "English";
+      sha256 = "15bbad39a5995031325d1d178f63b00e71706d3ec9001eba6d1681fbc991d3e1";
+      installer = "Mathematica_13.0.0_BNDL_LINUX.sh";
+    }
+    {
+      version = "12.3.1";
+      lang = "en";
+      language = "English";
+      sha256 = "51b9cab12fd91b009ea7ad4968a2c8a59e94dc55d2e6cc1d712acd5ba2c4d509";
+      installer = "Mathematica_12.3.1_LINUX.sh";
+    }
+    {
+      version = "12.3.0";
+      lang = "en";
+      language = "English";
+      sha256 = "045df045f6e796ded59f64eb2e0f1949ac88dcba1d5b6e05fb53ea0a4aed7215";
+      installer = "Mathematica_12.3.0_LINUX.sh";
+    }
+    {
+      version = "12.2.0";
+      lang = "en";
+      language = "English";
+      sha256 = "3b6676a203c6adb7e9c418a5484b037974287b5be09c64e7dfea74ddc0e400d7";
+      installer = "Mathematica_12.2.0_LINUX.sh";
+    }
+    {
+      version = "12.1.1";
+      lang = "en";
+      language = "English";
+      sha256 = "02mk8gmv8idnakva1nc7r7mx8ld02lk7jgsj1zbn962aps3bhixd";
+      installer = "Mathematica_12.1.1_LINUX.sh";
+    }
+    {
+      version = "12.1.0";
+      lang = "en";
+      language = "English";
+      sha256 = "15m9l20jvkxh5w6mbp81ys7mx2lx5j8acw5gz0il89lklclgb8z7";
+      installer = "Mathematica_12.1.0_LINUX.sh";
+    }
+    {
+      version = "12.0.0";
+      lang = "en";
+      language = "English";
+      sha256 = "b9fb71e1afcc1d72c200196ffa434512d208fa2920e207878433f504e58ae9d7";
+      installer = "Mathematica_12.0.0_LINUX.sh";
+    }
+    {
+      version = "11.3.0";
+      lang = "en";
+      language = "English";
+      sha256 = "0fcfe208c1eac8448e7be3af0bdb84370b17bd9c5d066c013928c8ee95aed10e";
+      installer = "Mathematica_11.3.0_LINUX.sh";
+    }
+    {
+      version = "11.2.0";
+      lang = "ja";
+      language = "Japanese";
+      sha256 = "916392edd32bed8622238df435dd8e86426bb043038a3336f30df10d819b49b1";
+      installer = "Mathematica_11.2.0_ja_LINUX.sh";
+    }
+  ]
+  ({ version, lang, language, sha256, installer }: {
+    inherit version lang;
+    name = "mathematica-${version}" + optionalString (lang != "en") "-${lang}";
+    src = requireFile {
+      name = installer;
+      message = ''
+        This nix expression requires that ${installer} is
+        already part of the store. Find the file on your Mathematica CD
+        and add it to the nix store with nix-store --add-fixed sha256 <FILE>.
+      '';
+      inherit sha256;
+    };
+  });
+minVersion =
+  with lib;
+  if majorVersion == null
+  then elemAt (builtins.splitVersion (elemAt allVersions 0).version) 0
+  else majorVersion;
+maxVersion = toString (1 + builtins.fromJSON minVersion);
+in
+with lib;
+findFirst (l: (l.lang == lang
+               && l.version >= minVersion
+               && l.version < maxVersion))
+          (throw "Version ${minVersion} in language ${lang} not supported")
+          allVersions
diff --git a/nixpkgs/pkgs/applications/science/math/maxima/default.nix b/nixpkgs/pkgs/applications/science/math/maxima/default.nix
new file mode 100644
index 000000000000..8bad09f17880
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/maxima/default.nix
@@ -0,0 +1,124 @@
+{ lib
+, stdenv
+, fetchurl
+, fetchpatch
+, texinfo
+, perl
+, python3
+, makeWrapper
+, autoreconfHook
+, rlwrap ? null
+, tk ? null
+, gnuplot ? null
+, lisp-compiler
+}:
+
+let
+  # Allow to remove some executables from the $PATH of the wrapped binary
+  searchPath = lib.makeBinPath
+    (lib.filter (x: x != null) [ lisp-compiler rlwrap tk gnuplot ]);
+in
+stdenv.mkDerivation rec {
+  pname = "maxima";
+  version = "5.45.1";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/${pname}/${pname}-${version}.tar.gz";
+    sha256 = "sha256-/pAWJ2lwvvIUoaJENIVYZEUU1/36pPyLnQ6Hr8u059w=";
+  };
+
+  nativeBuildInputs = [
+    autoreconfHook
+    lisp-compiler
+    makeWrapper
+    python3
+    texinfo
+  ];
+
+  strictDeps = true;
+
+  checkInputs = [
+    gnuplot
+  ];
+
+  postPatch = ''
+    substituteInPlace doc/info/Makefile.am --replace "/usr/bin/env perl" "${perl}/bin/perl"
+  '';
+
+  postInstall = ''
+    # Make sure that maxima can find its runtime dependencies.
+    for prog in "$out/bin/"*; do
+      wrapProgram "$prog" --prefix PATH ":" "$out/bin:${searchPath}"
+    done
+    # Move emacs modules and documentation into the right place.
+    mkdir -p $out/share/emacs $out/share/doc
+    ln -s ../maxima/${version}/emacs $out/share/emacs/site-lisp
+    ln -s ../maxima/${version}/doc $out/share/doc/maxima
+  ''
+   + (lib.optionalString (lisp-compiler.pname == "ecl") ''
+     cp src/binary-ecl/maxima.fas* "$out/lib/maxima/${version}/binary-ecl/"
+   '')
+  ;
+
+  patches = [
+    # fix path to info dir (see https://trac.sagemath.org/ticket/11348)
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/maxima/patches/infodir.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "09v64n60f7i6frzryrj0zd056lvdpms3ajky4f9p6kankhbiv21x";
+    })
+
+    # fix https://sourceforge.net/p/maxima/bugs/2596/
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/maxima/patches/matrixexp.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "06961hn66rhjijfvyym21h39wk98sfxhp051da6gz0n9byhwc6zg";
+    })
+
+    # undo https://sourceforge.net/p/maxima/code/ci/f5e9b0f7eb122c4e48ea9df144dd57221e5ea0ca
+    # see https://trac.sagemath.org/ticket/13364#comment:93
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/maxima/patches/undoing_true_false_printing_patch.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "0fvi3rcjv6743sqsbgdzazy9jb6r1p1yq63zyj9fx42wd1hgf7yx";
+    })
+  ] ++ lib.optionals (lisp-compiler.pname == "ecl") [
+    # build fasl, needed for ECL support
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/maxima/patches/maxima.system.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "18zafig8vflhkr80jq2ivk46k92dkszqlyq8cfmj0b2vcfjwwbar";
+    })
+  ];
+
+  # The test suite is disabled since 5.42.2 because of the following issues:
+  #
+  #   Error(s) found:
+  #   /build/maxima-5.44.0/share/linearalgebra/rtest_matrixexp.mac problems:
+  #   (20 21 22)
+  #   Tests that were expected to fail but passed:
+  #   /build/maxima-5.44.0/share/vector/rtest_vect.mac problem:
+  #   (19)
+  #   3 tests failed out of 16,184 total tests.
+  #
+  # These failures don't look serious. It would be nice to fix them, but I
+  # don't know how and probably won't have the time to find out.
+  doCheck = false;    # try to re-enable after next version update
+
+  enableParallelBuilding = true;
+
+  passthru = {
+    inherit lisp-compiler;
+  };
+
+  meta = with lib; {
+    description = "Computer algebra system";
+    homepage = "http://maxima.sourceforge.net";
+    license = licenses.gpl2Plus;
+
+    longDescription = ''
+      Maxima is a fairly complete computer algebra system written in
+      lisp with an emphasis on symbolic computation. It is based on
+      DOE-MACSYMA and licensed under the GPL. Its abilities include
+      symbolic integration, 3D plotting, and an ODE solver.
+    '';
+    maintainers = with maintainers; [ doronbehar ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/msieve/default.nix b/nixpkgs/pkgs/applications/science/math/msieve/default.nix
new file mode 100644
index 000000000000..6456608e7dbc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/msieve/default.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchurl, zlib, gmp, ecm }:
+
+stdenv.mkDerivation rec {
+  pname = "msieve";
+  version = "1.53";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/msieve/msieve/Msieve%20v${version}/msieve${lib.replaceStrings ["."] [""] version}_src.tar.gz";
+    sha256 = "1d1vv7j4rh3nnxsmvafi73qy7lw7n3akjlm5pjl3m936yapvmz65";
+  };
+
+  buildInputs = [ zlib gmp ecm ];
+
+  ECM = if ecm == null then "0" else "1";
+
+  # Doesn't hurt Linux but lets clang-based platforms like Darwin work fine too
+  makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" "all" ];
+
+  installPhase = ''
+    mkdir -p $out/bin/
+    cp msieve $out/bin/
+  '';
+
+  meta = {
+    description = "A C library implementing a suite of algorithms to factor large integers";
+    license = lib.licenses.publicDomain;
+    homepage = "http://msieve.sourceforge.net/";
+    maintainers = [ lib.maintainers.roconnor ];
+    platforms = [ "x86_64-linux" ] ++ lib.platforms.darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/mxnet/default.nix b/nixpkgs/pkgs/applications/science/math/mxnet/default.nix
new file mode 100644
index 000000000000..c9ffb8ed5cb3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/mxnet/default.nix
@@ -0,0 +1,70 @@
+{ config, stdenv, lib, fetchurl, fetchpatch, bash, cmake
+, opencv3, gtest, blas, gomp, llvmPackages, perl
+, cudaSupport ? config.cudaSupport or false, cudatoolkit, nvidia_x11
+, cudnnSupport ? cudaSupport, cudnn
+}:
+
+assert cudnnSupport -> cudaSupport;
+
+stdenv.mkDerivation rec {
+  pname = "mxnet";
+  version = "1.8.0";
+
+  src = fetchurl {
+    name = "apache-mxnet-src-${version}-incubating.tar.gz";
+    url = "https://dlcdn.apache.org/incubator/mxnet/${version}/apache-mxnet-src-${version}-incubating.tar.gz";
+    hash = "sha256-la/5hYlaukCcCNVRRRCuOLiEkM+2KBqzpf8PWCbI21Q=";
+  };
+
+  patches = [
+    # Fix build error https://github.com/apache/incubator-mxnet/issues/19405
+    (fetchpatch {
+      name = "mxnet-fix-gcc-linker-error-1.patch";
+      url = "https://github.com/apache/incubator-mxnet/commit/78e31d66d19e385ca4ef73245ce79a47e375d8d1.diff";
+      sha256 = "sha256-UfmGhh4RbvrEOXe6IJxHm1Aqpy1gS6gHxrX5KQBXjv4=";
+    })
+    (fetchpatch {
+      name = "mxnet-fix-gcc-linker-error-2.patch";
+      url = "https://github.com/apache/incubator-mxnet/commit/9bfe3116aabd01049fdbd90855cb245a30b795df.diff";
+      sha256 = "sha256-BL7Zf7Bgn0qpai9HbQ6LBxZNa3iLjVJSe5nxZgqI/fw=";
+    })
+  ];
+
+  nativeBuildInputs = [ cmake perl ];
+
+  buildInputs = [ opencv3 gtest blas.provider ]
+    ++ lib.optional stdenv.cc.isGNU gomp
+    ++ lib.optional stdenv.cc.isClang llvmPackages.openmp
+    ++ lib.optionals cudaSupport [ cudatoolkit nvidia_x11 ]
+    ++ lib.optional cudnnSupport cudnn;
+
+  cmakeFlags =
+    [ "-DUSE_MKL_IF_AVAILABLE=OFF" ]
+    ++ (if cudaSupport then [
+      "-DUSE_OLDCMAKECUDA=ON"  # see https://github.com/apache/incubator-mxnet/issues/10743
+      "-DCUDA_ARCH_NAME=All"
+      "-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/cc"
+    ] else [ "-DUSE_CUDA=OFF" ])
+    ++ lib.optional (!cudnnSupport) "-DUSE_CUDNN=OFF";
+
+  postPatch = ''
+    substituteInPlace 3rdparty/mkldnn/tests/CMakeLists.txt \
+      --replace "/bin/bash" "${bash}/bin/bash"
+
+    # Build against the system version of OpenMP.
+    # https://github.com/apache/incubator-mxnet/pull/12160
+    rm -rf 3rdparty/openmp
+  '';
+
+  postInstall = ''
+    rm "$out"/lib/*.a
+  '';
+
+  meta = with lib; {
+    description = "Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler";
+    homepage = "https://mxnet.incubator.apache.org/";
+    maintainers = with maintainers; [ abbradar ];
+    license = licenses.asl20;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/nasc/default.nix b/nixpkgs/pkgs/applications/science/math/nasc/default.nix
new file mode 100644
index 000000000000..2fe027365cdc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/nasc/default.nix
@@ -0,0 +1,88 @@
+{ lib, stdenv
+, fetchFromGitHub
+, pkg-config
+, fetchpatch
+, python3
+, meson
+, ninja
+, vala
+, gtk3
+, glib
+, pantheon
+, gtksourceview
+, libgee
+, nix-update-script
+, webkitgtk
+, libqalculate
+, intltool
+, gnuplot
+, wrapGAppsHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "nasc";
+  version = "0.8.0";
+
+  src = fetchFromGitHub {
+    owner = "parnold-x";
+    repo = pname;
+    rev = version;
+    sha256 = "02b9a59a9fzsb6nn3ycwwbcbv04qfzm6x7csq2addpzx5wak6dd8";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [
+    glib # post_install.py
+    gtk3 # post_install.py
+    intltool # for libqalculate
+    meson
+    ninja
+    pkg-config
+    python3
+    vala
+    wrapGAppsHook
+  ];
+
+  buildInputs = [
+    glib
+    gtk3
+    gtksourceview
+    libgee
+    pantheon.elementary-icon-theme
+    pantheon.granite
+    webkitgtk
+    # We add libqalculate's runtime dependencies because nasc has it as a modified subproject.
+  ] ++ libqalculate.buildInputs ++ libqalculate.propagatedBuildInputs;
+
+  postPatch = ''
+    chmod +x meson/post_install.py
+    patchShebangs meson/post_install.py
+
+    # patch subproject. same code in libqalculate expression
+    substituteInPlace subprojects/libqalculate/libqalculate/Calculator-plot.cc \
+      --replace 'commandline = "gnuplot"' 'commandline = "${gnuplot}/bin/gnuplot"' \
+      --replace '"gnuplot - ' '"${gnuplot}/bin/gnuplot - '
+  '';
+
+  passthru = {
+    updateScript = nix-update-script {
+      attrPath = pname;
+    };
+  };
+
+  meta = with lib; {
+    description = "Do maths like a normal person, designed for elementary OS";
+    longDescription = ''
+      It’s an app where you do maths like a normal person. It lets you
+      type whatever you want and smartly figures out what is math and
+      spits out an answer on the right pane. Then you can plug those
+      answers in to future equations and if that answer changes, so does
+      the equations it’s used in.
+    '';
+    homepage = "https://github.com/parnold-x/nasc";
+    maintainers = teams.pantheon.members;
+    platforms = platforms.linux;
+    license = licenses.gpl3Plus;
+    mainProgram = "com.github.parnold_x.nasc";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/nauty/default.nix b/nixpkgs/pkgs/applications/science/math/nauty/default.nix
new file mode 100644
index 000000000000..c435c63ab2ef
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/nauty/default.nix
@@ -0,0 +1,43 @@
+{ stdenv
+, lib
+, fetchurl
+}:
+stdenv.mkDerivation rec {
+  pname = "nauty";
+  version = "27r1";
+  src = fetchurl {
+    url = "https://pallini.di.uniroma1.it/nauty${version}.tar.gz";
+    sha256 = "0xsfqfcknbd6g6wzpa5l7crmmk3bf3zjh37rhylq6b20dqcmvjkn";
+  };
+  outputs = [ "out" "dev" ];
+  configureFlags = [
+    # Prevent nauty from sniffing some cpu features. While those are very
+    # widely available, it can lead to nasty bugs when they are not available:
+    # https://groups.google.com/forum/#!topic/sage-packaging/Pe4SRDNYlhA
+    "--${if stdenv.hostPlatform.sse4_2Support then "enable" else "disable"}-popcnt"
+    "--${if stdenv.hostPlatform.sse4_aSupport then "enable" else "disable"}-clz"
+  ];
+  installPhase = ''
+    mkdir -p "$out"/{bin,share/doc/nauty} "$dev"/{lib,include/nauty}
+
+    find . -type f -perm -111 \! -name '*.*' \! -name configure -exec cp '{}' "$out/bin" \;
+    cp [Rr][Ee][Aa][Dd]* COPYRIGHT This* [Cc]hange* "$out/share/doc/nauty"
+
+    cp *.h "$dev/include/nauty"
+    for i in *.a; do
+      cp "$i" "$dev/lib/lib$i";
+    done
+  '';
+  checkTarget = "checks";
+  meta = with lib; {
+    description = "Programs for computing automorphism groups of graphs and digraphs";
+    license = licenses.asl20;
+    maintainers = teams.sage.members;
+    platforms = platforms.unix;
+    # I'm not sure if the filename will remain the same for future changelog or
+    # if it will track changes to minor releases. Lets see. Better than nothing
+    # in any case.
+    changelog = "https://pallini.di.uniroma1.it/changes24-27.txt";
+    homepage = "https://pallini.di.uniroma1.it/";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/nota/default.nix b/nixpkgs/pkgs/applications/science/math/nota/default.nix
new file mode 100644
index 000000000000..897785ef6e8b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/nota/default.nix
@@ -0,0 +1,40 @@
+{ mkDerivation, haskellPackages, fetchurl, lib }:
+
+mkDerivation rec {
+  pname = "nota";
+  version = "1.0";
+
+  # Can't use fetchFromGitLab since codes.kary.us doesn't support https
+  src = fetchurl {
+    url = "http://codes.kary.us/nota/nota/-/archive/V${version}/nota-V${version}.tar.bz2";
+    sha256 = "0bbs6bm9p852hvqadmqs428ir7m65h2prwyma238iirv42pk04v8";
+  };
+
+  postUnpack = ''
+    export sourceRoot=$sourceRoot/source
+  '';
+
+  isLibrary = false;
+  isExecutable = true;
+
+  libraryHaskellDepends = with haskellPackages; [
+    base
+    bytestring
+    array
+    split
+    scientific
+    parsec
+    ansi-terminal
+    regex-compat
+    containers
+    terminal-size
+    numbers
+    text
+    time
+  ];
+
+  description = "The most beautiful command line calculator";
+  homepage = "https://kary.us/nota";
+  license = lib.licenses.mpl20;
+  maintainers = with lib.maintainers; [ dtzWill ];
+}
diff --git a/nixpkgs/pkgs/applications/science/math/numworks-epsilon/0001-ion-linux-makerules.patch b/nixpkgs/pkgs/applications/science/math/numworks-epsilon/0001-ion-linux-makerules.patch
new file mode 100644
index 000000000000..0bc29b9aab5f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/numworks-epsilon/0001-ion-linux-makerules.patch
@@ -0,0 +1,12 @@
+diff --git a/ion/src/simulator/linux/Makefile b/ion/src/simulator/linux/Makefile
+index ca7da03fa..b05bba115 100644
+--- a/ion/src/simulator/linux/Makefile
++++ b/ion/src/simulator/linux/Makefile
+@@ -28,7 +28,6 @@ ion_src += $(addprefix ion/src/simulator/shared/, \
+   collect_registers.cpp \
+   haptics.cpp \
+   journal.cpp \
+-  platform_action_modifier_ctrl.cpp \
+   state_file.cpp \
+ )
+ 
diff --git a/nixpkgs/pkgs/applications/science/math/numworks-epsilon/default.nix b/nixpkgs/pkgs/applications/science/math/numworks-epsilon/default.nix
new file mode 100644
index 000000000000..a90ebc67b65b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/numworks-epsilon/default.nix
@@ -0,0 +1,63 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, libpng
+, libjpeg
+, freetype
+, xorg
+, python3
+, imagemagick
+, gcc-arm-embedded
+, pkg-config
+}:
+
+stdenv.mkDerivation rec {
+  pname = "numworks-epsilon";
+  version = "15.5.0";
+
+  src = fetchFromGitHub {
+    owner = "numworks";
+    repo = "epsilon";
+    rev = version;
+    sha256 = "fPBO3FzZ4k5OxG+Ifc6R/au4Te974HNKAEdHz+aFdSg=";
+  };
+
+  nativeBuildInputs = [ pkg-config ];
+  buildInputs = [
+    libpng
+    libjpeg
+    freetype
+    xorg.libXext
+    python3
+    imagemagick
+    gcc-arm-embedded
+  ];
+
+  makeFlags = [
+    "PLATFORM=simulator"
+  ];
+
+  patches = [
+    # Remove make rule Introduced in cba596dde7
+    # which causes it to not build with nix
+    ./0001-ion-linux-makerules.patch
+  ];
+
+  installPhase = ''
+    runHook preInstall
+
+    mv ./output/release/simulator/linux/{epsilon.bin,epsilon}
+    mkdir -p $out/bin
+    cp -r ./output/release/simulator/linux/* $out/bin/
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Simulator for Epsilon, a High-performance graphing calculator operating system";
+    homepage = "https://numworks.com/";
+    license = licenses.cc-by-nc-sa-40;
+    maintainers = with maintainers; [ erikbackman ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/palp/default.nix b/nixpkgs/pkgs/applications/science/math/palp/default.nix
new file mode 100644
index 000000000000..ffe17bc3dec2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/palp/default.nix
@@ -0,0 +1,91 @@
+{ lib
+, stdenv
+, fetchurl
+, dimensions ? 6 # works for <= dimensions dimensions, but is only optimized for that exact value
+, doSymlink ? true # symlink the executables to the default location (without dimension postfix)
+}:
+
+let
+  dim = toString dimensions;
+in
+stdenv.mkDerivation rec {
+  pname = "palp";
+  version = "2.20";
+
+  src = fetchurl {
+    url = "http://hep.itp.tuwien.ac.at/~kreuzer/CY/palp/${pname}-${version}.tar.gz";
+    sha256 = "1q1cl3vpdir16szy0jcadysydcrjp48hqxyx42kr8g9digkqjgkj";
+  };
+
+  hardeningDisable = [
+    "format"
+  ];
+
+  patchPhase = lib.optionalString stdenv.isDarwin ''
+    substituteInPlace GNUmakefile --replace gcc cc
+  '';
+
+  preBuild = ''
+    echo Building PALP optimized for ${dim} dimensions
+    sed -i "s/^#define[^a-zA-Z]*POLY_Dmax.*/#define POLY_Dmax ${dim}/" Global.h
+  '';
+
+  # palp has no tests of its own. This test is an adapted sage test that failed
+  # when #28029 was merged.
+  doCheck = true;
+  checkPhase = ''
+    ./nef.x -f -N << EOF | grep -q 'np='
+      3 6
+      1  0  0 -1  0  0
+      0  1  0  0 -1  0
+      0  0  1  0  0 -1
+    EOF
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    for file in poly class cws nef mori; do
+      cp -p $file.x "$out/bin/$file-${dim}d.x"
+    done
+  '' + lib.optionalString doSymlink ''
+    cd $out/bin
+    for file in poly class cws nef mori; do
+      ln -sf $file-6d.x $file.x
+    done
+  '';
+
+  meta = with lib; {
+    description = "A Package for Analyzing Lattice Polytopes";
+    longDescription = ''
+      A Package for Analyzing Lattice Polytopes (PALP) is a set of C
+      programs for calculations with lattice polytopes and applications to
+      toric geometry.
+
+      It contains routines for vertex and facet enumeration, computation of
+      incidences and symmetries, as well as completion of the set of lattice
+      points in the convex hull of a given set of points. In addition, there
+      are procedures specialised to reflexive polytopes such as the
+      enumeration of reflexive subpolytopes, and applications to toric
+      geometry and string theory, like the computation of Hodge data and
+      fibration structures for toric Calabi-Yau varieties.  The package is
+      well tested and optimised in speed as it was used for time consuming
+      tasks such as the classification of reflexive polyhedra in 4
+      dimensions and the creation and manipulation of very large lists of
+      5-dimensional polyhedra.
+
+      While originally intended for low-dimensional applications, the
+      algorithms work in any dimension and our key routine for vertex and
+      facet enumeration compares well with existing packages.
+    '';
+    homepage = "http://hep.itp.tuwien.ac.at/~kreuzer/CY/CYpalp.html";
+    # Not really a changelog, but a one-line summary of each update that should
+    # be reviewed on update.
+    changelog = "http://hep.itp.tuwien.ac.at/~kreuzer/CY/CYpalp.html";
+    # Just a link on the website pointing to gpl -- now gplv3. When the last
+    # version was released that pointed to gplv2 however, so thats probably
+    # the right license.
+    license = licenses.gpl2;
+    maintainers = teams.sage.members;
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/pari/default.nix b/nixpkgs/pkgs/applications/science/math/pari/default.nix
new file mode 100644
index 000000000000..a9c002d210f2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/pari/default.nix
@@ -0,0 +1,86 @@
+{ lib
+, stdenv
+, fetchurl
+, gmp
+, libX11
+, perl
+, readline
+, tex
+, withThread ? true, libpthreadstubs
+}:
+
+assert withThread -> libpthreadstubs != null;
+
+stdenv.mkDerivation rec {
+  pname = "pari";
+  version = "2.13.3";
+
+  src = fetchurl {
+    urls = [
+      "https://pari.math.u-bordeaux.fr/pub/pari/unix/${pname}-${version}.tar.gz"
+      # old versions are at the url below
+      "https://pari.math.u-bordeaux.fr/pub/pari/OLD/${lib.versions.majorMinor version}/${pname}-${version}.tar.gz"
+    ];
+    hash = "sha256-zLp/FgbGhU8UQ2N7tXrQlY1Bx/R1P4roRZ8dZMJnoco=";
+  };
+
+  buildInputs = [
+    gmp
+    libX11
+    perl
+    readline
+    tex
+  ] ++ lib.optionals withThread [
+    libpthreadstubs
+  ];
+
+  configureScript = "./Configure";
+  configureFlags = [
+    "--with-gmp=${lib.getDev gmp}"
+    "--with-readline=${lib.getDev readline}"
+  ]
+  ++ lib.optional stdenv.isDarwin "--host=x86_64-darwin"
+  ++ lib.optional withThread "--mt=pthread";
+
+  preConfigure = ''
+    export LD=$CC
+  '';
+
+  postConfigure = lib.optionalString stdenv.isDarwin ''
+    echo 'echo x86_64-darwin' > config/arch-osname
+  '';
+
+  makeFlags = [ "all" ];
+
+  meta = with lib; {
+    homepage = "http://pari.math.u-bordeaux.fr";
+    description = "Computer algebra system for high-performance number theory computations";
+    longDescription = ''
+       PARI/GP is a widely used computer algebra system designed for fast
+       computations in number theory (factorizations, algebraic number theory,
+       elliptic curves...), but also contains a large number of other useful
+       functions to compute with mathematical entities such as matrices,
+       polynomials, power series, algebraic numbers etc., and a lot of
+       transcendental functions. PARI is also available as a C library to allow
+       for faster computations.
+
+       Originally developed by Henri Cohen and his co-workers (Université
+       Bordeaux I, France), PARI is now under the GPL and maintained by Karim
+       Belabas with the help of many volunteer contributors.
+
+       - PARI is a C library, allowing fast computations.
+       - gp is an easy-to-use interactive shell giving access to the PARI
+         functions.
+       - GP is the name of gp's scripting language.
+       - gp2c, the GP-to-C compiler, combines the best of both worlds by
+         compiling GP scripts to the C language and transparently loading the
+         resulting functions into gp. (gp2c-compiled scripts will typically run
+         3 or 4 times faster.) gp2c currently only understands a subset of the
+         GP language.
+    '';
+    downloadPage = "http://pari.math.u-bordeaux.fr/download.html";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ ertes AndersonTorres ] ++ teams.sage.members;
+    platforms = platforms.linux ++ platforms.darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/pari/gp2c.nix b/nixpkgs/pkgs/applications/science/math/pari/gp2c.nix
new file mode 100644
index 000000000000..7f31543a925f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/pari/gp2c.nix
@@ -0,0 +1,34 @@
+{ lib
+, stdenv
+, fetchurl
+, pari
+, perl
+}:
+
+stdenv.mkDerivation rec {
+  pname = "gp2c";
+  version = "0.0.12";
+
+  src = fetchurl {
+    url = "https://pari.math.u-bordeaux.fr/pub/pari/GP2C/${pname}-${version}.tar.gz";
+    sha256 = "039ip7qkwwv46wrcdrz7y12m30kazzkjr44kqbc0h137g4wzd7zf";
+  };
+
+  buildInputs = [
+    pari
+    perl
+  ];
+
+  configureFlags = [
+    "--with-paricfg=${pari}/lib/pari/pari.cfg"
+    "--with-perl=${perl}/bin/perl"
+  ];
+
+  meta = with lib; {
+    description =  "A compiler to translate GP scripts to PARI programs";
+    homepage = "http://pari.math.u-bordeaux.fr/";
+    downloadPage = "http://pari.math.u-bordeaux.fr/download.html";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ AndersonTorres ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/pcalc/default.nix b/nixpkgs/pkgs/applications/science/math/pcalc/default.nix
new file mode 100644
index 000000000000..97888b712eb1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/pcalc/default.nix
@@ -0,0 +1,26 @@
+{ lib, stdenv, fetchFromGitHub, bison, flex }:
+
+stdenv.mkDerivation rec {
+  pname = "pcalc";
+  version = "20181202";
+
+  src = fetchFromGitHub {
+    owner = "vapier";
+    repo = "pcalc";
+    rev = "d93be9e19ecc0b2674cf00ec91cbb79d32ccb01d";
+    sha256 = "sha256-m4xdsEJGKxLgp/d5ipxQ+cKG3z7rlvpPL6hELnDu6Hk=";
+  };
+
+  makeFlags = [ "DESTDIR= BINDIR=$(out)/bin" ];
+  nativeBuildInputs = [ bison flex ];
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    homepage = "https://vapier.github.io/pcalc/";
+    description = "Programmer's calculator";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ ftrvxmtrx ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/perseus/default.nix b/nixpkgs/pkgs/applications/science/math/perseus/default.nix
new file mode 100644
index 000000000000..4545203dacca
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/perseus/default.nix
@@ -0,0 +1,40 @@
+{ lib, stdenv, fetchurl, unzip }:
+
+stdenv.mkDerivation {
+  pname = "perseus";
+  version = "4-beta";
+  nativeBuildInputs = [ unzip ];
+
+  hardeningDisable = [ "stackprotector" ];
+
+  src = fetchurl {
+    url = "http://www.sas.upenn.edu/~vnanda/source/perseus_4_beta.zip";
+    sha256 = "09brijnqabhgfjlj5wny0bqm5dwqcfkp1x5wif6yzdmqh080jybj";
+  };
+
+  sourceRoot = ".";
+
+  buildPhase = ''
+    g++ Pers.cpp -O3 -fpermissive -o perseus
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp perseus $out/bin
+  '';
+
+  meta = {
+    description = "The Persistent Homology Software";
+    longDescription = ''
+      Persistent homology - or simply, persistence - is an algebraic
+      topological invariant of a filtered cell complex. Perseus
+      computes this invariant for a wide class of filtrations built
+      around datasets arising from point samples, images, distance
+      matrices and so forth.
+    '';
+    homepage = "http://www.sas.upenn.edu/~vnanda/perseus/index.html";
+    license = lib.licenses.gpl3;
+    maintainers = with lib.maintainers; [ erikryb ];
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/polymake/default.nix b/nixpkgs/pkgs/applications/science/math/polymake/default.nix
new file mode 100644
index 000000000000..d132a98dcb9a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/polymake/default.nix
@@ -0,0 +1,51 @@
+{ lib, stdenv, fetchurl
+, perl, gmp, mpfr, flint, boost
+, bliss, ppl, singular, cddlib, lrs, nauty
+, ninja, ant, openjdk
+, perlPackages
+, makeWrapper
+}:
+
+# polymake compiles its own version of sympol and atint because we
+# don't have those packages. other missing optional dependencies:
+# javaview, libnormaliz, scip, soplex, jreality.
+
+stdenv.mkDerivation rec {
+  pname = "polymake";
+  version = "4.6";
+
+  src = fetchurl {
+    # "The minimal version is a packager friendly version which omits
+    # the bundled sources of cdd, lrs, libnormaliz, nauty and jReality."
+    url = "https://polymake.org/lib/exe/fetch.php/download/polymake-${version}-minimal.tar.bz2";
+    sha256 = "sha256-QjpE3e8R6uqEV6sV3V2G3beovMbJuxF3b54pWNfc+dA=";
+  };
+
+  buildInputs = [
+    perl gmp mpfr flint boost
+    bliss ppl singular cddlib lrs nauty
+    openjdk
+  ] ++ (with perlPackages; [
+    JSON TermReadLineGnu TermReadKey XMLSAX
+  ]);
+
+  nativeBuildInputs = [
+    makeWrapper ninja ant perl
+  ];
+
+  ninjaFlags = [ "-C" "build/Opt" ];
+
+  postInstall = ''
+    for i in "$out"/bin/*; do
+      wrapProgram "$i" --prefix PERL5LIB : "$PERL5LIB"
+    done
+  '';
+
+  meta = with lib; {
+    description = "Software for research in polyhedral geometry";
+    license = licenses.gpl2Plus;
+    maintainers = teams.sage.members;
+    platforms = platforms.linux;
+    homepage = "https://www.polymake.org/doku.php";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/programmer-calculator/default.nix b/nixpkgs/pkgs/applications/science/math/programmer-calculator/default.nix
new file mode 100644
index 000000000000..e9c7cb985cb9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/programmer-calculator/default.nix
@@ -0,0 +1,34 @@
+{ lib, gccStdenv, fetchFromGitHub, ncurses }:
+
+gccStdenv.mkDerivation rec {
+  pname = "programmer-calculator";
+  version = "2.2";
+
+  src = fetchFromGitHub {
+    owner = "alt-romes";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "sha256-JQcYCYKdjdy8U2XMFzqTH9kAQ7CFv0r+sC1YfuAm7p8=";
+  };
+
+  buildInputs = [ ncurses ];
+
+  installPhase = ''
+    runHook preInstall
+    install -Dm 555 pcalc -t "$out/bin"
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "A terminal calculator for programmers";
+    longDescription = ''
+      Terminal calculator made for programmers working with multiple number
+      representations, sizes, and overall close to the bits
+    '';
+    homepage = "https://alt-romes.github.io/programmer-calculator";
+    changelog = "https://github.com/alt-romes/programmer-calculator/releases/tag/v${version}";
+    license = licenses.gpl3Only;
+    maintainers = with lib.maintainers; [ cjab ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/pspp/default.nix b/nixpkgs/pkgs/applications/science/math/pspp/default.nix
new file mode 100644
index 000000000000..6e9ff90315cd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/pspp/default.nix
@@ -0,0 +1,53 @@
+{ lib, stdenv, fetchurl, libxml2, readline, zlib, perl, cairo, gtk3, gsl
+, pkg-config, gtksourceview, pango, gettext, dconf
+, makeWrapper, gsettings-desktop-schemas, hicolor-icon-theme
+, texinfo, ssw, python3
+}:
+
+stdenv.mkDerivation rec {
+  pname = "pspp";
+  version = "1.4.1";
+
+  src = fetchurl {
+    url = "mirror://gnu/pspp/${pname}-${version}.tar.gz";
+    sha256 = "0lqrash677b09zxdlxp89z6k02y4i23mbqg83956dwl69wc53dan";
+  };
+
+  nativeBuildInputs = [ pkg-config texinfo python3 ];
+  buildInputs = [ libxml2 readline zlib perl cairo gtk3 gsl
+    gtksourceview pango gettext
+    makeWrapper gsettings-desktop-schemas hicolor-icon-theme ssw
+  ];
+
+  doCheck = false;
+
+  enableParallelBuilding = true;
+
+  preFixup = ''
+    wrapProgram "$out/bin/psppire" \
+     --prefix XDG_DATA_DIRS : "$out/share" \
+     --prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS" \
+     --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \
+     --prefix GIO_EXTRA_MODULES : "${lib.getLib dconf}/lib/gio/modules"
+  '';
+
+  meta = {
+    homepage = "https://www.gnu.org/software/pspp/";
+    description = "A free replacement for SPSS, a program for statistical analysis of sampled data";
+    license = lib.licenses.gpl3Plus;
+
+    longDescription = ''
+      PSPP is a program for statistical analysis of sampled data. It is
+      a Free replacement for the proprietary program SPSS.
+
+      PSPP can perform descriptive statistics, T-tests, anova, linear
+      and logistic regression, cluster analysis, factor analysis,
+      non-parametric tests and more. Its backend is designed to perform
+      its analyses as fast as possible, regardless of the size of the
+      input data. You can use PSPP with its graphical interface or the
+      more traditional syntax commands.
+    '';
+
+    platforms = lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/pynac/default.nix b/nixpkgs/pkgs/applications/science/math/pynac/default.nix
new file mode 100644
index 000000000000..88515b92beaf
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/pynac/default.nix
@@ -0,0 +1,60 @@
+{ lib, stdenv
+, fetchpatch
+, fetchFromGitHub
+, autoreconfHook
+, pkg-config
+, flint
+, gmp
+, python3
+, singular
+, ncurses
+}:
+
+stdenv.mkDerivation rec {
+  version = "0.7.29";
+  pname = "pynac";
+
+  src = fetchFromGitHub {
+    owner = "pynac";
+    repo = "pynac";
+    rev = "pynac-${version}";
+    sha256 = "sha256-ocR7emXtKs+Xe2f6dh4xEDAacgiolY8mtlLnWnNBS8A=";
+  };
+
+  patches = [
+    # the patch below is included in sage 9.4 and should be included
+    # in a future pynac release. see https://trac.sagemath.org/ticket/28357
+    (fetchpatch {
+      name = "realpartloop.patch";
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/pynac/patches/realpartloop.patch?h=9.4.beta5";
+      sha256 = "sha256-1nj0xtlFN5fZKEiRLD+tiW/ZtxMQre1ziEGA0OVUGE4=";
+    })
+  ];
+
+  buildInputs = [
+    flint
+    gmp
+    singular
+    python3
+    ncurses
+  ];
+
+  nativeBuildInputs = [
+    autoreconfHook
+    pkg-config
+  ];
+
+  meta = with lib; {
+    description = "Python is Not a CAS -- modified version of Ginac";
+    longDescription = ''
+      Pynac -- "Python is Not a CAS" is a modified version of Ginac that
+      replaces the depency of GiNaC on CLN by a dependency instead of Python.
+      It is a lite version of GiNaC as well, not implementing all the features
+      of the full GiNaC, and it is *only* meant to be used as a Python library.
+    '';
+    homepage    = "http://pynac.org";
+    license = licenses.gpl2Plus;
+    maintainers = teams.sage.members;
+    platforms   = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/qalculate-gtk/default.nix b/nixpkgs/pkgs/applications/science/math/qalculate-gtk/default.nix
new file mode 100644
index 000000000000..7ba5838faba1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/qalculate-gtk/default.nix
@@ -0,0 +1,27 @@
+{ lib, stdenv, fetchFromGitHub, intltool, autoreconfHook, pkg-config, libqalculate, gtk3, wrapGAppsHook }:
+
+stdenv.mkDerivation rec {
+  pname = "qalculate-gtk";
+  version = "4.0.0";
+
+  src = fetchFromGitHub {
+    owner = "qalculate";
+    repo = "qalculate-gtk";
+    rev = "v${version}";
+    sha256 = "sha256-l9lR5MVHWiRz5RG/I/nXRY4GQSSaXXP7PlRNoAu9+yo=";
+  };
+
+  hardeningDisable = [ "format" ];
+
+  nativeBuildInputs = [ intltool pkg-config autoreconfHook wrapGAppsHook ];
+  buildInputs = [ libqalculate gtk3 ];
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    description = "The ultimate desktop calculator";
+    homepage = "http://qalculate.github.io";
+    maintainers = with maintainers; [ gebner doronbehar ];
+    license = licenses.gpl2Plus;
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/ratpoints/default.nix b/nixpkgs/pkgs/applications/science/math/ratpoints/default.nix
new file mode 100644
index 000000000000..dd8258a3456d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/ratpoints/default.nix
@@ -0,0 +1,35 @@
+{ lib, stdenv, fetchurl, fetchpatch, gmp }:
+stdenv.mkDerivation rec {
+  pname = "ratpoints";
+  version = "2.1.3.p4";
+
+  src = fetchurl {
+    url = "http://www.mathe2.uni-bayreuth.de/stoll/programs/ratpoints-${version}.tar.gz";
+    sha256 = "0zhad84sfds7izyksbqjmwpfw4rvyqk63yzdjd3ysd32zss5bgf4";
+  };
+
+  enableParallelBuilding = true;
+
+  patches = [
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/ratpoints/patches/sturm_and_rp_private.patch?id=1615f58890e8f9881c4228c78a6b39b9aab1303a";
+      sha256 = "0q3wajncyfr3gahd8gwk9x7g56zw54lpywrl63lqk7drkf60mrcl";
+    })
+  ];
+
+  buildInputs = [ gmp ];
+
+  makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ];
+  buildFlags = lib.optional stdenv.isDarwin ["CCFLAGS2=-lgmp -lc -lm" "CCFLAGS=-UUSE_SSE"];
+  installFlags = [ "INSTALL_DIR=$(out)" ];
+
+  preInstall = ''mkdir -p "$out"/{bin,share,lib,include}'';
+
+  meta = {
+    description = "A program to find rational points on hyperelliptic curves";
+    license = lib.licenses.gpl2Plus;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.unix;
+    homepage = "http://www.mathe2.uni-bayreuth.de/stoll/programs/";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/ries/default.nix b/nixpkgs/pkgs/applications/science/math/ries/default.nix
new file mode 100644
index 000000000000..eb759723256d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/ries/default.nix
@@ -0,0 +1,22 @@
+{ lib, stdenv, fetchzip }:
+stdenv.mkDerivation rec {
+  pname = "ries";
+  version = "2018.04.11-1";
+
+  # upstream does not provide a stable link
+  src = fetchzip {
+    url = "https://salsa.debian.org/debian/ries/-/archive/debian/${version}/ries-debian-${version}.zip";
+    sha256 = "1h2wvd4k7f0l0i1vm9niz453xdbcs3nxccmri50qyrzzzc1b0842";
+  };
+
+  makeFlags = [ "PREFIX=$(out)" ];
+
+  meta = with lib; {
+    homepage = "https://mrob.com/pub/ries/";
+    description = "Tool to produce a list of equations that approximately solve to a given number";
+    platforms = platforms.all;
+    maintainers = with maintainers; [ symphorien ];
+    license = licenses.gpl3Plus;
+  };
+}
+
diff --git a/nixpkgs/pkgs/applications/science/math/ripser/default.nix b/nixpkgs/pkgs/applications/science/math/ripser/default.nix
new file mode 100644
index 000000000000..21f0d0033915
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/ripser/default.nix
@@ -0,0 +1,67 @@
+{ lib, stdenv, fetchurl, fetchFromGitHub
+, assembleReductionMatrix ? false
+, useCoefficients ? false
+, indicateProgress ? false
+, useGoogleHashmap ? false, sparsehash ? null
+, fileFormat ? "lowerTriangularCsv"
+}:
+
+with lib;
+
+assert assertOneOf "fileFormat" fileFormat
+  ["lowerTriangularCsv" "upperTriangularCsv" "dipha"];
+assert useGoogleHashmap -> sparsehash != null;
+
+let
+  inherit (lib) optional;
+  version = "1.0";
+in
+stdenv.mkDerivation {
+  pname = "ripser";
+  inherit version;
+
+  src = fetchFromGitHub {
+    owner = "Ripser";
+    repo = "ripser";
+    rev = "f69c6af6ca6883dd518c48faf41cf8901c379598";
+    sha256 = "1mw2898s7l29hgajsaf75bs9bjn2sn4g2mvmh41a602jpwp9r0rz";
+  };
+
+  #Patch from dev branch to make compilation work.
+  #Will be removed when it gets merged into master.
+  patches = [(fetchurl {
+    url = "https://github.com/Ripser/ripser/commit/dc78d8ce73ee35f3828f0aad67a4e53620277ebf.patch";
+    sha256 = "1y93aqpqz8fm1cxxrf90dhh67im3ndkr8dnxgbw5y96296n4r924";
+  })];
+
+  buildInputs = optional useGoogleHashmap sparsehash;
+
+  buildFlags = [
+    "-std=c++11"
+    "-Ofast"
+    "-D NDEBUG"
+  ]
+  ++ optional assembleReductionMatrix "-D ASSEMBLE_REDUCTION_MATRIX"
+  ++ optional useCoefficients "-D USE_COEFFICIENTS"
+  ++ optional indicateProgress "-D INDICATE_PROGRESS"
+  ++ optional useGoogleHashmap "-D USE_GOOGLE_HASHMAP"
+  ++ optional (fileFormat == "lowerTriangularCsv") "-D FILE_FORMAT_LOWER_TRIANGULAR_CSV"
+  ++ optional (fileFormat == "upperTriangularCsv") "-D FILE_FORMAT_UPPER_TRIANGULAR_CSV"
+  ++ optional (fileFormat == "dipha") "-D FILE_FORMAT_DIPHA"
+  ;
+
+  buildPhase = "c++ ripser.cpp -o ripser $buildFlags";
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp ripser $out/bin
+  '';
+
+  meta = {
+    description = "A lean C++ code for the computation of Vietoris–Rips persistence barcodes";
+    homepage = "https://github.com/Ripser/ripser";
+    license = lib.licenses.lgpl3;
+    maintainers = with lib.maintainers; [erikryb];
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/rofi-calc/0001-Patch-plugindir-to-output.patch b/nixpkgs/pkgs/applications/science/math/rofi-calc/0001-Patch-plugindir-to-output.patch
new file mode 100644
index 000000000000..197d1347d535
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/rofi-calc/0001-Patch-plugindir-to-output.patch
@@ -0,0 +1,25 @@
+From 0eaef67b683683fb423fcb2d5096b3cdf9a4a9cd Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= <mkg20001@gmail.com>
+Date: Sun, 22 Mar 2020 12:26:10 +0100
+Subject: [PATCH] Patch plugindir to output
+
+---
+ configure.ac | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index 50edb74..639ee86 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -50,7 +50,7 @@ PKG_CHECK_MODULES([glib],     [glib-2.0 >= 2.40 gio-unix-2.0 gmodule-2.0 ])
+ PKG_CHECK_MODULES([cairo],    [cairo])
+ PKG_CHECK_MODULES([rofi],     [rofi >= 1.5.4])
+ 
+-[rofi_PLUGIN_INSTALL_DIR]="`$PKG_CONFIG --variable=pluginsdir rofi`"
++[rofi_PLUGIN_INSTALL_DIR]="`echo $out/lib/rofi`"
+ AC_SUBST([rofi_PLUGIN_INSTALL_DIR])
+ 
+ LT_INIT([disable-static])
+-- 
+2.25.1
+
diff --git a/nixpkgs/pkgs/applications/science/math/rofi-calc/default.nix b/nixpkgs/pkgs/applications/science/math/rofi-calc/default.nix
new file mode 100644
index 000000000000..78943457d3b2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/rofi-calc/default.nix
@@ -0,0 +1,54 @@
+{ lib, stdenv
+, fetchFromGitHub
+, autoreconfHook
+, pkg-config
+, rofi-unwrapped
+, libqalculate
+, glib
+, cairo
+, gobject-introspection
+, wrapGAppsHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "rofi-calc";
+  version = "2.1.0";
+
+  src = fetchFromGitHub {
+    owner = "svenstaro";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "sha256-sfUcBSUYf/+neBAhEd5LAtMOfIbdXM/ieUOztjk8Pwg=";
+  };
+
+  nativeBuildInputs = [
+    autoreconfHook
+    pkg-config
+    gobject-introspection
+    wrapGAppsHook
+  ];
+
+  buildInputs = [
+    rofi-unwrapped
+    libqalculate
+    glib
+    cairo
+  ];
+
+  patches = [
+    ./0001-Patch-plugindir-to-output.patch
+  ];
+
+  postPatch = ''
+    sed "s|qalc_binary = \"qalc\"|qalc_binary = \"${libqalculate}/bin/qalc\"|" -i src/calc.c
+  '';
+
+  meta = with lib; {
+    description = "Do live calculations in rofi!";
+    homepage = "https://github.com/svenstaro/rofi-calc";
+    license = licenses.mit;
+    maintainers = with maintainers; [ luc65r albakham ];
+    platforms = with platforms; linux;
+  };
+}
+
diff --git a/nixpkgs/pkgs/applications/science/math/sage/README.md b/nixpkgs/pkgs/applications/science/math/sage/README.md
new file mode 100644
index 000000000000..26e91fc63133
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/README.md
@@ -0,0 +1,78 @@
+# Sage on nixos
+
+Sage is a pretty complex package that depends on many other complex packages and patches some of those. As a result, the sage nix package is also quite complex.
+
+Don't feel discouraged to fix, simplify or improve things though. The individual files have comments explaining their purpose. The most importent ones are `default.nix` linking everything together, `sage-src.nix` adding patches and `sagelib.nix` building the actual sage package.
+
+## The sage build is broken
+
+First you should find out which change to nixpkgs is at fault (if you don't already know). You can use `git-bisect` for that (see the manpage).
+
+If the build broke as a result of a package update, try those solutions in order:
+
+- search the [sage trac](https://trac.sagemath.org/) for keywords like "Upgrade <package>". Maybe somebody has already proposed a patch that fixes the issue. You can then add a `fetchpatch` to `sage-src.nix`.
+
+- check if [gentoo](https://github.com/cschwan/sage-on-gentoo/tree/master/sci-mathematics/sage), [debian](https://salsa.debian.org/science-team/sagemath/tree/master/debian) or [arch linux](https://git.archlinux.org/svntogit/community.git/tree/trunk?h=packages/sagemath) already solved the problem. You can then again add a `fetchpatch` to `sage-src.nix`. If applicable you should also [propose the patch upstream](#proposing-a-sage-patch).
+
+- fix the problem yourself. First clone the sagemath source and then check out the sage version you want to patch:
+
+```
+[user@localhost ~]$ git clone git://github.com/sagemath/sage.git
+[user@localhost ~]$ cd sage
+[user@localhost sage]$ git checkout 8.2 # substitute the relevant version here
+```
+
+Then make the needed changes and generate a patch with `git diff`:
+
+```
+[user@localhost ~]$ <make changes>
+[user@localhost ~]$ git diff -u > /path/to/nixpkgs/pkgs/applications/science/math/sage/patches/name-of-patch.patch
+```
+
+Now just add the patch to `sage-src.nix` and test your changes. If they fix the problem, [propose them upstream](#proposing-a-sage-patch) and add a link to the trac ticket.
+
+- pin the package version in `default.nix` and add a note that explains why that is necessary.
+
+
+## Proposing a sage patch
+
+You can [login the sage trac using GitHub](https://trac.sagemath.org/login). Your username will then be `gh-<your-github-name>`. The only other way is to request a trac account via email. After that refer to [git the hard way](http://doc.sagemath.org/html/en/developer/manual_git.html#chapter-manual-git) in the sage documentation. The "easy way" requires a non-GitHub account (requested via email) and a special tool. The "hard way" is really not all that hard if you're a bit familiar with git.
+
+Here's the gist, assuming you want to use ssh key authentication. First, [add your public ssh key](https://trac.sagemath.org/prefs/sshkeys). Then:
+
+```
+[user@localhost ~]$ git clone git://github.com/sagemath/sage.git
+[user@localhost ~]$ cd sage
+[user@localhost sage]$ git remote add trac git@trac.sagemath.org:sage.git -t master
+[user@localhost sage]$ git checkout -b u/gh-<your-github-username>/<your-branch-name> develop
+[user@localhost sage]$ <make changes>
+[user@localhost sage]$ git add .
+[user@localhost sage]$ git commit
+[user@localhost sage]$ git show # review your changes
+[user@localhost sage]$ git push --set-upstream trac u/gh-<your-github-username>/<your-branch-name>
+```
+
+You now created a branch on the trac server (you *must* follow the naming scheme as you only have push access to branches with the `u/gh-<your-github-username>/` prefix).
+Now you can [create a new trac ticket](https://trac.sagemath.org/newticket).
+- Write a description of the change
+- set the type and component as appropriate
+- write your real name in the "Authors" field
+- write `u/gh-<your-github-username>/<your-branch-name>` in the "Branch" field
+- click "Create ticket"
+- click "Modify" on the top right of your ticket (for some reason you can only change the ticket status after you have created it)
+- set the ticket status from `new` to `needs_review`
+- click "Save changes"
+
+Refer to sages [Developer's Guide](http://doc.sagemath.org/html/en/developer/index.html) for further details.
+
+## I want to update sage
+
+You'll need to change the `version` field in `sage-src.nix`. Afterwards just try to build and let nix tell you which patches no longer apply (hopefully because they were adopted upstream). Remove those.
+
+Hopefully the build will succeed now. If it doesn't and the problem is obvious, fix it as described in [The sage build is broken](#the-sage-build-is-broken).
+If the problem is not obvious, you can try to first update sage to an intermediate version (remember that you can also set the `version` field to any git revision of sage) and locate the sage commit that introduced the issue. You can even use `git-bisect` for that (it will only be a bit tricky to keep track of which patches to apply). Hopefully after that the issue will be obvious.
+
+## Well, that didn't help!
+
+If you couldn't fix the problem, create a GitHub issue on the nixpkgs repo and ping @timokau (or whoever is listed in the `maintainers` list of the sage package).
+Describe what you did and why it didn't work. Afterwards it would be great if you help the next guy out and improve this documentation!
diff --git a/nixpkgs/pkgs/applications/science/math/sage/default.nix b/nixpkgs/pkgs/applications/science/math/sage/default.nix
new file mode 100644
index 000000000000..70e24e2608d0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/default.nix
@@ -0,0 +1,172 @@
+{ pkgs
+, withDoc ? false
+, requireSageTests ? true
+, extraPythonPackages ? ps: []
+}:
+
+# Here sage and its dependencies are put together. Some dependencies may be pinned
+# as a last resort. Patching sage for compatibility with newer dependency versions
+# is always preferred, see `sage-src.nix` for that.
+
+let
+  inherit (pkgs) symlinkJoin callPackage nodePackages;
+
+  python3 = pkgs.python3.override {
+    packageOverrides = self: super: {
+      # `sagelib`, i.e. all of sage except some wrappers and runtime dependencies
+      sagelib = self.callPackage ./sagelib.nix {
+        inherit flint arb;
+        inherit sage-src env-locations singular;
+        inherit (maxima) lisp-compiler;
+        linbox = pkgs.linbox.override { withSage = true; };
+        pkg-config = pkgs.pkg-config; # not to confuse with pythonPackages.pkg-config
+      };
+
+      sage-docbuild = self.callPackage ./python-modules/sage-docbuild.nix {
+        inherit sage-src;
+      };
+
+      sage-setup = self.callPackage ./python-modules/sage-setup.nix {
+        inherit sage-src;
+      };
+    };
+  };
+
+  jupyter-kernel-definition = {
+    displayName = "SageMath ${sage-src.version}";
+    argv = [
+      "${sage-with-env}/bin/sage" # FIXME which sage
+      "--python"
+      "-m"
+      "sage.repl.ipython_kernel"
+      "-f"
+      "{connection_file}"
+    ];
+    language = "sagemath";
+    # just one 16x16 logo is available
+    logo32 = "${sage-src}/src/doc/common/themes/sage/static/sageicon.png";
+    logo64 = "${sage-src}/src/doc/common/themes/sage/static/sageicon.png";
+  };
+
+  three = callPackage ./threejs-sage.nix { };
+
+  # A bash script setting various environment variables to tell sage where
+  # the files its looking fore are located. Also see `sage-env`.
+  env-locations = callPackage ./env-locations.nix {
+    inherit pari_data;
+    inherit singular maxima;
+    inherit three;
+    cysignals = python3.pkgs.cysignals;
+    mathjax = nodePackages.mathjax;
+  };
+
+  # The shell file that gets sourced on every sage start. Will also source
+  # the env-locations file.
+  sage-env = callPackage ./sage-env.nix {
+    sagelib = python3.pkgs.sagelib;
+    sage-docbuild = python3.pkgs.sage-docbuild;
+    inherit env-locations;
+    inherit python3 singular palp flint pythonEnv maxima;
+    pkg-config = pkgs.pkg-config; # not to confuse with pythonPackages.pkg-config
+  };
+
+  # The documentation for sage, building it takes a lot of ram.
+  sagedoc = callPackage ./sagedoc.nix {
+    inherit sage-with-env;
+    inherit python3 maxima;
+  };
+
+  # sagelib with added wrappers and a dependency on sage-tests to make sure thet tests were run.
+  sage-with-env = callPackage ./sage-with-env.nix {
+    inherit python3 pythonEnv;
+    inherit sage-env;
+    inherit singular maxima;
+    inherit three;
+    pkg-config = pkgs.pkg-config; # not to confuse with pythonPackages.pkg-config
+  };
+
+  # Doesn't actually build anything, just runs sages testsuite. This is a
+  # separate derivation to make it possible to re-run the tests without
+  # rebuilding sagelib (which takes ~30 minutes).
+  # Running the tests should take something in the order of 1h.
+  sage-tests = callPackage ./sage-tests.nix {
+    inherit sage-with-env;
+  };
+
+  sage-src = callPackage ./sage-src.nix {};
+
+  pythonRuntimeDeps = with python3.pkgs; [
+    sagelib
+    sage-docbuild
+    cvxopt
+    networkx
+    service-identity
+    psutil
+    sympy
+    fpylll
+    matplotlib
+    tkinter # optional, as a matplotlib backend (use with `%matplotlib tk`)
+    scipy
+    ipywidgets
+    rpy2
+    sphinx
+    pillow
+  ] ++ extraPythonPackages python3.pkgs;
+
+  pythonEnv = python3.buildEnv.override {
+    extraLibs = pythonRuntimeDeps;
+    ignoreCollisions = true;
+  } // { extraLibs = pythonRuntimeDeps; }; # make the libs accessible
+
+  arb = pkgs.arb.override { inherit flint; };
+
+  singular = pkgs.singular.override { inherit flint; };
+
+  maxima = pkgs.maxima.override {
+    lisp-compiler = pkgs.ecl.override {
+      # "echo syntax error | ecl > /dev/full 2>&1" segfaults in
+      # ECL. We apply a patch to fix it (write_error.patch), but it
+      # only works if threads are disabled.  sage 9.2 tests this
+      # (src/sage/interfaces/tests.py) and ships ecl like so.
+      # https://gitlab.com/embeddable-common-lisp/ecl/-/merge_requests/1#note_1657275
+      threadSupport = false;
+
+      # if we don't use the system boehmgc, sending a SIGINT to ecl
+      # can segfault if we it happens during memory allocation.
+      # src/sage/libs/ecl.pyx would intermittently fail in this case.
+      useBoehmgc = true;
+    };
+  };
+
+  # With openblas (64 bit), the tests fail the same way as when sage is build with
+  # openblas instead of openblasCompat. Apparently other packages somehow use flints
+  # blas when it is available. Alternative would be to override flint to use
+  # openblasCompat.
+  flint = pkgs.flint.override { withBlas = false; };
+
+  # Multiple palp dimensions need to be available and sage expects them all to be
+  # in the same folder.
+  palp = symlinkJoin {
+    name = "palp-${pkgs.palp.version}";
+    paths = [
+      (pkgs.palp.override { dimensions = 4; doSymlink = false; })
+      (pkgs.palp.override { dimensions = 5; doSymlink = false; })
+      (pkgs.palp.override { dimensions = 6; doSymlink = true; })
+      (pkgs.palp.override { dimensions = 11; doSymlink = false; })
+    ];
+  };
+
+  # Sage expects those in the same directory.
+  pari_data = symlinkJoin {
+    name = "pari_data";
+    paths = with pkgs; [
+      pari-galdata
+      pari-seadata-small
+    ];
+  };
+in
+# A wrapper around sage that makes sure sage finds its docs (if they were build).
+callPackage ./sage.nix {
+  inherit sage-tests sage-with-env sagedoc jupyter-kernel-definition;
+  inherit withDoc requireSageTests;
+}
diff --git a/nixpkgs/pkgs/applications/science/math/sage/dist-tests.nix b/nixpkgs/pkgs/applications/science/math/sage/dist-tests.nix
new file mode 100644
index 000000000000..24a86a8f37a4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/dist-tests.nix
@@ -0,0 +1,17 @@
+# Lists past failures and files associated with it. The intention is to build
+# up a subset of a testsuite that catches 95% of failures that are relevant for
+# distributions while only taking ~5m to run. This in turn makes it more
+# reasonable to re-test sage on dependency changes and makes it easier for
+# users to override the sage derivation.
+# This is an experiment for now. If it turns out that there really is a small
+# subset of files responsible for the vast majority of packaging tests, we can
+# think about moving this upstream.
+[
+	"src/sage/env.py" # [1]
+	"src/sage/misc/persist.pyx" # [1]
+	"src/sage/misc/inline_fortran.py" # [1]
+	"src/sage/repl/ipython_extension.py" # [1]
+]
+
+# Numbered list of past failures to annotate files with
+# [1] PYTHONPATH related issue https://github.com/NixOS/nixpkgs/commit/ec7f569211091282410050e89e68832d4fe60528
diff --git a/nixpkgs/pkgs/applications/science/math/sage/env-locations.nix b/nixpkgs/pkgs/applications/science/math/sage/env-locations.nix
new file mode 100644
index 000000000000..45a4799d1a03
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/env-locations.nix
@@ -0,0 +1,48 @@
+{ writeTextFile
+, pari_data
+, pari
+, singular
+, maxima
+, conway_polynomials
+, graphs
+, elliptic_curves
+, polytopes_db
+, gap
+, combinatorial_designs
+, jmol
+, mathjax
+, three
+, cysignals
+}:
+
+# A bash script setting various environment variables to tell sage where
+# the files its looking fore are located. Also see `sage-env`.
+writeTextFile rec {
+  name = "sage-env-locations";
+  destination = "/${name}";
+  text = ''
+    export GP_DATA_DIR="${pari_data}/share/pari"
+    export PARI_DATA_DIR="${pari_data}"
+    export GPHELP="${pari}/bin/gphelp"
+    export GPDOCDIR="${pari}/share/pari/doc"
+    export SINGULARPATH='${singular}/share/singular'
+    export SINGULAR_SO='${singular}/lib/libSingular.so'
+    export GAP_SO='${gap}/lib/libgap.so'
+    export SINGULAR_EXECUTABLE='${singular}/bin/Singular'
+    export MAXIMA_FAS='${maxima}/lib/maxima/${maxima.version}/binary-ecl/maxima.fas'
+    export MAXIMA_PREFIX="${maxima}"
+    export CONWAY_POLYNOMIALS_DATA_DIR='${conway_polynomials}/share/conway_polynomials'
+    export GRAPHS_DATA_DIR='${graphs}/share/graphs'
+    export ELLCURVE_DATA_DIR='${elliptic_curves}/share/ellcurves'
+    export POLYTOPE_DATA_DIR='${polytopes_db}/share/reflexive_polytopes'
+    export GAP_ROOT_DIR='${gap}/share/gap/build-dir'
+    export ECLDIR='${maxima.lisp-compiler}/lib/${maxima.lisp-compiler.pname}-${maxima.lisp-compiler.version}/'
+    export COMBINATORIAL_DESIGN_DATA_DIR="${combinatorial_designs}/share/combinatorial_designs"
+    export CREMONA_MINI_DATA_DIR="${elliptic_curves}/share/cremona"
+    export JMOL_DIR="${jmol}/share/jmol" # point to the directory that contains JmolData.jar
+    export JSMOL_DIR="${jmol}/share/jsmol"
+    export MATHJAX_DIR="${mathjax}/lib/node_modules/mathjax"
+    export THREEJS_DIR="${three}/lib/node_modules/three"
+    export SAGE_INCLUDE_DIRECTORIES="${cysignals}/${cysignals.pythonModule.sitePackages}"
+  '';
+}
diff --git a/nixpkgs/pkgs/applications/science/math/sage/patches/Only-test-external-software-when-all-of-sage-is.patch b/nixpkgs/pkgs/applications/science/math/sage/patches/Only-test-external-software-when-all-of-sage-is.patch
new file mode 100644
index 000000000000..a478f50d92e8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/patches/Only-test-external-software-when-all-of-sage-is.patch
@@ -0,0 +1,46 @@
+diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
+index 01f32fb8e4..4d83dc7b47 100644
+--- a/src/sage/doctest/control.py
++++ b/src/sage/doctest/control.py
+@@ -1253,6 +1253,7 @@ class DocTestController(SageObject):
+ 
+             self.log("Using --optional=" + self._optional_tags_string())
+             available_software._allow_external = self.options.optional is True or 'external' in self.options.optional
++            available_software._autodetect_safe = self.options.optional is True or 'sage' in self.options.optional
+             self.log("Features to be detected: " + ','.join(available_software.detectable()))
+             self.add_files()
+             self.expand_files_into_sources()
+diff --git a/src/sage/doctest/external.py b/src/sage/doctest/external.py
+index 84dae19ea5..badc61466e 100644
+--- a/src/sage/doctest/external.py
++++ b/src/sage/doctest/external.py
+@@ -409,6 +409,7 @@ class AvailableSoftware(object):
+             []
+         """
+         self._allow_external = True
++        self._autodetect_safe = True
+         # For multiprocessing of doctests, the data self._seen should be
+         # shared among subprocesses. Thus we use Array class from the
+         # multiprocessing module.
+@@ -430,6 +431,8 @@ class AvailableSoftware(object):
+             sage: 'internet' in available_software # random, optional - internet
+             True
+         """
++        if not self._autodetect_safe:
++            return False
+         try:
+             idx = self._indices[item]
+         except KeyError:
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index 433338766d..233623b14a 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -12,7 +12,7 @@ class sagemath_doc_html(StaticFile):
+ 
+     EXAMPLES::
+ 
+-        sage: from sage.features.sagemath import sagemath_doc_html
++        sage: from sage.features.sagemath import sagemath_doc_html  # optional - sagemath_doc_html
+         sage: sagemath_doc_html().is_present()  # optional - sagemath_doc_html
+         FeatureTestResult('sagemath_doc_html', True)
+     """
diff --git a/nixpkgs/pkgs/applications/science/math/sage/patches/configurationpy-error-verbose.patch b/nixpkgs/pkgs/applications/science/math/sage/patches/configurationpy-error-verbose.patch
new file mode 100644
index 000000000000..e687281ad1a7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/patches/configurationpy-error-verbose.patch
@@ -0,0 +1,19 @@
+diff --git a/src/sage/repl/configuration.py b/src/sage/repl/configuration.py
+index 67d7d2accf..18279581e2 100644
+--- a/src/sage/repl/configuration.py
++++ b/src/sage/repl/configuration.py
+@@ -9,10 +9,11 @@ the IPython simple prompt is being used::
+     sage: cmd = 'print([sys.stdin.isatty(), sys.stdout.isatty()])'
+     sage: import pexpect
+     sage: output = pexpect.run(
+-    ....:     'bash -c \'echo "{0}" | sage\''.format(cmd),
++    ....:     'bash -c \'export SAGE_BANNER=no; echo "{0}" | sage\''.format(cmd),
+     ....: ).decode('utf-8', 'surrogateescape')
+-    sage: 'sage: [False, True]' in output
+-    True
++    sage: print(output)
++    sage...[False, True]
++    sage...Exiting Sage ...
+ """
+ 
+ #*****************************************************************************
diff --git a/nixpkgs/pkgs/applications/science/math/sage/patches/do-not-test-find-library.patch b/nixpkgs/pkgs/applications/science/math/sage/patches/do-not-test-find-library.patch
new file mode 100644
index 000000000000..90a23f94cb5f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/patches/do-not-test-find-library.patch
@@ -0,0 +1,87 @@
+diff --git a/src/sage/env.py b/src/sage/env.py
+index c4953cfa65..47b880f9ad 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -244,81 +244,8 @@ os.environ['MPMATH_SAGE'] = '1'
+ SAGE_BANNER = var("SAGE_BANNER", "")
+ SAGE_IMPORTALL = var("SAGE_IMPORTALL", "yes")
+ 
+-
+-def _get_shared_lib_path(*libnames: str) -> Optional[str]:
+-    """
+-    Return the full path to a shared library file installed in
+-    ``$SAGE_LOCAL/lib`` or the directories associated with the
+-    Python sysconfig.
+-
+-    This can also be passed more than one library name (e.g. for cases where
+-    some library may have multiple names depending on the platform) in which
+-    case the first one found is returned.
+-
+-    This supports most *NIX variants (in which ``lib<libname>.so`` is found
+-    under ``$SAGE_LOCAL/lib``), macOS (same, but with the ``.dylib``
+-    extension), and Cygwin (under ``$SAGE_LOCAL/bin/cyg<libname>.dll``,
+-    or ``$SAGE_LOCAL/bin/cyg<libname>-*.dll`` for versioned DLLs).
+-
+-    For distributions like Debian that use a multiarch layout, we also try the
+-    multiarch lib paths (i.e. ``/usr/lib/<arch>/``).
+-
+-    This returns ``None`` if no matching library file could be found.
+-
+-    EXAMPLES::
+-
+-        sage: from sage.env import _get_shared_lib_path
+-        sage: "gap" in _get_shared_lib_path("gap")
+-        True
+-        sage: _get_shared_lib_path("an_absurd_lib") is None
+-        True
+-
+-    """
+-
+-    for libname in libnames:
+-        search_directories: List[Path] = []
+-        patterns: List[str] = []
+-        if sys.platform == 'cygwin':
+-            # Later down we take the first matching DLL found, so search
+-            # SAGE_LOCAL first so that it takes precedence
+-            if SAGE_LOCAL:
+-                search_directories.append(Path(SAGE_LOCAL) / 'bin')
+-            search_directories.append(Path(sysconfig.get_config_var('BINDIR')))
+-            # Note: The following is not very robust, since if there are multible
+-            # versions for the same library this just selects one more or less
+-            # at arbitrary. However, practically speaking, on Cygwin, there
+-            # will only ever be one version
+-            patterns = [f'cyg{libname}.dll', f'cyg{libname}-*.dll']
+-        else:
+-            if sys.platform == 'darwin':
+-                ext = 'dylib'
+-            else:
+-                ext = 'so'
+-
+-            if SAGE_LOCAL:
+-                search_directories.append(Path(SAGE_LOCAL) / 'lib')
+-            libdir = sysconfig.get_config_var('LIBDIR')
+-            if libdir is not None:
+-                libdir = Path(libdir)
+-                search_directories.append(libdir)
+-
+-                multiarchlib = sysconfig.get_config_var('MULTIARCH')
+-                if multiarchlib is not None:
+-                    search_directories.append(libdir / multiarchlib),
+-
+-            patterns = [f'lib{libname}.{ext}']
+-
+-        for directory in search_directories:
+-            for pattern in patterns:
+-                path = next(directory.glob(pattern), None)
+-                if path is not None:
+-                    return str(path.resolve())
+-
+-    # Just return None if no files were found
+-    return None
+-
+ # locate libgap shared object
+-GAP_SO = var("GAP_SO", _get_shared_lib_path("gap", ""))
++GAP_SO = var("GAP_SO", '/default')
+ 
+ # post process
+ if DOT_SAGE is not None and ' ' in DOT_SAGE:
diff --git a/nixpkgs/pkgs/applications/science/math/sage/patches/fix-ecl-race.patch b/nixpkgs/pkgs/applications/science/math/sage/patches/fix-ecl-race.patch
new file mode 100644
index 000000000000..6056416c3a28
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/patches/fix-ecl-race.patch
@@ -0,0 +1,19 @@
+diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py
+index 02e18e67e7..2ebf6eb35f 100644
+--- a/src/sage/doctest/forker.py
++++ b/src/sage/doctest/forker.py
+@@ -1075,6 +1075,14 @@ class SageDocTestRunner(doctest.DocTestRunner, object):
+             sage: set(ex2.predecessors) == set([ex0,ex1])
+             True
+         """
++
++        # Fix ECL dir race conditions by using a separate dir for each process
++        # (https://trac.sagemath.org/ticket/26968)
++        os.environ['MAXIMA_USERDIR'] = "{}/sage-maxima-{}".format(
++            tempfile.gettempdir(),
++            os.getpid()
++        )
++
+         if isinstance(globs, RecordingDict):
+             globs.start()
+         example.sequence_number = len(self.history)
diff --git a/nixpkgs/pkgs/applications/science/math/sage/patches/linbox-1.7-upgrade.patch b/nixpkgs/pkgs/applications/science/math/sage/patches/linbox-1.7-upgrade.patch
new file mode 100644
index 000000000000..91e080aa294a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/patches/linbox-1.7-upgrade.patch
@@ -0,0 +1,58 @@
+diff --git a/src/sage/libs/linbox/conversion.pxd b/src/sage/libs/linbox/conversion.pxd
+index 7794c9edc3..1753277b1f 100644
+--- a/src/sage/libs/linbox/conversion.pxd
++++ b/src/sage/libs/linbox/conversion.pxd
+@@ -177,9 +177,8 @@ cdef inline Vector_integer_dense new_sage_vector_integer_dense(P, DenseVector_in
+     - v -- linbox vector
+     """
+     cdef Vector_integer_dense res = P()
+-    cdef cppvector[Integer] * vec = &v.refRep()
+     cdef size_t i
+     for i in range(<size_t> res._degree):
+-        mpz_set(res._entries[i], vec[0][i].get_mpz_const())
++        mpz_set(res._entries[i], v.getEntry(i).get_mpz_const())
+ 
+     return res
+diff --git a/src/sage/libs/linbox/linbox.pxd b/src/sage/libs/linbox/linbox.pxd
+index 9112d151f8..dcc482960c 100644
+--- a/src/sage/libs/linbox/linbox.pxd
++++ b/src/sage/libs/linbox/linbox.pxd
+@@ -32,7 +32,7 @@ cdef extern from "linbox/matrix/dense-matrix.h":
+         ctypedef Modular_double Field
+         ctypedef double Element
+         DenseMatrix_Modular_double(Field F, size_t m, size_t n)
+-        DenseMatrix_Modular_double(Field F, Element*, size_t m, size_t n)
++        DenseMatrix_Modular_double(Field F, size_t m, size_t n, Element*)
+         void setEntry(size_t i, size_t j, Element& a)
+         Element &getEntry(size_t i, size_t j)
+ 
+@@ -42,7 +42,7 @@ cdef extern from "linbox/matrix/dense-matrix.h":
+         ctypedef Modular_float Field
+         ctypedef float Element
+         DenseMatrix_Modular_float(Field F, size_t m, size_t n)
+-        DenseMatrix_Modular_float(Field F, Element*, size_t m, size_t n)
++        DenseMatrix_Modular_float(Field F, size_t m, size_t n, Element*)
+         void setEntry(size_t i, size_t j, Element& a)
+         Element &getEntry(size_t i, size_t j)
+ 
+@@ -101,7 +101,6 @@ cdef extern from "linbox/vector/vector.h":
+         DenseVector_integer (Field &F)
+         DenseVector_integer (Field &F, long& m)
+         DenseVector_integer (Field &F, cppvector[Integer]&)
+-        cppvector[Element]& refRep()
+         size_t size()
+         void resize(size_t)
+         void resize(size_t n, const Element&)
+diff --git a/src/sage/matrix/matrix_modn_dense_template.pxi b/src/sage/matrix/matrix_modn_dense_template.pxi
+index 010365d76f..3d60726ff9 100644
+--- a/src/sage/matrix/matrix_modn_dense_template.pxi
++++ b/src/sage/matrix/matrix_modn_dense_template.pxi
+@@ -219,7 +219,7 @@ cdef inline linbox_echelonize_efd(celement modulus, celement* entries, Py_ssize_
+         return 0,[]
+ 
+     cdef ModField *F = new ModField(<long>modulus)
+-    cdef DenseMatrix *A = new DenseMatrix(F[0], <ModField.Element*>entries,<Py_ssize_t>nrows, <Py_ssize_t>ncols)
++    cdef DenseMatrix *A = new DenseMatrix(F[0], <Py_ssize_t>nrows, <Py_ssize_t>ncols, <ModField.Element*>entries)
+     cdef Py_ssize_t r = reducedRowEchelonize(A[0])
+     cdef Py_ssize_t i,j
+     for i in range(nrows):
diff --git a/nixpkgs/pkgs/applications/science/math/sage/patches/no-cython-sources-in-tracebacks-on-ipython8.patch b/nixpkgs/pkgs/applications/science/math/sage/patches/no-cython-sources-in-tracebacks-on-ipython8.patch
new file mode 100644
index 000000000000..871e494c3625
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/patches/no-cython-sources-in-tracebacks-on-ipython8.patch
@@ -0,0 +1,52 @@
+diff --git a/src/sage/repl/interface_magic.py b/src/sage/repl/interface_magic.py
+index 8a455b69b0..a93e1c9e04 100644
+--- a/src/sage/repl/interface_magic.py
++++ b/src/sage/repl/interface_magic.py
+@@ -260,7 +260,7 @@ class InterfaceMagic(object):
+             2
+             120
+             sage: shell.run_cell('%%gap foo\n1+1;\n')
+-            ...File "<string>", line unknown
++            ...File...<string>...
+             SyntaxError: Interface magics have no options, got "foo"
+             <BLANKLINE>
+             sage: shell.run_cell('%%gap?')
+diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py
+index 71dbe429fd..36b1d986d6 100644
+--- a/src/sage/repl/interpreter.py
++++ b/src/sage/repl/interpreter.py
+@@ -70,25 +70,6 @@ that shell.  The bulk of this functionality is provided through
+ 
+ TESTS:
+ 
+-Check that Cython source code appears in tracebacks::
+-
+-    sage: from sage.repl.interpreter import get_test_shell
+-    sage: shell = get_test_shell()
+-    sage: print("dummy line"); shell.run_cell('1/0') # see #25320 for the reason of the `...` and the dummy line in this test
+-    dummy line
+-    ...
+-    ZeroDivisionError...Traceback (most recent call last)
+-    <ipython-input-...> in <module>...
+-    ----> 1 Integer(1)/Integer(0)
+-    .../sage/rings/integer.pyx in sage.rings.integer.Integer...div...
+-    ...
+-    -> ...                  raise ZeroDivisionError("rational division by zero")
+-       ....:            x = <Rational> Rational.__new__(Rational)
+-       ....:            mpq_div_zz(x.value, ....value, (<Integer>right).value)
+-    <BLANKLINE>
+-    ZeroDivisionError: rational division by zero
+-    sage: shell.quit()
+-
+ Test prompt transformer::
+ 
+     sage: from sage.repl.interpreter import SagePromptTransformer
+@@ -423,7 +404,7 @@ def SagePreparseTransformer(lines):
+         sage: from sage.repl.interpreter import get_test_shell
+         sage: shell = get_test_shell()
+         sage: shell.run_cell(bad_syntax)
+-          File "<string>", line unknown
++          File...<string>...
+         SyntaxError: Mismatched ']'
+         <BLANKLINE>
+         sage: shell.quit()
diff --git a/nixpkgs/pkgs/applications/science/math/sage/patches/sphinx-docbuild-subprocesses.patch b/nixpkgs/pkgs/applications/science/math/sage/patches/sphinx-docbuild-subprocesses.patch
new file mode 100644
index 000000000000..1ff081b25e0f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/patches/sphinx-docbuild-subprocesses.patch
@@ -0,0 +1,58 @@
+diff --git a/src/sage_docbuild/__init__.py b/src/sage_docbuild/__init__.py
+index 8a5c1a19d2..21fd192642 100644
+--- a/src/sage_docbuild/__init__.py
++++ b/src/sage_docbuild/__init__.py
+@@ -89,27 +89,6 @@ def builder_helper(type):
+     """
+     Returns a function which builds the documentation for
+     output type ``type``.
+-
+-    TESTS:
+-
+-    Check that :trac:`25161` has been resolved::
+-
+-        sage: from sage_docbuild import DocBuilder, setup_parser
+-        sage: DocBuilder._options = setup_parser().parse_args([]) # builder_helper needs _options to be set
+-
+-        sage: import sage_docbuild.sphinxbuild
+-        sage: def raiseBaseException():
+-        ....:     raise BaseException("abort pool operation")
+-        sage: original_runsphinx, sage_docbuild.sphinxbuild.runsphinx = sage_docbuild.sphinxbuild.runsphinx, raiseBaseException
+-
+-        sage: from sage_docbuild import builder_helper, build_ref_doc
+-        sage: from sage_docbuild import _build_many as build_many
+-        sage: helper = builder_helper("html")
+-        sage: try:
+-        ....:     build_many(build_ref_doc, [("docname", "en", "html", {})])
+-        ....: except Exception as E:
+-        ....:     "Non-exception during docbuild: abort pool operation" in str(E)
+-        True
+     """
+     def f(self, *args, **kwds):
+         output_dir = self._output_dir(type)
+@@ -131,10 +110,9 @@ def builder_helper(type):
+         logger.debug(build_command)
+ 
+         # Run Sphinx with Sage's special logger
+-        sys.argv = ["sphinx-build"] + build_command.split()
+-        from .sphinxbuild import runsphinx
++        args = "python3 -um sage_docbuild.sphinxbuild -N".split() + build_command.split()
+         try:
+-            runsphinx()
++            subprocess.check_call(args)
+         except Exception:
+             if ABORT_ON_ERROR:
+                 raise
+diff --git a/src/sage_docbuild/sphinxbuild.py b/src/sage_docbuild/sphinxbuild.py
+index d917c3e9d4..551cc8028a 100644
+--- a/src/sage_docbuild/sphinxbuild.py
++++ b/src/sage_docbuild/sphinxbuild.py
+@@ -327,3 +327,8 @@ def runsphinx():
+         sys.stderr = saved_stderr
+         sys.stdout.flush()
+         sys.stderr.flush()
++
++if __name__ == '__main__':
++    import sys
++    sys.argv[0] = "sphinx-build"
++    runsphinx()
diff --git a/nixpkgs/pkgs/applications/science/math/sage/patches/sympow-cache.patch b/nixpkgs/pkgs/applications/science/math/sage/patches/sympow-cache.patch
new file mode 100644
index 000000000000..d71f3acbc706
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/patches/sympow-cache.patch
@@ -0,0 +1,21 @@
+diff --git a/src/sage/lfunctions/sympow.py b/src/sage/lfunctions/sympow.py
+index 92cb01fd73..b123e6accc 100644
+--- a/src/sage/lfunctions/sympow.py
++++ b/src/sage/lfunctions/sympow.py
+@@ -50,6 +50,7 @@ from __future__ import print_function, absolute_import
+ 
+ import os
+ 
++from sage.env import DOT_SAGE
+ from sage.structure.sage_object import SageObject
+ from sage.misc.all import pager
+ from sage.misc.verbose import verbose
+@@ -78,7 +79,7 @@ class Sympow(SageObject):
+         """
+         Used to call sympow with given args
+         """
+-        cmd = 'sympow %s' % args
++        cmd = 'env SYMPOW_CACHEDIR="%s/sympow///" sympow %s' % (DOT_SAGE, args)
+         with os.popen(cmd) as f:
+             v = f.read().strip()
+         verbose(v, level=2)
diff --git a/nixpkgs/pkgs/applications/science/math/sage/patches/tachyon-renamed-focallength.patch b/nixpkgs/pkgs/applications/science/math/sage/patches/tachyon-renamed-focallength.patch
new file mode 100644
index 000000000000..5fea88309036
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/patches/tachyon-renamed-focallength.patch
@@ -0,0 +1,81 @@
+diff --git a/src/sage/interfaces/tachyon.py b/src/sage/interfaces/tachyon.py
+index 3f1dcdb538..b6fa8d1fbd 100644
+--- a/src/sage/interfaces/tachyon.py
++++ b/src/sage/interfaces/tachyon.py
+@@ -261,13 +261,13 @@ written in the sequence they are listed in the examples in this section.
+   The {\bf PROJECTION} keyword must be followed by one of the supported
+ camera projection mode identifiers {\bf PERSPECTIVE}, {\bf PERSPECTIVE_DOF},
+ {\bf ORTHOGRAPHIC}, or {\bf FISHEYE}.  The {\bf FISHEYE} projection mode
+-requires two extra parameters {\bf FOCALLENGTH} and {\bf APERTURE}
++requires two extra parameters {\bf FOCALDIST} and {\bf APERTURE}
+ which precede the regular camera options.
+ 
+ \begin{verbatim}
+ Camera
+   projection perspective_dof
+-  focallength 0.75
++  focaldist 0.75
+   aperture 0.02
+   Zoom 0.666667
+   Aspectratio 1.000000
+diff --git a/src/sage/plot/plot3d/tachyon.py b/src/sage/plot/plot3d/tachyon.py
+index 08caf38d67..3e827411ce 100644
+--- a/src/sage/plot/plot3d/tachyon.py
++++ b/src/sage/plot/plot3d/tachyon.py
+@@ -92,7 +92,7 @@ angle, right angle)::
+ Finally there is the ``projection='perspective_dof'`` option. ::
+ 
+     sage: T = Tachyon(xres=800, antialiasing=4, raydepth=10,
+-    ....: projection='perspective_dof', focallength='1.0', aperture='.0025')
++    ....: projection='perspective_dof', focaldist='1.0', aperture='.0025')
+     sage: T.light((0,5,7), 1.0, (1,1,1))
+     sage: T.texture('t1', opacity=1, specular=.3)
+     sage: T.texture('t2', opacity=1, specular=.3, color=(0,0,1))
+@@ -186,7 +186,7 @@ class Tachyon(WithEqualityById, SageObject):
+       or ``'fisheye'``.
+     - ``frustum`` - (default ''), otherwise list of four numbers. Only
+       used with projection='fisheye'.
+-    - ``focallength`` - (default ''), otherwise a number. Only used
++    - ``focaldist`` - (default ''), otherwise a number. Only used
+       with projection='perspective_dof'.
+     - ``aperture`` - (default ''), otherwise a number.  Only used
+       with projection='perspective_dof'.
+@@ -331,7 +331,7 @@ class Tachyon(WithEqualityById, SageObject):
+     Use of the ``projection='perspective_dof'`` option.  This may not be
+     implemented correctly. ::
+ 
+-        sage: T = Tachyon(xres=800,antialiasing=4, raydepth=10, projection='perspective_dof', focallength='1.0', aperture='.0025')
++        sage: T = Tachyon(xres=800,antialiasing=4, raydepth=10, projection='perspective_dof', focaldist='1.0', aperture='.0025')
+         sage: T.light((0,5,7), 1.0, (1,1,1))
+         sage: T.texture('t1', opacity=1, specular=.3)
+         sage: T.texture('t2', opacity=1, specular=.3, color=(0,0,1))
+@@ -365,7 +365,7 @@ class Tachyon(WithEqualityById, SageObject):
+                  look_at=[0, 0, 0],
+                  viewdir=None,
+                  projection='PERSPECTIVE',
+-                 focallength='',
++                 focaldist='',
+                  aperture='',
+                  frustum=''):
+         r"""
+@@ -391,7 +391,7 @@ class Tachyon(WithEqualityById, SageObject):
+             self._camera_position = (-3, 0, 0) # default value
+         self._updir = updir
+         self._projection = projection
+-        self._focallength = focallength
++        self._focaldist = focaldist
+         self._aperture = aperture
+         self._frustum = frustum
+         self._objects = []
+@@ -624,9 +624,9 @@ class Tachyon(WithEqualityById, SageObject):
+         camera_out = r"""
+            camera
+               projection %s""" % (tostr(self._projection))
+-        if self._focallength != '':
++        if self._focaldist != '':
+             camera_out = camera_out + r"""
+-              focallength %s""" % (float(self._focallength))
++              focaldist %s""" % (float(self._focaldist))
+         if self._aperture != '':
+             camera_out = camera_out + r"""
+               aperture %s""" % (float(self._aperture))
diff --git a/nixpkgs/pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix b/nixpkgs/pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix
new file mode 100644
index 000000000000..1766cec3e35d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix
@@ -0,0 +1,28 @@
+{ lib
+, buildPythonPackage
+, sage-src
+, sphinx
+}:
+
+buildPythonPackage rec {
+  version = src.version;
+  pname = "sage-docbuild";
+  src = sage-src;
+
+  propagatedBuildInputs = [
+    sphinx
+  ];
+
+  preBuild = ''
+    cd pkgs/sage-docbuild
+  '';
+
+  doCheck = false; # we will run tests in sagedoc.nix
+
+  meta = with lib; {
+    description = "Build system of the Sage documentation";
+    homepage = "https://www.sagemath.org";
+    license = licenses.gpl2Plus;
+    maintainers = teams.sage.members;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/sage/python-modules/sage-setup.nix b/nixpkgs/pkgs/applications/science/math/sage/python-modules/sage-setup.nix
new file mode 100644
index 000000000000..50346153123d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/python-modules/sage-setup.nix
@@ -0,0 +1,28 @@
+{ lib
+, buildPythonPackage
+, sage-src
+, pkgconfig # the python module, not the pkg-config alias
+}:
+
+buildPythonPackage rec {
+  version = src.version;
+  pname = "sage-setup";
+  src = sage-src;
+
+  buildInputs = [
+    pkgconfig
+  ];
+
+  preBuild = ''
+    cd pkgs/sage-setup
+  '';
+
+  doCheck = false; # sagelib depends on sage-setup, but sage-setup's tests depend on sagelib
+
+  meta = with lib; {
+    description = "Build system of the Sage library";
+    homepage = "https://www.sagemath.org";
+    license = licenses.gpl2Plus;
+    maintainers = teams.sage.members;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/sage/sage-env.nix b/nixpkgs/pkgs/applications/science/math/sage/sage-env.nix
new file mode 100644
index 000000000000..e680c0c3b22d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/sage-env.nix
@@ -0,0 +1,192 @@
+{ stdenv
+, lib
+, writeTextFile
+, sagelib
+, sage-docbuild
+, env-locations
+, gfortran
+, bash
+, coreutils
+, gnused
+, gnugrep
+, binutils
+, pythonEnv
+, python3
+, pkg-config
+, pari
+, gap
+, maxima
+, singular
+, fflas-ffpack
+, givaro
+, gd
+, libpng
+, linbox
+, m4ri
+, giac
+, palp
+, rWrapper
+, gfan
+, cddlib
+, jmol
+, tachyon
+, glpk
+, eclib
+, sympow
+, nauty
+, sqlite
+, ppl
+, ecm
+, lcalc
+, rubiks
+, flintqs
+, blas
+, lapack
+, flint
+, gmp
+, mpfr
+, zlib
+, gsl
+, ntl
+, jdk
+, less
+}:
+
+assert (!blas.isILP64) && (!lapack.isILP64);
+
+# This generates a `sage-env` shell file that will be sourced by sage on startup.
+# It sets up various environment variables, telling sage where to find its
+# dependencies.
+
+let
+  runtimepath = (lib.makeBinPath ([
+    "@sage-local@"
+    "@sage-local@/build"
+    pythonEnv
+    gfortran # for inline fortran
+    stdenv.cc # for cython
+    bash
+    coreutils
+    gnused
+    gnugrep
+    binutils.bintools
+    pkg-config
+    pari
+    gap
+    maxima.lisp-compiler
+    maxima
+    singular
+    giac
+    palp
+    # needs to be rWrapper since the default `R` doesn't include R's default libraries
+    rWrapper
+    gfan
+    cddlib
+    jmol
+    tachyon
+    glpk
+    eclib
+    sympow
+    nauty
+    sqlite
+    ppl
+    ecm
+    lcalc
+    rubiks
+    flintqs
+    jdk # only needed for `jmol` which may be replaced in the future
+    less # needed to prevent transient test errors until https://github.com/ipython/ipython/pull/11864 is resolved
+  ]
+  ));
+in
+writeTextFile rec {
+  name = "sage-env";
+  destination = "/${name}";
+  text = ''
+    export PKG_CONFIG_PATH='${lib.makeSearchPathOutput "dev" "lib/pkgconfig" [
+        # This should only be needed during build. However, since the  doctests
+        # also test the cython build (for example in src/sage/misc/cython.py),
+        # it is also needed for the testsuite to pass. We could fix the
+        # testsuite instead, but since all the packages are also runtime
+        # dependencies it doesn't really hurt to include them here.
+        singular
+        blas lapack
+        fflas-ffpack givaro
+        gd
+        libpng zlib
+        gsl
+        linbox
+        m4ri
+      ]
+    }'
+    export SAGE_ROOT='${sagelib.src}'
+  '' +
+    # TODO: is using pythonEnv instead of @sage-local@ here a good
+    # idea? there is a test in src/sage/env.py that checks if the values
+    # SAGE_ROOT and SAGE_LOCAL set here match the ones set in env.py.
+    # we fix up env.py's SAGE_ROOT in sage-src.nix (which does not
+    # have access to sage-with-env), but env.py autodetects
+    # SAGE_LOCAL to be pythonEnv.
+    # setting SAGE_LOCAL to pythonEnv also avoids having to create
+    # python3, ipython, ipython3 and jupyter symlinks in
+    # sage-with-env.nix.
+  ''
+    export SAGE_LOCAL='${pythonEnv}'
+
+    export SAGE_SHARE='${sagelib}/share'
+    export SAGE_ENV_CONFIG_SOURCED=1 # sage-env complains if sage-env-config is not sourced beforehand
+    orig_path="$PATH"
+    export PATH='${runtimepath}'
+
+    # set dependent vars, like JUPYTER_CONFIG_DIR
+    source "${sagelib.src}/src/bin/sage-env"
+    export PATH="$RUNTIMEPATH_PREFIX:${runtimepath}:$orig_path" # sage-env messes with PATH
+
+    export SAGE_LOGS="$TMPDIR/sage-logs"
+    export SAGE_DOC="''${SAGE_DOC_OVERRIDE:-doc-placeholder}"
+    export SAGE_DOC_SRC="''${SAGE_DOC_SRC_OVERRIDE:-${sagelib.src}/src/doc}"
+
+    # set locations of dependencies
+    . ${env-locations}/sage-env-locations
+
+    # needed for cython
+    export CC='${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc'
+    # cython needs to find these libraries, otherwise will fail with `ld: cannot find -lflint` or similar
+    export LDFLAGS='${
+      lib.concatStringsSep " " (map (pkg: "-L${pkg}/lib") [
+        flint
+        gap
+        glpk
+        gmp
+        mpfr
+        pari
+        zlib
+        eclib
+        gsl
+        ntl
+        jmol
+        sympow
+      ])
+    }'
+    export CFLAGS='${
+      lib.concatStringsSep " " (map (pkg: "-isystem ${pkg}/include") [
+        singular
+        gmp.dev
+        glpk
+        flint
+        gap
+        mpfr.dev
+      ])
+    }'
+
+    export SAGE_LIB='${sagelib}/${python3.sitePackages}'
+
+    export SAGE_EXTCODE='${sagelib.src}/src/sage/ext_data'
+
+  # for find_library
+    export DYLD_LIBRARY_PATH="${lib.makeLibraryPath [stdenv.cc.libc singular]}''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH"
+  '';
+} // { # equivalent of `passthru`, which `writeTextFile` doesn't support
+  lib = sagelib;
+  docbuild = sage-docbuild;
+}
diff --git a/nixpkgs/pkgs/applications/science/math/sage/sage-src.nix b/nixpkgs/pkgs/applications/science/math/sage/sage-src.nix
new file mode 100644
index 000000000000..bae33802d301
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/sage-src.nix
@@ -0,0 +1,191 @@
+{ stdenv
+, fetchFromGitHub
+, fetchpatch
+, runtimeShell
+}:
+
+# This file is responsible for fetching the sage source and adding necessary patches.
+# It does not actually build anything, it just copies the patched sources to $out.
+# This is done because multiple derivations rely on these sources and they should
+# all get the same sources with the same patches applied.
+
+let
+  # Fetch a diff between `base` and `rev` on sage's git server.
+  # Used to fetch trac tickets by setting the `base` to the last release and the
+  # `rev` to the last commit of the ticket.
+  fetchSageDiff = { base, name, rev, sha256, squashed ? false, ...}@args: (
+    fetchpatch ({
+      inherit name sha256;
+
+      # There are three places to get changes from:
+      #
+      # 1) From Sage's Trac. Contains all release tags (like "9.4") and all developer
+      # branches (wip patches from tickets), but exports each commit as a separate
+      # patch, so merge commits can lead to conflicts. Used if squashed == false.
+      #
+      # The above is the preferred option. To use it, find a Trac ticket and pass the
+      # "Commit" field from the ticket as "rev", choosing "base" as an appropriate
+      # release tag, i.e. a tag that doesn't cause the patch to include a lot of
+      # unrelated changes. If there is no such tag (due to nonlinear history, for
+      # example), there are two other options, listed below.
+      #
+      # 2) From GitHub's sagemath/sage repo. This lets us use a GH feature that allows
+      # us to choose between a .patch file, with one patch per commit, or a .diff file,
+      # which squashes all commits into a single diff. This is used if squashed ==
+      # true. This repo has all release tags. However, it has no developer branches, so
+      # this option can't be used if a change wasn't yet shipped in a (possibly beta)
+      # release.
+      #
+      # 3) From GitHub's sagemath/sagetrac-mirror repo. Mirrors all developer branches,
+      # but has no release tags. The only use case not covered by 1 or 2 is when we need
+      # to apply a patch from an open ticket that contains merge commits.
+      #
+      # Item 3 could cover all use cases if the sagemath/sagetrack-mirror repo had
+      # release tags, but it requires a sha instead of a release number in "base", which
+      # is inconvenient.
+      urls = if squashed
+             then [
+               "https://github.com/sagemath/sage/compare/${base}...${rev}.diff"
+               "https://github.com/sagemath/sagetrac-mirror/compare/${base}...${rev}.diff"
+             ]
+             else [ "https://git.sagemath.org/sage.git/patch?id2=${base}&id=${rev}" ];
+
+      # We don't care about sage's own build system (which builds all its dependencies).
+      # Exclude build system changes to avoid conflicts.
+      excludes = [ "build/*" ];
+    } // builtins.removeAttrs args [ "rev" "base" "sha256" "squashed" ])
+  );
+in
+stdenv.mkDerivation rec {
+  version = "9.5";
+  pname = "sage-src";
+
+  src = fetchFromGitHub {
+    owner = "sagemath";
+    repo = "sage";
+    rev = version;
+    sha256 = "sha256-uOsLpsGpcIGs8Xr82X82MElnTB2E908gytyNJ8WVD5w=";
+  };
+
+  # Patches needed because of particularities of nix or the way this is packaged.
+  # The goal is to upstream all of them and get rid of this list.
+  nixPatches = [
+    # Since https://trac.sagemath.org/ticket/32174, some external features are
+    # marked as "safe" and get auto-detected, in which case the corresponding
+    # optional tests are executed. We disable auto-detection of safe features if
+    # we are doctesting with an "--optional" argument which does not include
+    # "sage", because tests from autodetected features expect context provided
+    # by running basic sage tests. This is necessary to test sagemath_doc_html
+    # separately. See https://trac.sagemath.org/ticket/26110 for a related
+    # upstream discussion (from the time when Sage still had optional py2/py3
+    # tags).
+    ./patches/Only-test-external-software-when-all-of-sage-is.patch
+
+    # Fixes a potential race condition which can lead to transient doctest failures.
+    ./patches/fix-ecl-race.patch
+
+    # Not necessary since library location is set explicitly
+    # https://trac.sagemath.org/ticket/27660#ticket
+    ./patches/do-not-test-find-library.patch
+
+    # Parallelize docubuild using subprocesses, fixing an isolation issue. See
+    # https://groups.google.com/forum/#!topic/sage-packaging/YGOm8tkADrE
+    ./patches/sphinx-docbuild-subprocesses.patch
+  ];
+
+  # Since sage unfortunately does not release bugfix releases, packagers must
+  # fix those bugs themselves. This is for critical bugfixes, where "critical"
+  # == "causes (transient) doctest failures / somebody complained".
+  bugfixPatches = [
+    # To help debug the transient error in
+    # https://trac.sagemath.org/ticket/23087 when it next occurs.
+    ./patches/configurationpy-error-verbose.patch
+  ];
+
+  # Patches needed because of package updates. We could just pin the versions of
+  # dependencies, but that would lead to rebuilds, confusion and the burdons of
+  # maintaining multiple versions of dependencies. Instead we try to make sage
+  # compatible with never dependency versions when possible. All these changes
+  # should come from or be proposed to upstream. This list will probably never
+  # be empty since dependencies update all the time.
+  packageUpgradePatches = [
+    # After updating smypow to (https://trac.sagemath.org/ticket/3360) we can
+    # now set the cache dir to be within the .sage directory. This is not
+    # strictly necessary, but keeps us from littering in the user's HOME.
+    ./patches/sympow-cache.patch
+
+    # Upstream will wait until Sage 9.7 to upgrade to linbox 1.7 because it
+    # does not support gcc 6. We can upgrade earlier.
+    # https://trac.sagemath.org/ticket/32959
+    ./patches/linbox-1.7-upgrade.patch
+
+    # To emit better tracebacks, IPython 8 parses Python files using the ast
+    # module (via the stack_data package). Since Cython is a superset of Python,
+    # this results in no Cython code being printed in tracebacks. Fixing this
+    # properly is tracked in https://github.com/alexmojaki/stack_data/issues/21,
+    # but for now we just disable the corresponding test. An alternative would
+    # be to revert IPython's IPython/core/ultratb.py, but this would need to be
+    # Sage-specific (since it would worsen tracebacks for pure Python code).
+    # Sage tracks this at https://trac.sagemath.org/ticket/33170
+    ./patches/no-cython-sources-in-tracebacks-on-ipython8.patch
+
+    # https://trac.sagemath.org/ticket/32968
+    (fetchSageDiff {
+      base = "9.5";
+      name = "sphinx-4.3-update.patch";
+      rev = "fc84f82f52b6f05f512cb359ec7c100f93cf8841";
+      sha256 = "sha256-bBbfdcnw/9LUOlY8rHJRbFJEdMXK4shosqTNaobTS1Q=";
+    })
+
+    # https://trac.sagemath.org/ticket/33189
+    (fetchSageDiff {
+      base = "9.5";
+      name = "arb-2.22-update.patch";
+      rev = "53532ddd4e2dc92469c1590ebf0c40f8f69bf579";
+      sha256 = "sha256-6SoSBvIlqvNwZV3jTB6uPdUtaWIOeNmddi2poK/WvGs=";
+    })
+
+    # TODO: This will not be necessary when Sphinx 4.4.1 is released,
+    # since some warnings introduced in 4.4.0 will be disabled by then
+    # (https://github.com/sphinx-doc/sphinx/pull/10126).
+    # https://trac.sagemath.org/ticket/33272
+    (fetchSageDiff {
+      base = "9.5";
+      name = "sphinx-4.4-warnings.patch";
+      rev = "97d7958bed441cf2ccc714d88f83d3a8426bc085";
+      sha256 = "sha256-y1STE0oxswnijGCsBw8eHWWqpmT1XMznIfA0vvX9pFA=";
+    })
+
+    # adapted from https://trac.sagemath.org/ticket/23712#comment:22
+    ./patches/tachyon-renamed-focallength.patch
+  ];
+
+  patches = nixPatches ++ bugfixPatches ++ packageUpgradePatches;
+
+  postPatch = ''
+    # Make sure sage can at least be imported without setting any environment
+    # variables. It won't be close to feature complete though.
+    sed -i \
+      "s|var(\"SAGE_ROOT\".*|var(\"SAGE_ROOT\", \"$out\")|" \
+      src/sage/env.py
+
+    # src/doc/en/reference/spkg/conf.py expects index.rst in its directory,
+    # a list of external packages in the sage distribution (build/pkgs)
+    # generated by the bootstrap script (which we don't run).  this is not
+    # relevant for other distributions, so remove it.
+    rm src/doc/en/reference/spkg/conf.py
+    sed -i "/spkg/d" src/doc/en/reference/index.rst
+
+    # the bootstrap script also generates installation instructions for
+    # arch, debian, fedora, cygwin and homebrew using data from build/pkgs.
+    # we don't run the bootstrap script, so disable including the generated
+    # files. docbuilding fails otherwise.
+    sed -i "/literalinclude/d" src/doc/en/installation/source.rst
+  '';
+
+  buildPhase = "# do nothing";
+
+  installPhase = ''
+    cp -r . "$out"
+  '';
+}
diff --git a/nixpkgs/pkgs/applications/science/math/sage/sage-tests.nix b/nixpkgs/pkgs/applications/science/math/sage/sage-tests.nix
new file mode 100644
index 000000000000..451edb8f085e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/sage-tests.nix
@@ -0,0 +1,61 @@
+{ stdenv
+, lib
+, sage-with-env
+, makeWrapper
+, files ? null # "null" means run all tests
+, longTests ? true # run tests marked as "long time" (roughly doubles runtime)
+# Run as many tests as possible in approximately n seconds. This will give each
+# file to test a "time budget" and stop tests if it is exceeded. 300 is the
+# upstream default value.
+# https://trac.sagemath.org/ticket/25270 for details.
+, timeLimit ? null
+}:
+
+# for a quick test of some source files:
+# nix-build -E 'with (import ./. {}); sage.tests.override { files = [ "src/sage/misc/cython.py" ];}'
+
+let
+  src = sage-with-env.env.lib.src;
+  runAllTests = files == null;
+  testArgs = if runAllTests then "--all" else testFileList;
+  patienceSpecifier = if longTests then "--long" else "";
+  timeSpecifier = if timeLimit == null then "" else "--short ${toString timeLimit}";
+  relpathToArg = relpath: lib.escapeShellArg "${src}/${relpath}"; # paths need to be absolute
+  testFileList = lib.concatStringsSep " " (map relpathToArg files);
+in
+stdenv.mkDerivation {
+  version = src.version;
+  pname = "sage-tests";
+  inherit src;
+
+  buildInputs = [
+    makeWrapper
+    sage-with-env
+  ];
+
+  dontUnpack = true;
+  configurePhase = "#do nothing";
+  buildPhase = "#do nothing";
+
+  installPhase = ''
+    # This output is not actually needed for anything, the package just
+    # exists to decouple the sage build from its t ests.
+
+    mkdir -p "$out/bin"
+    # Like a symlink, but make sure that $0 points to the original.
+    makeWrapper "${sage-with-env}/bin/sage" "$out/bin/sage"
+  '';
+
+  doInstallCheck = true;
+  installCheckPhase = ''
+    export HOME="$TMPDIR/sage-home"
+    mkdir -p "$HOME"
+
+    # avoid running out of memory with many threads in subprocesses, see
+    # https://github.com/NixOS/nixpkgs/pull/65802
+    export GLIBC_TUNABLES=glibc.malloc.arena_max=4
+
+    echo "Running sage tests with arguments ${timeSpecifier} ${patienceSpecifier} ${testArgs}"
+    "sage" -t --timeout=0 --nthreads "$NIX_BUILD_CORES" --optional=sage ${timeSpecifier} ${patienceSpecifier} ${testArgs}
+  '';
+}
diff --git a/nixpkgs/pkgs/applications/science/math/sage/sage-with-env.nix b/nixpkgs/pkgs/applications/science/math/sage/sage-with-env.nix
new file mode 100644
index 000000000000..df3a1467d53c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/sage-with-env.nix
@@ -0,0 +1,139 @@
+{ stdenv
+, lib
+, makeWrapper
+, sage-env
+, blas
+, lapack
+, pkg-config
+, three
+, singular
+, gap
+, giac
+, maxima
+, pari
+, gmp
+, gfan
+, python3
+, flintqs
+, eclib
+, ntl
+, ecm
+, pythonEnv
+}:
+
+# lots of segfaults with (64 bit) blas
+assert (!blas.isILP64) && (!lapack.isILP64);
+
+# Wrapper that combined `sagelib` with `sage-env` to produce an actually
+# executable sage. No tests are run yet and no documentation is built.
+
+let
+  buildInputs = [
+    pythonEnv # for patchShebangs
+    makeWrapper
+    pkg-config
+    blas lapack
+    singular
+    three
+    giac
+    gap
+    pari
+    gmp
+    gfan
+    maxima
+    eclib
+    flintqs
+    ntl
+    ecm
+  ];
+
+  # remove python prefix, replace "-" in the name by "_", apply patch_names
+  # python3.8-some-pkg-1.0 -> some_pkg-1.0
+  pkg_to_spkg_name = pkg: patch_names: let
+    parts = lib.splitString "-" pkg.name;
+    # remove python3.8-
+    stripped_parts = if (builtins.head parts) == python3.libPrefix then builtins.tail parts else parts;
+    version = lib.last stripped_parts;
+    orig_pkgname = lib.init stripped_parts;
+    pkgname = patch_names (lib.concatStringsSep "_" orig_pkgname);
+  in pkgname + "-" + version;
+
+
+  # return the names of all dependencies in the transitive closure
+  transitiveClosure = dep:
+  if dep == null then
+    # propagatedBuildInputs might contain null
+    # (although that might be considered a programming error in the derivation)
+    []
+  else
+    [ dep ] ++ (
+      if builtins.hasAttr "propagatedBuildInputs" dep then
+        lib.unique (builtins.concatLists (map transitiveClosure dep.propagatedBuildInputs))
+      else
+      []
+    );
+
+  allInputs = lib.remove null (buildInputs ++ pythonEnv.extraLibs);
+  transitiveDeps = lib.unique (builtins.concatLists (map transitiveClosure allInputs ));
+  # fix differences between spkg and sage names
+  # (could patch sage instead, but this is more lightweight and also works for packages depending on sage)
+  patch_names = builtins.replaceStrings [
+    "zope.interface"
+    "node_three"
+  ] [
+    "zope_interface"
+    "threejs"
+  ];
+  # spkg names (this_is_a_package-version) of all transitive deps
+  input_names = map (dep: pkg_to_spkg_name dep patch_names) transitiveDeps;
+in
+stdenv.mkDerivation rec {
+  version = src.version;
+  pname = "sage-with-env";
+  src = sage-env.lib.src;
+
+  inherit buildInputs;
+
+  configurePhase = "#do nothing";
+
+  buildPhase = ''
+    mkdir installed
+    for pkg in ${lib.concatStringsSep " " input_names}; do
+      touch "installed/$pkg"
+    done
+
+    # threejs version is in format 0.<version>.minor, but sage currently still
+    # relies on installed_packages for the online version of threejs to work
+    # and expects the format r<version>. This is a hotfix for now.
+    # upstream: https://trac.sagemath.org/ticket/26434
+    rm "installed/threejs"*
+    touch "installed/threejs-r${lib.versions.minor three.version}"
+  '';
+
+  installPhase = ''
+    mkdir -p "$out/var/lib/sage"
+    cp -r installed "$out/var/lib/sage"
+
+    mkdir -p "$out/etc"
+    # sage tests will try to create this file if it doesn't exist
+    touch "$out/etc/sage-started.txt"
+
+    mkdir -p "$out/build"
+
+    # the scripts in src/bin will find the actual sage source files using environment variables set in `sage-env`
+    cp -r src/bin "$out/bin"
+    cp -r build/bin "$out/build/bin"
+
+    # sage assumes the existence of sage-src-env-config.in means it's being executed in-tree. in this case, it
+    # adds SAGE_SRC/bin to PATH, breaking our wrappers
+    rm "$out/bin"/*.in "$out/build/bin"/*.in
+
+    cp -f '${sage-env}/sage-env' "$out/bin/sage-env"
+    substituteInPlace "$out/bin/sage-env" \
+      --subst-var-by sage-local "$out"
+  '';
+
+  passthru = {
+    env = sage-env;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/sage/sage.nix b/nixpkgs/pkgs/applications/science/math/sage/sage.nix
new file mode 100644
index 000000000000..96122fba5ab4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/sage.nix
@@ -0,0 +1,70 @@
+{ lib, stdenv
+, makeWrapper
+, sage-tests
+, sage-with-env
+, jupyter-kernel-definition
+, jupyter-kernel
+, sagedoc
+, withDoc
+, requireSageTests
+}:
+
+# A wrapper that makes sure sage finds its docs (if they were build) and the
+# jupyter kernel spec.
+
+let
+  # generate kernel spec + default kernels
+  kernel-specs = jupyter-kernel.create {
+    definitions = jupyter-kernel.default // {
+      sagemath = jupyter-kernel-definition;
+    };
+  };
+in
+stdenv.mkDerivation rec {
+  version = src.version;
+  pname = "sage";
+  src = sage-with-env.env.lib.src;
+
+  buildInputs = [
+    makeWrapper
+  ] ++ lib.optionals requireSageTests [
+    # This is a hack to make sure sage-tests is evaluated. It doesn't acutally
+    # produce anything of value, it just decouples the tests from the build.
+    sage-tests
+  ];
+
+  dontUnpack = true;
+  configurePhase = "#do nothing";
+  buildPhase = "#do nothing";
+
+  installPhase = ''
+    mkdir -p "$out/bin"
+    makeWrapper "${sage-with-env}/bin/sage" "$out/bin/sage" \
+      --set SAGE_DOC_SRC_OVERRIDE "${src}/src/doc" ${
+        lib.optionalString withDoc "--set SAGE_DOC_OVERRIDE ${sagedoc}/share/doc/sage"
+      } \
+      --prefix JUPYTER_PATH : "${kernel-specs}"
+  '';
+
+  doInstallCheck = withDoc;
+  installCheckPhase = ''
+    export HOME="$TMPDIR/sage-home"
+    mkdir -p "$HOME"
+    "$out/bin/sage" -c 'browse_sage_doc._open("reference", testing=True)'
+  '';
+
+  passthru = {
+    tests = sage-tests;
+    quicktest = sage-tests.override { longTests = false; timeLimit = 600; }; # as many tests as possible in ~10m
+    doc = sagedoc;
+    lib = sage-with-env.env.lib;
+    kernelspec = jupyter-kernel-definition;
+  };
+
+  meta = with lib; {
+    description = "Open Source Mathematics Software, free alternative to Magma, Maple, Mathematica, and Matlab";
+    homepage = "https://www.sagemath.org";
+    license = licenses.gpl2Plus;
+    maintainers = teams.sage.members;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/sage/sagedoc.nix b/nixpkgs/pkgs/applications/science/math/sage/sagedoc.nix
new file mode 100644
index 000000000000..489fc2edfe55
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/sagedoc.nix
@@ -0,0 +1,88 @@
+{ stdenv
+, sage-with-env
+, python3
+, maxima
+, tachyon
+, jmol
+, cddlib
+}:
+
+stdenv.mkDerivation rec {
+  version = src.version;
+  pname = "sagedoc";
+  src = sage-with-env.env.lib.src;
+
+
+  # Building the documentation has many dependencies, because all documented
+  # modules are imported and because matplotlib is used to produce plots.
+  buildInputs = [
+    sage-with-env.env.lib
+    python3
+    maxima
+    tachyon
+    jmol
+    cddlib
+  ] ++ (with python3.pkgs; [
+    sage-docbuild
+    psutil
+    future
+    sphinx
+    scipy
+    sympy
+    matplotlib
+    pillow
+    networkx
+    ipykernel
+    ipywidgets
+    jupyter-client
+  ]);
+
+  unpackPhase = ''
+    export SAGE_DOC_OVERRIDE="$PWD/share/doc/sage"
+    export SAGE_DOC_SRC_OVERRIDE="$PWD/docsrc"
+
+    cp -r "${src}/src/doc" "$SAGE_DOC_SRC_OVERRIDE"
+    chmod -R 755 "$SAGE_DOC_SRC_OVERRIDE"
+  '';
+
+  buildPhase = ''
+    export SAGE_NUM_THREADS="$NIX_BUILD_CORES"
+    export HOME="$TMPDIR/sage_home"
+    mkdir -p "$HOME"
+
+    # needed to link them in the sage docs using intersphinx
+    export PPLPY_DOCS=${python3.pkgs.pplpy.doc}/share/doc/pplpy
+
+    # adapted from src/doc/bootstrap (which we don't run)
+    OUTPUT_DIR="$SAGE_DOC_SRC_OVERRIDE/en/reference/repl"
+    mkdir -p "$OUTPUT_DIR"
+    OUTPUT="$OUTPUT_DIR/options.txt"
+    ${sage-with-env}/bin/sage -advanced > "$OUTPUT"
+
+    ${sage-with-env}/bin/sage --docbuild \
+      --mathjax \
+      --no-pdf-links \
+      all html
+  '';
+
+  installPhase = ''
+    cd "$SAGE_DOC_OVERRIDE"
+
+    mkdir -p "$out/share/doc/sage"
+    cp -r html "$out"/share/doc/sage
+
+    # Replace duplicated files by symlinks (Gentoo)
+    cd "$out"/share/doc/sage
+    mv html/en/_static{,.tmp}
+    for _dir in `find -name _static` ; do
+          rm -r $_dir
+          ln -rs html/en/_static $_dir
+    done
+    mv html/en/_static{.tmp,}
+  '';
+
+  doCheck = true;
+  checkPhase = ''
+    ${sage-with-env}/bin/sage -t --optional=sagemath_doc_html --all
+  '';
+}
diff --git a/nixpkgs/pkgs/applications/science/math/sage/sagelib.nix b/nixpkgs/pkgs/applications/science/math/sage/sagelib.nix
new file mode 100644
index 000000000000..8d685c8da60f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/sagelib.nix
@@ -0,0 +1,204 @@
+{ sage-src
+, env-locations
+, perl
+, buildPythonPackage
+, m4
+, arb
+, blas
+, lapack
+, brial
+, cliquer
+, cypari2
+, cysignals
+, cython
+, lisp-compiler
+, eclib
+, ecm
+, flint
+, gd
+, giac
+, givaro
+, glpk
+, gsl
+, iml
+, jinja2
+, lcalc
+, lrcalc
+, gap
+, linbox
+, m4ri
+, m4rie
+, memory-allocator
+, libmpc
+, mpfi
+, ntl
+, numpy
+, pari
+, pkgconfig # the python module, not the pkg-config alias
+, pkg-config
+, planarity
+, ppl
+, primecountpy
+, python
+, ratpoints
+, readline
+, rankwidth
+, symmetrica
+, zn_poly
+, fflas-ffpack
+, boost
+, singular
+, pip
+, jupyter_core
+, sage-setup
+, libhomfly
+, libbraiding
+, gmpy2
+, pplpy
+, sqlite
+, jupyter-client
+, ipywidgets
+, mpmath
+, rpy2
+, fpylll
+, scipy
+, sympy
+, matplotlib
+, pillow
+, ipykernel
+, networkx
+, sphinx # TODO: this is in setup.cfg, bug should we override it?
+}:
+
+assert (!blas.isILP64) && (!lapack.isILP64);
+
+# This is the core sage python package. Everything else is just wrappers gluing
+# stuff together. It is not very useful on its own though, since it will not
+# find many of its dependencies without `sage-env`, will not be tested without
+# `sage-tests` and will not have html docs without `sagedoc`.
+
+buildPythonPackage rec {
+  version = src.version;
+  pname = "sagelib";
+  src = sage-src;
+
+  nativeBuildInputs = [
+    iml
+    perl
+    jupyter_core
+    pkg-config
+    sage-setup
+    pip # needed to query installed packages
+    lisp-compiler
+    m4
+  ];
+
+  buildInputs = [
+    gd
+    readline
+    iml
+  ];
+
+  propagatedBuildInputs = [
+    cypari2
+    jinja2
+    numpy
+    pkgconfig
+    boost
+    arb
+    brial
+    cliquer
+    lisp-compiler
+    eclib
+    ecm
+    fflas-ffpack
+    flint
+    giac
+    givaro
+    glpk
+    gsl
+    lcalc
+    gap
+    libmpc
+    linbox
+    lrcalc
+    m4ri
+    m4rie
+    memory-allocator
+    mpfi
+    ntl
+    blas
+    lapack
+    pari
+    planarity
+    ppl
+    primecountpy
+    rankwidth
+    ratpoints
+    singular
+    symmetrica
+    zn_poly
+    pip
+    cython
+    cysignals
+    libhomfly
+    libbraiding
+    gmpy2
+    pplpy
+    sqlite
+    mpmath
+    rpy2
+    scipy
+    sympy
+    matplotlib
+    pillow
+    ipykernel
+    fpylll
+    networkx
+    jupyter-client
+    ipywidgets
+    sphinx
+  ];
+
+  preBuild = ''
+    export SAGE_ROOT="$PWD"
+    export SAGE_LOCAL="$SAGE_ROOT"
+    export SAGE_SHARE="$SAGE_LOCAL/share"
+
+    # set locations of dependencies (needed for nbextensions like threejs)
+    . ${env-locations}/sage-env-locations
+
+    export JUPYTER_PATH="$SAGE_LOCAL/jupyter"
+    export PATH="$SAGE_ROOT/build/bin:$SAGE_ROOT/src/bin:$PATH"
+
+    export SAGE_NUM_THREADS="$NIX_BUILD_CORES"
+
+    mkdir -p "$SAGE_SHARE/sage/ext/notebook-ipython"
+    mkdir -p "var/lib/sage/installed"
+
+    cd build/pkgs/sagelib
+
+    # some files, like Pipfile, pyproject.toml, requirements.txt and setup.cfg
+    # are generated by the bootstrap script using m4. these can fetch data from
+    # build/pkgs, either directly or via sage-get-system-packages.
+    sed -i 's/==2.1.0rc1/>=2.1.1/' ../gmpy2/install-requires.txt
+    sed -i 's/, <3.4//' ../rpy2/install-requires.txt
+    sed -i 's/, <4.3//' ../sphinx/install-requires.txt
+    sed -i '/sage_conf/d' src/setup.cfg.m4
+    sed -i '/sage_conf/d' src/requirements.txt.m4
+    for infile in src/*.m4; do
+        if [ -f "$infile" ]; then
+            outfile="src/$(basename $infile .m4)"
+            m4 "$infile" > "$outfile"
+        fi
+    done
+
+    cd src
+  '';
+
+  postInstall = ''
+    rm -r "$out/${python.sitePackages}/sage/cython_debug"
+  '';
+
+  doCheck = false; # we will run tests in sage-tests.nix
+}
diff --git a/nixpkgs/pkgs/applications/science/math/sage/threejs-sage.nix b/nixpkgs/pkgs/applications/science/math/sage/threejs-sage.nix
new file mode 100644
index 000000000000..bc7230f333ab
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/threejs-sage.nix
@@ -0,0 +1,19 @@
+{ stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  pname = "threejs-sage";
+  version = "r122";
+
+  src = fetchFromGitHub {
+    owner = "sagemath";
+    repo = "threejs-sage";
+    rev = version;
+    sha256 = "sha256-xPAPt36Fon3hYQq6SOmGkIyUzAII2LMl10nqYG4UPI0=";
+  };
+
+  installPhase = ''
+    mkdir -p "$out/lib/node_modules/three/"
+    cp version "$out/lib/node_modules/three"
+    cp -r build "$out/lib/node_modules/three/$(cat version)"
+  '';
+}
diff --git a/nixpkgs/pkgs/applications/science/math/scilab-bin/default.nix b/nixpkgs/pkgs/applications/science/math/scilab-bin/default.nix
new file mode 100644
index 000000000000..18dba2952cad
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/scilab-bin/default.nix
@@ -0,0 +1,102 @@
+{ stdenv, fetchurl, lib, xorg }:
+
+let
+  name = "scilab-bin-${ver}";
+
+  ver = "6.1.1";
+
+  badArch = throw "${name} requires i686-linux or x86_64-linux";
+
+  architecture =
+    if stdenv.hostPlatform.system == "i686-linux" then
+      "i686"
+    else if stdenv.hostPlatform.system == "x86_64-linux" then
+      "x86_64"
+    else
+      badArch;
+in
+stdenv.mkDerivation {
+  inherit name;
+
+  src = fetchurl {
+    url = "https://www.scilab.org/download/${ver}/scilab-${ver}.bin.linux-${architecture}.tar.gz";
+    sha256 =
+      if stdenv.hostPlatform.system == "i686-linux" then
+        "0fgjc2ak3b2qi6yin3fy50qwk2bcj0zbz1h4lyyic9n1n1qcliib"
+      else if stdenv.hostPlatform.system == "x86_64-linux" then
+        "sha256-PuGnz2YdAhriavwnuf5Qyy0cnCeRHlWC6dQzfr7bLHk="
+      else
+        badArch;
+  };
+
+  libPath = lib.makeLibraryPath [
+    stdenv.cc.cc
+    xorg.libX11
+    xorg.libXext
+    xorg.libXi
+    xorg.libXrender
+    xorg.libXtst
+    xorg.libXxf86vm
+  ];
+
+  fixupPhase = ''
+    sed -i 's|\$(/bin/|$(|g' bin/scilab
+    sed -i 's|/usr/bin/||g' bin/scilab
+
+    sci="$out/opt/scilab-${ver}"
+    fullLibPath="$sci/lib/scilab:$sci/lib/thirdparty:$libPath"
+    fullLibPath="$fullLibPath:$sci/lib/thirdparty/redist"
+
+    patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
+             --set-rpath "$fullLibPath" bin/scilab-bin
+    find . -name '*.so' -type f | while read file; do
+      patchelf --set-rpath "$fullLibPath" "$file" 2>/dev/null
+    done
+  '';
+
+  installPhase = ''
+    mkdir -p "$out/opt/scilab-${ver}"
+    cp -r . "$out/opt/scilab-${ver}/"
+
+    # Create bin/ dir
+    mkdir "$out/bin"
+
+    # Creating executable symlinks
+    ln -s "$out/opt/scilab-${ver}/bin/scilab" "$out/bin/scilab"
+    ln -s "$out/opt/scilab-${ver}/bin/scilab-cli" "$out/bin/scilab-cli"
+    ln -s "$out/opt/scilab-${ver}/bin/scilab-adv-cli" "$out/bin/scilab-adv-cli"
+
+    # Creating desktop config dir
+    mkdir -p "$out/share/applications"
+
+    # Moving desktop config files
+    mv $out/opt/scilab-${ver}/share/applications/*.desktop $out/share/applications
+
+    # Fixing Exec paths and launching each app with a terminal
+    sed -i -e "s|Exec=|Exec=$out/opt/scilab-${ver}/bin/|g" \
+           -e "s|Terminal=.*$|Terminal=true|g" $out/share/applications/*.desktop
+
+    # Moving icons to the appropriate locations
+    for path in $out/opt/scilab-${ver}/share/icons/hicolor/*/*/*
+    do
+      newpath=$(echo $path | sed 's|/opt/scilab-${ver}||g')
+      filename=$(echo $path | sed 's|.*/||g')
+      dir=$(echo $newpath | sed "s|$filename||g")
+      mkdir -p $dir
+      mv $path $newpath
+    done
+
+    # Removing emptied folders
+    rm -rf $out/opt/scilab-${ver}/share/{applications,icons}
+
+    # Moving other share/ folders
+    mv $out/opt/scilab-${ver}/share/{appdata,locale,mime} $out/share
+  '';
+
+  meta = {
+    homepage = "http://www.scilab.org/";
+    description = "Scientific software package for numerical computations (Matlab lookalike)";
+    # see http://www.scilab.org/legal_notice
+    license = "Scilab";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/scilab/default.nix b/nixpkgs/pkgs/applications/science/math/scilab/default.nix
new file mode 100644
index 000000000000..4ce04340f3a1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/scilab/default.nix
@@ -0,0 +1,67 @@
+{stdenv, fetchurl, lib, gfortran
+, ncurses
+, withXaw3d ? false
+#, withPVMlib ? false
+, tcl, tk, withTk ? true
+, gtk2, withGtk ? false # working ?
+#, withF2c ? false
+, ocaml, withOCaml ? true
+#, withJava ? false
+#, atlasMath, withAtlas ? false
+, xlibsWrapper, withX ? true
+}:
+
+stdenv.mkDerivation rec {
+  version = "4.1.2";
+  pname = "scilab";
+  src = fetchurl {
+    url = "https://www.scilab.org/download/${version}/${pname}-${version}-src.tar.gz";
+    sha256 = "1adk6jqlj7i3gjklvlf1j3il1nb22axnp4rvwl314an62siih0sc";
+  };
+
+  nativeBuildInputs = [ gfortran ];
+
+  buildInputs = [ ncurses ]
+    ++ lib.optionals withGtk [ gtk2 ]
+    ++ lib.optionals withOCaml [ ocaml ]
+    ++ lib.optional withX xlibsWrapper;
+
+
+/*
+  --with-atlas-library=DIR  Atlas library files are in DIR and we use Atlas
+*/
+  configureFlags = [
+    # use gcc C compiler and gnu Fortran compiler (g77 or gfortran)
+    "--with-gcc" "--with-g77"
+    # do not compile with PVM library
+    "--without-pvm"
+    # compile with GTK
+    (lib.enableFeature withGtk "gtk")
+    (lib.enableFeature withGtk "gtk2")
+    # compile with ocaml
+    (lib.withFeature withOCaml "ocaml")
+    # do not compile Java interface
+    "--without-java"
+    # use the X Window System
+    (lib.withFeature withX "x")
+    # compile with TCL/TK
+  ] ++ lib.optionals withTk [
+    "--with-tk"
+    "--with-tcl-library=${tcl}/lib"
+    "--with-tcl-include=${tcl}/include"
+    "--with-tk-library=${tk}/lib"
+    "--with-tk-include=${tk}/include"
+  ]    # use Xaw3d widgets given with Scilab
+    ++ lib.optional (!withXaw3d) "--with-local-xaw"
+  ;
+
+  makeFlags = [ "all" ];
+
+  meta = {
+    homepage = "http://www.scilab.org/";
+    description = "Scientific software package for numerical computations (Matlab lookalike)";
+    # see http://www.scilab.org/legal
+    license = "SciLab";
+    broken = true;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/scotch/default.nix b/nixpkgs/pkgs/applications/science/math/scotch/default.nix
new file mode 100644
index 000000000000..1eb057cfc7c5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/scotch/default.nix
@@ -0,0 +1,36 @@
+{ lib, stdenv, fetchurl, bison, mpi, flex, zlib}:
+
+stdenv.mkDerivation rec {
+  version = "6.1.1";
+  pname = "scotch";
+  src_name = "scotch_${version}";
+
+  buildInputs = [ bison mpi flex zlib ];
+
+  src = fetchurl {
+    url = "https://gforge.inria.fr/frs/download.php/file/34618/${src_name}.tar.gz";
+    sha256 = "sha256-OQUvWf9HSkppzvwlzzyvhClACIneugEO5kA8oYj4sxE=";
+  };
+
+  sourceRoot = "${src_name}/src";
+
+  preConfigure = ''
+    ln -s Make.inc/Makefile.inc.x86-64_pc_linux2 Makefile.inc
+  '';
+
+  buildFlags = [ "scotch ptscotch" ];
+  installFlags = [ "prefix=\${out}" ];
+
+  meta = {
+    description = "Graph and mesh/hypergraph partitioning, graph clustering, and sparse matrix ordering";
+    longDescription = ''
+      Scotch is a software package for graph and mesh/hypergraph partitioning, graph clustering,
+      and sparse matrix ordering.
+    '';
+    homepage = "http://www.labri.fr/perso/pelegrin/scotch";
+    license = lib.licenses.cecill-c;
+    maintainers = [ lib.maintainers.bzizou ];
+    platforms = lib.platforms.linux;
+  };
+}
+
diff --git a/nixpkgs/pkgs/applications/science/math/singular/default.nix b/nixpkgs/pkgs/applications/science/math/singular/default.nix
new file mode 100644
index 000000000000..23712061160e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/singular/default.nix
@@ -0,0 +1,172 @@
+{ stdenv, fetchFromGitHub, gmp, bison, perl, ncurses, readline, coreutils, pkg-config
+, lib
+, autoreconfHook
+, buildPackages
+, sharutils
+, file
+, flint
+, ntl
+, cddlib
+, gfan
+, lrcalc
+, doxygen
+, graphviz
+, latex2html
+# upstream generates docs with texinfo 4. later versions of texinfo
+# use letters instead of numbers for post-appendix chapters, and we
+# want it to match the upstream format because sage depends on it.
+, texinfo4
+, texlive
+, enableDocs ? true
+, enableGfanlib ? true
+}:
+
+stdenv.mkDerivation rec {
+  pname = "singular";
+  version = "4.3.0";
+
+  # since the tarball does not contain tests, we fetch from GitHub.
+  src = fetchFromGitHub {
+    owner = "Singular";
+    repo = "Singular";
+
+    # if a release is tagged (which sometimes does not happen), it will
+    # be in the format below.
+    # rev = "Release-${lib.replaceStrings ["."] ["-"] version}";
+    rev = "d895b0f1f543c61eb03adddad20f08655a419d4e";
+    sha256 = "sha256-c5Qr6VUuPKjfw8fowjJJz3oGAyUwo/K0WeMvU5djzVA=";
+
+    # the repository's .gitattributes file contains the lines "/Tst/
+    # export-ignore" and "/doc/ export-ignore" so some directories are
+    # not included in the tarball downloaded by fetchzip.
+    forceFetchGit = true;
+  };
+
+  configureFlags = [
+    "--with-ntl=${ntl}"
+    "--disable-pyobject-module"
+  ] ++ lib.optionals enableDocs [
+    "--enable-doc-build"
+  ] ++ lib.optionals enableGfanlib [
+    "--enable-gfanlib"
+  ];
+
+  prePatch = ''
+    # don't let the tests depend on `hostname`
+    substituteInPlace Tst/regress.cmd --replace 'mysystem_catch("hostname")' 'nix_test_runner'
+
+    patchShebangs .
+  '';
+
+  # For reference (last checked on commit 75f460d):
+  # https://github.com/Singular/Singular/blob/spielwiese/doc/Building-Singular-from-source.md
+  # https://github.com/Singular/Singular/blob/spielwiese/doc/external-packages-dynamic-modules.md
+  buildInputs = [
+    # necessary
+    gmp
+    # by upstream recommended but optional
+    ncurses
+    readline
+    ntl
+    flint
+    lrcalc
+    gfan
+  ] ++ lib.optionals enableGfanlib [
+    cddlib
+  ];
+
+  nativeBuildInputs = [
+    bison
+    perl
+    pkg-config
+    autoreconfHook
+    sharutils # needed for regress.cmd install checks
+  ] ++ lib.optionals enableDocs [
+    doxygen
+    graphviz
+    latex2html
+    texinfo4
+    texlive.combined.scheme-small
+  ];
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
+
+  preAutoreconf = ''
+    find . -type f -readable -writable -exec sed \
+      -e 's@/bin/rm@${coreutils}&@g' \
+      -e 's@/bin/uname@${coreutils}&@g' \
+      -e 's@/usr/bin/file@${file}/bin/file@g' \
+      -i '{}' ';'
+  '';
+
+  hardeningDisable = lib.optional stdenv.isi686 "stackprotector";
+
+  doCheck = true; # very basic checks, does not test any libraries
+
+  installPhase = ''
+    make install
+  '' + lib.optionalString enableDocs ''
+    # Sage uses singular.info, which is not installed by default
+    mkdir -p $out/share/info
+    cp doc/singular.info $out/share/info
+  '' + ''
+    # Make sure patchelf picks up the right libraries
+    rm -rf libpolys factory resources omalloc Singular
+  '';
+
+  # singular tests are a bit complicated, see
+  # https://github.com/Singular/Singular/tree/spielwiese/Tst
+  # https://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=2773
+  testsToRun = [
+    "Old/universal.lst"
+    "Buch/buch.lst"
+    "Plural/short.lst"
+    "Old/factor.tst"
+  ] ++ lib.optionals enableGfanlib [
+    # tests that require gfanlib
+    "Short/ok_s.lst"
+  ];
+
+  # simple test to make sure singular starts and finds its libraries
+  doInstallCheck = true;
+  installCheckPhase = ''
+    # Very basic sanity check to make sure singular starts and finds its libraries.
+    # This is redundant with the below tests. It is only kept because the singular test
+    # runner is a bit complicated. In case we decide to give up those tests in the future,
+    # this will still be useful. It takes barely any time.
+    "$out/bin/Singular" -c 'LIB "freegb.lib"; exit;'
+    if [ $? -ne 0 ]; then
+        echo >&2 "Error loading the freegb library in Singular."
+        exit 1
+    fi
+
+    # Run the test suite
+    cd Tst
+    perl ./regress.cmd \
+      -s "$out/bin/Singular" \
+      ${lib.concatStringsSep " " (map lib.escapeShellArg testsToRun)} \
+      2>"$TMPDIR/out-err.log"
+
+    # unfortunately regress.cmd always returns exit code 0, so check stderr
+    # https://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=2773
+    if [[ -s "$TMPDIR/out-err.log" ]]; then
+      cat "$TMPDIR/out-err.log"
+      exit 1
+    fi
+
+    echo "Exit status $?"
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    description = "A CAS for polynomial computations";
+    maintainers = teams.sage.members;
+    # 32 bit x86 fails with some link error: `undefined reference to `__divmoddi4@GCC_7.0.0'`
+    # https://www.singular.uni-kl.de:8002/trac/ticket/837
+    platforms = subtractLists platforms.i686 platforms.unix;
+    license = licenses.gpl3; # Or GPLv2 at your option - but not GPLv4
+    homepage = "http://www.singular.uni-kl.de";
+    downloadPage = "http://www.mathematik.uni-kl.de/ftp/pub/Math/Singular/SOURCES/";
+    mainProgram = "Singular";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/speedcrunch/default.nix b/nixpkgs/pkgs/applications/science/math/speedcrunch/default.nix
new file mode 100644
index 000000000000..a4e15060fe3b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/speedcrunch/default.nix
@@ -0,0 +1,37 @@
+{ mkDerivation, lib, fetchFromBitbucket, cmake, qtbase, qttools }:
+
+mkDerivation rec {
+  pname = "speedcrunch";
+  version = "unstable-2021-10-09";
+
+  src = fetchFromBitbucket {
+    owner = "heldercorreia";
+    repo = pname;
+    rev = "74756f3438149c01e9edc3259b0f411fa319a22f";
+    sha256 = "sha256-XxQv+A5SfYXFIRK7yacxGHHne1Q93pwCGeHhchIKizU=";
+  };
+
+  buildInputs = [ qtbase qttools ];
+
+  nativeBuildInputs = [ cmake ];
+
+  preConfigure = ''
+    cd src
+  '';
+
+  meta = with lib; {
+    homepage    = "http://speedcrunch.org";
+    license     = licenses.gpl2Plus;
+    description = "A fast power user calculator";
+    longDescription = ''
+      SpeedCrunch is a fast, high precision and powerful desktop calculator.
+      Among its distinctive features are a scrollable display, up to 50 decimal
+      precisions, unlimited variable storage, intelligent automatic completion
+      full keyboard-friendly and more than 15 built-in math function.
+    '';
+    maintainers = with maintainers; [ gebner j0hax ];
+    inherit (qtbase.meta) platforms;
+    # works with qt 5.6 and qt 5.8
+    broken = builtins.compareVersions qtbase.version "5.7.0" == 0;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/symmetrica/default.nix b/nixpkgs/pkgs/applications/science/math/symmetrica/default.nix
new file mode 100644
index 000000000000..ed9e64347a87
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/symmetrica/default.nix
@@ -0,0 +1,36 @@
+{ stdenv
+, lib
+, fetchFromGitLab
+, fetchpatch
+, autoreconfHook
+}:
+stdenv.mkDerivation rec {
+  pname = "symmetrica";
+  version = "3.0.1";
+
+  # Fork of the original symmetrica, which can be found here
+  # http://www.algorithm.uni-bayreuth.de/en/research/SYMMETRICA/index.html
+  # "This fork was created to modernize the codebase, and to resume making
+  # releases with the fixes that have accrued over the years."
+  # Also see https://trac.sagemath.org/ticket/29061#comment:3.
+  src = fetchFromGitLab {
+    owner = "sagemath";
+    repo = "symmetrica";
+    rev = version;
+    sha256 = "0wfmrzw82f5i91d7rf24mcdqcj2fmgrgy02pw4pliz7ncwaq14w3";
+  };
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    description = "A collection of routines for representation theory and combinatorics";
+    license = licenses.isc;
+    maintainers = teams.sage.members;
+    platforms = platforms.unix;
+    homepage = "https://gitlab.com/sagemath/symmetrica";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/weka/default.nix b/nixpkgs/pkgs/applications/science/math/weka/default.nix
new file mode 100644
index 000000000000..9d18763aa32d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/weka/default.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchurl, jre, unzip, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  pname = "weka";
+  version = "3.9.2";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/weka/${lib.replaceChars ["."]["-"] "${pname}-${version}"}.zip";
+    sha256 = "0zwmhspmqb0a7cm6k6i0s6q3w19ws1g9dx3cp2v3g3vsif6cdh31";
+  };
+
+  nativeBuildInputs = [ makeWrapper unzip ];
+
+  # The -Xmx1000M comes suggested from their download page:
+  # http://www.cs.waikato.ac.nz/ml/weka/downloading.html
+  installPhase = ''
+    mkdir -pv $out/share/weka
+    cp -Rv * $out/share/weka
+
+    makeWrapper ${jre}/bin/java $out/bin/weka \
+      --add-flags "-Xmx1000M -jar $out/share/weka/weka.jar"
+  '';
+
+  meta = {
+    homepage = "http://www.cs.waikato.ac.nz/ml/weka/";
+    description = "Collection of machine learning algorithms for data mining tasks";
+    license = lib.licenses.gpl2Plus;
+    maintainers = [ lib.maintainers.mimame ];
+    platforms = lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/wxmaxima/default.nix b/nixpkgs/pkgs/applications/science/math/wxmaxima/default.nix
new file mode 100644
index 000000000000..76d2c782b4d4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/wxmaxima/default.nix
@@ -0,0 +1,47 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, wrapGAppsHook
+, cmake
+, gettext
+, maxima
+, wxGTK
+, gnome
+}:
+
+stdenv.mkDerivation rec {
+  pname = "wxmaxima";
+  version = "21.11.0";
+
+  src = fetchFromGitHub {
+    owner = "wxMaxima-developers";
+    repo = "wxmaxima";
+    rev = "Version-${version}";
+    sha256 = "sha256-LwuqldMGsmFR8xrNg5vsrogmdi5ysqEQGWITM460IZk=";
+  };
+
+  buildInputs = [
+    wxGTK
+    maxima
+    # So it won't embed svg files into headers.
+    gnome.adwaita-icon-theme
+  ];
+
+  nativeBuildInputs = [
+    wrapGAppsHook
+    cmake
+    gettext
+  ];
+
+  preConfigure = ''
+    gappsWrapperArgs+=(--prefix PATH ":" ${maxima}/bin)
+  '';
+
+  meta = with lib; {
+    description = "Cross platform GUI for the computer algebra system Maxima";
+    license = licenses.gpl2;
+    homepage = "https://wxmaxima-developers.github.io/wxmaxima/";
+    maintainers = with maintainers; [ doronbehar ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/yacas/default.nix b/nixpkgs/pkgs/applications/science/math/yacas/default.nix
new file mode 100644
index 000000000000..f7dc2a344e18
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/yacas/default.nix
@@ -0,0 +1,86 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, fetchpatch
+, cmake
+, perl
+, enableGui ? false
+, qtbase
+, wrapQtAppsHook
+, qtwebengine
+, enableJupyter ? true
+, boost
+, jsoncpp
+, openssl
+, zmqpp
+, enableJava ? false
+, openjdk
+, gtest
+}:
+
+stdenv.mkDerivation rec {
+  pname = "yacas";
+  version = "1.9.1";
+
+  src = fetchFromGitHub {
+    owner = "grzegorzmazur";
+    repo = "yacas";
+    rev = "v${version}";
+    sha256 = "0dqgqvsb6ggr8jb3ngf0jwfkn6xwj2knhmvqyzx3amc74yd3ckqx";
+  };
+
+  hardeningDisable = [ "format" ];
+
+  cmakeFlags = [
+    "-DENABLE_CYACAS_GUI=${if enableGui then "ON" else "OFF"}"
+    "-DENABLE_CYACAS_KERNEL=${if enableJupyter then "ON" else "OFF"}"
+    "-DENABLE_JYACAS=${if enableJava then "ON" else "OFF"}"
+    "-DENABLE_CYACAS_UNIT_TESTS=ON"
+  ];
+  patches = [
+    # upstream issue: https://github.com/grzegorzmazur/yacas/issues/340
+    # Upstream patch which doesn't apply on 1.9.1 is:
+    # https://github.com/grzegorzmazur/yacas/pull/342
+    ./jsoncpp-fix-include.patch
+    # Fixes testing - https://github.com/grzegorzmazur/yacas/issues/339
+    # PR: https://github.com/grzegorzmazur/yacas/pull/343
+    (fetchpatch {
+      url = "https://github.com/grzegorzmazur/yacas/commit/8bc22d517ecfdde3ac94800dc8506f5405564d48.patch";
+      sha256 = "sha256-aPO5T8iYNkGtF8j12YxNJyUPJJPKrXje1DmfCPt317A=";
+    })
+  ];
+  preCheck = ''
+    patchShebangs ../tests/test-yacas
+  '';
+  checkInputs = [
+    gtest
+  ];
+  doCheck = true;
+
+  nativeBuildInputs = [
+    cmake
+    # Perl is only for the documentation
+    perl
+  ] ++ lib.optionals enableJava [
+    openjdk
+  ];
+  buildInputs = [
+  ] ++ lib.optionals enableGui [
+    qtbase
+    wrapQtAppsHook
+    qtwebengine
+  ] ++ lib.optionals enableJupyter [
+    boost
+    jsoncpp
+    openssl
+    zmqpp
+  ];
+
+  meta = {
+    description = "Easy to use, general purpose Computer Algebra System${lib.optionalString enableGui ", built with GUI."}";
+    homepage = "http://www.yacas.org/";
+    license = lib.licenses.gpl2Plus;
+    maintainers = with lib.maintainers; [ viric ];
+    platforms = with lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/yacas/fix-test-script.patch b/nixpkgs/pkgs/applications/science/math/yacas/fix-test-script.patch
new file mode 100644
index 000000000000..da85f0dc0e1b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/yacas/fix-test-script.patch
@@ -0,0 +1,26 @@
+diff --git i/tests/test-yacas w/tests/test-yacas
+index b375d78b..0e3a616b 100755
+--- i/tests/test-yacas
++++ w/tests/test-yacas
+@@ -35,9 +35,9 @@ FAILED_TESTS=""  # list of failed tests
+ FAILURES=0       # number of failed tests
+ TOTALTESTS=0     # total number of tests
+ 
+-TESTFILE=/tmp/test-yacas.$$
+-TIMEFILE=/tmp/time-yacas.$$
+-VERSIONF=/tmp/version-yacas-$$.ys
++TESTFILE="$(mktemp -t test-yacas.XXX)"
++TIMEFILE="$(mktemp -t time-yacas.XXX)"
++VERSIONF="$(mktemp -t version-yacas-XXX.ys)"
+ LOGFILE=yacas-logfile.txt
+ echo "Print(Version());" > $VERSIONF
+ VERSION=`$CMD $VERSIONF`
+@@ -69,7 +69,7 @@ for scr in $SCRIPTS; do
+ #		fi
+     echo "Running $scr"
+ 	if [ -f $TESTFILE ]; then rm $TESTFILE ; fi
+-    /bin/bash -c "time -p ($CMD $f || echo \"Error: exit status $?\") | tee $TESTFILE" \
++	    bash -c "time -p ($CMD $f || echo \"Error: exit status $?\") | tee $TESTFILE" \
+ 		2> $TIMEFILE \
+ 		|| (echo "Error -- User interrupt" > $TESTFILE)
+ #	cat $TIMEFILE
diff --git a/nixpkgs/pkgs/applications/science/math/yacas/jsoncpp-fix-include.patch b/nixpkgs/pkgs/applications/science/math/yacas/jsoncpp-fix-include.patch
new file mode 100644
index 000000000000..8fe914e55be3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/yacas/jsoncpp-fix-include.patch
@@ -0,0 +1,63 @@
+diff --git i/cyacas/yacas-kernel/CMakeLists.txt w/cyacas/yacas-kernel/CMakeLists.txt
+index fe1600aa..dcc329f8 100644
+--- i/cyacas/yacas-kernel/CMakeLists.txt
++++ w/cyacas/yacas-kernel/CMakeLists.txt
+@@ -22,8 +22,9 @@ find_library (ZEROMQ_LIBRARY NAMES zmq)
+ find_path (ZMQPP_INCLUDE_DIR zmqpp.hpp)
+ find_library (ZMQPP_LIBRARY NAMES zmqpp)
+ 
+-find_path (JSONCPP_INCLUDE_DIR json.h)
+-find_library (JSONCPP_LIBRARY NAMES jsoncpp)
++# https://github.com/open-source-parsers/jsoncpp/wiki/Building#another-approach-for-cmake
++find_package(jsoncpp REQUIRED)
++get_target_property(JSON_INC_PATH jsoncpp_lib INTERFACE_INCLUDE_DIRECTORIES)
+ 
+ find_package (OpenSSL)
+ find_package (Boost REQUIRED date_time filesystem)
+@@ -31,6 +32,6 @@ find_package (Boost REQUIRED date_time filesystem)
+ include_directories (include)
+ 
+ add_executable (yacas-kernel src/main.cpp src/yacas_kernel.cpp src/yacas_engine.cpp src/hmac_sha256.cpp src/base64.cpp)
+-target_link_libraries (yacas-kernel libyacas ${ZMQPP_LIBRARY} ${ZEROMQ_LIBRARY} ${JSONCPP_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ${Boost_LIBRARIES} pthread ${CMAKE_DL_LIBS})
++target_link_libraries (yacas-kernel libyacas ${ZMQPP_LIBRARY} ${ZEROMQ_LIBRARY} jsoncpp_lib ${OPENSSL_CRYPTO_LIBRARY} ${Boost_LIBRARIES} pthread ${CMAKE_DL_LIBS})
+ 
+ install (TARGETS yacas-kernel DESTINATION ${CMAKE_INSTALL_BINDIR})
+diff --git i/cyacas/yacas-kernel/include/yacas_kernel.hpp w/cyacas/yacas-kernel/include/yacas_kernel.hpp
+index 91d36ac0..d12f905c 100644
+--- i/cyacas/yacas-kernel/include/yacas_kernel.hpp
++++ w/cyacas/yacas-kernel/include/yacas_kernel.hpp
+@@ -29,7 +29,7 @@
+ #include "yacas_engine.hpp"
+ 
+ #include <boost/uuid/random_generator.hpp>
+-#include <jsoncpp/json/json.h>
++#include <json/json.h>
+ #include <zmqpp/zmqpp.hpp>
+ 
+ #include <map>
+diff --git i/cyacas/yacas-kernel/src/main.cpp w/cyacas/yacas-kernel/src/main.cpp
+index c31f17f2..832e9128 100644
+--- i/cyacas/yacas-kernel/src/main.cpp
++++ w/cyacas/yacas-kernel/src/main.cpp
+@@ -24,7 +24,7 @@
+ 
+ #include "yacas_kernel.hpp"
+ 
+-#include <jsoncpp/json/json.h>
++#include <json/json.h>
+ 
+ #include <boost/dll/runtime_symbol_info.hpp>
+ 
+diff --git i/cyacas/yacas-kernel/src/yacas_engine.cpp w/cyacas/yacas-kernel/src/yacas_engine.cpp
+index 6ed60ca3..18e9b3fd 100644
+--- i/cyacas/yacas-kernel/src/yacas_engine.cpp
++++ w/cyacas/yacas-kernel/src/yacas_engine.cpp
+@@ -22,7 +22,7 @@
+  * Created on November 7, 2015, 12:52 PM
+  */
+ 
+-#include <jsoncpp/json/writer.h>
++#include <json/writer.h>
+ 
+ #include "yacas_engine.hpp"
+ 
diff --git a/nixpkgs/pkgs/applications/science/math/zegrapher/default.nix b/nixpkgs/pkgs/applications/science/math/zegrapher/default.nix
new file mode 100644
index 000000000000..32633eb8015d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/zegrapher/default.nix
@@ -0,0 +1,36 @@
+{ lib, stdenv
+, fetchFromGitHub
+, qmake
+, wrapQtAppsHook
+, boost }:
+
+stdenv.mkDerivation rec {
+  pname = "zegrapher";
+  version = "3.1.1";
+
+  src = fetchFromGitHub {
+    owner = "AdelKS";
+    repo = "ZeGrapher";
+    rev = "v${version}";
+    sha256 = "sha256-OSQXm0gDI1zM2MBM4iiY43dthJcAZJkprklolsNMEvk=";
+  };
+
+  nativeBuildInputs = [
+    qmake
+    wrapQtAppsHook
+  ];
+  buildInputs = [
+    boost
+  ];
+
+  meta = with lib; {
+    homepage = "https://zegrapher.com/";
+    description = "An open source math plotter";
+    longDescription = ''
+      An open source, free and easy to use math plotter. It can plot functions,
+      sequences, parametric equations and data on the plane.
+    '';
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ AndersonTorres ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/medicine/aliza/default.nix b/nixpkgs/pkgs/applications/science/medicine/aliza/default.nix
new file mode 100644
index 000000000000..0eb89b63e475
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/medicine/aliza/default.nix
@@ -0,0 +1,59 @@
+{ lib, stdenv, fetchurl, rpmextract, makeWrapper, patchelf, qt4, zlib, libX11, libXt, libSM, libICE, libXext, libGLU, libGL }:
+
+with lib;
+stdenv.mkDerivation {
+  pname = "aliza";
+  version = "1.98.57";
+  src = fetchurl {
+    # See https://www.aliza-dicom-viewer.com/download
+    urls = [
+      "https://drive.google.com/uc?export=download&id=1-AXa3tjy_onecW2k7ftjAQl0KGTb0B1Y"
+      "https://web.archive.org/web/20210327224315/https://doc-0s-0s-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/1lgjid9ti29rdf5ebmd7o58iqhs3gfpo/1616884950000/16072287944266838401/*/1-AXa3tjy_onecW2k7ftjAQl0KGTb0B1Y?e=download"
+    ];
+    sha256 = "01qk2gadmc24pmfdnmpiz7vgfiqkvhznyq9rsr153frscg76gc9b";
+    name = "aliza.rpm";
+  };
+
+  nativeBuildInputs = [ makeWrapper rpmextract ];
+
+  unpackCmd = "rpmextract $curSrc";
+
+  postPatch = ''
+    sed -i 's/^Exec.*$/Exec=aliza %F/' share/applications/aliza.desktop
+  '';
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out
+    cp -r bin share $out
+
+    runHook postInstall
+  '';
+
+  postInstall = let
+    libs = lib.makeLibraryPath [ qt4 zlib stdenv.cc.cc libSM libICE libX11 libXext libXt libGLU libGL ];
+  in ''
+    ${patchelf}/bin/patchelf \
+      --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+      $out/bin/aliza
+
+    ${patchelf}/bin/patchelf \
+      --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+      $out/bin/aliza-vtkvol
+
+    wrapProgram $out/bin/aliza \
+      --prefix LD_LIBRARY_PATH : ${libs}
+
+    wrapProgram $out/bin/aliza-vtkvol \
+      --prefix LD_LIBRARY_PATH : ${libs}
+  '';
+
+  meta = {
+    description = "Medical imaging software with 2D, 3D and 4D capabilities";
+    homepage = "https://www.aliza-dicom-viewer.com";
+    license = licenses.unfreeRedistributable;
+    maintainers = with maintainers; [ mounium ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/medicine/dcmtk/default.nix b/nixpkgs/pkgs/applications/science/medicine/dcmtk/default.nix
new file mode 100644
index 000000000000..b6a9c161638a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/medicine/dcmtk/default.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchFromGitHub, zlib, libtiff, libxml2, openssl, libiconv, libpng, cmake }:
+
+with lib;
+stdenv.mkDerivation rec {
+  pname = "dcmtk";
+  version = "3.6.6";
+  src = fetchFromGitHub {
+    owner = "DCMTK";
+    repo = pname;
+    rev = "DCMTK-${version}";
+    sha256 = "sha256-bpvf2JJXikV/CqmXZb3w4Ua3VBEQcQk7PXw9ie0t8xo=";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ libpng zlib libtiff libxml2 openssl libiconv ];
+
+  meta = {
+    description = "Collection of libraries and applications implementing large parts of the DICOM standard";
+    longDescription = ''
+      DCMTK is a collection of libraries and applications implementing large parts of the DICOM standard.
+      It includes software for examining, constructing and converting DICOM image files, handling offline media,
+      sending and receiving images over a network connection, as well as demonstrative image storage and worklist servers.
+      DCMTK is is written in a mixture of ANSI C and C++.
+      It comes in complete source code and is made available as "open source" software.
+    '';
+    homepage = "https://dicom.offis.de/dcmtk";
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ iimog ];
+    platforms = with platforms; linux ++ darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/medicine/xmedcon/default.nix b/nixpkgs/pkgs/applications/science/medicine/xmedcon/default.nix
new file mode 100644
index 000000000000..bee2be729d1e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/medicine/xmedcon/default.nix
@@ -0,0 +1,36 @@
+{ stdenv
+, lib
+, fetchurl
+, gtk3
+, glib
+, pkg-config
+, libpng
+, zlib
+}:
+
+stdenv.mkDerivation rec {
+  pname = "xmedcon";
+  version = "0.21.2";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/${pname}/${pname}-${version}.tar.bz2";
+    sha256 = "0svff8rc3j2p47snaq1hx9mv4ydmxawpb0hf3d165g1ccjwvmm6m";
+  };
+
+  buildInputs = [
+    gtk3
+    glib
+    libpng
+    zlib
+  ];
+
+  nativeBuildInputs = [ pkg-config ];
+
+  meta = with lib; {
+    description = "An open source toolkit for medical image conversion ";
+    homepage = "https://xmedcon.sourceforge.io/Main/HomePage";
+    license = licenses.lgpl2Plus;
+    maintainers = with maintainers; [ arianvp flokli ];
+    platforms = platforms.darwin ++ platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/bada-bib/default.nix b/nixpkgs/pkgs/applications/science/misc/bada-bib/default.nix
new file mode 100644
index 000000000000..bd2f94ac4a74
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/bada-bib/default.nix
@@ -0,0 +1,78 @@
+{ lib
+, meson
+, ninja
+, fetchFromGitHub
+, appstream-glib
+, desktop-file-utils
+, gdk-pixbuf
+, gettext
+, glib
+, gnome
+, gobject-introspection
+, gtk4
+, libxml2
+, pkg-config
+, python3Packages
+, wrapGAppsHook4 }:
+
+python3Packages.buildPythonApplication rec {
+  pname = "bada-bib";
+  version = "0.5.1";
+  format = "other";
+  strictDeps = false; # https://github.com/NixOS/nixpkgs/issues/56943
+
+  src = fetchFromGitHub {
+    owner = "RogerCrocker";
+    repo = "BadaBib";
+    rev = "v${version}";
+    sha256 = "sha256-tb/720WPqcO4w1EMmidjtEidsjZ0dEhe+/vnJPM6kxo=";
+  };
+
+  nativeBuildInputs = [
+    gettext
+    gobject-introspection
+    libxml2
+    meson
+    ninja
+    pkg-config
+    wrapGAppsHook4
+  ];
+
+  buildInputs = [
+    gdk-pixbuf
+    glib
+    gtk4
+  ];
+
+  checkInputs = [
+    appstream-glib
+    desktop-file-utils
+  ];
+
+  pythonPath = with python3Packages; [
+    bibtexparser
+    pygobject3
+    watchgod
+  ];
+
+  postPatch = ''
+    patchShebangs build-aux/meson/postinstall.py
+  '';
+
+  dontWrapGApps = true; # Needs python wrapper
+
+  preFixup = ''
+    makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
+  '';
+
+  postFixup = ''
+    wrapPythonProgramsIn "$out/libexec" "$out $pythonPath"
+  '';
+
+  meta = with lib; {
+    homepage = "https://github.com/RogerCrocker/BadaBib";
+    description = "A simple BibTeX Viewer and Editor";
+    maintainers = [ maintainers.Cogitri ];
+    license = licenses.gpl3Plus;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/boinc/default.nix b/nixpkgs/pkgs/applications/science/misc/boinc/default.nix
new file mode 100644
index 000000000000..05304ef6a9e2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/boinc/default.nix
@@ -0,0 +1,51 @@
+{ fetchFromGitHub, lib, stdenv, autoconf, automake, pkg-config, m4, curl,
+libGLU, libGL, libXmu, libXi, freeglut, libjpeg, libtool, wxGTK30, xcbutil,
+sqlite, gtk2, patchelf, libXScrnSaver, libnotify, libX11, libxcb }:
+
+let
+  majorVersion = "7.18";
+  minorVersion = "1";
+in
+
+stdenv.mkDerivation rec {
+  version = "${majorVersion}.${minorVersion}";
+  pname = "boinc";
+
+  src = fetchFromGitHub {
+    name = "${pname}-${version}-src";
+    owner = "BOINC";
+    repo = "boinc";
+    rev = "client_release/${majorVersion}/${version}";
+    sha256 = "sha256-ijkfWTFwwJXvh6f0P5hkzWODxU+Ugz6iQUK+5jEpWXQ=";
+  };
+
+  nativeBuildInputs = [ libtool automake autoconf m4 pkg-config ];
+
+  buildInputs = [
+    curl libGLU libGL libXmu libXi freeglut libjpeg wxGTK30 sqlite gtk2 libXScrnSaver
+    libnotify patchelf libX11 libxcb xcbutil
+  ];
+
+  NIX_LDFLAGS = "-lX11";
+
+  preConfigure = ''
+    ./_autosetup
+    configureFlags="$configureFlags --sysconfdir=$out/etc"
+  '';
+
+  enableParallelBuilding = true;
+
+  configureFlags = [ "--disable-server" ];
+
+  postInstall = ''
+    install --mode=444 -D 'client/scripts/boinc-client.service' "$out/etc/systemd/system/boinc.service"
+  '';
+
+  meta = with lib; {
+    description = "Free software for distributed and grid computing";
+    homepage = "https://boinc.berkeley.edu/";
+    license = licenses.lgpl2Plus;
+    platforms = platforms.linux;  # arbitrary choice
+    maintainers = with maintainers; [ Luflosi ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/colmap/default.nix b/nixpkgs/pkgs/applications/science/misc/colmap/default.nix
new file mode 100644
index 000000000000..c41c8593a5c4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/colmap/default.nix
@@ -0,0 +1,37 @@
+{ mkDerivation, lib, fetchFromGitHub, cmake, boost17x, ceres-solver, eigen,
+  freeimage, glog, libGLU, glew, qtbase,
+  cudaSupport ? false, cudatoolkit ? null }:
+
+assert !cudaSupport || cudatoolkit != null;
+
+let boost_static = boost17x.override { enableStatic = true; };
+in
+mkDerivation rec {
+  version = "3.7";
+  pname = "colmap";
+  src = fetchFromGitHub {
+     owner = "colmap";
+     repo = "colmap";
+     rev = version;
+     sha256 = "sha256-uVAw6qwhpgIpHkXgxttKupU9zU+vD0Za0maw2Iv4x+I=";
+  };
+
+  buildInputs = [
+    boost_static ceres-solver eigen
+    freeimage glog libGLU glew qtbase
+  ] ++ lib.optional cudaSupport cudatoolkit;
+
+  nativeBuildInputs = [ cmake ];
+
+  meta = with lib; {
+    description = "COLMAP - Structure-From-Motion and Multi-View Stereo pipeline";
+    longDescription = ''
+       COLMAP is a general-purpose Structure-from-Motion (SfM) and Multi-View Stereo (MVS) pipeline
+       with a graphical and command-line interface.
+    '';
+    homepage = "https://colmap.github.io/index.html";
+    license = licenses.bsd3;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ lebastr ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/convertall/default.nix b/nixpkgs/pkgs/applications/science/misc/convertall/default.nix
new file mode 100644
index 000000000000..9a7ac2a8b13c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/convertall/default.nix
@@ -0,0 +1,37 @@
+{ lib, stdenv, fetchFromGitHub, python3, wrapQtAppsHook }:
+
+let
+  inherit (python3.pkgs) wrapPython pyqt5;
+in stdenv.mkDerivation rec {
+  pname = "convertall";
+  version = "0.8.0";
+
+  src = fetchFromGitHub {
+    owner = "doug-101";
+    repo = "ConvertAll";
+    rev = "v${version}";
+    sha256 = "02xxasgbjbivsbhyfpn3cpv52lscdx5kc95s6ns1dvnmdg0fpng0";
+  };
+
+  nativeBuildInputs = [ python3 wrapPython wrapQtAppsHook ];
+
+  propagatedBuildInputs = [ pyqt5 ];
+
+  installPhase = ''
+    python3 install.py -p $out -x
+  '';
+
+  postFixup = ''
+    buildPythonPath $out
+    patchPythonScript $out/share/convertall/convertall.py
+    makeQtWrapper $out/share/convertall/convertall.py $out/bin/convertall
+  '';
+
+  meta = with lib; {
+    homepage = "https://convertall.bellz.org/";
+    description = "Graphical unit converter";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ orivej ];
+    platforms = pyqt5.meta.platforms;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/cwltool/default.nix b/nixpkgs/pkgs/applications/science/misc/cwltool/default.nix
new file mode 100644
index 000000000000..b3647e0f1b60
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/cwltool/default.nix
@@ -0,0 +1,76 @@
+{ lib
+, fetchFromGitHub
+, git
+, nodejs
+, python3
+}:
+
+python3.pkgs.buildPythonApplication rec {
+  pname = "cwltool";
+  version = "3.1.20220221074232";
+  format = "setuptools";
+
+  src = fetchFromGitHub {
+    owner = "common-workflow-language";
+    repo = pname;
+    rev = version;
+    sha256 = "sha256-hUdwtqYHcfyJ68LzwwCXAxr7YIkJm64brb+kA/WJqU8=";
+  };
+
+  postPatch = ''
+    substituteInPlace setup.py \
+      --replace "ruamel.yaml >= 0.15, < 0.17.18" "ruamel.yaml" \
+      --replace "prov == 1.5.1" "prov" \
+      --replace "setup_requires=PYTEST_RUNNER," ""
+  '';
+
+  nativeBuildInputs = [
+    git
+  ];
+
+  propagatedBuildInputs = with python3.pkgs; [
+    argcomplete
+    bagit
+    coloredlogs
+    mypy-extensions
+    prov
+    psutil
+    pydot
+    rdflib
+    requests
+    ruamel-yaml
+    schema-salad
+    shellescape
+    typing-extensions
+  ];
+
+  checkInputs = with python3.pkgs; [
+    mock
+    nodejs
+    pytest-mock
+    pytest-xdist
+    pytestCheckHook
+  ];
+
+  disabledTests = [
+    "test_content_types"
+    "test_env_filtering"
+    "test_http_path_mapping"
+  ];
+
+  disabledTestPaths = [
+    "tests/test_udocker.py"
+    "tests/test_provenance.py"
+  ];
+
+  pythonImportsCheck = [
+    "cwltool"
+  ];
+
+  meta = with lib; {
+    description = "Common Workflow Language reference implementation";
+    homepage = "https://www.commonwl.org";
+    license = with licenses; [ asl20 ];
+    maintainers = with maintainers; [ veprbl ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/cytoscape/default.nix b/nixpkgs/pkgs/applications/science/misc/cytoscape/default.nix
new file mode 100644
index 000000000000..a907a5f8c169
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/cytoscape/default.nix
@@ -0,0 +1,44 @@
+{ lib, stdenv, fetchurl, jre, makeWrapper, substituteAll, coreutils }:
+
+stdenv.mkDerivation rec {
+  pname = "cytoscape";
+  version = "3.9.1";
+
+  src = fetchurl {
+    url = "https://github.com/cytoscape/cytoscape/releases/download/${version}/${pname}-unix-${version}.tar.gz";
+    sha256 = "sha256-I4C2yGiIygnFUkRBC4LBSQFgjZlVKCoQGRphynVpscw=";
+  };
+
+  patches = [
+    # By default, gen_vmoptions.sh tries to store custom options in $out/share
+    # at run time. This patch makes sure $HOME is used instead.
+    (substituteAll {
+      src = ./gen_vmoptions_to_homedir.patch;
+      inherit coreutils;
+    })
+  ];
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ jre ];
+
+  installPhase = ''
+    mkdir -pv $out/{share,bin}
+    cp -Rv * $out/share/
+
+    ln -s $out/share/cytoscape.sh $out/bin/cytoscape
+
+    wrapProgram $out/share/cytoscape.sh \
+      --set JAVA_HOME "${jre}" \
+      --set JAVA  "${jre}/bin/java"
+
+    chmod +x $out/bin/cytoscape
+  '';
+
+  meta = {
+    homepage = "http://www.cytoscape.org";
+    description = "A general platform for complex network analysis and visualization";
+    license = lib.licenses.lgpl21;
+    maintainers = [lib.maintainers.mimame];
+    platforms = lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/cytoscape/gen_vmoptions_to_homedir.patch b/nixpkgs/pkgs/applications/science/misc/cytoscape/gen_vmoptions_to_homedir.patch
new file mode 100644
index 000000000000..e31681e8541f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/cytoscape/gen_vmoptions_to_homedir.patch
@@ -0,0 +1,19 @@
+diff -Nur a/gen_vmoptions.sh b/gen_vmoptions.sh
+--- a/gen_vmoptions.sh	2020-03-30 21:57:47.000000000 +0100
++++ b/gen_vmoptions.sh	2020-05-05 09:49:57.974989824 +0100
+@@ -1,13 +1,10 @@
+ #!/bin/sh
+ # Generates the Cytoscape.vmoptions file
+ 
+-script_path="$(dirname -- $0)"
+-
+-#vm_options_path="$HOME/.cytoscape"
+-vm_options_path=$script_path
++vm_options_path="$HOME/.cytoscape"
+ 
+ if [ ! -e $vm_options_path ]; then
+-    /bin/mkdir $vm_options_path
++    @coreutils@/bin/mkdir $vm_options_path
+ fi
+ 
+ # Determine amount of physical memory present:
diff --git a/nixpkgs/pkgs/applications/science/misc/fityk/default.nix b/nixpkgs/pkgs/applications/science/misc/fityk/default.nix
new file mode 100644
index 000000000000..974fd3ece45c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/fityk/default.nix
@@ -0,0 +1,28 @@
+{ lib, stdenv, fetchFromGitHub, autoreconfHook, wxGTK30, boost, lua, zlib, bzip2
+, xylib, readline, gnuplot, swig3 }:
+
+let
+  name    = "fityk";
+  version = "1.3.1";
+in
+stdenv.mkDerivation {
+  name = "${name}-${version}";
+
+  src = fetchFromGitHub {
+    owner = "wojdyr";
+    repo = "fityk";
+    rev = "v${version}";
+    sha256 = "0kmrjjjwrh6xgw590awcd52b86kksmv6rfgih75zvpiavr1ygwsi";
+  };
+
+  nativeBuildInputs = [ autoreconfHook ];
+  buildInputs = [ wxGTK30 boost lua zlib bzip2 xylib readline
+    gnuplot swig3 ];
+
+  meta = {
+    description = "Curve fitting and peak fitting software";
+    license = lib.licenses.gpl2;
+    homepage = "https://fityk.nieto.pl/";
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/foldingathome/client.nix b/nixpkgs/pkgs/applications/science/misc/foldingathome/client.nix
new file mode 100644
index 000000000000..cc3d5445b594
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/foldingathome/client.nix
@@ -0,0 +1,59 @@
+{ lib, stdenv
+, autoPatchelfHook
+, buildFHSUserEnv
+, dpkg
+, fetchurl
+, gcc-unwrapped
+, ocl-icd
+, zlib
+, extraPkgs ? []
+}:
+let
+  majMin = lib.versions.majorMinor version;
+  version = "7.6.13";
+
+  fahclient = stdenv.mkDerivation rec {
+    inherit version;
+    pname = "fahclient";
+
+    src = fetchurl {
+      url = "https://download.foldingathome.org/releases/public/release/fahclient/debian-stable-64bit/v${majMin}/fahclient_${version}_amd64.deb";
+      sha256 = "1j2cnsyassvifp6ymwd9kxwqw09hks24834gf7nljfncyy9g4g0i";
+    };
+
+    nativeBuildInputs = [
+      autoPatchelfHook
+      dpkg
+    ];
+
+    buildInputs = [
+      gcc-unwrapped.lib
+      zlib
+    ];
+
+    unpackPhase = "dpkg-deb -x ${src} ./";
+    installPhase = "cp -ar usr $out";
+  };
+in
+buildFHSUserEnv {
+  name = fahclient.name;
+
+  targetPkgs = pkgs': [
+    fahclient
+    ocl-icd
+  ] ++ extraPkgs;
+
+  runScript = "/bin/FAHClient";
+
+  extraInstallCommands = ''
+    mv $out/bin/$name $out/bin/FAHClient
+  '';
+
+  meta = {
+    description = "Folding@home client";
+    homepage = "https://foldingathome.org/";
+    license = lib.licenses.unfree;
+    maintainers = [ lib.maintainers.zimbatm ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/foldingathome/control.nix b/nixpkgs/pkgs/applications/science/misc/foldingathome/control.nix
new file mode 100644
index 000000000000..e5cc02edcfbe
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/foldingathome/control.nix
@@ -0,0 +1,58 @@
+{ lib, stdenv
+, autoPatchelfHook
+, dpkg
+, fahviewer
+, fetchurl
+, makeWrapper
+, python2
+}:
+let
+  majMin = lib.versions.majorMinor version;
+  version = "7.6.21";
+
+  python = python2.withPackages
+    (
+      ps: [
+        ps.pycairo
+        ps.pygobject2
+        ps.pygtk
+      ]
+    );
+in
+stdenv.mkDerivation rec {
+  inherit version;
+  pname = "fahcontrol";
+
+  src = fetchurl {
+    url = "https://download.foldingathome.org/releases/public/release/fahcontrol/debian-stable-64bit/v${majMin}/fahcontrol_${version}-1_all.deb";
+    sha256 = "1vfrdqkrvdlyxaw3f6z92w5dllrv6810lmf8yhcmjcwmphipvf71";
+  };
+
+  nativeBuildInputs = [
+    dpkg
+    makeWrapper
+  ];
+
+  buildInputs = [ fahviewer python ];
+
+  unpackPhase = ''
+    dpkg-deb -x ${src} ./
+  '';
+
+  installPhase = "cp -ar usr $out";
+
+  postFixup = ''
+    sed -e "s|/usr/bin|$out/bin|g" -i $out/share/applications/FAHControl.desktop
+    wrapProgram "$out/bin/FAHControl" \
+      --suffix PATH : "${fahviewer.outPath}/bin" \
+      --set PYTHONPATH "$out/lib/python2.7/dist-packages"
+  '';
+
+  meta = {
+    description = "Folding@home control";
+    homepage = "https://foldingathome.org/";
+    license = lib.licenses.unfree;
+    maintainers = [ lib.maintainers.zimbatm ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/foldingathome/viewer.nix b/nixpkgs/pkgs/applications/science/misc/foldingathome/viewer.nix
new file mode 100644
index 000000000000..75e900a0a72c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/foldingathome/viewer.nix
@@ -0,0 +1,55 @@
+{ lib, stdenv
+, autoPatchelfHook
+, dpkg
+, fetchurl
+, freeglut
+, gcc-unwrapped
+, libGL
+, libGLU
+, makeWrapper
+, zlib
+}:
+let
+  majMin = lib.versions.majorMinor version;
+  version = "7.6.21";
+in
+stdenv.mkDerivation rec {
+  inherit version;
+  pname = "fahviewer";
+
+  src = fetchurl {
+    url = "https://download.foldingathome.org/releases/public/release/fahviewer/debian-stable-64bit/v${majMin}/fahviewer_${version}_amd64.deb";
+    sha256 = "00fd00pf6fcpplcaahvy9ir60mk69d9rcmwsyq3jrv9mxqm9aq7p";
+  };
+
+  nativeBuildInputs = [
+    autoPatchelfHook
+    dpkg
+    makeWrapper
+  ];
+
+  buildInputs = [
+    freeglut
+    gcc-unwrapped.lib
+    libGL
+    libGLU
+    zlib
+  ];
+
+  unpackPhase = ''
+    dpkg-deb -x ${src} ./
+    sed -e "s|/usr/bin|$out/bin|g" -i usr/share/applications/FAHViewer.desktop
+  '';
+
+  installPhase = ''
+    cp -ar usr $out
+  '';
+
+  meta = {
+    description = "Folding@home viewer";
+    homepage = "https://foldingathome.org/";
+    license = lib.licenses.unfree;
+    maintainers = [ lib.maintainers.zimbatm ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/gephi/default.nix b/nixpkgs/pkgs/applications/science/misc/gephi/default.nix
new file mode 100644
index 000000000000..95112fa9098e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/gephi/default.nix
@@ -0,0 +1,65 @@
+{ lib, stdenv, fetchFromGitHub, jdk, maven, javaPackages }:
+
+let
+  version = "0.9.2";
+
+  src = fetchFromGitHub {
+    owner = "gephi";
+    repo = "gephi";
+    rev = "v${version}";
+    sha256 = "0kqp2nvnsb55j1axb6hk0mlw5alyaiyb70z0mdybhpqqxyw2da2r";
+  };
+
+  # perform fake build to make a fixed-output derivation out of the files downloaded from maven central (120MB)
+  deps = stdenv.mkDerivation {
+    name = "gephi-${version}-deps";
+    inherit src;
+    buildInputs = [ jdk maven ];
+    buildPhase = ''
+      while mvn package -Dmaven.repo.local=$out/.m2 -Dmaven.wagon.rto=5000; [ $? = 1 ]; do
+        echo "timeout, restart maven to continue downloading"
+      done
+    '';
+    # keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
+    installPhase = ''find $out/.m2 -type f -regex '.+\(\.lastUpdated\|resolver-status\.properties\|_remote\.repositories\)' -delete'';
+    outputHashAlgo = "sha256";
+    outputHashMode = "recursive";
+    outputHash = "1p7yf97dn0nvr005cbs6vdk3i341s8fya4kfccj8qqad2qgxflif";
+  };
+in
+stdenv.mkDerivation {
+  pname = "gephi";
+  inherit version;
+
+  inherit src;
+
+  buildInputs = [ jdk maven ];
+
+  buildPhase = ''
+    # 'maven.repo.local' must be writable so copy it out of nix store
+    mvn package --offline -Dmaven.repo.local=$(cp -dpR ${deps}/.m2 ./ && chmod +w -R .m2 && pwd)/.m2
+  '';
+
+  installPhase = ''
+    cp -r modules/application/target/gephi $out
+
+    # remove garbage
+    find $out -type f -name  .lastModified -delete
+    find $out -type f -regex '.+\.exe'     -delete
+
+    # use self-compiled JOGL to avoid patchelf'ing .so inside jars
+    rm $out/gephi/modules/ext/org.gephi.visualization/org-jogamp-{jogl,gluegen}/*.jar
+    cp ${javaPackages.jogl_2_3_2}/share/java/jogl*.jar $out/gephi/modules/ext/org.gephi.visualization/org-jogamp-jogl/
+    cp ${javaPackages.jogl_2_3_2}/share/java/glue*.jar $out/gephi/modules/ext/org.gephi.visualization/org-jogamp-gluegen/
+
+    echo "jdkhome=${jdk}" >> $out/etc/gephi.conf
+  '';
+
+  meta = with lib; {
+    description = "A platform for visualizing and manipulating large graphs";
+    homepage = "https://gephi.org";
+    license = licenses.gpl3;
+    maintainers = [ maintainers.taeer ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/golly/beta.nix b/nixpkgs/pkgs/applications/science/misc/golly/beta.nix
new file mode 100644
index 000000000000..9846be8a43a8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/golly/beta.nix
@@ -0,0 +1,50 @@
+{lib, stdenv, fetchgit
+, wxGTK, perl, python2, zlib, libGLU, libGL, libX11
+, automake, autoconf
+}:
+
+stdenv.mkDerivation rec {
+  pname = "golly";
+  version = "2.8.99.2.20161122";
+  #src = fetchurl {
+  #  url="mirror://sourceforge/project/golly/golly/golly-2.8/golly-2.8-src.tar.gz";
+  #  sha256="0a4vn2hm7h4b47v2iwip1z3n9y8isf79v08aipl2iqms2m3p5204";
+  #};
+  src = fetchgit {
+    url = "git://git.code.sf.net/p/golly/code";
+    rev = "93495edf3c9639332c6eb43ca7149c69629ee5d8";
+    sha256 = "1j308s9zlqkr3wnl1l32s5zk7r3g4ijwawkkysl8j5ik9sibi2gk";
+  };
+
+  setSourceRoot = ''
+    export sourceRoot="$(echo */gui-wx/configure)"
+  '';
+
+  nativeBuildInputs = [autoconf automake];
+
+  buildInputs = [
+    wxGTK perl python2 zlib libGLU libGL libX11
+  ];
+
+  # Link against Python explicitly as it is needed for scripts
+  makeFlags=[
+    "AM_LDFLAGS="
+  ];
+  NIX_LDFLAGS="-l${python2.libPrefix} -lperl -ldl -lGL";
+  preConfigure=''
+    export NIX_LDFLAGS="$NIX_LDFLAGS -L$(dirname "$(find ${perl} -name libperl.so)")"
+    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE
+      -DPYTHON_SHLIB=$(basename "$(
+        readlink -f ${python2}/lib/libpython*.so)")"
+
+    sh autogen.sh
+  '';
+
+  meta = {
+    description = "Cellular automata simulation program";
+    license = lib.licenses.gpl2;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.linux;
+    downloadPage = "https://sourceforge.net/projects/golly/files/golly";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/golly/default.nix b/nixpkgs/pkgs/applications/science/misc/golly/default.nix
new file mode 100644
index 000000000000..7d91c76579f9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/golly/default.nix
@@ -0,0 +1,54 @@
+{lib, stdenv, fetchurl, wxGTK, perl, python3, zlib, libGLU, libGL, libX11, SDL2}:
+stdenv.mkDerivation rec {
+  pname = "golly";
+  version = "4.1";
+
+  src = fetchurl {
+    sha256 = "1j30dpzy6wh8fv1j2750hzc6wb0nhk83knl9fapccxgxw9n5lrbc";
+    url="mirror://sourceforge/project/golly/golly/golly-${version}/golly-${version}-src.tar.gz";
+  };
+
+  buildInputs = [
+    wxGTK perl python3 zlib libGLU libGL libX11 SDL2
+  ];
+
+  setSourceRoot = ''
+    sourceRoot=$(echo */gui-wx/)
+  '';
+
+  postPatch = ''
+    sed -e '/gollydir =/agollydir += "/../share/golly/";' -i wxgolly.cpp
+    grep share/golly wxgolly.cpp
+
+    sed -e 's@PYTHON_SHLIB@${python3}/lib/libpython3.so@' -i wxprefs.cpp
+    sed -e 's@PERL_SHLIB@'"$(find "${perl}/lib/" -name libperl.so)"'@' -i wxprefs.cpp
+    ! grep _SHLIB *.cpp
+
+    grep /lib/libpython wxprefs.cpp
+    grep /libperl wxprefs.cpp
+  '';
+
+  makeFlags=[
+    "-f" "makefile-gtk"
+    "ENABLE_SOUND=1" "ENABLE_PERL=1"
+  ];
+
+  installPhase = ''
+    mkdir -p "$out/bin"
+    cp ../golly ../bgolly "$out/bin"
+
+    mkdir -p "$out/share/doc/golly/"
+    cp ../docs/*  "$out/share/doc/golly/"
+
+    mkdir -p "$out/share/golly"
+    cp -r ../{Help,Patterns,Scripts,Rules} "$out/share/golly"
+  '';
+
+  meta = {
+    description = "Cellular automata simulation program";
+    license = lib.licenses.gpl2;
+    maintainers = [lib.maintainers.raskin];
+    platforms = lib.platforms.linux;
+    downloadPage = "https://sourceforge.net/projects/golly/files/golly";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/gplates/default.nix b/nixpkgs/pkgs/applications/science/misc/gplates/default.nix
new file mode 100644
index 000000000000..7cbf37fcaf8a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/gplates/default.nix
@@ -0,0 +1,71 @@
+{ lib
+, stdenv
+, mkDerivation
+, fetchurl
+, cmake
+, doxygen
+, graphviz
+, boost
+, cgal_5
+, gdal
+, glew
+, gmp
+, libGL
+, libGLU
+, mpfr
+, proj
+, python3
+, qtxmlpatterns
+, qwt
+}:
+
+let
+  python = python3.withPackages (ps: with ps; [
+    numpy
+  ]);
+  boost' = boost.override {
+    enablePython = true;
+    inherit python;
+  };
+  cgal = cgal_5.override {
+    boost = boost';
+  };
+in mkDerivation rec {
+  pname = "gplates";
+  version = "2.3.0";
+
+  src = fetchurl {
+    name = "gplates_${version}_src.tar.bz2";
+    url = "https://www.earthbyte.org/download/8421/?uid=b89bb31428";
+    sha256 = "0lrcmcxc924ixddii8cyglqlwwxvk7f00g4yzbss5i3fgcbh8n96";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    doxygen
+    graphviz
+  ];
+
+  buildInputs = [
+    boost'
+    cgal
+    gdal
+    glew
+    gmp
+    libGL
+    libGLU
+    mpfr
+    proj
+    python
+    qtxmlpatterns
+    qwt
+  ];
+
+  meta = with lib; {
+    description = "Desktop software for the interactive visualisation of plate-tectonics";
+    homepage = "https://www.gplates.org";
+    license = licenses.gpl2Only;
+    platforms = platforms.all;
+    broken = stdenv.isDarwin; # never built on Hydra https://hydra.nixos.org/job/nixpkgs/trunk/gplates.x86_64-darwin
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/graphia/default.nix b/nixpkgs/pkgs/applications/science/misc/graphia/default.nix
new file mode 100644
index 000000000000..4f452c96b8e7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/graphia/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, lib, cmake, fetchFromGitHub
+, wrapQtAppsHook, qtbase, qtquickcontrols2, qtgraphicaleffects
+}:
+
+stdenv.mkDerivation rec {
+  pname = "graphia";
+  version = "2.2";
+
+  src = fetchFromGitHub {
+    owner = "graphia-app";
+    repo = "graphia";
+    rev = version;
+    sha256 = "sha256:05givvvg743sawqy2vhljkfgn5v1s907sflsnsv11ddx6x51na1w";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    wrapQtAppsHook
+  ];
+  buildInputs = [
+    qtbase
+    qtquickcontrols2
+    qtgraphicaleffects
+  ];
+
+  meta = with lib; {
+    description = "A visualisation tool for the creation and analysis of graphs.";
+    homepage = "https://graphia.app";
+    license = licenses.gpl3Only;
+    maintainers = [ maintainers.bgamari ];
+    platforms = platforms.all;
+    broken = stdenv.isDarwin; # never built on Hydra https://hydra.nixos.org/job/nixpkgs/trunk/graphia.x86_64-darwin
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/megam/default.nix b/nixpkgs/pkgs/applications/science/misc/megam/default.nix
new file mode 100644
index 000000000000..6c55027d3c6f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/megam/default.nix
@@ -0,0 +1,47 @@
+{ fetchurl, lib, stdenv, ocaml, makeWrapper, ncurses }:
+
+let version = "0.92"; in
+stdenv.mkDerivation {
+  pname = "megam";
+  inherit version;
+
+  src = fetchurl {
+    url = "http://hal3.name/megam/megam_src.tgz";
+    sha256 = "dc0e9f59ff8513449fe3bd40b260141f89c88a4edf6ddc8b8a394c758e49724e";
+  };
+
+  patches = [ ./ocaml-includes.patch ./ocaml-3.12.patch ];
+
+  buildInputs = [ ocaml ncurses ];
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  makeFlags = [ "CAML_INCLUDES=${ocaml}/lib/ocaml/caml" ];
+
+  # see https://bugzilla.redhat.com/show_bug.cgi?id=435559
+  dontStrip = true;
+
+  installPhase = ''
+    mkdir -pv $out/bin
+    cp -Rv megam $out/bin
+  '';
+
+
+  meta = {
+    description = "MEGA Model Optimization Package";
+
+    longDescription =
+      ''  The software here is an implementation of maximum likelihood
+          and maximum a posterior optimization of the parameters of
+          these models.  The algorithms used are much more efficient
+          than the iterative scaling techniques used in almost every
+          other maxent package out there.  '';
+
+    homepage = "http://www.umiacs.umd.edu/~hal/megam";
+
+    license = "non-commercial";
+
+    maintainers = [ ];
+    platforms = lib.platforms.gnu ++ lib.platforms.linux;  # arbitrary choice
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/megam/ocaml-3.12.patch b/nixpkgs/pkgs/applications/science/misc/megam/ocaml-3.12.patch
new file mode 100644
index 000000000000..8265acf6e4a7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/megam/ocaml-3.12.patch
@@ -0,0 +1,12 @@
+diff -ru megam_0.92/Makefile megam_0.92-b/Makefile
+--- megam_0.92/Makefile	2007-10-08 18:06:04.000000000 +0100
++++ megam_0.92-b/Makefile	2013-11-25 10:14:20.000000000 +0000
+@@ -59,7 +59,7 @@
+ 
+ WITHUNIX =unix.cma -cclib -lunix
+ 
+-WITHSTR =str.cma -cclib -lstr
++WITHSTR =str.cma -cclib -lcamlstr
+ 
+ WITHBIGARRAY =bigarray.cma -cclib -lbigarray
+ 
diff --git a/nixpkgs/pkgs/applications/science/misc/megam/ocaml-includes.patch b/nixpkgs/pkgs/applications/science/misc/megam/ocaml-includes.patch
new file mode 100644
index 000000000000..b3a56643448c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/megam/ocaml-includes.patch
@@ -0,0 +1,21 @@
+diff -ru megam_0.92/Makefile megam_0.92-b/Makefile
+--- megam_0.92/Makefile	2007-10-08 18:06:04.000000000 +0100
++++ megam_0.92-b/Makefile	2013-11-25 10:14:20.000000000 +0000
+@@ -41,7 +41,7 @@
+ #
+ # The Caml compilers. #
+ # You may fix here the path to access the Caml compiler on your machine
+-CAMLC = ocamlc -g
++CAMLC = ocamlc -g $(WITHCLIBS)
+ CAMLOPT = ocamlopt -unsafe -ccopt -O4 -ccopt -ffast-math -inline 99999 
+ CAMLDEP = ocamldep
+ CAMLLEX = ocamllex
+@@ -70,7 +70,7 @@
+ WITHDBM =dbm.cma -cclib -lmldbm -cclib -lndbm
+ 
+ #WITHCLIBS =-I /usr/lib/ocaml/3.09.2/caml
+-WITHCLIBS =-I /usr/lib/ocaml/caml
++WITHCLIBS =-I $(CAML_INCLUDES) 
+ 
+ ################ End of user's variables #####################
+ 
diff --git a/nixpkgs/pkgs/applications/science/misc/netlogo/default.nix b/nixpkgs/pkgs/applications/science/misc/netlogo/default.nix
new file mode 100644
index 000000000000..ed92dfb90dab
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/netlogo/default.nix
@@ -0,0 +1,58 @@
+{ jre, lib, stdenv, fetchurl, makeWrapper, makeDesktopItem }:
+
+let
+
+  desktopItem = makeDesktopItem rec {
+    name = "netlogo";
+    exec = name;
+    icon = name;
+    comment = "A multi-agent programmable modeling environment";
+    desktopName = "NetLogo";
+    categories = [ "Science" ];
+  };
+
+in
+
+stdenv.mkDerivation rec {
+  pname = "netlogo";
+  version = "6.1.1";
+
+  src = fetchurl {
+    url = "https://ccl.northwestern.edu/netlogo/${version}/NetLogo-${version}-64.tgz";
+    sha256 = "1j08df68pgggxqkmpzd369w4h97q0pivmmljdb48hjghx7hacblp";
+  };
+
+  src1 = fetchurl {
+    name = "netlogo.png";
+    url = "https://netlogoweb.org/assets/images/desktopicon.png";
+    sha256 = "1i43lhr31lzva8d2r0dxpcgr58x496gb5vmb0h2da137ayvifar8";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  installPhase = ''
+    mkdir -pv $out/share/netlogo $out/share/icons/hicolor/256x256/apps $out/share/applications $out/share/doc
+    cp -rv app $out/share/netlogo
+    cp -v readme.md $out/share/doc/
+
+    # launcher with `cd` is required b/c otherwise the model library isn't usable
+    makeWrapper "${jre}/bin/java" "$out/bin/netlogo" \
+      --run "cd $out/share/netlogo/app" \
+      --add-flags "-jar netlogo-${version}.jar"
+
+    cp $src1 $out/share/icons/hicolor/256x256/apps/netlogo.png
+    cp ${desktopItem}/share/applications/* $out/share/applications
+  '';
+
+  meta = with lib; {
+    description = "A multi-agent programmable modeling environment";
+    longDescription = ''
+      NetLogo is a multi-agent programmable modeling environment. It is used by
+      many tens of thousands of students, teachers and researchers worldwide.
+    '';
+    homepage = "https://ccl.northwestern.edu/netlogo/index.shtml";
+    license = licenses.gpl2;
+    maintainers = [ maintainers.dpaetzel ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/nextinspace/default.nix b/nixpkgs/pkgs/applications/science/misc/nextinspace/default.nix
new file mode 100644
index 000000000000..fd7e58183144
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/nextinspace/default.nix
@@ -0,0 +1,44 @@
+{ lib
+, fetchFromGitHub
+, python3
+}:
+
+python3.pkgs.buildPythonApplication rec {
+  pname = "nextinspace";
+  version = "2.0.3";
+  format = "pyproject";
+
+  src = fetchFromGitHub {
+    owner = "not-stirred";
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-Macx2pQglB95Bhc939TFVCHd1qvqJsco91EXKCIQLgg=";
+  };
+
+  nativeBuildInputs = with python3.pkgs; [
+    poetry-core
+  ];
+
+  pythonPath = with python3.pkgs; [
+    requests
+    tzlocal
+    colorama
+  ];
+
+  checkInputs = with python3.pkgs; [
+    pytest-lazy-fixture
+    pytestCheckHook
+    requests-mock
+  ];
+
+  pythonImportsCheck = [
+    "nextinspace"
+  ];
+
+  meta = with lib; {
+    description = "Print upcoming space-related events in your terminal";
+    homepage = "https://github.com/The-Kid-Gid/nextinspace";
+    license = licenses.gpl3Only;
+    maintainers = with maintainers; [ penguwin ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/combined/default.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/combined/default.nix
new file mode 100644
index 000000000000..0c2220b7ea28
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/combined/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, lib, openmodelica, symlinkJoin, gnumake, blas, lapack, makeWrapper }:
+symlinkJoin {
+  name = "openmodelica-combined";
+  paths = with openmodelica; [
+    omcompiler
+    omsimulator
+    omplot
+    omparser
+    omedit
+    omlibrary
+    omshell
+  ];
+
+  buildInputs = [ gnumake makeWrapper ];
+
+  postBuild = ''
+    wrapProgram $out/bin/OMEdit \
+      --prefix PATH : ${lib.makeBinPath [ gnumake stdenv.cc ]} \
+      --prefix LIBRARY_PATH : "${lib.makeLibraryPath [ blas lapack ]}" \
+      --set-default OPENMODELICALIBRARY "${openmodelica.omlibrary}/lib/omlibrary"
+  '';
+
+  meta = with lib; {
+    description = "An open-source Modelica-based modeling and simulation environment intended for industrial and academic usage";
+    homepage = "https://openmodelica.org";
+    license = licenses.gpl3Only;
+    maintainers = with maintainers; [ balodja smironov ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/default.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/default.nix
new file mode 100644
index 000000000000..10fccfdf6da8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/default.nix
@@ -0,0 +1,17 @@
+{ lib, newScope, libsForQt5, clangStdenv }:
+lib.makeScope newScope (self:
+  let
+    callPackage = self.newScope { stdenv = clangStdenv; };
+    callQtPackage = self.newScope (libsForQt5 // { stdenv = clangStdenv; });
+  in
+  {
+    mkOpenModelicaDerivation = callPackage ./mkderivation { };
+    omcompiler = callPackage ./omcompiler { };
+    omplot = callQtPackage ./omplot { };
+    omsimulator = callPackage ./omsimulator { };
+    omparser = callPackage ./omparser { };
+    omedit = callQtPackage ./omedit { };
+    omlibrary = callPackage ./omlibrary { };
+    omshell = callQtPackage ./omshell { };
+    combined = callPackage ./combined { };
+  })
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/mkderivation/default.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/mkderivation/default.nix
new file mode 100644
index 000000000000..088fa83b7d92
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/mkderivation/default.nix
@@ -0,0 +1,101 @@
+# mkOpenModelicaDerivation is an mkDerivation function for packages
+# from OpenModelica suite.
+
+{ stdenv, lib, fetchgit, autoconf, automake, libtool, cmake, autoreconfHook, symlinkJoin }:
+pkg:
+let
+  inherit (builtins) hasAttr getAttr length elemAt;
+  inherit (lib) attrByPath concatStringsSep;
+
+
+  # A few helpers functions:
+
+  # getAttrDef is just a getAttr with default fallback
+  getAttrDef = attr: default: x: attrByPath [ attr ] default x;
+
+  # getAttr-like helper for optional append to string:
+  # "Hello" + appendByAttr "a" " " {a = "world";} = "Hello world"
+  # "Hello" + appendByAttr "a" " " {} = "Hello"
+  appendByAttr = attr: sep: x: if hasAttr attr x then sep + (getAttr attr x) else "";
+
+  # Are there any OM dependencies at all?
+  ifDeps = length pkg.omdeps != 0;
+
+  # Dependencies of current OpenModelica-target joined in one file tree.
+  # Return the dep itself in case it is a single one.
+  joinedDeps =
+    if length pkg.omdeps == 1
+    then elemAt pkg.omdeps 0
+    else
+      symlinkJoin {
+        name = pkg.pname + "-omhome";
+        paths = pkg.omdeps;
+      };
+
+  # Should we run ./configure for the target pkg?
+  omautoconf = getAttrDef "omautoconf" false pkg;
+
+  # Name of the make target
+  omtarget = getAttrDef "omtarget" pkg.pname pkg;
+
+  # Directory of target sources
+  omdir = getAttrDef "omdir" pkg.pname pkg;
+
+  # Simple to to m4 configuration scripts
+  postPatch = lib.optionalString ifDeps ''
+    sed -i ''$(find -name omhome.m4) -e 's|if test ! -z "$USINGPRESETBUILDDIR"|if test ! -z "$USINGPRESETBUILDDIR" -a -z "$OMHOME"|'
+  '' +
+  appendByAttr "postPatch" "\n" pkg;
+
+  # Update shebangs in the scripts before running configuration.
+  preAutoreconf = "patchShebangs --build common" +
+    appendByAttr "preAutoreconf" "\n" pkg;
+
+  # Tell OpenModelica where built dependencies are located.
+  configureFlags = lib.optional ifDeps "--with-openmodelicahome=${joinedDeps}" ++
+    getAttrDef "configureFlags" [ ] pkg;
+
+  # Our own configurePhase that accounts for omautoconf
+  configurePhase = ''
+    runHook preConfigure
+    export configureFlags="''${configureFlags} --with-ombuilddir=$PWD/build --prefix=$prefix"
+    ./configure --no-recursion $configureFlags
+    ${lib.optionalString omautoconf "(cd ${omdir}; ./configure $configureFlags)"}
+    runHook postConfigure
+  '';
+
+  # Targets that we want to build ourselves:
+  deptargets = lib.forEach pkg.omdeps (dep: dep.omtarget);
+
+  # ... so we ask openmodelica makefile to skip those targets.
+  preBuild = ''
+    for target in ${concatStringsSep " " deptargets}; do
+      touch ''${target}.skip;
+    done
+  '' +
+  appendByAttr "preBuild" "\n" pkg;
+
+  makeFlags = "${omtarget}" +
+    appendByAttr "makeFlags" " " pkg;
+
+  installFlags = "-i " +
+    appendByAttr "installFlags" " " pkg;
+
+
+in
+stdenv.mkDerivation (pkg // {
+  inherit omtarget postPatch preAutoreconf configureFlags configurePhase preBuild makeFlags installFlags;
+
+  src = fetchgit (import ./src-main.nix);
+  version = "1.18.0";
+
+  nativeBuildInputs = getAttrDef "nativeBuildInputs" [ ] pkg
+    ++ [ autoconf automake libtool cmake autoreconfHook ];
+
+  buildInputs = getAttrDef "buildInputs" [ ] pkg
+    ++ lib.optional ifDeps joinedDeps;
+
+  dontUseCmakeConfigure = true;
+
+  hardeningDisable = [ "format" ];
+})
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/mkderivation/src-main.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/mkderivation/src-main.nix
new file mode 100644
index 000000000000..1ab8d9390db3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/mkderivation/src-main.nix
@@ -0,0 +1,7 @@
+{
+  url = "https://github.com/OpenModelica/OpenModelica/";
+  rev = "49be4faa5a625a18efbbd74cc2f5be86aeea37bb";
+  sha256 = "0klqiy4sdizl1djb9hb0arcvfcjz2mmnakrjx81mmxcbr8yq2016";
+  fetchSubmodules = true;
+}
+# Update with: nix run -f ./nixpkgs/default.nix nix-prefetch-git -c nix-prefetch-git 'https://github.com/OpenModelica/OpenModelica/' 'v1.18.0' --fetch-submodules
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/omcompiler/default.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/omcompiler/default.nix
new file mode 100644
index 000000000000..39591eceb40d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/omcompiler/default.nix
@@ -0,0 +1,63 @@
+{ stdenv
+, lib
+, gfortran
+, flex
+, bison
+, jre8
+, blas
+, lapack
+, curl
+, readline
+, expat
+, pkg-config
+, buildPackages
+, targetPackages
+, libffi
+, binutils
+, mkOpenModelicaDerivation
+}:
+let
+  isCross = stdenv.buildPlatform != stdenv.hostPlatform;
+  nativeOMCompiler = buildPackages.openmodelica.omcompiler;
+in
+mkOpenModelicaDerivation ({
+  pname = "omcompiler";
+  omtarget = "omc";
+  omdir = "OMCompiler";
+  omdeps = [ ];
+  omautoconf = true;
+
+  nativeBuildInputs = [
+    jre8
+    gfortran
+    flex
+    bison
+    pkg-config
+  ] ++ lib.optional isCross nativeOMCompiler;
+
+  buildInputs = [ targetPackages.stdenv.cc.cc blas lapack curl readline expat libffi binutils ];
+
+  postPatch = ''
+    sed -i -e '/^\s*AR=ar$/ s/ar/${stdenv.cc.targetPrefix}ar/
+               /^\s*ar / s/ar /${stdenv.cc.targetPrefix}ar /
+               /^\s*ranlib/ s/ranlib /${stdenv.cc.targetPrefix}ranlib /' \
+        $(find ./OMCompiler -name 'Makefile*')
+  '';
+
+  preFixup = ''
+    for entry in $(find $out -name libipopt.so); do
+      patchelf --shrink-rpath --allowed-rpath-prefixes /nix/store $entry
+      patchelf --set-rpath '$ORIGIN':"$(patchelf --print-rpath $entry)" $entry
+    done
+  '';
+
+  meta = with lib; {
+    description = "Modelica compiler from OpenModelica suite";
+    homepage = "https://openmodelica.org";
+    license = licenses.gpl3Only;
+    maintainers = with maintainers; [ balodja smironov ];
+    platforms = platforms.linux;
+  };
+} // lib.optionalAttrs isCross {
+  configureFlags = [ "--with-omc=${nativeOMCompiler}/bin/omc" ];
+})
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/omedit/default.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/omedit/default.nix
new file mode 100644
index 000000000000..b24a43f702bb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/omedit/default.nix
@@ -0,0 +1,38 @@
+{ lib
+, jre8
+, qmake
+, qtbase
+, qttools
+, qtwebkit
+, qtxmlpatterns
+, binutils
+, wrapQtAppsHook
+, openmodelica
+, mkOpenModelicaDerivation
+}:
+with openmodelica;
+mkOpenModelicaDerivation rec {
+  pname = "omedit";
+  omdir = "OMEdit";
+  omdeps = [ omcompiler omplot omparser omsimulator ];
+  omautoconf = true;
+
+  nativeBuildInputs = [ jre8 qmake qtbase qttools wrapQtAppsHook ];
+
+  buildInputs = [ qtwebkit qtxmlpatterns binutils ];
+
+  postPatch = ''
+    sed -i ''$(find -name qmake.m4) -e '/^\s*LRELEASE=/ s|LRELEASE=.*$|LRELEASE=${lib.getDev qttools}/bin/lrelease|'
+  '';
+
+  dontUseQmakeConfigure = true;
+  QMAKESPEC = "linux-clang";
+
+  meta = with lib; {
+    description = "A Modelica connection editor for OpenModelica";
+    homepage = "https://openmodelica.org";
+    license = licenses.gpl3Only;
+    maintainers = with maintainers; [ balodja smironov ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/omlibrary/default.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/omlibrary/default.nix
new file mode 100644
index 000000000000..a89b73eb8664
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/omlibrary/default.nix
@@ -0,0 +1,37 @@
+{ lib
+, stdenv
+, fetchgit
+, bash
+, pkg-config
+, jre8
+, libuuid
+, openmodelica
+, mkOpenModelicaDerivation
+}:
+let
+  fakegit = import ./fakegit.nix { inherit lib stdenv fetchgit bash; };
+in
+mkOpenModelicaDerivation {
+  pname = "omlibrary";
+  omdir = "libraries";
+  omtarget = "omlibrary-all";
+  omdeps = [ openmodelica.omcompiler ];
+
+  postPatch = ''
+    patchShebangs --build libraries
+    cp -fv ${fakegit}/bin/checkout-git.sh libraries/checkout-git.sh
+
+    # The EMOTH library is broken in OpenModelica 1.17.0
+    # Let's remove it from targets.
+    sed -i -e '/^OTHER_LIBS=/ s/EMOTH //' libraries/Makefile.libs
+  '';
+
+  meta = with lib; {
+    description = "A collection of Modelica libraries to use with OpenModelica,
+including Modelica Standard Library";
+    homepage = "https://openmodelica.org";
+    license = licenses.gpl3Only;
+    maintainers = with maintainers; [ balodja smironov ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/omlibrary/fakegit.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/omlibrary/fakegit.nix
new file mode 100644
index 000000000000..fdbc79aae599
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/omlibrary/fakegit.nix
@@ -0,0 +1,49 @@
+{ lib, stdenv, fetchgit, bash }:
+let
+  mkscript = path: text: ''
+    mkdir -pv `dirname ${path}`
+    cat > ${path} <<"EOF"
+    #!${bash}/bin/bash
+    ME=$(basename ${path})
+    ${text}
+    EOF
+    sed -i "s@%out@$out@g" ${path}
+    chmod +x ${path}
+  '';
+
+  hashname = r:
+    let
+      rpl = lib.replaceChars [ ":" "/" ] [ "_" "_" ];
+    in
+    (rpl r.url) + "-" + (rpl r.rev);
+
+in
+stdenv.mkDerivation {
+  name = "fakegit";
+
+  buildCommand = ''
+    mkdir -pv $out/repos
+    ${lib.concatMapStrings
+      (r: "cp -r ${fetchgit r} $out/repos/${hashname r}\n")
+      (import ./src-libs.nix)}
+
+    ${mkscript "$out/bin/checkout-git.sh" ''
+      if test "$#" -ne 4; then
+        echo "Usage: $0 DESTINATION URL GITBRANCH HASH"
+        exit 1
+      fi
+      DEST=$1
+      URL=`echo $2 | tr :/ __`
+      GITBRANCH=$3
+      REVISION=$4
+
+      REVISION=`echo $REVISION | tr :/ __`
+
+      rm -rf $DEST
+      mkdir -pv $DEST
+      echo "FAKEGIT cp -r %out/repos/$URL-$REVISION $DEST" >&2
+      cp -r %out/repos/$URL-$REVISION/* $DEST
+      chmod u+w -R $DEST
+    ''}
+  '';
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/omlibrary/src-libs.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/omlibrary/src-libs.nix
new file mode 100644
index 000000000000..dff5ee78936a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/omlibrary/src-libs.nix
@@ -0,0 +1,81 @@
+[
+{ url = "https://github.com/modelica-3rdparty/AdvancedNoise.git"; rev = "5ce57acd279dadd0d25b76a6b02d3f9e9d061246"; sha256 = "07jjbj0y6bak269md3xniqb5lgc33m92ar5qixqxj5yxdjaahfs2"; fetchSubmodules = true; }
+{ url = "https://github.com/RWTH-EBC/AixLib.git"; rev = "65e49ddf5c935846888a61aa303e52c909619079"; sha256 = "18xn8j3x3j4x9bpjgqnq0b6p3yzzsg5n62fv1ldqbbjcmi0vimd5"; fetchSubmodules = true; }
+{ url = "https://github.com/RWTH-EBC/AixLib.git"; rev = "v0.4.0"; sha256 = "0dw34mjq29n55xh51g1c9a9d0d8gbpn16gj309dfxn4v2hbnfvzx"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/AlgebraTestSuite.git"; rev = "b937e1a7f447138c59abec9b2092f84f16bf02e8"; sha256 = "0406inasx61dk7vcnziiyhxkna7g61a5hn0znnbxj817hz6q11zn"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/ApproxSpline.git"; rev = "28420f5c1a88c9cd069defbd8c05e4a78a090675"; sha256 = "07gpyi2brj5zpvrlsnflqjnhbrgxvpqbdshp8lp4lh9mnj5jv95d"; fetchSubmodules = true; }
+{ url = "https://github.com/OpenModelica/BioChem.git"; rev = "v1.0.2"; sha256 = "037bvj2lqrslg8k5r0rjgdzccslj9bj25b55k4g440vabm5p05qm"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/BondGraph.git"; rev = "20c23e60d12989bd4668ccac47659d82d39d29cc"; sha256 = "0yrkk708v4bvf423xb4zgpmnaj8qhq5primdg758ayddgli23wa9"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/BrineProp.git"; rev = "834fb3519ca8f89efe268582d39d00a7c3991150"; sha256 = "1iwqh4kr36wgxc0gci63gdgbqln2sap1w4bkydk1vkss2s302lg4"; fetchSubmodules = true; }
+{ url = "https://github.com/EDF-TREE/BuildSysPro.git"; rev = "v3.3.0"; sha256 = "1cvcany3q9p1xndarxa2d8mmqxdnqk22476q8l61nayz5qy25x61"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/BuildingControlLib.git"; rev = "v1.0.0"; sha256 = "0ckdxway0m755mbrl94k4458sijzgknlzsrf7xs5bjymxchm8r2m"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/BuildingSystems.git"; rev = "c3070d48015ee75c1577f349cb388a498bef7270"; sha256 = "0r876wm6f1xx4cli1lqlylpl3zgaddmy06hcafbnzry9j38vbz4y"; fetchSubmodules = true; }
+{ url = "https://github.com/lbl-srg/modelica-buildings.git"; rev = "v6.0.0"; sha256 = "0rnnk1clji0myzr7adggki6knbl6v8381vwnqgiz8mkxbmzdwm4f"; fetchSubmodules = true; }
+{ url = "https://github.com/lbl-srg/modelica-buildings.git"; rev = "v7.0.0"; sha256 = "04n04pp4zvyg8n8h7h79c3wyk7lmn940mh7qzs0lv76g1ybypnlz"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/Chemical.git"; rev = "5645573fced862430b7b598b4d7ec1a39c7aa0fa"; sha256 = "1kh7kpmjfz55pb8553srlnrh8l00nw21xf5mjzh7nx9b1rndnmyg"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/DeployStructLib.git"; rev = "v1.0"; sha256 = "1k4zw9lnd0javw4zigxc15l58yf7xdz36b7808g65qxy89w6ksr2"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/DisHeatLib.git"; rev = "b11f53379c122870a52f2da9b1705d2c911cd21d"; sha256 = "1vm96a4z0b40r0nisxrrzyvan4yphjdkx4ad655phva2636xb5rr"; fetchSubmodules = true; }
+{ url = "https://github.com/AHaumer/DriveControl.git"; rev = "b7233fd97a92867bb4ec2c3647c7f7e888398644"; sha256 = "0nyp1n8wrkjzfypsmjjzac0g9p4wbc1cxxr040fj20bqdg9l3h1b"; fetchSubmodules = true; }
+{ url = "https://github.com/christiankral/ElectroMechanicalDrives.git"; rev = "v2.2.0"; sha256 = "0012phmn1y9fgpph45lwbjk0yhm5czidf2z6khm8lddvk93wf31b"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/ExternData.git"; rev = "v2.5.0"; sha256 = "19dsyq1mk5vl54fqaffzqafm5w94l011cy7pg16c7i933dbqnkki"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica/ExternalMedia.git"; rev = "6138312c96142ff3c01190147e6277991bfa2fca"; sha256 = "1d9g2hbdvgz13j7kdi1kglkkllj9f00x3dwdp5piyypvs464jsn5"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/ExternalMemoryLib.git"; rev = "6488d5815bda23c665123baa916789e283e16d2c"; sha256 = "06y1i5w690b3b9x23nzls8y67fl7yd7bn4xl5j0dmyi4qx33aqda"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/FMITest.git"; rev = "a67a276083f4010b249802ad8fc70dc30c09adfd"; sha256 = "0mg8jlvlwql2nsjiy7c3rdibv73bkfk149ac0450d5pc0hfn9mln"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/FailureModes.git"; rev = "v1.2.1"; sha256 = "1z8bwrld1rkydgssab5gnrd76frrbky8qxi1lvlaf2jidj6bzn1l"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/FaultTriggering.git"; rev = "v0.6.6"; sha256 = "0a08yyrbg4a49s0bgqgyds6pidx9xr47yspvl9bdak1mq34qibip"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/FeedDriveLibrary.git"; rev = "1.0.1"; sha256 = "15fi9dj6zgl0fr90cwxqjbpphj0dwrrmk74hf25j6zd85w2ycqdz"; fetchSubmodules = true; }
+{ url = "https://github.com/DLR-SR/FractionalOrder.git"; rev = "99918820e346c362c3ad52d782c8215e5deeac4c"; sha256 = "1pycss6fqh86frfdbdfffjhaz09fz1558f9azgckhf8drx6ry1qs"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/Greenhouses-Library.git"; rev = "89ae0e8097eb0751abce2013d304fa5f9c09b885"; sha256 = "1q77xj6aysqsn3d7kjmcq7dihbw18iqm35ifzdi75xgf3cgwla4f"; fetchSubmodules = true; }
+{ url = "https://github.com/christiankral/HanserModelica.git"; rev = "v1.1.0"; sha256 = "0zwkrhg2y42m18p4z51izrickiv1vikgz0z7fpjia4dbppckav8i"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/HelmholtzMedia.git"; rev = "3b4a4bca94d388744b2d045344ea2f9b0b4d405b"; sha256 = "17fzpan89075vb5vbhw5ylgxcdsmj2vjnmmka7cgzh06izb69nvh"; fetchSubmodules = true; }
+{ url = "https://github.com/ibpsa/modelica-ibpsa.git"; rev = "v3.0.0"; sha256 = "0xwgfndlw76zfmiiqadl85l9na9igsqlmfcawx526sdw2lhhgics"; fetchSubmodules = true; }
+{ url = "https://github.com/open-ideas/IDEAS.git"; rev = "v2.1.0"; sha256 = "0xp0zg6ib5536d5vl361lsn5w5faqdf6djhcmfxns629wjima8rn"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/IndustrialControlSystems.git"; rev = "v1.1.0"; sha256 = "1nvgx94iy1pws0768anrl7ssjlzslb5mbp21j7xvf6wpqfmj0npc"; fetchSubmodules = true; }
+{ url = "https://github.com/christiankral/KeyWordIO.git"; rev = "v0.9.0"; sha256 = "10kvj6zn2r6m3403ja8nkkxbfcchkz0pfk3g70ibr76zivxb5nim"; fetchSubmodules = true; }
+{ url = "https://github.com/FishSim/LibRAS.git"; rev = "fca9de50a484a2213f3ca1b39e275c237c471688"; sha256 = "0w1c87sifq8klq0f2l70qxjrlvahyxy1cx9rln80rni4d427yc1k"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/LinearMPC.git"; rev = "v1.0"; sha256 = "1crj60i5f33l9pgip0xbv6ankcga7px0644cj7c2wnzn1fjmn2k8"; fetchSubmodules = true; }
+{ url = "https://github.com/looms-polimi/MEV.git"; rev = "v1.0.1"; sha256 = "1a7ih9lc01wzaq8a8aznggpi4aqnczyzq49q5hc4fqvmfwl7l0j3"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/ModPowerSystems.git"; rev = "df3afce27d5e935c4111f392275744a655abe216"; sha256 = "1b1fikm92lv6gj82imka3hxbjwv04i4h33y69yhcxdpqa6z6hm4z"; fetchSubmodules = true; }
+{ url = "https://github.com/OpenModelica/OpenModelica-ModelicaStandardLibrary.git"; rev = "4a91d52248b0f17415bba1d58881fc730bd94215"; sha256 = "19caxz6hvlrsls3b2387a24zwwnykbb138jpb42gwpy8jlh93yzi"; fetchSubmodules = true; }
+{ url = "https://github.com/OpenModelica/OpenModelica-ModelicaStandardLibrary.git"; rev = "cab27240a4a3ed4ea137226f056bbc0d79543f7a"; sha256 = "06y911i2hs7hg4ykhb8wngvxhwnaww8rsakwa7ssd047a7glzsb0"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/Modelica-Arduino.git"; rev = "v0.1.0"; sha256 = "1n34dksqhrn1synv2mp2ifk4dxyhp15f5v1jb1b3dbw9n19951qb"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/Modelica-GNU_ScientificLibrary.git"; rev = "9235ab28bdd7f0fe3e7abba48af53d73332858ec"; sha256 = "168g9gg12lfa863ifs41bnx6yd0yyjnal6986dgpm51dj5arw6id"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/Modelica-MVEM.git"; rev = "v1.0.1"; sha256 = "1p68691dnl06lgwm4bl9g036brn4vl7m5x3gq4rxc291339frixk"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/ModelicaADS.git"; rev = "v1.0.1"; sha256 = "0fhxrl07d7v3wa79d30psm1gxydc0p7s2akfirdx6dai0633skp9"; fetchSubmodules = true; }
+{ url = "https://github.com/xogeny/ModelicaBook.git"; rev = "v0.6.0"; sha256 = "0yqbll6p738yvpi1x11cjngpz2glda07mljrkjlm23p7l53x63dc"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-compliance/compliance.git"; rev = "8a91e75d8a26acc4de30fc0e5d5e9db83c970bd6"; sha256 = "1cym1wlgsvfrryq8zqzzrgs4wam1l7pc20q07hk3d615nhq21lg6"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/ModelicaDFR.git"; rev = "37a441934d05330cf3d13e9ec551954d27eca84c"; sha256 = "13rpcs8cl9x15vi655150zmhmg1iaxpzvxrl3rqif46zpl5dhlj2"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica/Modelica_DeviceDrivers.git"; rev = "v1.8.2"; sha256 = "16c0p9zn0qrraz59ivinibmikdd251plm1vqngznzhksjwvz6bja"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica/Modelica_LinearSystems2.git"; rev = "v2.3.5"; sha256 = "0rzicynqgayydxqynnairxk7ybg4alv1xnfz8cgkrpicl2g9bacg"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/Modelica_Requirements.git"; rev = "a427b5cb7997e9036c577d219e6b8a5d0c28389a"; sha256 = "1ihx46kifnfi9kw1g8nmd9sarl766whbzdk6a44alczsya4gg45k"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica/Modelica_Synchronous.git"; rev = "c8350276bfd945086962cf4150ba941b9c57ed13"; sha256 = "12ad7fpjy50ky3lvl65r9d5xvlzvw5yqdnbp4rsgl3qw7s3wrmja"; fetchSubmodules = true; }
+{ url = "https://github.com/jwindahlModelon/MultiPhaseMixtureMedia.git"; rev = "0bda0c58af6384f8e0edf7aa7520afb369af3e38"; sha256 = "11bqm69504bh4h05dxlwdmjfxwls06mr49cz47kl8jmrygkfi4i2"; fetchSubmodules = true; }
+{ url = "https://github.com/OpenIPSL/OpenIPSL.git"; rev = "v1.5.0"; sha256 = "09xrcz0rdxdy220ki5zyl7920y0a4lg24p0aibna4ad15vszhhwj"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/Optimisers.git"; rev = "e33c69edaad6dad8029167b0ca00533964a6fe37"; sha256 = "0hcxsrr2n4fzaxdjvgvqayz38kpfk86cclvg5pzcfmjc5bznb8bs"; fetchSubmodules = true; }
+{ url = "https://github.com/lochel/PNlib.git"; rev = "059545d48dd9ceeccfa3b4e47689ec8dd334dcd8"; sha256 = "1a0hxkgsi4klw9c8zav1dy2p1c85ald29gx82hfacwv55xl9f127"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/PVSystems.git"; rev = "v0.6.2"; sha256 = "0vcgvdaqfbn46lpzk0kvsif3d55wf8yzhkbdpf5zv04kv7zw25w9"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/PhotoVoltaics.git"; rev = "v1.6.0"; sha256 = "0zqx77z217iln3vfxn2v3c2jl0jz5kgcd96ylvimjnwr30mxr09n"; fetchSubmodules = true; }
+{ url = "https://github.com/MarekMatejak/Physiolibrary.git"; rev = "v2.3.1"; sha256 = "0nxfw63m278gaff18zz29n2s1vk4kwdbv2qvbjmcq86fl1i5b3bg"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/Physiomodel.git"; rev = "v1.0.0"; sha256 = "1sdhv5qgjqv3zdq57pkkrh04ainwv9n5zqd8mb9a3ybjmwdjf6f9"; fetchSubmodules = true; }
+{ url = "https://github.com/dzimmer/PlanarMechanics.git"; rev = "55224a9e76de8aa7f708236bd4d7dee624ecba50"; sha256 = "0hf7vi44adss86x5ahk5if7bdjgw773d8mb3d8ianq12g8azycyd"; fetchSubmodules = true; }
+{ url = "https://github.com/PowerGrids/PowerGrids.git"; rev = "v1.0.0"; sha256 = "06bx8mqvmizhfwg99djdfgh2mblc4wzmg0zq4ilrp586jwfninmz"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica/PowerSystems.git"; rev = "v1.0.0"; sha256 = "1xwhwich7gi6vl33zl2r78xdjklchgkjcnvww6390j20l1wjznkn"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica/PowerSystems.git"; rev = "f0721333f4875143565147a7d043bee1c300873b"; sha256 = "0gbvx0gzf3akb0w7yvdxfq2y4ps91cy5b93iwnvnw7652x716813"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/RealTimeCoordinationLibrary.git"; rev = "v1.0.2"; sha256 = "0ch4la04hm059ii5wzph9gsbvqhnfqrvvpqi57qn27bm10c4la0m"; fetchSubmodules = true; }
+{ url = "https://github.com/casella/ScalableTestSuite.git"; rev = "v1.11.5"; sha256 = "0bhj1q9b8d29nrbr253zszy1w1yvyizvyr3law1pqjj6mhbqmg4i"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/Servomechanisms.git"; rev = "3bf82ba5d3f31b4a0ae05f99ae690037358e153e"; sha256 = "1swka7d58wkg5pqv59lqgfi7gv6rg5vra4j6r76pn9czx9ddal8w"; fetchSubmodules = true; }
+{ url = "https://github.com/SolarTherm/SolarTherm.git"; rev = "203fb5af3b95c731c7fcbe2833d51fd420e80796"; sha256 = "1bh4y4igzd0k59xm8j14p52gnlbwkiwwy6bhhyarpr361yrchn33"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/Soltermica.git"; rev = "9f7224bd89335f95dffe1ccdaa094df5a3279fdf"; sha256 = "1bif3cnwjas6x7b8ahwkm7dbrqrfdqwwa26zmdc6zrpfncl3kqd0"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/SystemDynamics.git"; rev = "2f6bd9382c5aac2aff9148cd9113a418767734b6"; sha256 = "0ii2mj6ngwjir3gzyad8wsj86pvd6wzal91nz2y7gzwj1djchb3x"; fetchSubmodules = true; }
+{ url = "https://github.com/thom-marx/ThermalSeparation.git"; rev = "ffa0495ba829ecab105be4bfb3b7652625ec9c03"; sha256 = "1czm97bcrpp2jv0a0kd31a929wqlrlzdhdxvyy4w499dn20jzv1l"; fetchSubmodules = true; }
+{ url = "https://github.com/casella/ThermoPower.git"; rev = "650be2c8cbd5abc3535e92b865e509073afc8aeb"; sha256 = "08ijrx8xw43dadz5s3kiwa17ax9faq2wyq9gm0vlz9ddbkj0hcaq"; fetchSubmodules = true; }
+{ url = "https://openmodelica.org/git/ThermoSysPro.git"; rev = "db81ae1b5a6a85f6c6c7693244cafa6087e18ff5"; sha256 = "12fsf0xxxc1ja6vmm9ff85f8j5sg1lb7w4g57s2w3fkf4d3a7d0c"; fetchSubmodules = true; }
+{ url = "https://openmodelica.org/git/ThermoSysPro.git"; rev = "5cef9acb4dedf8af6f4638a4448f08a544ebd30b"; sha256 = "0ihnz1s4rs42yis9zym9nw29ia2lqz2yx2wblc50p6f221w7q78s"; fetchSubmodules = true; }
+{ url = "https://github.com/lenaRB/VVDRlib.git"; rev = "eae4981674642eddffc7f2aa3690320fcaddee0e"; sha256 = "0qxxk2xlas5mqyc1h8ndic208qj1sm5mr5y8664kv3py7i8jdqi4"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica/VehicleInterfaces.git"; rev = "v1.2.5"; sha256 = "044k17cpc88wprrvw03p6crm6dy6x9a6xj5104d5nln71lqz5sdq"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/WasteWater.git"; rev = "v2.1.0"; sha256 = "1dxr4m9j7b5266daj4klbrhvnkqr73sximdw9bk9v5qf0s28li99"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/WindPowerPlants.git"; rev = "v1.2.0"; sha256 = "1lyrqwsb6sm1wc7vlj72zk5cpjhhzh27fviiqayddqy2b903xish"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/ipsl.git"; rev = "v1.1.1"; sha256 = "1w2iah8c5d8n01wmxydjk0rrcxh88g8yjy2zmv403azcccq7byzp"; fetchSubmodules = true; }
+{ url = "https://github.com/modelica-3rdparty/netCDF-DataReader.git"; rev = "v2.5.0"; sha256 = "1pd5xf5bgz010lryv8bj6lvlfqn9p184csiffwj8icx7rycnlcqb"; fetchSubmodules = true; }
+{ url = "https://github.com/joewa/open-bldc-modelica.git"; rev = "58a83b5b36f267613de4676c95163489b1ddc2e7"; sha256 = "0wf6dn64d2psv9b3xg5227vzpk109r3dqzi4m2wwhrilaxs3v004"; fetchSubmodules = true; }
+]
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/omlibrary/update-src-libs.sh b/nixpkgs/pkgs/applications/science/misc/openmodelica/omlibrary/update-src-libs.sh
new file mode 100755
index 000000000000..b8f2e95923b5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/omlibrary/update-src-libs.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env nix-shell
+#! nix-shell -i bash -p bash
+
+CWD=$PWD
+
+chko() {
+  (
+    T=`mktemp -d`
+    trap "rm -rf $T" EXIT INT PIPE
+    cd $T
+    cat >check.nix <<EOF
+with import <nixpkgs> {};
+fetchgit `cat $CWD/../mkderivation/src-main.nix`
+EOF
+    nix-build check.nix
+    cat result/libraries/Makefile.libs
+  )
+}
+
+getsha256() {
+  URL=$(echo "$1" | sed 's/^"\(.*\)"$/\1/')
+  REV=$(echo "$2" | sed 's/^"\(.*\)"$/\1/')
+  SHA=$(nix run nixpkgs.nix-prefetch-git -c nix-prefetch-git --fetch-submodules "$URL" "$REV" 2>/dev/null | sed -n 's/.*"sha256": "\(.*\)",/\1/g p')
+  echo "{ url = $1; rev = $2; sha256 = \"$SHA\"; fetchSubmodules = true; }"
+}
+
+OUT=src-libs.nix
+
+echo '[' > $OUT
+
+chko |
+grep checkout-git.sh |
+tr \' \" |
+while read NM TGT URL BR REV ; do
+  echo Trying $TGT $URL $REV >&2
+  getsha256 $URL $REV >> $OUT || exit 1
+done
+
+echo ']' >> $OUT
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/omparser/Makefile.in.patch b/nixpkgs/pkgs/applications/science/misc/openmodelica/omparser/Makefile.in.patch
new file mode 100644
index 000000000000..a8f04203a8c9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/omparser/Makefile.in.patch
@@ -0,0 +1,22 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -23,7 +23,7 @@
+ omedit-testsuite: omedit-testsuite.skip
+ omedit-testsuite.skip: omedit.skip testsuite-depends
+ 	$(MAKE) -f $(defaultMakefileTarget) -C OMEdit/Testsuite
+-omparser: omparser.skip
++omparser: build-dirs omparser.skip
+ omparser.skip:
+ 	test -f $@ || $(MAKE) -C OMParser OMBUILDDIR=@OMBUILDDIR@ "host_short=@host_short@" CC="@CC@" CXX="@CXX@" CFLAGS="@CFLAGS@" CPPFLAGS="@CPPFLAGS@" CXXFLAGS="@CXXFLAGS@"
+ omsimulator: omsimulator.skip
+@@ -134,6 +134,10 @@
+ INSTALL_JAVADIR    = ${DESTDIR}${datadir}/omc/java
+ INSTALL_LOCALEDIR  = ${DESTDIR}${datadir}/locale
+ 
++build-dirs:
++	mkdir -p "@OMBUILDDIR@"/lib/@host_short@/omc
++	mkdir -p "@OMBUILDDIR@"/include/omc
++
+ install-dirs:
+ 	@test ! "${DESTDIR}/@prefix@" -ef "@OMBUILDDIR@" || (echo Error: Install and build dirs are the same && false)
+ 	if [ "@APP@" = ".app" ]; then mkdir -p ${INSTALL_APPDIR}; fi
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/omparser/default.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/omparser/default.nix
new file mode 100644
index 000000000000..cbf8f2255e76
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/omparser/default.nix
@@ -0,0 +1,28 @@
+{ lib
+, pkg-config
+, jre8
+, libuuid
+, openmodelica
+, mkOpenModelicaDerivation
+}:
+
+mkOpenModelicaDerivation rec {
+  pname = "omparser";
+  omdir = "OMParser";
+  omdeps = [ openmodelica.omcompiler ];
+
+  nativeBuildInputs = [ pkg-config ];
+
+  buildInputs = [ jre8 libuuid ];
+
+  patches = [ ./Makefile.in.patch ];
+
+  meta = with lib; {
+    description = "An antlr4-based parser of Modelica files from OpenModelica
+suite";
+    homepage = "https://openmodelica.org";
+    license = licenses.gpl3Only;
+    maintainers = with maintainers; [ balodja smironov ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/omplot/default.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/omplot/default.nix
new file mode 100644
index 000000000000..51ab89407f4c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/omplot/default.nix
@@ -0,0 +1,34 @@
+{ lib
+, qtbase
+, qttools
+, qmake
+, wrapQtAppsHook
+, openmodelica
+, mkOpenModelicaDerivation
+}:
+
+mkOpenModelicaDerivation rec {
+  pname = "omplot";
+  omdir = "OMPlot";
+  omdeps = [ openmodelica.omcompiler ];
+  omautoconf = true;
+
+  nativeBuildInputs = [ qtbase qttools qmake wrapQtAppsHook ];
+
+  postPatch = ''
+    sed -i OMPlot/Makefile.in -e 's|bindir = @includedir@|includedir = @includedir@|'
+    sed -i OMPlot/OMPlot/OMPlotGUI/*.pro -e '/INCLUDEPATH +=/s|$| ../../qwt/src|'
+    sed -i ''$(find -name qmake.m4) -e '/^\s*LRELEASE=/ s|LRELEASE=.*$|LRELEASE=${lib.getDev qttools}/bin/lrelease|'
+  '';
+
+  dontUseQmakeConfigure = true;
+  QMAKESPEC = "linux-clang";
+
+  meta = with lib; {
+    description = "Plotting tool for OpenModelica-generated results files";
+    homepage = "https://openmodelica.org";
+    license = licenses.gpl3Only;
+    maintainers = with maintainers; [ balodja smironov ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/omshell/default.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/omshell/default.nix
new file mode 100644
index 000000000000..3c39d62f92d6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/omshell/default.nix
@@ -0,0 +1,40 @@
+{ lib, qttools, qmake, qtwebkit, wrapQtAppsHook, readline, openmodelica, mkOpenModelicaDerivation }:
+
+mkOpenModelicaDerivation rec {
+  pname = "omshell";
+  omdir = "OMShell";
+  omdeps = [ openmodelica.omcompiler ];
+  omautoconf = true;
+
+  nativeBuildInputs = [ qmake wrapQtAppsHook ];
+
+  buildInputs = [ readline qtwebkit ];
+
+  postPatch = with openmodelica; ''
+    sed -i ''$(find -name qmake.m4) -e '/^\s*LRELEASE=/ s|LRELEASE=.*$|LRELEASE=${lib.getDev qttools}/bin/lrelease|'
+    sed -i OMShell/OMShell/OMShellGUI/*.pro -e '
+      s|\$\$\[QT_INSTALL_BINS\]/lrelease|${lib.getDev qttools}/bin/lrelease|
+      /^\s*OMCLIBS =/ s|\$\$(OMBUILDDIR)|${omcompiler}|
+      /^\s*OMCINC =/ s|\$\$(OMBUILDDIR)|${omcompiler}|
+    '
+    sed -i OMShell/OMShell/OMShellGUI/OMShell.config.in -e '
+      s|@OMBUILDDIR@|${omcompiler}|
+      s|@OPENMODELICAHOME@|${omcompiler}|
+    '
+    sed -i OMShell/mosh/src/Makefile.in -e '
+      /^CFLAGS =/ s|-I../../../build|-I${omcompiler}|
+      /^LIBS =/ s|-L@OMBUILDDIR@|-L${omcompiler}|
+      '
+  '';
+
+  dontUseQmakeConfigure = true;
+  QMAKESPEC = "linux-clang";
+
+  meta = with lib; {
+    description = "Interactive OpenModelica session shell";
+    homepage = "https://openmodelica.org";
+    license = licenses.gpl3Only;
+    maintainers = with maintainers; [ balodja smironov ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/omsimulator/default.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/omsimulator/default.nix
new file mode 100644
index 000000000000..d91d427a0770
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/omsimulator/default.nix
@@ -0,0 +1,26 @@
+{ lib
+, pkg-config
+, boost
+, readline
+, libxml2
+, openmodelica
+, mkOpenModelicaDerivation
+}:
+
+mkOpenModelicaDerivation rec {
+  pname = "omsimulator";
+  omdir = "OMSimulator";
+  omdeps = [ openmodelica.omcompiler ];
+
+  nativeBuildInputs = [ pkg-config ];
+
+  buildInputs = [ readline libxml2 boost ];
+
+  meta = with lib; {
+    description = "The OpenModelica FMI & SSP-based co-simulation environment";
+    homepage = "https://openmodelica.org";
+    license = licenses.gpl3Only;
+    maintainers = with maintainers; [ balodja smironov ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/openmvg/default.nix b/nixpkgs/pkgs/applications/science/misc/openmvg/default.nix
new file mode 100644
index 000000000000..585c5ac4f398
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmvg/default.nix
@@ -0,0 +1,49 @@
+{ lib, stdenv, fetchFromGitHub, pkg-config, cmake
+, libjpeg ? null
+, zlib ? null
+, libpng ? null
+, eigen ? null
+, libtiff ? null
+, enableExamples ? false
+, enableDocs ? false }:
+
+stdenv.mkDerivation rec {
+  version = "2.0";
+  pname = "openmvg";
+
+  src = fetchFromGitHub {
+    owner = "openmvg";
+    repo = "openmvg";
+    rev = "v${version}";
+    sha256 = "sha256-6F/xUgZpqY+v6CpwTBhIXI4JdT8HVB0P5JzOL66AVd8=";
+    fetchSubmodules = true;
+  };
+
+  buildInputs = [ libjpeg zlib libpng eigen libtiff ];
+
+  nativeBuildInputs = [ cmake pkg-config ];
+
+  cmakeFlags = [
+    "-DCMAKE_CXX_FLAGS=-std=c++11"
+    "-DOpenMVG_BUILD_EXAMPLES=${if enableExamples then "ON" else "OFF"}"
+    "-DOpenMVG_BUILD_DOC=${if enableDocs then "ON" else "OFF"}"
+  ];
+
+  cmakeDir = "./src";
+
+  dontUseCmakeBuildDir = true;
+
+  # This can be enabled, but it will exhause virtual memory on most machines.
+  enableParallelBuilding = false;
+
+  # Without hardeningDisable, certain flags are passed to the compile that break the build (primarily string format errors)
+  hardeningDisable = [ "all" ];
+
+  meta = {
+    description = "A library for computer-vision scientists and targeted for the Multiple View Geometry community";
+    homepage = "https://openmvg.readthedocs.io/en/latest/";
+    license = lib.licenses.mpl20;
+    platforms = lib.platforms.linux;
+    maintainers = with lib.maintainers; [ mdaiter ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/openmvs/default.nix b/nixpkgs/pkgs/applications/science/misc/openmvs/default.nix
new file mode 100644
index 000000000000..a92920c5e795
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmvs/default.nix
@@ -0,0 +1,77 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, pkg-config
+, cmake
+, eigen
+, opencv
+, ceres-solver
+, cgal
+, boost
+, vcg
+, gmp
+, mpfr
+, glog
+, gflags
+, libjpeg_turbo
+}:
+
+stdenv.mkDerivation {
+  pname = "openmvs";
+  version = "unstable-2018-05-26";
+
+  src = fetchFromGitHub {
+    owner = "cdcseacave";
+    repo = "openmvs";
+    rev = "939033c55b50478339084431aac2c2318041afad";
+    sha256 = "12dgkwwfdp24581y3i41gsd1k9hq0aw917q0ja5s0if4qbmc8pni";
+  };
+
+  buildInputs = [ eigen opencv ceres-solver cgal boost vcg gmp mpfr glog gflags libjpeg_turbo ];
+
+  nativeBuildInputs = [ cmake pkg-config ];
+
+  preConfigure = ''
+    cmakeFlagsArray=(
+      $cmakeFlagsArray
+      "-DCMAKE_CXX_FLAGS=-std=c++11"
+      "-DBUILD_SHARED_LIBS=ON"
+      "-DBUILD_STATIC_RUNTIME=ON"
+      "-DINSTALL_BIN_DIR=$out/bin"
+      "-DVCG_DIR=${vcg}"
+      "-DCGAL_ROOT=${cgal}/lib/cmake/CGAL"
+      "-DCERES_DIR=${ceres-solver}/lib/cmake/Ceres/"
+    )
+  '';
+
+  postFixup = ''
+    rp=$(patchelf --print-rpath $out/bin/DensifyPointCloud)
+    patchelf --set-rpath $rp:$out/lib/OpenMVS $out/bin/DensifyPointCloud
+
+    rp=$(patchelf --print-rpath $out/bin/InterfaceVisualSFM)
+    patchelf --set-rpath $rp:$out/lib/OpenMVS $out/bin/InterfaceVisualSFM
+
+    rp=$(patchelf --print-rpath $out/bin/ReconstructMesh)
+    patchelf --set-rpath $rp:$out/lib/OpenMVS $out/bin/ReconstructMesh
+
+    rp=$(patchelf --print-rpath $out/bin/RefineMesh)
+    patchelf --set-rpath $rp:$out/lib/OpenMVS $out/bin/RefineMesh
+
+    rp=$(patchelf --print-rpath $out/bin/TextureMesh)
+    patchelf --set-rpath $rp:$out/lib/OpenMVS $out/bin/TextureMesh
+  '';
+
+  cmakeDir = "./";
+
+  dontUseCmakeBuildDir = true;
+
+  meta = with lib; {
+    description = "A library for computer-vision scientists and especially targeted to the Multi-View Stereo reconstruction community";
+    homepage = "http://cdcseacave.github.io/openMVS/";
+    license = licenses.agpl3;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ mdaiter ];
+    # 20190414-174115: CMake cannot find CGAL which is passed as build input
+    broken = true;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/rink/default.nix b/nixpkgs/pkgs/applications/science/misc/rink/default.nix
new file mode 100644
index 000000000000..d319dbe3e704
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/rink/default.nix
@@ -0,0 +1,30 @@
+{ lib, stdenv, fetchFromGitHub, rustPlatform, openssl, pkg-config, ncurses
+, libiconv, Security }:
+
+rustPlatform.buildRustPackage rec {
+  version = "0.6.2";
+  pname = "rink";
+
+  src = fetchFromGitHub {
+    owner = "tiffany352";
+    repo = "rink-rs";
+    rev = "v${version}";
+    sha256 = "sha256-l2Rj15zaJm94EHwvOssfvYQNOoWj45Nq9M85n+A0vo4=";
+  };
+
+  cargoSha256 = "sha256-GhuvwVkDRFjC6BghaNMFZZG9hResTN1u0AuvIXlFmig=";
+
+  nativeBuildInputs = [ pkg-config ];
+  buildInputs = [ ncurses ]
+    ++ (if stdenv.isDarwin then [ libiconv Security ] else [ openssl ]);
+
+  # Some tests fail and/or attempt to use internet servers.
+  doCheck = false;
+
+  meta = with lib; {
+    description = "Unit-aware calculator";
+    homepage = "https://rinkcalc.app";
+    license = with licenses; [ mpl20 gpl3Plus ];
+    maintainers = with maintainers; [ sb0 Br1ght0ne ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/root/5.nix b/nixpkgs/pkgs/applications/science/misc/root/5.nix
new file mode 100644
index 000000000000..de85043f127e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/root/5.nix
@@ -0,0 +1,143 @@
+{ lib
+, stdenv
+, fetchurl
+, fetchpatch
+, cmake
+, pcre
+, pkg-config
+, python2
+, libX11
+, libXpm
+, libXft
+, libXext
+, libGLU
+, libGL
+, zlib
+, libxml2
+, lz4
+, xz
+, gsl_1
+, xxHash
+, Cocoa
+, OpenGL
+, noSplash ? false
+}:
+
+stdenv.mkDerivation rec {
+  pname = "root";
+  version = "5.34.38";
+
+  src = fetchurl {
+    url = "https://root.cern.ch/download/root_v${version}.source.tar.gz";
+    sha256 = "1ln448lszw4d6jmbdphkr2plwxxlhmjkla48vmmq750xc1lxlfrc";
+  };
+
+  nativeBuildInputs = [ cmake pkg-config ];
+  buildInputs = [ pcre python2 zlib libxml2 lz4 xz gsl_1 xxHash ]
+    ++ lib.optionals (!stdenv.isDarwin) [ libX11 libXpm libXft libXext libGLU libGL ]
+    ++ lib.optionals (stdenv.isDarwin) [ Cocoa OpenGL ]
+  ;
+
+  patches = [
+    ./sw_vers_root5.patch
+
+    # prevents rootcint from looking in /usr/includes and such
+    ./purify_include_paths_root5.patch
+
+    # disable dictionary generation for stuff that includes libc headers
+    # our glibc requires a modern compiler
+    ./disable_libc_dicts_root5.patch
+
+    (fetchpatch {
+      name = "root5-gcc9-fix.patch";
+      url = "https://github.com/root-project/root/commit/348f30a6a3b5905ef734a7bd318bc0ee8bca6dc9.diff";
+      sha256 = "0dvrsrkpacyn5z87374swpy7aciv9a8s6m61b4iqd7a956r67rn3";
+    })
+    (fetchpatch {
+      name = "root5-gcc10-fix.patch";
+      url = "https://github.com/root-project/root/commit/3c243b18768d3c3501faf3ca4e4acfc071021350.diff";
+      sha256 = "1hjmgnp4zx6im8ps78673x0rrhmfyy1nffhgxjlfl1r2z8cq210z";
+    })
+  ];
+
+  preConfigure = ''
+    # binutils 2.37 fixes
+    fixupList=(
+      cint/demo/gl/make0
+      cint/demo/exception/Makefile
+      cint/demo/makecint/KRcc/Makefile
+      cint/demo/makecint/Stub2/Make2
+      cint/demo/makecint/Array/Makefile
+      cint/demo/makecint/DArray/Makefile
+      cint/demo/makecint/ReadFile/Makefile
+      cint/demo/makecint/stl/Makefile
+      cint/demo/makecint/Stub2/Make1
+      cint/cint/include/makemat
+      cint/cint/lib/WildCard/Makefile
+      cint/cint/include/make.arc
+      cint/cint/lib/qt/Makefile
+      cint/cint/lib/pthread/Makefile
+      graf2d/asimage/src/libAfterImage/Makefile.in
+    )
+    for toFix in "''${fixupList[@]}"; do
+      substituteInPlace "$toFix" --replace "clq" "cq"
+    done
+
+    patchShebangs build/unix/
+    ln -s ${lib.getDev stdenv.cc.libc}/include/AvailabilityMacros.h cint/cint/include/
+  ''
+  # Fix CINTSYSDIR for "build" version of rootcint
+  # This is probably a bug that breaks out-of-source builds
+  + ''
+    substituteInPlace cint/cint/src/loadfile.cxx\
+      --replace 'env = "cint";' 'env = "'`pwd`'/cint";'
+  '' + lib.optionalString noSplash ''
+    substituteInPlace rootx/src/rootx.cxx --replace "gNoLogo = false" "gNoLogo = true"
+  '';
+
+  cmakeFlags = [
+    "-Drpath=ON"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+    "-Dalien=OFF"
+    "-Dbonjour=OFF"
+    "-Dcastor=OFF"
+    "-Dchirp=OFF"
+    "-Ddavix=OFF"
+    "-Ddcache=OFF"
+    "-Dfftw3=OFF"
+    "-Dfitsio=OFF"
+    "-Dfortran=OFF"
+    "-Dgfal=OFF"
+    "-Dgsl_shared=ON"
+    "-Dgviz=OFF"
+    "-Dhdfs=OFF"
+    "-Dkrb5=OFF"
+    "-Dldap=OFF"
+    "-Dmathmore=ON"
+    "-Dmonalisa=OFF"
+    "-Dmysql=OFF"
+    "-Dodbc=OFF"
+    "-Dopengl=ON"
+    "-Doracle=OFF"
+    "-Dpgsql=OFF"
+    "-Dpythia6=OFF"
+    "-Dpythia8=OFF"
+    "-Drfio=OFF"
+    "-Dsqlite=OFF"
+    "-Dssl=OFF"
+    "-Dxml=ON"
+    "-Dxrootd=OFF"
+  ]
+  ++ lib.optional stdenv.isDarwin "-DOPENGL_INCLUDE_DIR=${OpenGL}/Library/Frameworks";
+
+  setupHook = ./setup-hook.sh;
+
+  meta = with lib; {
+    homepage = "https://root.cern.ch/";
+    description = "A data analysis framework";
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ veprbl ];
+    license = licenses.lgpl21;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/root/default.nix b/nixpkgs/pkgs/applications/science/misc/root/default.nix
new file mode 100644
index 000000000000..872438158d66
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/root/default.nix
@@ -0,0 +1,192 @@
+{ stdenv
+, lib
+, fetchurl
+, fetchpatch
+, makeWrapper
+, cmake
+, git
+, ftgl
+, gl2ps
+, glew
+, gsl
+, lapack
+, libX11
+, libXpm
+, libXft
+, libXext
+, libGLU
+, libGL
+, libxml2
+, llvm_9
+, lz4
+, xz
+, openblas
+, pcre
+, nlohmann_json
+, pkg-config
+, python
+, xxHash
+, zlib
+, zstd
+, libAfterImage
+, giflib
+, libjpeg
+, libtiff
+, libpng
+, tbb
+, Cocoa
+, CoreSymbolication
+, OpenGL
+, noSplash ? false
+}:
+
+stdenv.mkDerivation rec {
+  pname = "root";
+  version = "6.24.06";
+
+  src = fetchurl {
+    url = "https://root.cern.ch/download/root_v${version}.source.tar.gz";
+    sha256 = "sha256-kH9p9LrKHk8w7rSXlZjKdZm2qoA8oEboDiW2u6oO9SI=";
+  };
+
+  nativeBuildInputs = [ makeWrapper cmake pkg-config git ];
+  buildInputs = [
+    ftgl
+    gl2ps
+    glew
+    pcre
+    zlib
+    zstd
+    lapack
+    libxml2
+    llvm_9
+    lz4
+    xz
+    gsl
+    openblas
+    xxHash
+    libAfterImage
+    giflib
+    libjpeg
+    libtiff
+    libpng
+    nlohmann_json
+    python.pkgs.numpy
+    tbb
+  ]
+  ++ lib.optionals (!stdenv.isDarwin) [ libX11 libXpm libXft libXext libGLU libGL ]
+  ++ lib.optionals (stdenv.isDarwin) [ Cocoa CoreSymbolication OpenGL ]
+  ;
+
+  patches = [
+    ./sw_vers.patch
+
+    # Fix builtin_llvm=OFF support
+    (fetchpatch {
+      url = "https://github.com/root-project/root/commit/0cddef5d3562a89fe254e0036bb7d5ca8a5d34d2.diff";
+      excludes = [ "interpreter/cling/tools/plugins/clad/CMakeLists.txt" ];
+      sha256 = "sha256-VxWUbxRHB3O6tERFQdbGI7ypDAZD3sjSi+PYfu1OAbM=";
+    })
+  ];
+
+  # Fix build against vanilla LLVM 9
+  postPatch = ''
+    sed \
+      -e '/#include "llvm.*RTDyldObjectLinkingLayer.h"/i#define private protected' \
+      -e '/#include "llvm.*RTDyldObjectLinkingLayer.h"/a#undef private' \
+      -i interpreter/cling/lib/Interpreter/IncrementalJIT.h
+  '';
+
+  preConfigure = ''
+    rm -rf builtins/*
+    substituteInPlace cmake/modules/SearchInstalledSoftware.cmake \
+      --replace 'set(lcgpackages ' '#set(lcgpackages '
+
+    # Don't require textutil on macOS
+    : > cmake/modules/RootCPack.cmake
+
+    # Hardcode path to fix use with cmake
+    sed -i cmake/scripts/ROOTConfig.cmake.in \
+      -e '1iset(nlohmann_json_DIR "${nlohmann_json}/lib/cmake/nlohmann_json/")'
+
+    patchShebangs build/unix/
+  '' + lib.optionalString noSplash ''
+    substituteInPlace rootx/src/rootx.cxx --replace "gNoLogo = false" "gNoLogo = true"
+  '' + lib.optionalString stdenv.isDarwin ''
+    # Eliminate impure reference to /System/Library/PrivateFrameworks
+    substituteInPlace core/CMakeLists.txt \
+      --replace "-F/System/Library/PrivateFrameworks" ""
+  '';
+
+  cmakeFlags = [
+    "-Drpath=ON"
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    "-DCMAKE_INSTALL_INCLUDEDIR=include"
+    "-Dbuiltin_llvm=OFF"
+    "-Dbuiltin_nlohmannjson=OFF"
+    "-Dbuiltin_openui5=OFF"
+    "-Dalien=OFF"
+    "-Dbonjour=OFF"
+    "-Dcastor=OFF"
+    "-Dchirp=OFF"
+    "-Dclad=OFF"
+    "-Ddavix=OFF"
+    "-Ddcache=OFF"
+    "-Dfail-on-missing=ON"
+    "-Dfftw3=OFF"
+    "-Dfitsio=OFF"
+    "-Dfortran=OFF"
+    "-Dimt=ON"
+    "-Dgfal=OFF"
+    "-Dgviz=OFF"
+    "-Dhdfs=OFF"
+    "-Dhttp=ON"
+    "-Dkrb5=OFF"
+    "-Dldap=OFF"
+    "-Dmonalisa=OFF"
+    "-Dmysql=OFF"
+    "-Dodbc=OFF"
+    "-Dopengl=ON"
+    "-Doracle=OFF"
+    "-Dpgsql=OFF"
+    "-Dpythia6=OFF"
+    "-Dpythia8=OFF"
+    "-Drfio=OFF"
+    "-Droot7=OFF"
+    "-Dsqlite=OFF"
+    "-Dssl=OFF"
+    "-Dtmva=ON"
+    "-Dvdt=OFF"
+    "-Dwebgui=OFF"
+    "-Dxml=ON"
+    "-Dxrootd=OFF"
+  ]
+  ++ lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${lib.getDev stdenv.cc.libc}/include"
+  ++ lib.optionals stdenv.isDarwin [
+    "-DOPENGL_INCLUDE_DIR=${OpenGL}/Library/Frameworks"
+    "-DCMAKE_DISABLE_FIND_PACKAGE_Python2=TRUE"
+
+    # fatal error: module map file '/nix/store/<hash>-Libsystem-osx-10.12.6/include/module.modulemap' not found
+    # fatal error: could not build module '_Builtin_intrinsics'
+    "-Druntime_cxxmodules=OFF"
+  ];
+
+  postInstall = ''
+    for prog in rootbrowse rootcp rooteventselector rootls rootmkdir rootmv rootprint rootrm rootslimtree; do
+      wrapProgram "$out/bin/$prog" \
+        --set PYTHONPATH "$out/lib" \
+        --set ${lib.optionalString stdenv.isDarwin "DY"}LD_LIBRARY_PATH "$out/lib"
+    done
+  '';
+
+  setupHook = ./setup-hook.sh;
+
+  meta = with lib; {
+    homepage = "https://root.cern.ch/";
+    description = "A data analysis framework";
+    platforms = platforms.unix;
+    maintainers = [ maintainers.veprbl ];
+    license = licenses.lgpl21;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/root/disable_libc_dicts_root5.patch b/nixpkgs/pkgs/applications/science/misc/root/disable_libc_dicts_root5.patch
new file mode 100644
index 000000000000..abd6222847ef
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/root/disable_libc_dicts_root5.patch
@@ -0,0 +1,27 @@
+diff --git a/cint/ROOT/CMakeLists.txt b/cint/ROOT/CMakeLists.txt
+--- a/cint/ROOT/CMakeLists.txt
++++ b/cint/ROOT/CMakeLists.txt
+@@ -47,21 +47,13 @@ set(CINTSTLDLLHEADERS
+     ${CMAKE_SOURCE_DIR}/cint/cint/lib/stdstrct/stdcxxfunc.h
+   )
+ set(CINTINCDLLNAMES 
+-    stdfunc 
++#    stdfunc 
+ #    stdcxxfunc
+    )
+ set(CINTINCDLLHEADERS
+-    ${CMAKE_SOURCE_DIR}/cint/cint/lib/stdstrct/stdfunc.h 
++#    ${CMAKE_SOURCE_DIR}/cint/cint/lib/stdstrct/stdfunc.h 
+ #    ${CMAKE_SOURCE_DIR}/cint/cint/lib/stdstrct/stdcxxfunc.h
+    )
+-if(NOT WIN32)
+-  set(CINTSTLDLLNAMES ${CINTSTLDLLNAMES}  valarray)
+-  set(CINTSTLDLLHEADERS ${CINTSTLDLLHEADERS} ${CINTDLLDIR}/vary.h)
+-  set(CINTINCDLLNAMES ${CINTINCDLLNAMES} posix ipc)
+-  set(CINTINCDLLHEADERS ${CINTINCDLLHEADERS} 
+-    ${CMAKE_SOURCE_DIR}/cint/cint/lib/posix/exten.h 
+-    ${CMAKE_SOURCE_DIR}/cint/cint/lib/ipc/ipcif.h)
+-endif()
+ 
+ set(CINTBUILDLOADER
+     vector 
diff --git a/nixpkgs/pkgs/applications/science/misc/root/purify_include_paths_root5.patch b/nixpkgs/pkgs/applications/science/misc/root/purify_include_paths_root5.patch
new file mode 100644
index 000000000000..6773603b8ad3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/root/purify_include_paths_root5.patch
@@ -0,0 +1,204 @@
+diff --git a/cint/cint/src/loadfile.cxx b/cint/cint/src/loadfile.cxx
+--- a/cint/cint/src/loadfile.cxx
++++ b/cint/cint/src/loadfile.cxx
+@@ -1365,92 +1365,6 @@ int G__statfilename(const char *filenamein, struct stat *statBuf,
+          }
+       }         
+ #endif /* G__EDU_VERSION */
+-      
+-#ifdef G__VISUAL
+-      /**********************************************
+-       * try /msdev/include
+-       **********************************************/
+-      if('\0'!=G__cintsysdir[0]) {
+-         workname.Format("/msdev/include/%s%s",filename(),addpost[i2]);
+-         res = stat( workname, statBuf );         
+-         if (res==0) {
+-            if (fullPath) fullPath->Swap(workname);
+-            return res;
+-         }
+-      }
+-#endif /* G__VISUAL */
+-         
+-#ifdef G__SYMANTEC
+-      /**********************************************
+-       * try /sc/include
+-       **********************************************/
+-      if('\0'!=G__cintsysdir[0]) {
+-         workname.Format("/sc/include/%s%s",filename(),addpost[i2]);
+-         res = stat( workname, statBuf );         
+-         if (res==0) {
+-            if (fullPath) fullPath->Swap(workname);
+-            return res;
+-         }
+-      }
+-#endif // G__SYMANTEC
+-         
+-#ifndef G__WIN32
+-      /**********************************************
+-       * try /usr/include/filename
+-       **********************************************/
+-      if('\0'!=G__cintsysdir[0]) {
+-         workname.Format("/usr/include/%s%s",filename(),addpost[i2]);
+-         res = stat( workname, statBuf );         
+-         if (res==0) {
+-            if (fullPath) fullPath->Swap(workname);
+-            return res;
+-         }
+-      }
+-#endif
+-      
+-#ifdef __GNUC__
+-      /**********************************************
+-       * try /usr/include/g++/filename
+-       **********************************************/
+-      if('\0'!=G__cintsysdir[0]) {
+-         workname.Format("/usr/include/g++/%s%s",filename(),addpost[i2]);
+-         res = stat( workname, statBuf );         
+-         if (res==0) {
+-            if (fullPath) fullPath->Swap(workname);
+-            return res;
+-         }
+-      }
+-#endif /* __GNUC__ */
+-      
+-#ifndef G__WIN32
+-      /* #ifdef __hpux */
+-      /**********************************************
+-       * try /usr/include/CC/filename
+-       **********************************************/
+-      if('\0'!=G__cintsysdir[0]) {
+-         workname.Format("/usr/include/CC/%s%s",filename(),addpost[i2]);
+-         res = stat( workname, statBuf );         
+-         if (res==0) {
+-            if (fullPath) fullPath->Swap(workname);
+-            return res;
+-         }
+-      }         
+-#endif
+-         
+-#ifndef G__WIN32
+-      /**********************************************
+-       * try /usr/include/codelibs/filename
+-       **********************************************/
+-      if('\0'!=G__cintsysdir[0]) {
+-         workname.Format("/usr/include/codelibs/%s%s"
+-                         ,filename(),addpost[i2]);
+-         res = stat( workname, statBuf );         
+-         if (res==0) {
+-            if (fullPath) fullPath->Swap(workname);
+-            return res;
+-         }
+-      }
+-#endif
+    }
+    return -1;
+ }
+@@ -1960,107 +1874,6 @@ int G__loadfile(const char *filenamein)
+       }
+       if(G__ifile.fp) break;
+ #endif /* G__EDU_VERSION */
+-
+-#ifdef G__VISUAL
+-      /**********************************************
+-       * try /msdev/include
+-       **********************************************/
+-      if('\0'!=G__cintsysdir[0]) {
+-         G__snprintf(G__ifile.name,G__MAXFILENAME,"/msdev/include/%s%s",filename(),addpost[i2]);
+-#ifndef G__WIN32
+-        G__ifile.fp = fopen(G__ifile.name,"r");
+-#else
+-        G__ifile.fp = fopen(G__ifile.name,"rb");
+-#endif
+-        G__globalcomp=G__store_globalcomp;
+-      }
+-      if(G__ifile.fp) break;
+-#endif /* G__VISUAL */
+-
+-#ifdef G__SYMANTEC
+-      /**********************************************
+-       * try /sc/include
+-       **********************************************/
+-      if('\0'!=G__cintsysdir[0]) {
+-         G__snprintf(G__ifile.name,G__MAXFILENAME,"/sc/include/%s%s",filename(),addpost[i2]);
+-#ifndef G__WIN32
+-        G__ifile.fp = fopen(G__ifile.name,"r");
+-#else
+-        G__ifile.fp = fopen(G__ifile.name,"rb");
+-#endif
+-        G__globalcomp=G__store_globalcomp;
+-      }
+-      if(G__ifile.fp) break;
+-#endif /* G__SYMANTEC */
+-
+-#ifndef G__WIN32
+-      /**********************************************
+-       * try /usr/include/filename
+-       **********************************************/
+-      if('\0'!=G__cintsysdir[0]) {
+-         G__snprintf(G__ifile.name,G__MAXFILENAME,"/usr/include/%s%s",filename(),addpost[i2]);
+-#ifndef G__WIN32
+-        G__ifile.fp = fopen(G__ifile.name,"r");
+-#else
+-        G__ifile.fp = fopen(G__ifile.name,"rb");
+-#endif
+-        G__globalcomp=G__store_globalcomp;
+-      }
+-      if(G__ifile.fp) break;
+-#endif
+-
+-#ifdef __GNUC__
+-      /**********************************************
+-       * try /usr/include/g++/filename
+-       **********************************************/
+-      if('\0'!=G__cintsysdir[0]) {
+-         G__snprintf(G__ifile.name,G__MAXFILENAME,"/usr/include/g++/%s%s",filename(),addpost[i2]);
+-#ifndef G__WIN32
+-        G__ifile.fp = fopen(G__ifile.name,"r");
+-#else
+-        G__ifile.fp = fopen(G__ifile.name,"rb");
+-#endif
+-        G__globalcomp=G__store_globalcomp;
+-      }
+-      if(G__ifile.fp) break;
+-#endif /* __GNUC__ */
+-
+-#ifndef G__WIN32
+-/* #ifdef __hpux */
+-      /**********************************************
+-       * try /usr/include/CC/filename
+-       **********************************************/
+-      if('\0'!=G__cintsysdir[0]) {
+-         G__snprintf(G__ifile.name,G__MAXFILENAME,"/usr/include/CC/%s%s",filename(),addpost[i2]);
+-#ifndef G__WIN32
+-        G__ifile.fp = fopen(G__ifile.name,"r");
+-#else
+-        G__ifile.fp = fopen(G__ifile.name,"rb");
+-#endif
+-        G__globalcomp=G__store_globalcomp;
+-      }
+-      if(G__ifile.fp) break;
+-/* #endif __hpux */
+-#endif
+-
+-#ifndef G__WIN32
+-/* #ifdef __hpux */
+-      /**********************************************
+-       * try /usr/include/codelibs/filename
+-       **********************************************/
+-      if('\0'!=G__cintsysdir[0]) {
+-        G__snprintf(G__ifile.name,G__MAXFILENAME,"/usr/include/codelibs/%s%s"
+-                    ,filename(),addpost[i2]);
+-#ifndef G__WIN32
+-        G__ifile.fp = fopen(G__ifile.name,"r");
+-#else
+-        G__ifile.fp = fopen(G__ifile.name,"rb");
+-#endif
+-        G__globalcomp=G__store_globalcomp;
+-      }
+-      if(G__ifile.fp) break;
+-/* #endif __hpux */
+-#endif
+     }
+   }
+ 
diff --git a/nixpkgs/pkgs/applications/science/misc/root/setup-hook.sh b/nixpkgs/pkgs/applications/science/misc/root/setup-hook.sh
new file mode 100644
index 000000000000..b26cf9b779f8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/root/setup-hook.sh
@@ -0,0 +1,13 @@
+thisroot () {
+    # Workaround thisroot.sh dependency on man
+    if [ -z "${MANPATH-}" ]; then
+        MANPATH=:
+    fi
+    local oldOpts="-u"
+    shopt -qo nounset || oldOpts="+u"
+    set +u
+    source @out@/bin/thisroot.sh
+    set "$oldOpts"
+}
+
+postHooks+=(thisroot)
diff --git a/nixpkgs/pkgs/applications/science/misc/root/sw_vers.patch b/nixpkgs/pkgs/applications/science/misc/root/sw_vers.patch
new file mode 100644
index 000000000000..836bbb5b17a4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/root/sw_vers.patch
@@ -0,0 +1,87 @@
+diff a/cmake/modules/SetUpMacOS.cmake b/cmake/modules/SetUpMacOS.cmake
+--- a/cmake/modules/SetUpMacOS.cmake
++++ b/cmake/modules/SetUpMacOS.cmake
+@@ -28,17 +28,10 @@ if(CMAKE_VERSION VERSION_LESS 3.14.4)
+ endif()
+ 
+ if (CMAKE_SYSTEM_NAME MATCHES Darwin)
+-  EXECUTE_PROCESS(COMMAND sw_vers "-productVersion"
+-                  COMMAND cut -d . -f 1-2
+-                  OUTPUT_VARIABLE MACOSX_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
+-
+   MESSAGE(STATUS "Found a macOS system ${MACOSX_VERSION}")
+ 
+-  if(MACOSX_VERSION VERSION_GREATER 10.7 AND ${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
+     set(libcxx ON CACHE BOOL "Build using libc++" FORCE)
+-  endif()
+ 
+-  if(MACOSX_VERSION VERSION_GREATER 10.4)
+     #TODO: check haveconfig and rpath -> set rpath true
+     #TODO: check Thread, define link command
+     #TODO: more stuff check configure script
+@@ -57,22 +50,7 @@ if (CMAKE_SYSTEM_NAME MATCHES Darwin)
+        SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -m64")
+        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
+        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
+-    else()
+-       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
+-       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
+-       SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -m32")
+     endif()
+-  endif()
+-
+-  if(MACOSX_VERSION VERSION_GREATER 10.6)
+-    set(MACOSX_SSL_DEPRECATED ON)
+-  endif()
+-  if(MACOSX_VERSION VERSION_GREATER 10.7)
+-    set(MACOSX_ODBC_DEPRECATED ON)
+-  endif()
+-  if(MACOSX_VERSION VERSION_GREATER 10.8)
+-    set(MACOSX_GLU_DEPRECATED ON)
+-  endif()
+ 
+   if (CMAKE_COMPILER_IS_GNUCXX)
+      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -W -Wshadow -Wall -Woverloaded-virtual -fsigned-char -fno-common")
+@@ -130,7 +108,6 @@ if (CMAKE_SYSTEM_NAME MATCHES Darwin)
+   endif()
+ 
+   #---Set Linker flags----------------------------------------------------------------------
+-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mmacosx-version-min=${MACOSX_VERSION}")
+ else (CMAKE_SYSTEM_NAME MATCHES Darwin)
+   MESSAGE(FATAL_ERROR "There is no setup for this this Apple system up to now. Don't know waht to do. Stop cmake at this point.")
+ endif (CMAKE_SYSTEM_NAME MATCHES Darwin)
+diff a/config/root-config.in b/config/root-config.in
+--- a/config/root-config.in
++++ b/config/root-config.in
+@@ -312,12 +312,6 @@ macosxicc)
+    ;;
+ macosx64|macosxarm64)
+    # MacOS X with gcc (GNU cc v4.x) in 64 bit mode
+-   macosx_major=`sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 1 | sed -e 's/^[[:space:]]*//'`
+-   macosx_minor=`sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2`
+-   # cannot find the one linked to libGraf if relocated after built
+-   if [ $macosx_major -eq 10 -a $macosx_minor -le 4 ]; then
+-      rootlibs="$rootlibs -lfreetype"
+-   fi
+    auxcflags="${cxxversionflag} -m64"
+    auxldflags="-m64"
+    auxlibs="-lm -ldl"
+@@ -378,18 +372,11 @@ freebsd* | openbsd* | linux*)
+    done
+    ;;
+ macosx*)
+-   if [ \( $macosx_major -eq 10 -a $macosx_minor -ge 5 \) -o $macosx_major -gt 10  ]; then
+       auxcflags="-pthread $auxcflags"
+       auxlibs="-lpthread $auxlibs"
+-   else
+-      auxcflags="-D_REENTRANT $auxcflags"
+-      auxlibs="-lpthread $auxlibs"
+-   fi
+    for f in $features ; do
+       if test "x$f" = "xrpath" ; then
+-         if [ \( $macosx_major -eq 10 -a $macosx_minor -ge 5 \) -o $macosx_major -gt 10  ]; then
+             auxlibs="-Wl,-rpath,$libdir $auxlibs"
+-         fi
+       fi
+       if test "x$f" = "xlibcxx" ; then
+          auxcflags="-stdlib=libc++ $auxcflags"
diff --git a/nixpkgs/pkgs/applications/science/misc/root/sw_vers_root5.patch b/nixpkgs/pkgs/applications/science/misc/root/sw_vers_root5.patch
new file mode 100644
index 000000000000..f044bed91f3d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/root/sw_vers_root5.patch
@@ -0,0 +1,104 @@
+diff --git a/build/unix/compiledata.sh b/build/unix/compiledata.sh
+--- a/build/unix/compiledata.sh
++++ b/build/unix/compiledata.sh
+@@ -49,7 +49,7 @@ fi
+ 
+ if [ "$ARCH" = "macosx" ] || [ "$ARCH" = "macosx64" ] || \
+    [ "$ARCH" = "macosxicc" ]; then
+-   macosx_minor=`sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2`
++   macosx_minor=7
+    SOEXT="so"
+    if [ $macosx_minor -ge 5 ]; then
+       if [ "x`echo $SOFLAGS | grep -- '-install_name'`" != "x" ]; then
+diff --git a/cmake/modules/SetUpMacOS.cmake b/cmake/modules/SetUpMacOS.cmake
+--- a/cmake/modules/SetUpMacOS.cmake
++++ b/cmake/modules/SetUpMacOS.cmake
+@@ -12,25 +12,11 @@ set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} /usr/X11R6)
+ #---------------------------------------------------------------------------------------------------------
+ 
+ if (CMAKE_SYSTEM_NAME MATCHES Darwin)
+-  EXECUTE_PROCESS(COMMAND sw_vers "-productVersion"
+-                  COMMAND cut -d . -f 1-2
+-                  OUTPUT_VARIABLE MACOSX_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
+-  MESSAGE(STATUS "Found a Mac OS X System ${MACOSX_VERSION}")
+-  EXECUTE_PROCESS(COMMAND sw_vers "-productVersion"
+-                  COMMAND cut -d . -f 2
+-                  OUTPUT_VARIABLE MACOSX_MINOR OUTPUT_STRIP_TRAILING_WHITESPACE)
+-
+-  if(MACOSX_VERSION VERSION_GREATER 10.7 AND ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
+     set(libcxx ON CACHE BOOL "Build using libc++" FORCE)
+-  endif()
+ 
+-  if(${MACOSX_MINOR} GREATER 4)
+     #TODO: check haveconfig and rpath -> set rpath true
+     #TODO: check Thread, define link command
+     #TODO: more stuff check configure script
+-    execute_process(COMMAND /usr/sbin/sysctl machdep.cpu.extfeatures OUTPUT_VARIABLE SYSCTL_OUTPUT)
+-    if(${SYSCTL_OUTPUT} MATCHES 64)
+-       MESSAGE(STATUS "Found a 64bit system")
+        set(ROOT_ARCHITECTURE macosx64)
+        SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
+        SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -m64")
+@@ -38,28 +24,6 @@ if (CMAKE_SYSTEM_NAME MATCHES Darwin)
+        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
+        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
+        SET(CMAKE_FORTRAN_FLAGS "${CMAKE_FORTRAN_FLAGS} -m64")
+-    else(${SYSCTL_OUTPUT} MATCHES 64)
+-       MESSAGE(STATUS "Found a 32bit system")
+-       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
+-       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
+-       SET(CMAKE_FORTRAN_FLAGS "${CMAKE_FORTRAN_FLAGS} -m32")
+-    endif(${SYSCTL_OUTPUT} MATCHES 64)
+-  endif()
+-
+-  if(MACOSX_VERSION VERSION_GREATER 10.6)
+-    set(MACOSX_SSL_DEPRECATED ON)
+-  endif()
+-  if(MACOSX_VERSION VERSION_GREATER 10.7)
+-    set(MACOSX_ODBC_DEPRECATED ON)
+-  endif()
+-  if(MACOSX_VERSION VERSION_GREATER 10.8)
+-    set(MACOSX_GLU_DEPRECATED ON)
+-    set(MACOSX_KRB5_DEPRECATED ON)
+-    set(MACOSX_TMPNAM_DEPRECATED ON)
+-  endif()
+-  if(MACOSX_VERSION VERSION_GREATER 10.9)
+-    set(MACOSX_LDAP_DEPRECATED ON)
+-  endif()
+ 
+   if (CMAKE_COMPILER_IS_GNUCXX)
+      message(STATUS "Found GNU compiler collection")
+@@ -132,7 +96,7 @@ if (CMAKE_SYSTEM_NAME MATCHES Darwin)
+   endif()
+ 
+   #---Set Linker flags----------------------------------------------------------------------
+-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}  -mmacosx-version-min=${MACOSX_VERSION} -Wl,-rpath,@loader_path/../lib")
++  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,@loader_path/../lib")
+ 
+ 
+ else (CMAKE_SYSTEM_NAME MATCHES Darwin)
+diff --git a/config/root-config.in b/config/root-config.in
+--- a/config/root-config.in
++++ b/config/root-config.in
+@@ -391,7 +391,7 @@ macosxicc)
+    ;;
+ macosx64)
+    # MacOS X with gcc (GNU cc v4.x) in 64 bit mode
+-   macosx_minor=`sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2`
++   macosx_minor=7
+    # cannot find the one linked to libGraf if relocated after built
+    if [ $macosx_minor -le 4 ]; then
+       rootlibs="$rootlibs -lfreetype"
+diff --git a/cint/ROOT/CMakeLists.txt b/cint/ROOT/CMakeLists.txt
+--- a/cint/ROOT/CMakeLists.txt
++++ b/cint/ROOT/CMakeLists.txt
+@@ -232,9 +232,7 @@ foreach(_name ${CINTINCDLLNAMES})
+                        DEPENDS ${HEADER_OUTPUT_PATH}/systypes.h
+                       )
+
+-    if(MACOSX_MINOR GREATER 4)
+       set(_ExtraFlag "-D__DARWIN_UNIX03")
+-    endif()
+
+     add_custom_command(OUTPUT ${OutFileName}
+                        COMMAND cint_tmp -K -w1 -z${_name} -n${OutFileName} -D__MAKECINT__ -DG__MAKECINT ${_ExtraFlag} -c-2 -Z0 ${InFileName} ${AdditionalHeaderFiles} ${CMAKE_BINARY_DIR}/cint/cint/include/sys/types.h ${CMAKE_SOURCE_DIR}/cint/cint/lib/posix/posix.h
\ No newline at end of file
diff --git a/nixpkgs/pkgs/applications/science/misc/sasview/default.nix b/nixpkgs/pkgs/applications/science/misc/sasview/default.nix
new file mode 100644
index 000000000000..51dea2755785
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/sasview/default.nix
@@ -0,0 +1,62 @@
+{ lib
+, python3
+, fetchFromGitHub
+, which
+, wrapQtAppsHook
+}:
+
+python3.pkgs.buildPythonApplication rec {
+  pname = "sasview";
+  version = "5.0.4";
+
+  src = fetchFromGitHub {
+    owner = "SasView";
+    repo = "sasview";
+    rev = "v${version}";
+    hash = "sha256-TjcchqA6GCvkr59ZgDuGglan2RxLp+aMjJk28XhvoiY=";
+  };
+
+  nativeBuildInputs = [
+    python3.pkgs.pyqt5
+    wrapQtAppsHook
+  ];
+
+  propagatedBuildInputs = with python3.pkgs; [
+    bumps
+    h5py
+    lxml
+    periodictable
+    pillow
+    pyparsing
+    pyqt5
+    qt5reactor
+    sasmodels
+    scipy
+    setuptools
+    xhtml2pdf
+  ];
+
+  postBuild = ''
+    ${python3.interpreter} src/sas/qtgui/convertUI.py
+  '';
+
+  dontWrapQtApps = true;
+
+  makeWrapperArgs = [
+    "\${qtWrapperArgs[@]}"
+  ];
+
+  checkInputs = with python3.pkgs; [
+    pytestCheckHook
+    unittest-xml-reporting
+  ];
+
+  pytestFlagsArray = [ "test" ];
+
+  meta = with lib; {
+    homepage = "https://www.sasview.org";
+    description = "Fitting and data analysis for small angle scattering data";
+    maintainers = with maintainers; [ rprospero ];
+    license = licenses.bsd3;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/sasview/xhtml2pdf.nix b/nixpkgs/pkgs/applications/science/misc/sasview/xhtml2pdf.nix
new file mode 100644
index 000000000000..41d15e2f1bab
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/sasview/xhtml2pdf.nix
@@ -0,0 +1,33 @@
+{lib, fetchPypi, buildPythonPackage, html5lib, httplib2, nose, pillow, pypdf2, reportlab}:
+
+let
+  #xhtml2pdf specifically requires version "1.0b10" of html5lib
+  html5 = html5lib.overrideAttrs( oldAttrs: rec {
+    name = "${oldAttrs.pname}-${version}";
+    version = "1.0b10";
+    src = oldAttrs.src.override {
+      inherit version;
+      sha256 = "1yd068a5c00wd0ajq0hqimv7fd82lhrw0w3s01vbhy9bbd6xapqd";
+    };
+  });
+in
+
+buildPythonPackage rec {
+  pname = "xhtml2pdf";
+  version = "0.2.1";
+
+  buildInputs = [html5];
+  propagatedBuildInputs = [httplib2 nose pillow pypdf2 reportlab html5];
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "1n9r8zdk9gc2x539fq60bhszmd421ipj8g78zmsn3njvma1az9k1";
+  };
+
+  meta = {
+    description = "A pdf converter for the ReportLab Toolkit";
+    homepage = "https://github.com/xhtml2pdf/xhtml2pdf";
+    license = lib.licenses.asl20;
+    maintainers = with lib.maintainers; [ rprospero ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/simgrid/default.nix b/nixpkgs/pkgs/applications/science/misc/simgrid/default.nix
new file mode 100644
index 000000000000..888419fbc86f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/simgrid/default.nix
@@ -0,0 +1,120 @@
+{ stdenv, lib, fetchFromGitLab, cmake, perl, python3, boost
+, fortranSupport ? false, gfortran
+, buildDocumentation ? false, fig2dev, ghostscript, doxygen
+, buildJavaBindings ? false, openjdk
+, buildPythonBindings ? true, python3Packages
+, modelCheckingSupport ? false, libunwind, libevent, elfutils # Inside elfutils: libelf and libdw
+, minimalBindings ? false
+, debug ? false
+, optimize ? (!debug)
+, moreTests ? false
+, withoutBin ? false
+}:
+
+with lib;
+
+let
+  optionOnOff = option: if option then "on" else "off";
+in
+
+stdenv.mkDerivation rec {
+  pname = "simgrid";
+  version = "3.30";
+
+  src = fetchFromGitLab {
+    domain = "framagit.org";
+    owner = pname;
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "1dg8ywqif20g0fs8dnd6364n080nvwx7f444zcfwqwz6iax61qv1";
+  };
+
+  propagatedBuildInputs = [ boost ];
+  nativeBuildInputs = [ cmake perl python3 ]
+    ++ optionals fortranSupport [ gfortran ]
+    ++ optionals buildJavaBindings [ openjdk ]
+    ++ optionals buildPythonBindings [ python3Packages.pybind11 ]
+    ++ optionals buildDocumentation [ fig2dev ghostscript doxygen ]
+    ++ optionals modelCheckingSupport [ libunwind libevent elfutils ];
+
+  outputs = [ "out" ]
+    ++ optionals buildPythonBindings [ "python" ];
+
+  # "Release" does not work. non-debug mode is Debug compiled with optimization
+  cmakeBuildType = "Debug";
+  cmakeFlags = [
+    "-Denable_documentation=${optionOnOff buildDocumentation}"
+    "-Denable_java=${optionOnOff buildJavaBindings}"
+    "-Denable_python=${optionOnOff buildPythonBindings}"
+    "-DSIMGRID_PYTHON_LIBDIR=./" # prevents CMake to install in ${python3} dir
+    "-Denable_msg=${optionOnOff buildJavaBindings}"
+    "-Denable_fortran=${optionOnOff fortranSupport}"
+    "-Denable_model-checking=${optionOnOff modelCheckingSupport}"
+    "-Denable_ns3=off"
+    "-Denable_lua=off"
+    "-Denable_lib_in_jar=off"
+    "-Denable_maintainer_mode=off"
+    "-Denable_mallocators=on"
+    "-Denable_debug=on"
+    "-Denable_smpi=on"
+    "-Dminimal-bindings=${optionOnOff minimalBindings}"
+    "-Denable_smpi_ISP_testsuite=${optionOnOff moreTests}"
+    "-Denable_smpi_MPICH3_testsuite=${optionOnOff moreTests}"
+    "-Denable_compile_warnings=off"
+    "-Denable_compile_optimizations=${optionOnOff optimize}"
+    "-Denable_lto=${optionOnOff optimize}"
+  ];
+  makeFlags = optional debug "VERBOSE=1";
+
+  # needed to run tests and to ensure correct shabangs in output scripts
+  preBuild = ''
+    patchShebangs ..
+  '';
+
+  # needed by tests (so libsimgrid.so is found)
+  preConfigure = ''
+    export LD_LIBRARY_PATH="$PWD/build/lib"
+  '';
+
+  doCheck = true;
+  preCheck = ''
+    # prevent the execution of tests known to fail
+    cat <<EOW >CTestCustom.cmake
+    SET(CTEST_CUSTOM_TESTS_IGNORE smpi-replay-multiple)
+    EOW
+
+    # make sure tests are built in parallel (this can be long otherwise)
+    make tests -j $NIX_BUILD_CORES
+  '';
+
+  postInstall = lib.optionalString withoutBin ''
+    # remove bin from output if requested.
+    # having a specific bin output would be cleaner but it does not work currently (circular references)
+    rm -rf $out/bin
+  '' + lib.optionalString buildPythonBindings ''
+    # manually install the python binding if requested.
+    mkdir -p $python/lib/python${lib.versions.majorMinor python3.version}/site-packages/
+    cp ./lib/simgrid.cpython*.so $python/lib/python${lib.versions.majorMinor python3.version}/site-packages/
+   '';
+
+  # improve debuggability if requested
+  hardeningDisable = lib.optionals debug [ "fortify" ];
+  dontStrip = debug;
+
+  meta = {
+    description = "Framework for the simulation of distributed applications";
+    longDescription = ''
+      SimGrid is a toolkit that provides core functionalities for the
+      simulation of distributed applications in heterogeneous distributed
+      environments.  The specific goal of the project is to facilitate
+      research in the area of distributed and parallel application
+      scheduling on distributed computing platforms ranging from simple
+      network of workstations to Computational Grids.
+    '';
+    homepage = "https://simgrid.org/";
+    license = licenses.lgpl2Plus;
+    maintainers = with maintainers; [ mickours mpoquet ];
+    platforms = platforms.all;
+    broken = stdenv.isDarwin;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/snakemake/default.nix b/nixpkgs/pkgs/applications/science/misc/snakemake/default.nix
new file mode 100644
index 000000000000..f4a3da9711dd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/snakemake/default.nix
@@ -0,0 +1,71 @@
+{ lib, python3Packages, fetchFromGitHub }:
+
+python3Packages.buildPythonApplication rec {
+  pname = "snakemake";
+  version = "6.15.5";
+
+  propagatedBuildInputs = with python3Packages; [
+    appdirs
+    configargparse
+    connection-pool
+    datrie
+    docutils
+    filelock
+    GitPython
+    jinja2
+    jsonschema
+    nbformat
+    networkx
+    psutil
+    pulp
+    pygraphviz
+    pyyaml
+    ratelimiter
+    requests
+    smart-open
+    stopit
+    tabulate
+    toposort
+    wrapt
+  ];
+
+  src = fetchFromGitHub {
+    owner = "snakemake";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "sha256-i8C7gPLzUzSxNH9xwpr+fUKI1SvpYFsFBlspS74LoWU=";
+  };
+
+  # See
+  # https://github.com/snakemake/snakemake/blob/main/.github/workflows/main.yml#L99
+  # for the current basic test suite. Tibanna and Tes require extra
+  # setup.
+
+  checkInputs = with python3Packages; [
+    pandas
+    pytestCheckHook
+    requests-mock
+  ];
+
+  disabledTestPaths = [
+    "tests/test_tes.py"
+    "tests/test_tibanna.py"
+    "tests/test_linting.py"
+  ];
+
+  pythonImportsCheck = [ "snakemake" ];
+
+  meta = with lib; {
+    homepage = "https://snakemake.github.io";
+    license = licenses.mit;
+    description = "Python-based execution environment for make-like workflows";
+    longDescription = ''
+      Snakemake is a workflow management system that aims to reduce the complexity of
+      creating workflows by providing a fast and comfortable execution environment,
+      together with a clean and readable specification language in Python style. Snakemake
+      workflows are essentially Python scripts extended by declarative code to define
+      rules. Rules describe how to create output files from input files.
+    '';
+    maintainers = with maintainers; [ helkafen renatoGarcia veprbl ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/toil/default.nix b/nixpkgs/pkgs/applications/science/misc/toil/default.nix
new file mode 100644
index 000000000000..b13ad0ad10ca
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/toil/default.nix
@@ -0,0 +1,46 @@
+{ lib
+, fetchFromGitHub
+, python3
+}:
+
+python3.pkgs.buildPythonApplication rec {
+  pname = "toil";
+  version = "5.6.0";
+  format = "setuptools";
+
+  src = python3.pkgs.fetchPypi {
+    inherit pname version;
+    sha256 = "sha256-m6tzrRCCLULO+wB8htUlt0KESLm/vdIeTzBrihnAo/I=";
+  };
+
+  propagatedBuildInputs = with python3.pkgs; [
+    addict
+    docker
+    pytz
+    pyyaml
+    enlighten
+    psutil
+    py-tes
+    python-dateutil
+    dill
+  ];
+
+  checkInputs = with python3.pkgs; [
+    pytestCheckHook
+  ];
+
+  pytestFlagsArray = [
+    "src/toil/test"
+  ];
+
+  pythonImportsCheck = [
+    "toil"
+  ];
+
+  meta = with lib; {
+    description = "Workflow engine written in pure Python";
+    homepage = "https://toil.ucsc-cgl.org/";
+    license = with licenses; [ asl20 ];
+    maintainers = with maintainers; [ veprbl ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/tulip/default.nix b/nixpkgs/pkgs/applications/science/misc/tulip/default.nix
new file mode 100644
index 000000000000..87a05f146e9e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/tulip/default.nix
@@ -0,0 +1,40 @@
+{ fetchurl, lib, stdenv, libxml2, freetype, libGLU, libGL, glew
+, qtbase, wrapQtAppsHook, python3
+, cmake, libjpeg }:
+
+stdenv.mkDerivation rec {
+  pname = "tulip";
+  version = "5.6.1";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/auber/${pname}-${version}_src.tar.gz";
+    sha256 = "1fy3nvgxv3igwc1d23zailcgigj1d0f2kkh7a5j24c0dyqz5zxmw";
+  };
+
+  buildInputs = [ libxml2 freetype glew libGLU libGL libjpeg qtbase python3 ];
+  nativeBuildInputs = [ cmake wrapQtAppsHook ];
+
+  qtWrapperArgs = [ ''--prefix PATH : ${lib.makeBinPath [ python3 ]}'' ];
+
+  # FIXME: "make check" needs Docbook's DTD 4.4, among other things.
+  doCheck = false;
+
+  meta = {
+    description = "A visualization framework for the analysis and visualization of relational data";
+
+    longDescription =
+      '' Tulip is an information visualization framework dedicated to the
+         analysis and visualization of relational data.  Tulip aims to
+         provide the developer with a complete library, supporting the design
+         of interactive information visualization applications for relational
+         data that can be tailored to the problems he or she is addressing.
+      '';
+
+    homepage = "http://tulip.labri.fr/";
+
+    license = lib.licenses.gpl3Plus;
+
+    maintainers = [ ];
+    platforms = lib.platforms.gnu ++ lib.platforms.linux;  # arbitrary choice
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/vite/default.nix b/nixpkgs/pkgs/applications/science/misc/vite/default.nix
new file mode 100644
index 000000000000..7d284d5eebb7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/vite/default.nix
@@ -0,0 +1,46 @@
+{ fetchsvn, lib, stdenv, cmake, qt4, libGLU, libGL }:
+
+# ViTE 1.1 has several bugs, so use the SVN version.
+let
+  rev = "1543";
+  externals = fetchsvn {
+    url = "svn://scm.gforge.inria.fr/svn/vite/externals";
+    sha256 = "1a422n3dp72v4visq5b1i21cf8sj12903sgg5v2hah3sgk02dnyz";
+    inherit rev;
+  };
+in
+stdenv.mkDerivation {
+  pname = "vite";
+  version = "1.2pre${rev}";
+
+  src = fetchsvn {
+    url = "svn://scm.gforge.inria.fr/svn/vite/trunk";
+    sha256 = "02479dv96h29d0w0svp42mjjrxhmv8lkkqp30w7mlx5gr2g0v7lf";
+    inherit rev;
+  };
+
+  preConfigure = ''
+    rm -rv externals
+    ln -sv "${externals}" externals
+  '';
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ qt4 libGLU libGL ];
+
+  NIX_LDFLAGS = "-lGLU";
+
+  meta = {
+    description = "Visual Trace Explorer (ViTE), a tool to visualize execution traces";
+
+    longDescription = ''
+      ViTE is a trace explorer. It is a tool to visualize execution
+      traces in Pajé or OTF format for debugging and profiling
+      parallel or distributed applications.
+    '';
+
+    homepage = "http://vite.gforge.inria.fr/";
+    license = lib.licenses.cecill20;
+    maintainers = with lib.maintainers; [ ];
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/molecular-dynamics/dl-poly-classic/default.nix b/nixpkgs/pkgs/applications/science/molecular-dynamics/dl-poly-classic/default.nix
new file mode 100644
index 000000000000..cf4584979ba2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/molecular-dynamics/dl-poly-classic/default.nix
@@ -0,0 +1,39 @@
+{ lib, stdenv, fetchurl
+, gfortran, mpi
+}:
+
+stdenv.mkDerivation {
+  version = "1.10";
+  pname = "DL_POLY_Classic";
+
+  src = fetchurl {
+    url = "https://ccpforge.cse.rl.ac.uk/gf/download/frsrelease/574/8924/dl_class_1.10.tar.gz";
+    sha256 = "1r76zvln3bwycxlmqday0sqzv5j260y7mdh66as2aqny6jzd5ld7";
+  };
+
+  nativeBuildInputs = [ gfortran ];
+
+  buildInputs = [ mpi ];
+
+  configurePhase = ''
+    cd source
+    cp -v ../build/MakePAR Makefile
+  '';
+
+  buildPhase = ''
+    make dlpoly
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp -v ../execute/DLPOLY.X $out/bin
+  '';
+
+  meta = with lib; {
+    homepage = "https://www.ccp5.ac.uk/DL_POLY_C";
+    description = "DL_POLY Classic is a general purpose molecular dynamics simulation package";
+    license = licenses.bsdOriginal;
+    platforms = [ "x86_64-linux" ];
+    maintainers = [ maintainers.costrouc ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/molecular-dynamics/gromacs/default.nix b/nixpkgs/pkgs/applications/science/molecular-dynamics/gromacs/default.nix
new file mode 100644
index 000000000000..69810f95b846
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/molecular-dynamics/gromacs/default.nix
@@ -0,0 +1,92 @@
+{ lib, stdenv, fetchurl, cmake, hwloc, fftw, perl, blas, lapack, mpi, cudatoolkit
+, singlePrec ? true
+, enableMpi ? false
+, enableCuda ? false
+, cpuAcceleration ? null
+}:
+
+let
+  # Select reasonable defaults for all major platforms
+  # The possible values are defined in CMakeLists.txt:
+  # AUTO None SSE2 SSE4.1 AVX_128_FMA AVX_256 AVX2_256
+  # AVX2_128 AVX_512 AVX_512_KNL MIC ARM_NEON ARM_NEON_ASIMD
+  SIMD = x: if (cpuAcceleration != null) then x else
+    if stdenv.hostPlatform.system == "i686-linux" then "SSE2" else
+    if stdenv.hostPlatform.system == "x86_64-linux" then "SSE4.1" else
+    if stdenv.hostPlatform.system == "x86_64-darwin" then "SSE4.1" else
+    if stdenv.hostPlatform.system == "aarch64-linux" then "ARM_NEON_ASIMD" else
+    "None";
+
+in stdenv.mkDerivation rec {
+  pname = "gromacs";
+  version = "2022";
+
+  src = fetchurl {
+    url = "ftp://ftp.gromacs.org/pub/gromacs/gromacs-${version}.tar.gz";
+    sha256 = "0s1bv8nvmdpiyk2yhcmzq8q936hm5jgnqb393101drh2dih0vmps";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  buildInputs = [
+    fftw
+    perl
+    hwloc
+    blas
+    lapack
+  ] ++ lib.optional enableMpi mpi
+    ++ lib.optional enableCuda cudatoolkit
+  ;
+
+  propagatedBuildInputs = lib.optional enableMpi mpi;
+  propagatedUserEnvPkgs = lib.optional enableMpi mpi;
+
+  cmakeFlags = [
+    "-DGMX_SIMD:STRING=${SIMD cpuAcceleration}"
+    "-DGMX_OPENMP:BOOL=TRUE"
+    "-DBUILD_SHARED_LIBS=ON"
+  ] ++ (
+    if singlePrec then [
+      "-DGMX_DOUBLE=OFF"
+    ] else [
+      "-DGMX_DOUBLE=ON"
+      "-DGMX_DEFAULT_SUFFIX=OFF"
+    ]
+  ) ++ (
+    if enableMpi
+      then [
+        "-DGMX_MPI:BOOL=TRUE"
+        "-DGMX_THREAD_MPI:BOOL=FALSE"
+      ]
+     else [
+       "-DGMX_MPI:BOOL=FALSE"
+     ]
+  ) ++ lib.optional enableCuda "-DGMX_GPU=CUDA";
+
+  meta = with lib; {
+    homepage = "http://www.gromacs.org";
+    license = licenses.gpl2;
+    description = "Molecular dynamics software package";
+    longDescription = ''
+      GROMACS is a versatile package to perform molecular dynamics,
+      i.e. simulate the Newtonian equations of motion for systems
+      with hundreds to millions of particles.
+
+      It is primarily designed for biochemical molecules like
+      proteins, lipids and nucleic acids that have a lot of
+      complicated bonded interactions, but since GROMACS is
+      extremely fast at calculating the nonbonded interactions (that
+      usually dominate simulations) many groups are also using it
+      for research on non-biological systems, e.g. polymers.
+
+      GROMACS supports all the usual algorithms you expect from a
+      modern molecular dynamics implementation, (check the online
+      reference or manual for details), but there are also quite a
+      few features that make it stand out from the competition.
+
+      See: http://www.gromacs.org/About_Gromacs for details.
+    '';
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ sheepforce markuskowa ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/molecular-dynamics/lammps/default.nix b/nixpkgs/pkgs/applications/science/molecular-dynamics/lammps/default.nix
new file mode 100644
index 000000000000..c377d961820e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/molecular-dynamics/lammps/default.nix
@@ -0,0 +1,67 @@
+{ lib, stdenv, fetchFromGitHub
+, libpng, gzip, fftw, blas, lapack
+, withMPI ? false
+, mpi
+}:
+let packages = [
+     "asphere" "body" "class2" "colloid" "compress" "coreshell"
+     "dipole" "granular" "kspace" "manybody" "mc" "misc" "molecule"
+     "opt" "peri" "qeq" "replica" "rigid" "shock" "snap" "srd" "user-reaxc"
+    ];
+    lammps_includes = "-DLAMMPS_EXCEPTIONS -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64";
+in
+stdenv.mkDerivation rec {
+  # LAMMPS has weird versioning converted to ISO 8601 format
+  version = "stable_29Oct2020";
+  pname = "lammps";
+
+  src = fetchFromGitHub {
+    owner = "lammps";
+    repo = "lammps";
+    rev = version;
+    sha256 = "1rmi9r5wj2z49wg43xyhqn9sm37n95cyli3g7vrqk3ww35mmh21q";
+  };
+
+  passthru = {
+    inherit mpi;
+    inherit packages;
+  };
+
+  buildInputs = [ fftw libpng blas lapack gzip ]
+    ++ (lib.optionals withMPI [ mpi ]);
+
+  configurePhase = ''
+    cd src
+    for pack in ${lib.concatStringsSep " " packages}; do make "yes-$pack" SHELL=$SHELL; done
+  '';
+
+  # Must do manual build due to LAMMPS requiring a seperate build for
+  # the libraries and executable. Also non-typical make script
+  buildPhase = ''
+    make mode=exe ${if withMPI then "mpi" else "serial"} SHELL=$SHELL LMP_INC="${lammps_includes}" FFT_PATH=-DFFT_FFTW3 FFT_LIB=-lfftw3 JPG_LIB=-lpng
+    make mode=shlib ${if withMPI then "mpi" else "serial"} SHELL=$SHELL LMP_INC="${lammps_includes}" FFT_PATH=-DFFT_FFTW3 FFT_LIB=-lfftw3 JPG_LIB=-lpng
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin $out/include $out/lib
+
+    cp -v lmp_* $out/bin/
+    cp -v *.h $out/include/
+    cp -v liblammps* $out/lib/
+  '';
+
+  meta = with lib; {
+    description = "Classical Molecular Dynamics simulation code";
+    longDescription = ''
+      LAMMPS is a classical molecular dynamics simulation code designed to
+      run efficiently on parallel computers. It was developed at Sandia
+      National Laboratories, a US Department of Energy facility, with
+      funding from the DOE. It is an open-source code, distributed freely
+      under the terms of the GNU Public License (GPL).
+      '';
+    homepage = "https://lammps.sandia.gov";
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.costrouc ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/molecular-dynamics/viennarna/default.nix b/nixpkgs/pkgs/applications/science/molecular-dynamics/viennarna/default.nix
new file mode 100644
index 000000000000..1629a6bba268
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/molecular-dynamics/viennarna/default.nix
@@ -0,0 +1,40 @@
+{ lib
+, stdenv
+, fetchurl
+, gsl
+, mpfr
+, perl
+, python3
+}:
+
+stdenv.mkDerivation rec {
+  pname = "ViennaRNA";
+  version = "2.4.18";
+
+  src = fetchurl {
+    url = "https://www.tbi.univie.ac.at/RNA/download/sourcecode/2_4_x/${pname}-${version}.tar.gz";
+    sha256 = "17b0mcfkms0gn1a3faa4cakig65k9nk282x6mdh1mmjwbqzp5akw";
+  };
+
+  buildInputs = [
+    gsl
+    mpfr
+    perl
+    python3
+  ];
+
+  configureFlags = [
+    "--with-cluster"
+    "--with-kinwalker"
+  ];
+
+  meta = with lib; {
+    description = "Prediction and comparison of RNA secondary structures";
+    homepage = "https://www.tbi.univie.ac.at/RNA/";
+    license = licenses.unfree;
+    maintainers = with maintainers; [ prusnak ];
+    platforms = platforms.unix;
+    # Perl bindings fail on aarch64-darwin with "Undefined symbols for architecture arm64"
+    broken = stdenv.isDarwin && stdenv.isAarch64;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/networking/sumo/default.nix b/nixpkgs/pkgs/applications/science/networking/sumo/default.nix
new file mode 100644
index 000000000000..9cdf576b9c68
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/networking/sumo/default.nix
@@ -0,0 +1,68 @@
+{ lib, bzip2, cmake, eigen, fetchFromGitHub, ffmpeg, fox_1_6, gdal,
+  git, gl2ps, gpp , gtest, jdk, libGL, libGLU, libX11, libjpeg,
+  libpng, libtiff, openscenegraph , proj, python3, python37Packages,
+  stdenv, swig, xercesc, xorg, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "sumo";
+  version = "1.9.2";
+
+  src = fetchFromGitHub {
+    owner = "eclipse";
+    repo = "sumo";
+    rev = "v${lib.replaceStrings ["."] ["_"] version}";
+    sha256 = "0zpd331vy1kfi4hfiszv3m8wl4m0wdfr3zzza200kkaakw5hjxhs";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [
+    cmake
+    git
+    swig
+  ];
+
+  buildInputs = [
+    bzip2
+    eigen
+    ffmpeg
+    fox_1_6
+    gdal
+    gl2ps
+    gpp
+    gtest
+    jdk
+    libGL
+    libGLU
+    libjpeg
+    libpng
+    libtiff
+    openscenegraph
+    proj
+    python37Packages.setuptools
+    xercesc
+    zlib
+    python3
+  ] ++ (with xorg; [
+    libX11
+    libXcursor
+    libXext
+    libXfixes
+    libXft
+    libXrandr
+    libXrender
+  ]);
+
+  meta = with lib; {
+    description = "The SUMO traffic simulator";
+    longDescription = ''
+      Eclipse SUMO is an open source, highly
+      portable, microscopic and continuous traffic simulation package
+      designed to handle large networks. It allows for intermodal
+      simulation including pedestrians and comes with a large set of
+      tools for scenario creation.
+    '';
+    homepage = "https://github.com/eclipse/sumo";
+    license = licenses.epl20;
+    maintainers = with maintainers; [ mtreca ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/physics/MCFM/default.nix b/nixpkgs/pkgs/applications/science/physics/MCFM/default.nix
new file mode 100644
index 000000000000..7b6000dfea8d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/physics/MCFM/default.nix
@@ -0,0 +1,33 @@
+{ lib, stdenv, fetchurl, cmake, gfortran, lhapdf }:
+
+stdenv.mkDerivation rec {
+  pname = "MCFM";
+  version = "10.0.1";
+
+  src = fetchurl {
+    url = "https://mcfm.fnal.gov/downloads/${pname}-${version}.tar.gz";
+    sha256 = "sha256-3Dg4KoILb0XhgGkzItDh/1opCtYrrIvtbuALYqPUvE8=";
+  };
+
+  postPatch = ''
+    substituteInPlace CMakeLists.txt \
+      --replace 'target_link_libraries(mcfm lhapdf_lib)' \
+                'target_link_libraries(mcfm ''${lhapdf_lib})'
+  '';
+
+  nativeBuildInputs = [ cmake gfortran ];
+  buildInputs = [ lhapdf ];
+
+  cmakeFlags = [
+    "-Duse_external_lhapdf=ON"
+    "-Duse_internal_lhapdf=OFF"
+  ];
+
+  meta = with lib; {
+    description = "Monte Carlo for FeMtobarn processes";
+    homepage = "https://mcfm.fnal.gov";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ veprbl ];
+    platforms = lib.platforms.x86_64;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/physics/elmerfem/default.nix b/nixpkgs/pkgs/applications/science/physics/elmerfem/default.nix
new file mode 100644
index 000000000000..63dfe6c28373
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/physics/elmerfem/default.nix
@@ -0,0 +1,43 @@
+{ lib, stdenv, fetchFromGitHub, cmake, git, gfortran, mpi, blas, liblapack, qt4, qwt6_qt4, pkg-config }:
+
+stdenv.mkDerivation rec {
+  pname = "elmerfem";
+  version = "9.0";
+
+  src = fetchFromGitHub {
+    owner = "elmercsc";
+    repo = "elmerfem";
+    rev = "release-${version}";
+    sha256 = "VK7jvu4s5d7k0c39XqY9dEzg/vXtX5Yr/09VcuZVQ9A=";
+  };
+
+  hardeningDisable = [ "format" ];
+
+  nativeBuildInputs = [ cmake gfortran pkg-config git ];
+  buildInputs = [ mpi blas liblapack qt4 qwt6_qt4 ];
+
+  preConfigure = ''
+    patchShebangs ./
+  '';
+
+  storepath = placeholder "out";
+
+  cmakeFlags = [
+  "-DELMER_INSTALL_LIB_DIR=${storepath}/lib"
+  "-DWITH_OpenMP:BOOLEAN=TRUE"
+  "-DWITH_MPI:BOOLEAN=TRUE"
+  "-DWITH_ELMERGUI:BOOLEAN=TRUE"
+  "-DCMAKE_INSTALL_LIBDIR=lib"
+  "-DCMAKE_INSTALL_INCLUDEDIR=include"
+  "-DCMAKE_OpenGL_GL_PREFERENCE=GLVND"
+  ];
+
+  meta = with lib; {
+    homepage = "https://elmerfem.org/";
+    description = "A finite element software for multiphysical problems";
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ wulfsta broke ];
+    license = licenses.lgpl21;
+  };
+
+}
diff --git a/nixpkgs/pkgs/applications/science/physics/professor/default.nix b/nixpkgs/pkgs/applications/science/physics/professor/default.nix
new file mode 100644
index 000000000000..6d52951ee9c9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/physics/professor/default.nix
@@ -0,0 +1,41 @@
+{ lib, stdenv, fetchurl, eigen, makeWrapper, python3 }:
+
+stdenv.mkDerivation rec {
+  pname = "professor";
+  version = "2.3.3";
+
+  src = fetchurl {
+    name = "Professor-${version}.tar.gz";
+    url = "https://professor.hepforge.org/downloads/?f=Professor-${version}.tar.gz";
+    sha256 = "17q026r2fpfxzf74d1013ksy3a9m57rcr2q164n9x02ci40bmib0";
+  };
+
+  postPatch = lib.optionalString stdenv.isDarwin ''
+    substituteInPlace Makefile \
+      --replace '-shared -o' '-shared -install_name "$(out)/$@" -o'
+  '';
+
+  nativeBuildInputs = [ python3.pkgs.cython makeWrapper ];
+  buildInputs = [ python3 eigen ];
+  propagatedBuildInputs = with python3.pkgs; [ iminuit numpy matplotlib yoda ];
+
+  CPPFLAGS = [ "-I${eigen}/include/eigen3" ];
+  PREFIX = placeholder "out";
+
+  postInstall = ''
+    for prog in "$out"/bin/*; do
+      wrapProgram "$prog" --set PYTHONPATH "$PYTHONPATH:$(toPythonPath "$out")"
+    done
+  '';
+
+  doInstallCheck = true;
+  installCheckTarget = "check";
+
+  meta = with lib; {
+    description = "A tuning tool for Monte Carlo event generators";
+    homepage = "https://professor.hepforge.org/";
+    license = licenses.unfree; # no license specified
+    maintainers = [ maintainers.veprbl ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/physics/quantomatic/default.nix b/nixpkgs/pkgs/applications/science/physics/quantomatic/default.nix
new file mode 100644
index 000000000000..8c33a8ae6b1a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/physics/quantomatic/default.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchurl, jre, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  pname = "quantomatic";
+  version = "0.7";
+
+  src = fetchurl {
+    url = "https://github.com/Quantomatic/quantomatic/releases/download/v${version}/Quantomatic-v${version}.jar";
+    sha256 = "04dd5p73a7plb4l4x2balam8j7mxs8df06rjkalxycrr1id52q4r";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ jre ];
+
+  dontUnpack = true;
+
+  installPhase = ''
+    mkdir -p $out/libexec/quantomatic
+    cp $src $out/libexec/quantomatic/quantomatic.jar
+    mkdir -p $out/bin
+    makeWrapper ${jre}/bin/java $out/bin/quantomatic --add-flags "-jar $out/libexec/quantomatic/quantomatic.jar"
+  '';
+
+  meta = with lib; {
+    description = "A piece of software for reasoning about monoidal theories; in particular, quantum information processing";
+    license = licenses.gpl3;
+    homepage = "https://quantomatic.github.io/";
+    maintainers = with maintainers; [ nickhu ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/physics/sacrifice/compat.patch b/nixpkgs/pkgs/applications/science/physics/sacrifice/compat.patch
new file mode 100644
index 000000000000..c66b91b76280
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/physics/sacrifice/compat.patch
@@ -0,0 +1,12 @@
+diff --git a/src/PythiaMain.cxx b/src/PythiaMain.cxx
+index 0e5ddd2..2b626ab 100644
+--- a/src/PythiaMain.cxx
++++ b/src/PythiaMain.cxx
+@@ -96,7 +96,6 @@ int main(int argc, char **argv){
+   HepMCConverter pythiaToHepMC;
+ 
+   pythiaToHepMC.set_store_pdf(true);
+-  pythiaToHepMC.set_crash_on_problem(true);
+   
+   if(photosHandler.isEnabled()){
+     photosHandler.initialise();
diff --git a/nixpkgs/pkgs/applications/science/physics/sacrifice/default.nix b/nixpkgs/pkgs/applications/science/physics/sacrifice/default.nix
new file mode 100644
index 000000000000..34e4d989e959
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/physics/sacrifice/default.nix
@@ -0,0 +1,48 @@
+{ lib, stdenv, fetchurl, boost, hepmc2, lhapdf, pythia, makeWrapper }:
+
+stdenv.mkDerivation {
+  pname = "sacrifice";
+  version = "1.0.0";
+
+  src = fetchurl {
+    url = "https://www.hepforge.org/archive/agile/Sacrifice-1.0.0.tar.gz";
+    sha256 = "10bvpq63kmszy1habydwncm0j1dgvam0fkrmvkgbkvf804dcjp6g";
+  };
+
+  buildInputs = [ boost hepmc2 lhapdf pythia ];
+  nativeBuildInputs = [ makeWrapper ];
+
+  patches = [
+    ./compat.patch
+    ./pythia83xx.patch
+  ];
+
+  preConfigure = ''
+    substituteInPlace configure --replace HAVE_LCG=yes HAVE_LCG=no
+  ''
+  + lib.optionalString stdenv.isDarwin ''
+    substituteInPlace configure --replace LIB_SUFFIX=\"so\" LIB_SUFFIX=\"dylib\"
+  '';
+
+  configureFlags = [
+    "--with-HepMC=${hepmc2}"
+    "--with-pythia=${pythia}"
+  ];
+
+  postInstall = if stdenv.isDarwin then ''
+    install_name_tool -add_rpath ${pythia}/lib "$out"/bin/run-pythia
+  '' else ''
+    wrapProgram $out/bin/run-pythia \
+      --prefix LD_LIBRARY_PATH : "${pythia}/lib"
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "A standalone contribution to AGILe for steering Pythia 8";
+    license     = lib.licenses.gpl2;
+    homepage    = "https://agile.hepforge.org/trac/wiki/Sacrifice";
+    platforms   = lib.platforms.unix;
+    maintainers = with lib.maintainers; [ veprbl ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/physics/sacrifice/pythia83xx.patch b/nixpkgs/pkgs/applications/science/physics/sacrifice/pythia83xx.patch
new file mode 100644
index 000000000000..ea162e30c9a8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/physics/sacrifice/pythia83xx.patch
@@ -0,0 +1,55 @@
+diff --git a/include/Sacrifice/UserHooksFactory.hh b/include/Sacrifice/UserHooksFactory.hh
+index 04b105b..19f2b4f 100644
+--- a/include/Sacrifice/UserHooksFactory.hh
++++ b/include/Sacrifice/UserHooksFactory.hh
+@@ -12,7 +12,7 @@
+ 
+ namespace Sacrifice{
+ 
+-  using Pythia8::UserHooks;
++  using Pythia8::UserHooksPtr;
+   using std::string;
+   using std::map;
+ 
+@@ -21,7 +21,7 @@ namespace Sacrifice{
+ 
+   public:
+ 
+-    static UserHooks* create(const string &hookName);
++    static UserHooksPtr create(const string &hookName);
+ 
+     /**
+      *  Loads a library of UserHooks
+@@ -39,7 +39,7 @@ namespace Sacrifice{
+ 
+     class ICreator{
+     public:
+-      virtual UserHooks *create() const = 0;
++      virtual UserHooksPtr create() const = 0;
+       virtual ~ICreator(){};
+     };
+ 
+@@ -61,8 +61,8 @@ namespace Sacrifice{
+         }
+       }
+ 
+-      UserHooks *create()const{
+-        return new T;
++      UserHooksPtr create()const{
++        return std::make_shared<T>();
+       }
+ 
+     private:
+diff --git a/src/UserHooksFactory.cxx b/src/UserHooksFactory.cxx
+index 84a485b..5274119 100644
+--- a/src/UserHooksFactory.cxx
++++ b/src/UserHooksFactory.cxx
+@@ -11,7 +11,7 @@ namespace Sacrifice{
+   using std::ifstream;
+ 
+   //////////////////////////////////////////////////////////////////////////////
+-  UserHooks *UserHooksFactory::create(const string &name){
++  UserHooksPtr UserHooksFactory::create(const string &name){
+     map<string, const ICreator*>::const_iterator it = s_creators().find(name);
+     if(it == s_creators().end()){
+       //eek!
diff --git a/nixpkgs/pkgs/applications/science/physics/sherpa/default.nix b/nixpkgs/pkgs/applications/science/physics/sherpa/default.nix
new file mode 100644
index 000000000000..29c72b7f11c0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/physics/sherpa/default.nix
@@ -0,0 +1,38 @@
+{ lib, stdenv, fetchurl, autoconf, gfortran, hepmc2, fastjet, lhapdf, rivet, sqlite }:
+
+stdenv.mkDerivation rec {
+  pname = "sherpa";
+  version = "2.2.12";
+
+  src = fetchurl {
+    url = "https://www.hepforge.org/archive/sherpa/SHERPA-MC-${version}.tar.gz";
+    sha256 = "sha256-UpRkd1yoKLncllEQUm80DedDtgA8Hm+Kvi/BRVCu0AE=";
+  };
+
+  postPatch = lib.optionalString (stdenv.hostPlatform.libc == "glibc") ''
+    sed -ie '/sys\/sysctl.h/d' ATOOLS/Org/Run_Parameter.C
+  '';
+
+  nativeBuildInputs = [ autoconf gfortran ];
+
+  buildInputs = [ sqlite lhapdf rivet ];
+
+  enableParallelBuilding = true;
+
+  configureFlags = [
+    "--with-sqlite3=${sqlite.dev}"
+    "--enable-hepmc2=${hepmc2}"
+    "--enable-fastjet=${fastjet}"
+    "--enable-lhapdf=${lhapdf}"
+    "--enable-rivet=${rivet}"
+    "--enable-pythia"
+  ];
+
+  meta = with lib; {
+    description = "Simulation of High-Energy Reactions of PArticles in lepton-lepton, lepton-photon, photon-photon, lepton-hadron and hadron-hadron collisions";
+    license = licenses.gpl2;
+    homepage = "https://gitlab.com/sherpa-team/sherpa";
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ veprbl ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/physics/shtns/default.nix b/nixpkgs/pkgs/applications/science/physics/shtns/default.nix
new file mode 100644
index 000000000000..a720213b3913
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/physics/shtns/default.nix
@@ -0,0 +1,22 @@
+{ lib, stdenv, fetchgit, fftw }:
+
+stdenv.mkDerivation rec {
+  pname = "shtns";
+  version = "3.5.1";
+
+  src = fetchgit {
+    url = "https://bitbucket.org/nschaeff/shtns";
+    rev = "v${version}";
+    sha256 = "1ajrplhv7a2dvb3cn3n638281w0bzdcydvvwbg64awbjg622mdpd";
+  };
+
+  buildInputs = [ fftw ];
+
+  meta = with lib; {
+    description = "High performance library for Spherical Harmonic Transform";
+    homepage = "https://nschaeff.bitbucket.io/shtns/";
+    license = licenses.cecill21;
+    maintainers = [ maintainers.bzizou ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/physics/xfitter/default.nix b/nixpkgs/pkgs/applications/science/physics/xfitter/default.nix
new file mode 100644
index 000000000000..51d6c9d68fe4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/physics/xfitter/default.nix
@@ -0,0 +1,58 @@
+{ lib, stdenv, fetchurl, apfel, apfelgrid, applgrid, blas, gfortran, lhapdf, lapack, libyaml, lynx
+, mela, root5, qcdnum, which, libtirpc
+, memorymappingHook, memstreamHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "xfitter";
+  version = "2.0.1";
+
+  src = fetchurl {
+    name = "${pname}-${version}.tgz";
+    url = "https://www.xfitter.org/xFitter/xFitter/DownloadPage?action=AttachFile&do=get&target=${pname}-${version}.tgz";
+    sha256 = "0kmgc67nw5flp92yw5x6l2vsnhwsfi5z2a20404anisdgdjs8zc6";
+  };
+
+  patches = [
+    ./undefined_behavior.patch
+  ];
+
+  preConfigure =
+  # Fix F77LD to workaround for a following build error:
+  #
+  #   gfortran: error: unrecognized command line option '-stdlib=libc++'
+  #
+    lib.optionalString stdenv.isDarwin ''
+      substituteInPlace src/Makefile.in \
+        --replace "F77LD = \$(F77)" "F77LD = \$(CXXLD)" \
+    '';
+
+  configureFlags = [
+    "--enable-apfel"
+    "--enable-apfelgrid"
+    "--enable-applgrid"
+    "--enable-mela"
+    "--enable-lhapdf"
+  ];
+
+  nativeBuildInputs = [ gfortran which ];
+  buildInputs =
+    [ apfel apfelgrid applgrid blas lhapdf libyaml lapack mela root5 qcdnum ]
+    ++ lib.optionals (stdenv.system == "x86_64-darwin") [ memorymappingHook memstreamHook ]
+    ++ lib.optional (stdenv.hostPlatform.libc == "glibc") libtirpc
+    ;
+  propagatedBuildInputs = [ lynx ];
+
+  enableParallelBuilding = true;
+
+  NIX_CFLAGS_COMPILE = lib.optional (stdenv.hostPlatform.libc == "glibc") "-I${libtirpc.dev}/include/tirpc";
+  NIX_LDFLAGS = lib.optional (stdenv.hostPlatform.libc == "glibc") "-ltirpc";
+
+  meta = with lib; {
+    description = "The xFitter project is an open source QCD fit framework ready to extract PDFs and assess the impact of new data";
+    license     = licenses.gpl3;
+    homepage    = "https://www.xfitter.org/xFitter";
+    platforms   = platforms.unix;
+    maintainers = with maintainers; [ veprbl ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/physics/xfitter/undefined_behavior.patch b/nixpkgs/pkgs/applications/science/physics/xfitter/undefined_behavior.patch
new file mode 100644
index 000000000000..53278527a807
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/physics/xfitter/undefined_behavior.patch
@@ -0,0 +1,454 @@
+diff --git a/DY/src/finterface.cc b/DY/src/finterface.cc
+--- a/DY/src/finterface.cc
++++ b/DY/src/finterface.cc
+@@ -14,17 +14,17 @@
+ using namespace std;
+ 
+ extern "C" {
+-  int dy_create_calc_(const int *ds_id, const int *chg_prod, 
++  void dy_create_calc_(const int *ds_id, const int *chg_prod, 
+       const double *beam_en, const char *boz,
+       const double *ranges, const char *var_name, 
+       const int *n_bins, const double *bin_edges);
+ 
+-  int dy_do_calc_();
++  void dy_do_calc_();
+ 
+-  int dy_get_res_(const int *ds_id, double *calc_res);
++  void dy_get_res_(const int *ds_id, double *calc_res);
+ 
+-  int dy_release_();
+-  int dy_set_ewpars_();
++  void dy_release_();
++  void dy_set_ewpars_();
+ }
+ 
+ typedef map <int, DYcalc* > DCmap;
+@@ -34,7 +34,7 @@ vector<BinMatrix*> gBinMatrices;
+ 
+ // initializes Drell-Yan LO calculations with info on
+ // beam, process, kinematic cuts, and bins.
+-int dy_create_calc_(const int *ds_id, const int *chg_prod, 
++void dy_create_calc_(const int *ds_id, const int *chg_prod, 
+     const double *beam_en, const char *boz,
+     const double *ranges, const char *var_name, 
+     const int *n_bins, const double *bin_edges)
+@@ -99,13 +99,11 @@ int dy_create_calc_(const int *ds_id, const int *chg_prod,
+   // create calculator and put to map
+   DYcalc * dc = new DYcalc(bm, pc, int_steps);
+   gCalcs.insert( pair<int,DYcalc*>( *ds_id,dc ) );
+-
+-  return 1;
+ }
+ 
+ 
+ // calculate Drell-Yan LO cross sections for all data sets
+-int dy_do_calc_()
++void dy_do_calc_()
+ {
+   // evolve convolutions
+   vector<PDFconv*>::iterator ipc = gPDFconvs.begin();
+@@ -118,28 +116,24 @@ int dy_do_calc_()
+     if ( true != idc->second->Integrate() ) {
+       cout << "Something is wrong with DY integration for " 
+            << idc->first << " data set." << endl;
+-      return 0;
++      return;
+     }
+   }
+-
+-  return 1;
+ }
+ 
+ 
+ // return DY calculations for data set ds_name
+-int dy_get_res_(const int *ds_id, double *calc_res)
++void dy_get_res_(const int *ds_id, double *calc_res)
+ {
+   DYcalc * dc = gCalcs.find(*ds_id)->second;
+   dc->getCalcRes(calc_res);
+-
+-  return 1;
+ }
+ 
+-int dy_set_ewpars_(){
++void dy_set_ewpars_(){
+   PhysPar::setPhysPar();
+ }
+ 
+-int dy_release_()
++void dy_release_()
+ {
+   vector<PDFconv*>::iterator ipc = gPDFconvs.begin();
+   for (; ipc!=gPDFconvs.end(); ipc++){
+@@ -155,6 +149,4 @@ int dy_release_()
+   for (; idc != gCalcs.end() ; idc++){
+     delete (idc->second);
+   }
+-
+-  return 1;
+ }
+diff --git a/DiffDIS/include/DataTable.h b/DiffDIS/include/DataTable.h
+--- a/DiffDIS/include/DataTable.h
++++ b/DiffDIS/include/DataTable.h
+@@ -307,6 +307,7 @@ class DataTable_t {
+       for(ic=0; ic < GetNcols(); ic++) {
+         for(ir=0; ir < npt; ir++) Data[ic][ir] = A.Data[ic][ir];
+       }
++      return *this;
+     }
+     
+     //@}
+diff --git a/FastNLO/src/FastNLOInterface.cc b/FastNLO/src/FastNLOInterface.cc
+--- a/FastNLO/src/FastNLOInterface.cc
++++ b/FastNLO/src/FastNLOInterface.cc
+@@ -39,14 +39,14 @@ void gauleg(double x1,double x2,double *x,double *w, int n);
+ 
+ 
+ extern "C" {
+-  int fastnloinit_(const char *s, const int *idataset, const char *thfile, int *I_FIT_ORDER, bool *PublicationUnits , double* murdef, double* murscale, double *mufdef, double* mufscale);
+-  int fastnlocalc_(const int *idataset, double *xsec);
+-  int fastnlocalctop_(const int *idataset, double *xsec, double *thbin, double *tot, int *Npt);
+-  int fastnlopointskip_(const int *idataset, int *point, int *npoints);
+-  int hf_errlog_(const int* ID, const char* TEXT, long length);
+-  int hf_stop_();
++  void fastnloinit_(const char *s, const int *idataset, const char *thfile, int *I_FIT_ORDER, bool *PublicationUnits , double* murdef, double* murscale, double *mufdef, double* mufscale);
++  void fastnlocalc_(const int *idataset, double *xsec);
++  void fastnlocalctop_(const int *idataset, double *xsec, double *thbin, double *tot, int *Npt);
++  void fastnlopointskip_(const int *idataset, int *point, int *npoints);
++  void hf_errlog_(const int* ID, const char* TEXT, long length);
++  void hf_stop_();
+   double interp_(double *A, double *xx1, double *x, int *NGrid1, double *res);
+-  int setfastnlotoppar_(const int *idataset);
++  void setfastnlotoppar_(const int *idataset);
+ }
+ 
+ 
+@@ -58,7 +58,7 @@ map<int, FastNLOxFitter*> gFastNLO_array;
+ map<int, BoolArray*>     gUsedPoints_array;
+ int CreateUsedPointsArray(int idataset, int npoints);
+ 
+-int fastnloinit_(const char *s, const int *idataset, const char *thfile, int *I_FIT_ORDER, bool *PublicationUnits , double* murdef, double* murscale, double *mufdef, double* mufscale) {
++void fastnloinit_(const char *s, const int *idataset, const char *thfile, int *I_FIT_ORDER, bool *PublicationUnits , double* murdef, double* murscale, double *mufdef, double* mufscale) {
+ 
+   
+    map<int, FastNLOxFitter*>::const_iterator FastNLOIterator = gFastNLO_array.find(*idataset);
+@@ -67,7 +67,7 @@ int fastnloinit_(const char *s, const int *idataset, const char *thfile, int *I_
+      const char* text = "I: Double initialization of the same fastnlo data set!";
+      hf_errlog_(&id, text, (long)strlen(text));
+      //hf_stop_();
+-     return 1;
++     return;
+    }
+    
+    FastNLOxFitter* fnloreader = new FastNLOxFitter( thfile );  
+@@ -112,10 +112,9 @@ int fastnloinit_(const char *s, const int *idataset, const char *thfile, int *I_
+    }
+    
+    gFastNLO_array.insert(pair<int, FastNLOxFitter*>(*idataset, fnloreader) );
+-   return 0;
+ }
+ 
+-int setfastnlotoppar_(const int *idataset) {
++void setfastnlotoppar_(const int *idataset) {
+    //!< Dedicated settings for difftop
+    map<int, FastNLOxFitter*>::const_iterator FastNLOIterator = gFastNLO_array.find(*idataset);
+    map<int, BoolArray*>::const_iterator UsedPointsIterator = gUsedPoints_array.find(*idataset);
+@@ -130,11 +129,9 @@ int setfastnlotoppar_(const int *idataset) {
+    fnloreader->SetExternalFuncForMuF( &Function_Mu );
+    fnloreader->SetExternalFuncForMuR( &Function_Mu);
+    //fnloreader->SetScaleFactorsMuRMuF(1.0,1.0); //Be reminded that muR and muF scales are hard coded (that's not true!)
+-
+-   return 0;
+ }
+ 
+-int fastnlocalc_(const int *idataset, double *xsec) {
++void fastnlocalc_(const int *idataset, double *xsec) {
+   
+    map<int, FastNLOxFitter*>::const_iterator FastNLOIterator = gFastNLO_array.find(*idataset);
+    map<int, BoolArray*>::const_iterator UsedPointsIterator = gUsedPoints_array.find(*idataset);
+@@ -176,13 +173,10 @@ int fastnlocalc_(const int *idataset, double *xsec) {
+        outputidx++;
+      }
+    }
+- 
+-
+-   return 0;
+ }
+ 
+ //MK14 New function for Difftop calculation: it is called in trunk/src/difftop_fastnlo.f
+-int fastnlocalctop_(const int *idataset, double *xsec, double *thbin, double *tot, int *Npt){
++void fastnlocalctop_(const int *idataset, double *xsec, double *thbin, double *tot, int *Npt){
+   
+    map<int, FastNLOxFitter*>::const_iterator FastNLOIterator = gFastNLO_array.find(*idataset);
+    map<int, BoolArray*>::const_iterator UsedPointsIterator = gUsedPoints_array.find(*idataset);
+@@ -262,10 +256,6 @@ int fastnlocalctop_(const int *idataset, double *xsec, double *thbin, double *to
+      Total += interpC(xsec,xg[k],thbin,Nthpoints)*wg[k];
+ 
+    *tot = Total;
+-
+-
+-
+-   return 0;
+ }
+ 
+ 
+@@ -277,7 +267,7 @@ int fastnlocalctop_(const int *idataset, double *xsec, double *thbin, double *to
+ 
+ 
+ 
+-int fastnlopointskip_(const int *idataset, int *point, int *npoints) {
++void fastnlopointskip_(const int *idataset, int *point, int *npoints) {
+   map<int, BoolArray*>::const_iterator UsedPointsIterator = gUsedPoints_array.find(*idataset);
+   if(UsedPointsIterator == gUsedPoints_array.end( )) 
+     CreateUsedPointsArray(*idataset, *npoints);
+@@ -292,8 +282,6 @@ int fastnlopointskip_(const int *idataset, int *point, int *npoints) {
+   
+   BoolArray*     usedpoints = UsedPointsIterator->second;
+   usedpoints->at(*point-1) = false;
+-
+-  return 0;
+ }
+ 
+ int CreateUsedPointsArray(int idataset, int npoints) {
+diff --git a/Hathor/src/HathorInterface.cc b/Hathor/src/HathorInterface.cc
+--- a/Hathor/src/HathorInterface.cc
++++ b/Hathor/src/HathorInterface.cc
+@@ -6,9 +6,9 @@
+ #include "../interface/xFitterPdf.h"
+ 
+ extern "C" {
+-  int hathorinit_(const int* idataset, const double& sqrtS, const bool& ppbar, const double& mt,
++  void hathorinit_(const int* idataset, const double& sqrtS, const bool& ppbar, const double& mt,
+ 		  const unsigned int& pertubOrder, const unsigned int& precisionLevel);
+-  int hathorcalc_(const int *idataset, double *xsec);
++  void hathorcalc_(const int *idataset, double *xsec);
+ }
+ 
+ extern "C" {
+@@ -19,7 +19,7 @@ extern "C" {
+ }
+ 
+ extern "C" {
+-  int hf_errlog_(const int* ID, const char* TEXT, long length);
++  void hf_errlog_(const int* ID, const char* TEXT, long length);
+ }
+ 
+ // FIXME: delete pointers at the end! (in some hathordestroy_ or so)
+@@ -28,7 +28,7 @@ xFitterPdf* pdf;
+ int* rndStore;
+ double mtop;
+ 
+-int hathorinit_(const int* idataset, const double& sqrtS, const bool& ppbar, const double& mt,
++void hathorinit_(const int* idataset, const double& sqrtS, const bool& ppbar, const double& mt,
+ 		const unsigned int& pertubOrder, const unsigned int& precisionLevel) {
+ 
+   if(hathor_array.size()==0) {
+@@ -69,7 +69,7 @@ int hathorinit_(const int* idataset, const double& sqrtS, const bool& ppbar, con
+   return 0;
+ }
+ 
+-int hathorcalc_(const int *idataset, double *xsec) {
++void hathorcalc_(const int *idataset, double *xsec) {
+   rlxd_reset(rndStore);
+ 
+   std::map<int, Hathor*>::const_iterator hathorIter = hathor_array.find(*idataset);
+diff --git a/src/TheorEval.cc b/src/TheorEval.cc
+--- a/src/TheorEval.cc
++++ b/src/TheorEval.cc
+@@ -62,6 +62,7 @@ TheorEval::initTheory()
+   list<tToken> sl;
+   this->assignTokens(sl);
+   this->convertToRPN(sl);
++  return 0;
+ }
+ 
+ int 
+@@ -167,6 +168,7 @@ TheorEval::assignTokens(list<tToken> &sl)
+       sl.push_back(t);
+     }
+   }
++  return 0;
+ }
+ 
+ int
+@@ -217,6 +219,7 @@ TheorEval::convertToRPN(list<tToken> &sl)
+   cout << endl;
+   */
+   
++  return 0;
+ }
+ 
+ int
+@@ -236,6 +239,7 @@ TheorEval::initTerm(int iterm, valarray<double> *val)
+     hf_errlog_(id, text, textlen);
+     return -1;
+   }
++  return 0;
+ }
+ 
+ int
+@@ -348,6 +352,7 @@ TheorEval::initGridTerm(int iterm, valarray<double> *val)
+ 
+   // associate grid and valarray pointers in token
+   _mapGridToken[g] = val;
++  return 0;
+ }
+ 
+ int
+@@ -430,6 +435,7 @@ TheorEval::initKfTerm(int iterm, valarray<double> *val)
+ 
+   // write k-factor array to the token valarray
+   *val = valarray<double>(vkf.data(), vkf.size());
++  return 0;
+ }  
+ 
+ int
+@@ -465,6 +471,7 @@ TheorEval::setCKM(const vector<double> &v_ckm)
+    int textlen = strlen(text);
+    hf_errlog_(id, text, textlen);
+ #endif
++   return 0;
+ }
+ 
+ int
+@@ -531,6 +538,7 @@ TheorEval::Evaluate(valarray<double> &vte )
+       }
+     //vte /= _units;
+   }
++  return 0;
+ }
+ 
+ int
+@@ -555,6 +563,7 @@ TheorEval::getGridValues()
+     
+     
+   }
++  return 0;
+ }
+ 
+ int
+diff --git a/src/ftheor_eval.cc b/src/ftheor_eval.cc
+--- a/src/ftheor_eval.cc
++++ b/src/ftheor_eval.cc
+@@ -19,15 +19,15 @@
+ using namespace std;
+ 
+ extern "C" {
+-  int set_theor_eval_(int *dsId);//, int *nTerms, char **TermName, char **TermType, 
++  void set_theor_eval_(int *dsId);//, int *nTerms, char **TermName, char **TermType, 
+ //    char **TermSource, char *TermExpr);
+-  int set_theor_bins_(int *dsId, int *nBinDimension, int *nPoints, int *binFlags, 
++  void set_theor_bins_(int *dsId, int *nBinDimension, int *nPoints, int *binFlags, 
+     double *allBins);
+ //  int set_theor_units_(int *dsId, double *units);
+-  int init_theor_eval_(int *dsId);
+-  int update_theor_ckm_();
+-  int get_theor_eval_(int *dsId, int* np, int* idx);
+-  int close_theor_eval_();
++  void init_theor_eval_(int *dsId);
++  void update_theor_ckm_();
++  void get_theor_eval_(int *dsId, int* np, int* idx);
++  void close_theor_eval_();
+ }
+ 
+ /// global dataset to theory evaluation pointer map
+@@ -59,7 +59,7 @@ extern struct ord_scales {
+  dataset ID.
+  write details on argumets
+  */
+-int set_theor_eval_(int *dsId)//, int *nTerms, char **TermName, char **TermType, 
++void set_theor_eval_(int *dsId)//, int *nTerms, char **TermName, char **TermType, 
+ //  char **TermSource, char *TermExpr)
+ {
+   // convert fortran strings to c++
+@@ -90,15 +90,13 @@ int set_theor_eval_(int *dsId)//, int *nTerms, char **TermName, char **TermType,
+     << " already exists." << endl;
+     exit(1); // make proper exit later
+   }
+-
+-  return 1;
+ }
+ 
+ /*!
+  Sets datasets bins in theory evaluations.
+  write details on argumets
+  */
+-int set_theor_bins_(int *dsId, int *nBinDimension, int *nPoints, int *binFlags, 
++void set_theor_bins_(int *dsId, int *nBinDimension, int *nPoints, int *binFlags, 
+   double *allBins)
+ {
+   tTEmap::iterator it = gTEmap.find(*dsId);
+@@ -110,7 +108,6 @@ int set_theor_bins_(int *dsId, int *nBinDimension, int *nPoints, int *binFlags,
+   
+   TheorEval *te = gTEmap.at(*dsId);
+   te->setBins(*nBinDimension, *nPoints, binFlags, allBins);
+-  return 1;
+ }
+ 
+ /*
+@@ -132,7 +129,7 @@ int set_theor_units_(int *dsId, double *units)
+ /*!
+  Initializes theory for requested dataset.
+  */
+-int init_theor_eval_(int *dsId)
++void init_theor_eval_(int *dsId)
+ {
+   tTEmap::iterator it = gTEmap.find(*dsId);
+   if (it == gTEmap.end() ) { 
+@@ -148,7 +145,7 @@ int init_theor_eval_(int *dsId)
+ /*!
+  Updates the CKM matrix to all the initialized appl grids
+  */
+-int update_theor_ckm_()
++void update_theor_ckm_()
+ {
+   double a_ckm[] = { ckm_matrix_.Vud, ckm_matrix_.Vus, ckm_matrix_.Vub,
+                                   ckm_matrix_.Vcd, ckm_matrix_.Vcs, ckm_matrix_.Vcb,
+@@ -164,7 +161,7 @@ int update_theor_ckm_()
+ /*!
+  Evaluates theory for requested dataset and writes it to the global THEO array.
+  */
+-int get_theor_eval_(int *dsId, int *np, int*idx)
++void get_theor_eval_(int *dsId, int *np, int*idx)
+ {
+ 
+   tTEmap::iterator it = gTEmap.find(*dsId);
+@@ -194,11 +191,11 @@ int get_theor_eval_(int *dsId, int *np, int*idx)
+   // write the predictions to THEO array
+   if( ip != *np ){
+     cout << "ERROR in get_theor_eval_: number of points mismatch" << endl;
+-    return -1;
++    return;
+   }
+ }
+ 
+-int close_theor_eval_()
++void close_theor_eval_()
+ {
+   tTEmap::iterator it = gTEmap.begin();
+   for (; it!= gTEmap.end(); it++){
+diff --git a/src/lhapdf6_output.c b/src/lhapdf6_output.c
+--- a/src/lhapdf6_output.c
++++ b/src/lhapdf6_output.c
+@@ -64,7 +64,7 @@ extern double bvalij_(int *,int *,int *,int *,int *);
+ extern double bvalxq_(int *,int *,double *,double *,int *);

+ extern double hf_get_alphas_(double *);

+ extern int getord_(int *);

+-extern int grpars_(int *, double *, double *, int *, double *, double *, int *);

++extern void grpars_(int *, double *, double *, int *, double *, double *, int *);

+ extern int getcbt_(int *, double *, double *, double *);

+ extern void getpdfunctype_heraf_(int *mc, int *asymh, int *symh, char *name, size_t size);

+ extern void hf_errlog_(int *, char *, size_t);

+diff --git a/tools/draw/include/FileOpener.h b/tools/draw/include/FileOpener.h
+--- a/tools/draw/include/FileOpener.h
++++ b/tools/draw/include/FileOpener.h
+@@ -61,7 +61,7 @@ class InFileOpener_t {
+   string GetPath() const {return ind < 0 ? "" : Flist[ind];}
+   
+   // ==================================
+-  int Add(const string& fname) {
++  void Add(const string& fname) {
+     Flist.push_back(fname);
+   }
+ 
diff --git a/nixpkgs/pkgs/applications/science/physics/xflr5/default.nix b/nixpkgs/pkgs/applications/science/physics/xflr5/default.nix
new file mode 100644
index 000000000000..dd3fef5bf26c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/physics/xflr5/default.nix
@@ -0,0 +1,21 @@
+{ mkDerivation, lib, fetchurl, qmake }:
+
+mkDerivation rec {
+  pname = "xflr5";
+  version = "6.47";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/xflr5/${pname}_v${version}_src.tar.gz";
+    sha256 = "02x3r9iv3ndwxa65mxn9m5dlhcrnjiq7cffi6rmb456gs3v3dnav";
+  };
+
+  nativeBuildInputs = [ qmake ];
+
+  meta = with lib; {
+    description = "An analysis tool for airfoils, wings and planes";
+    homepage = "https://sourceforge.net/projects/xflr5/";
+    license = licenses.gpl3;
+    maintainers = [ maintainers.esclear ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/programming/fdr/default.nix b/nixpkgs/pkgs/applications/science/programming/fdr/default.nix
new file mode 100644
index 000000000000..bc67c30aa61c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/programming/fdr/default.nix
@@ -0,0 +1,69 @@
+{ lib, stdenv, fetchurl, qtbase, qtx11extras, ncurses5, xorg, zlib, python27Packages }:
+stdenv.mkDerivation {
+  pname = "fdr";
+  version = "4.2.7";
+  src = fetchurl {
+    url = "https://dl.cocotec.io/fdr/fdr-3814-linux-x86_64.tar.gz";
+    sha256 = "0cajz1gz4slq9nfhm8dqdgxl0kc950838n0lrf8jw4vl54gv6chh";
+  };
+
+  libPath = lib.makeLibraryPath [
+    stdenv.cc.cc
+    python27Packages.python
+    qtbase
+    qtx11extras
+    ncurses5
+    xorg.libX11
+    xorg.libXft
+    zlib
+  ];
+
+  dontConfigure = true;
+  installPhase = ''
+    mkdir -p "$out"
+
+    # shipped Qt is buggy
+    rm lib/libQt*
+    rm -r lib/qt_plugins
+
+    cp -r * "$out"
+    ln -s ${ncurses5.out}/lib/libtinfo.so.5 $out/lib/libtinfo.so.5
+    ln -s ${qtbase.bin}/${qtbase.qtPluginPrefix} $out/lib/qt_plugins
+    ln -s ${zlib.out}/lib/libz.so.1 $out/lib/libz.so.1
+
+    for b in fdr4 _fdr4 refines _refines cspmprofiler cspmexplorerprof
+    do
+      patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
+        --set-rpath "$libPath:$out/lib" \
+        "$out/bin/$b"
+    done
+
+    for l in corei7/librefines.so \
+      libcspm_process_compiler.so \
+      libcsp_operators.so \
+      _fdr.so \
+      libfdr.so \
+      libfdr_java.so \
+      libprocess_compiler.so \
+      librefines_gui.so \
+      librefines_licensing.so  \
+      libboost_date_time.so.1.60.0 \
+      libboost_filesystem.so.1.60.0 \
+      libboost_iostreams.so.1.60.0 \
+      libboost_program_options.so.1.60.0 \
+      libboost_serialization.so.1.60.0 \
+      libboost_system.so.1.60.0
+    do
+      patchelf --set-rpath "$libPath:$out/lib" \
+        "$out/lib/$l"
+    done
+  '';
+
+  meta = with lib; {
+    homepage = "https://cocotec.io/fdr/";
+    description = "The CSP refinement checker";
+    license = licenses.unfreeRedistributable;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ nickhu ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/programming/groove/default.nix b/nixpkgs/pkgs/applications/science/programming/groove/default.nix
new file mode 100644
index 000000000000..f4c323defd6f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/programming/groove/default.nix
@@ -0,0 +1,54 @@
+{ lib, stdenv, fetchurl, unzip, makeWrapper, makeDesktopItem, icoutils, jre8 }:
+
+let
+  desktopItem = makeDesktopItem {
+    name = "groove-simulator";
+    exec = "groove-simulator";
+    icon = "groove";
+    desktopName = "GROOVE Simulator";
+    comment = "GRaphs for Object-Oriented VErification";
+    categories = [ "Science" "ComputerScience" ];
+  };
+
+in stdenv.mkDerivation rec {
+  pname = "groove";
+  version = "5.8.1";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/groove/groove/${version}/${pname}-${builtins.replaceStrings ["."] ["_"] version}-bin.zip";
+    sha256 = "sha256-JwoUlO6F2+8NtCnLC+xm5q0Jm8RIyU1rnuKGmjgJhFU=";
+  };
+
+  nativeBuildInputs = [ unzip makeWrapper icoutils ];
+
+  dontBuild = true;
+
+  installPhase = ''
+    mkdir -p $out/share/groove
+    cp -r bin lib $out/share/groove/
+
+    mkdir -p $out/share/doc/groove
+    cp CHANGES README *.pdf $out/share/doc/groove/
+
+    mkdir -p $out/bin
+    for bin in Generator Imager ModelChecker PrologChecker Simulator Viewer; do
+      makeWrapper ${jre8}/bin/java $out/bin/groove-''${bin,,} \
+        --add-flags "-jar $out/share/groove/bin/$bin.jar"
+    done
+
+    mkdir -p $out/share/applications
+    ln -s ${desktopItem}/share/applications/* $out/share/applications/
+
+    mkdir -p $out/share/icons/hicolor/{16x16,32x32}/apps
+    icotool -x -i 1 -o $out/share/icons/hicolor/32x32/apps/groove.png groove-green-g.ico
+    icotool -x -i 2 -o $out/share/icons/hicolor/16x16/apps/groove.png groove-green-g.ico
+  '';
+
+  meta = with lib; {
+    description = "GRaphs for Object-Oriented VErification";
+    homepage = "http://groove.cs.utwente.nl/";
+    license = licenses.asl20;
+    platforms = platforms.all;
+    maintainers = with maintainers; [ jfrankenau ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/programming/plm/default.nix b/nixpkgs/pkgs/applications/science/programming/plm/default.nix
new file mode 100644
index 000000000000..ca8e87a05533
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/programming/plm/default.nix
@@ -0,0 +1,39 @@
+{ lib, stdenv, fetchurl, makeWrapper, jre, gcc, valgrind }:
+# gcc and valgrind are not strict dependencies, they could be made
+# optional. They are here because plm can only help you learn C if you
+# have them installed.
+stdenv.mkDerivation rec {
+  pname = "plm";
+  version = "2.9.3";
+
+  src = fetchurl {
+    url = "https://github.com/BuggleInc/PLM/releases/download/v${version}/plm-${version}.jar";
+    sha256 = "0i9ghx9pm3kpn9x9n1hl10zdr36v5mv3drx8lvhsqwhlsvz42p5i";
+    name = "${pname}-${version}.jar";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ jre gcc valgrind ];
+
+  dontUnpack = true;
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p "$prefix/bin"
+
+    makeWrapper ${jre}/bin/java $out/bin/plm \
+      --add-flags "-jar $src" \
+      --prefix PATH : "$PATH"
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Free cross-platform programming exerciser";
+    homepage = "http://people.irisa.fr/Martin.Quinson/Teaching/PLM/";
+    license = licenses.gpl3;
+    maintainers = [ ];
+    platforms = lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/robotics/apmplanner2/default.nix b/nixpkgs/pkgs/applications/science/robotics/apmplanner2/default.nix
new file mode 100644
index 000000000000..b65c23521395
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/robotics/apmplanner2/default.nix
@@ -0,0 +1,43 @@
+{ lib, mkDerivation, fetchFromGitHub, fetchpatch, qmake
+, qtbase, qtscript, qtwebkit, qtserialport, qtsvg, qtdeclarative, qtquickcontrols2
+, alsa-lib, libsndfile, flite, openssl, udev, SDL2
+}:
+
+mkDerivation rec {
+  pname = "apmplanner2";
+  version = "2.0.28";
+
+  src = fetchFromGitHub {
+    owner = "ArduPilot";
+    repo = "apm_planner";
+    rev = version;
+    sha256 = "0wvbfjnnf7sh6fpgw8gimh5hgzywj3nwrgr80r782f5gayd3v2l1";
+  };
+
+  buildInputs = [
+    alsa-lib libsndfile flite openssl udev SDL2
+    qtbase qtscript qtwebkit qtserialport qtsvg qtdeclarative qtquickcontrols2
+  ];
+
+  nativeBuildInputs = [ qmake ];
+
+  qmakeFlags = [ "apm_planner.pro" ];
+
+  # this ugly hack is necessary, as `bin/apmplanner2` needs the contents of `share/APMPlanner2` inside of `bin/`
+  preFixup = ''
+    ln --relative --symbolic $out/share/APMPlanner2/* $out/bin/
+    substituteInPlace $out/share/applications/apmplanner2.desktop \
+      --replace /usr $out
+  '';
+
+  meta = {
+    description = "Ground station software for autonomous vehicles";
+    longDescription = ''
+      A GUI ground control station for autonomous vehicles using the MAVLink protocol.
+      Includes support for the APM and PX4 based controllers.
+    '';
+    homepage = "https://ardupilot.org/planner2/";
+    license = lib.licenses.gpl3;
+    maintainers = with lib.maintainers; [ wucke13 ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/robotics/betaflight-configurator/default.nix b/nixpkgs/pkgs/applications/science/robotics/betaflight-configurator/default.nix
new file mode 100644
index 000000000000..506572399524
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/robotics/betaflight-configurator/default.nix
@@ -0,0 +1,49 @@
+{lib, stdenv, fetchurl, unzip, makeDesktopItem, nwjs, wrapGAppsHook, gsettings-desktop-schemas, gtk3 }:
+
+let
+  pname = "betaflight-configurator";
+  desktopItem = makeDesktopItem {
+    name = pname;
+    exec = pname;
+    icon = pname;
+    comment = "Betaflight configuration tool";
+    desktopName = "Betaflight Configurator";
+    genericName = "Flight controller configuration tool";
+  };
+in
+stdenv.mkDerivation rec {
+  inherit pname;
+  version = "10.7.2";
+  src = fetchurl {
+    url = "https://github.com/betaflight/${pname}/releases/download/${version}/${pname}_${version}_linux64.zip";
+    sha256 = "sha256-FDmtFRUupPKiHeF3Xvh/VagqMo+FJi8I7mhTz0VDs3o=";
+  };
+
+  nativeBuildInputs = [ wrapGAppsHook unzip ];
+
+  buildInputs = [ gsettings-desktop-schemas gtk3 ];
+
+  installPhase = ''
+    mkdir -p $out/bin \
+             $out/opt/${pname}
+
+    cp -r . $out/opt/${pname}/
+    install -m 444 -D icon/bf_icon_128.png $out/share/icons/hicolor/128x128/apps/${pname}.png
+    cp -r ${desktopItem}/share/applications $out/share/
+
+    makeWrapper ${nwjs}/bin/nw $out/bin/${pname} --add-flags $out/opt/${pname}
+  '';
+
+  meta = with lib; {
+    description = "The Betaflight flight control system configuration tool";
+    longDescription = ''
+      A crossplatform configuration tool for the Betaflight flight control system.
+      Various types of aircraft are supported by the tool and by Betaflight, e.g.
+      quadcopters, hexacopters, octocopters and fixed-wing aircraft.
+    '';
+    homepage    = "https://github.com/betaflight/betaflight/wiki";
+    license     = licenses.gpl3;
+    maintainers = with maintainers; [ wucke13 ];
+    platforms   = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/robotics/emuflight-configurator/default.nix b/nixpkgs/pkgs/applications/science/robotics/emuflight-configurator/default.nix
new file mode 100644
index 000000000000..ca486006fecb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/robotics/emuflight-configurator/default.nix
@@ -0,0 +1,50 @@
+{lib, stdenv, fetchurl, unzip, makeDesktopItem, copyDesktopItems, nwjs
+, wrapGAppsHook, gsettings-desktop-schemas, gtk3 }:
+
+stdenv.mkDerivation rec {
+  pname = "emuflight-configurator";
+  version = "0.4.0";
+
+  src = fetchurl {
+    url = "https://github.com/emuflight/EmuConfigurator/releases/download/${version}/emuflight-configurator_${version}_linux64.zip";
+    sha256 = "sha256-s5AE+r9Fw6S7IG2cDW2T7vctcYIAY8al7eCFIDjD5oI=";
+  };
+
+  nativeBuildInputs = [ wrapGAppsHook unzip copyDesktopItems ];
+
+  buildInputs = [ gsettings-desktop-schemas gtk3 ];
+
+  installPhase = ''
+    mkdir -p $out/bin $out/share/${pname}
+
+    cp -r . $out/share/${pname}/
+    install -m 444 -D icon/emu_icon_128.png $out/share/icons/hicolor/128x128/apps/${pname}.png
+
+    makeWrapper ${nwjs}/bin/nw $out/bin/${pname} --add-flags $out/share/${pname}
+  '';
+
+  desktopItems = [
+    (makeDesktopItem {
+      name = pname;
+      exec = pname;
+      icon = pname;
+      comment = "Emuflight configuration tool";
+      desktopName = "Emuflight Configurator";
+      genericName = "Flight controller configuration tool";
+    })
+  ];
+
+  meta = with lib; {
+    description = "The Emuflight flight control system configuration tool";
+    longDescription = ''
+      A crossplatform configuration tool for the Emuflight flight control system.
+      Various types of aircraft are supported by the tool and by Emuflight, e.g.
+      quadcopters, hexacopters, octocopters and fixed-wing aircraft.
+      The application allows you to configure the Emuflight software running on any supported Emuflight target.
+    '';
+    homepage    = "https://github.com/emuflight/EmuConfigurator";
+    license     = licenses.gpl3Only;
+    maintainers = with maintainers; [ beezow ];
+    platforms   = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/robotics/inav-configurator/default.nix b/nixpkgs/pkgs/applications/science/robotics/inav-configurator/default.nix
new file mode 100644
index 000000000000..40914a8ac1a5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/robotics/inav-configurator/default.nix
@@ -0,0 +1,57 @@
+{ lib, stdenv, fetchurl, makeDesktopItem, copyDesktopItems, nwjs, wrapGAppsHook, gsettings-desktop-schemas, gtk3 }:
+
+stdenv.mkDerivation rec {
+  pname = "inav-configurator";
+  version = "3.0.2";
+
+  src = fetchurl {
+    url = "https://github.com/iNavFlight/inav-configurator/releases/download/${version}/INAV-Configurator_linux64_${version}.tar.gz";
+    sha256 = "0v6dcg634wpp9q4ya3mj00j3pg25g62aq209iq2dsvj0a03afbp2";
+  };
+
+  icon = fetchurl {
+    url = "https://raw.githubusercontent.com/iNavFlight/inav-configurator/bf3fc89e6df51ecb83a386cd000eebf16859879e/images/inav_icon_128.png";
+    sha256 = "1i844dzzc5s5cr4vfpi6k2kdn8jiqq2n6c0fjqvsp4wdidwjahzw";
+  };
+
+  nativeBuildInputs = [ copyDesktopItems wrapGAppsHook ];
+
+  buildInputs = [ gsettings-desktop-schemas gtk3 ];
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out/bin \
+             $out/opt/${pname}
+
+    cp -r inav-configurator $out/opt/inav-configurator/
+    install -m 444 -D $icon $out/share/icons/hicolor/128x128/apps/${pname}.png
+
+    chmod +x $out/opt/inav-configurator/inav-configurator
+    makeWrapper ${nwjs}/bin/nw $out/bin/${pname} --add-flags $out/opt/inav-configurator/inav-configurator
+
+    runHook postInstall
+  '';
+
+  desktopItems = makeDesktopItem {
+    name = pname;
+    exec = pname;
+    icon = pname;
+    comment = "iNavFlight configuration tool";
+    desktopName = "iNav Configurator";
+    genericName = "Flight controller configuration tool";
+  };
+
+  meta = with lib; {
+    description = "The iNav flight control system configuration tool";
+    longDescription = ''
+      A crossplatform configuration tool for the iNav flight control system.
+      Various types of aircraft are supported by the tool and by iNav, e.g.
+      quadcopters, hexacopters, octocopters and fixed-wing aircraft.
+    '';
+    homepage = "https://github.com/iNavFlight/inav/wiki";
+    license = licenses.gpl3Only;
+    maintainers = with maintainers; [ tilcreator wucke13 ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/robotics/mavproxy/default.nix b/nixpkgs/pkgs/applications/science/robotics/mavproxy/default.nix
new file mode 100644
index 000000000000..c1e5b128fc71
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/robotics/mavproxy/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, lib, buildPythonApplication, fetchPypi, matplotlib, numpy, pymavlink, pyserial
+, setuptools, wxPython_4_0, billiard, gnureadline }:
+
+buildPythonApplication rec {
+  pname = "MAVProxy";
+  version = "1.8.46";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "c740c11551af4bcb1378772bde77ca6c846c6fd261b79d932c0ecbb164afe3bd";
+  };
+
+  postPatch = ''
+    substituteInPlace setup.py \
+      --replace "opencv-python" ""
+  '';
+
+  propagatedBuildInputs = [
+    matplotlib
+    numpy
+    pymavlink
+    pyserial
+    setuptools
+    wxPython_4_0
+  ] ++ lib.optionals stdenv.isDarwin [ billiard gnureadline ];
+
+  # No tests
+  doCheck = false;
+
+  meta = with lib; {
+    description = "MAVLink proxy and command line ground station";
+    homepage = "https://github.com/ArduPilot/MAVProxy";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ lopsided98 ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/robotics/mission-planner/default.nix b/nixpkgs/pkgs/applications/science/robotics/mission-planner/default.nix
new file mode 100644
index 000000000000..3f0a6a6cde50
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/robotics/mission-planner/default.nix
@@ -0,0 +1,59 @@
+{ lib, stdenv, fetchurl, makeDesktopItem, makeWrapper, unzip, mono }:
+
+let
+  pname = "mission-planner";
+  desktopItem = makeDesktopItem {
+    name = pname;
+    exec = pname;
+    icon = pname;
+    comment = "MissionPlanner GCS & Ardupilot configuration tool";
+    desktopName = "MissionPlanner";
+    genericName = "Ground Control Station";
+  };
+in stdenv.mkDerivation rec {
+  inherit pname;
+  version = "1.3.76";
+
+  src = fetchurl {
+    url = "https://firmware.ardupilot.org/Tools/MissionPlanner/MissionPlanner-${version}.zip";
+    sha256 = "sha256-vdunUGwLjDKf1LDhtyTQAExddecyWc1TdZOyuu0qMlk=";
+  };
+
+  nativeBuildInputs = [ makeWrapper mono unzip ];
+  sourceRoot = ".";
+
+  AOT_FILES = [ "MissionPlanner.exe" "MissionPlanner.*.dll" ];
+
+  buildPhase = ''
+    runHook preBuild
+    for file in $AOT_FILES
+    do
+      mono --aot $file
+    done
+    runHook postBuild
+  '';
+
+  installPhase = ''
+    runHook preInstall
+    mkdir -p $out/{bin,opt/mission-planner}
+    install -m 444 -D mpdesktop150.png $out/share/icons/mission-planner.png
+    cp -r ${desktopItem}/share/applications $out/share/
+    mv * $out/opt/mission-planner
+    makeWrapper ${mono}/bin/mono $out/bin/mission-planner \
+      --add-flags $out/opt/mission-planner/MissionPlanner.exe
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "An ArduPilot ground station";
+    longDescription = ''
+      Full-featured ground station application for the ArduPilot open source
+      autopilot project.  Lets you both flash, configure and control ArduPilot
+      Plane, Copter and Rover targets.
+    '';
+    homepage = "https://ardupilot.org/planner/";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ wucke13 ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/robotics/qgroundcontrol/default.nix b/nixpkgs/pkgs/applications/science/robotics/qgroundcontrol/default.nix
new file mode 100644
index 000000000000..afd05c3e8f71
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/robotics/qgroundcontrol/default.nix
@@ -0,0 +1,78 @@
+{ lib, mkDerivation, fetchFromGitHub, SDL2
+, qtbase, qtcharts, qtlocation, qtserialport, qtsvg, qtquickcontrols2
+, qtgraphicaleffects, qtspeech, qtx11extras, qmake, qttools
+, gst_all_1, wayland, pkg-config
+}:
+
+mkDerivation rec {
+  pname = "qgroundcontrol";
+  version = "4.2.0";
+
+  qtInputs = [
+    qtbase qtcharts qtlocation qtserialport qtsvg qtquickcontrols2
+    qtgraphicaleffects qtspeech qtx11extras
+  ];
+
+  gstInputs = with gst_all_1; [
+    gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad wayland
+  ];
+
+  buildInputs = [ SDL2 ] ++ gstInputs ++ qtInputs;
+  nativeBuildInputs = [ pkg-config qmake qttools ];
+
+  preConfigure = ''
+    mkdir build
+    cd build
+  '';
+
+  qmakeFlags = [
+    "CONFIG+=StableBuild"
+    # Default install tries to copy Qt files into package
+    "CONFIG+=QGC_DISABLE_BUILD_SETUP"
+    # Tries to download x86_64-only prebuilt binaries
+    "DEFINES+=DISABLE_AIRMAP"
+    "../qgroundcontrol.pro"
+  ];
+
+  installPhase = ''
+    runHook preInstall
+
+    cd ..
+
+    mkdir -p $out/share/applications
+    sed 's/Exec=.*$/Exec=QGroundControl/g' --in-place deploy/qgroundcontrol.desktop
+    cp -v deploy/qgroundcontrol.desktop $out/share/applications
+
+    mkdir -p $out/bin
+    cp -v build/staging/QGroundControl "$out/bin/"
+
+    mkdir -p $out/share/qgroundcontrol
+    cp -rv resources/ $out/share/qgroundcontrol
+
+    mkdir -p $out/share/pixmaps
+    cp -v resources/icons/qgroundcontrol.png $out/share/pixmaps
+
+    runHook postInstall
+  '';
+
+  postInstall = ''
+    qtWrapperArgs+=(--prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "$GST_PLUGIN_SYSTEM_PATH_1_0")
+  '';
+
+  # TODO: package mavlink so we can build from a normal source tarball
+  src = fetchFromGitHub {
+    owner = "mavlink";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "sha256-TBnJQKO9cwxP9q+bIB1CaGnm9npymJ3iEAD9kPJi9JA=";
+    fetchSubmodules = true;
+  };
+
+  meta = with lib; {
+    description = "Provides full ground station support and configuration for the PX4 and APM Flight Stacks";
+    homepage = "http://qgroundcontrol.com/";
+    license = licenses.gpl3Plus;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ lopsided98 ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/robotics/sumorobot-manager/default.nix b/nixpkgs/pkgs/applications/science/robotics/sumorobot-manager/default.nix
new file mode 100644
index 000000000000..c0f619b9592c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/robotics/sumorobot-manager/default.nix
@@ -0,0 +1,44 @@
+{ lib, stdenv, python3, qt5, fetchFromGitHub, wrapPython, pyqt5, pyserial, dos2unix }:
+
+stdenv.mkDerivation rec {
+  pname = "sumorobot-manager";
+  version = "1.0.0";
+
+  src = fetchFromGitHub {
+    owner = "robokoding";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "07snhwmqqp52vdgr66vx50zxx0nmpmns5cdjgh50hzlhji2z1fl9";
+  };
+
+  buildInputs = [ python3 ];
+  pythonPath = [
+    pyqt5.dev pyserial
+  ];
+
+  nativeBuildInputs = [ wrapPython qt5.wrapQtAppsHook dos2unix ];
+
+  buildPhase = "true";
+
+  installPhase = ''
+    mkdir -p $out/opt/sumorobot-manager
+    cp -r main.py lib res $out/opt/sumorobot-manager
+    chmod -R 644 $out/opt/sumorobot-manager/lib/*
+    mkdir $out/bin
+    dos2unix $out/opt/sumorobot-manager/main.py
+    makeQtWrapper $out/opt/sumorobot-manager/main.py $out/bin/sumorobot-manager \
+      --run "cd $out/opt/sumorobot-manager"
+  '';
+
+  preFixup = ''
+    patchShebangs $out/opt/sumorobot-manager/main.py
+    wrapPythonProgramsIn "$out/opt" "$pythonPath"
+  '';
+
+  meta = with lib; {
+    description = "Desktop App for managing SumoRobots";
+    homepage = "https://www.robokoding.com/kits/sumorobot/sumomanager/";
+    license = licenses.mit;
+    maintainers = with maintainers; [ abbradar ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/robotics/yarp/default.nix b/nixpkgs/pkgs/applications/science/robotics/yarp/default.nix
new file mode 100644
index 000000000000..3b33096dc683
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/robotics/yarp/default.nix
@@ -0,0 +1,36 @@
+{ lib, stdenv, fetchFromGitHub, cmake, ace
+}:
+
+stdenv.mkDerivation rec {
+  pname = "yarp";
+  version = "2.3.70.2";
+  src = fetchFromGitHub {
+    owner = "robotology";
+    repo = "yarp";
+    rev = "v${version}";
+    sha256 = "0mphh899niy30xbjjwi9xpsliq8mladfldbbbjfngdrqfhiray1a";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ ace ];
+
+  cmakeFlags = [
+    "-DYARP_COMPILE_UNMAINTAINED:BOOL=ON"
+    "-DCREATE_YARPC:BOOL=ON"
+    "-DCREATE_YARPCXX:BOOL=ON"
+  ];
+
+  # since we cant expand $out in cmakeFlags
+  preConfigure = ''cmakeFlags="$cmakeFlags -DCMAKE_INSTALL_LIBDIR=$out/lib"'';
+
+  postInstall = "mv ./$out/lib/*.so $out/lib/";
+
+  meta = {
+    description = "Yet Another Robot Platform";
+    homepage = "http://yarp.it";
+    license = lib.licenses.lgpl21;
+    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.nico202 ];
+  };
+}
+