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/celestia/default.nix75
-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.nix69
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/gildas/wrapper.patch19
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/gpredict/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/gravit/default.nix42
-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.nix89
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/openspace/vrpn.patch13
-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.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/xplanet/gcc6.patch128
-rw-r--r--nixpkgs/pkgs/applications/science/astronomy/xplanet/giflib.patch141
-rw-r--r--nixpkgs/pkgs/applications/science/biology/EZminc/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/biology/N3/default.nix35
-rw-r--r--nixpkgs/pkgs/applications/science/biology/ants/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/biology/bcftools/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/science/biology/bedtools/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/biology/bftools/default.nix41
-rw-r--r--nixpkgs/pkgs/applications/science/biology/bowtie2/default.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/biology/bwa/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/science/biology/cmtk/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/science/biology/conglomerate/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/biology/dcm2niix/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/biology/diamond/default.nix41
-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.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/biology/emboss/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/biology/freebayes/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/biology/hisat2/default.nix49
-rw-r--r--nixpkgs/pkgs/applications/science/biology/hmmer/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/science/biology/igv/default.nix33
-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/iv/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/biology/kallisto/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/science/biology/minc-tools/default.nix35
-rw-r--r--nixpkgs/pkgs/applications/science/biology/minc-widgets/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/biology/minimap2/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/biology/mni_autoreg/default.nix36
-rw-r--r--nixpkgs/pkgs/applications/science/biology/mosdepth/default.nix45
-rw-r--r--nixpkgs/pkgs/applications/science/biology/mrbayes/builder.sh9
-rw-r--r--nixpkgs/pkgs/applications/science/biology/mrbayes/default.nix29
-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.nix80
-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.nix24
-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.nix38
-rw-r--r--nixpkgs/pkgs/applications/science/biology/plink-ng/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/biology/plink/default.nix25
-rwxr-xr-xnixpkgs/pkgs/applications/science/biology/poretools/default.nix23
-rw-r--r--nixpkgs/pkgs/applications/science/biology/raxml/default.nix41
-rw-r--r--nixpkgs/pkgs/applications/science/biology/samtools/default.nix35
-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.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/biology/seaview/default.nix41
-rw-r--r--nixpkgs/pkgs/applications/science/biology/snpeff/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/biology/somatic-sniper/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/biology/somatic-sniper/somatic-sniper.patch26
-rw-r--r--nixpkgs/pkgs/applications/science/biology/star/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/biology/strelka/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/biology/varscan/default.nix36
-rwxr-xr-xnixpkgs/pkgs/applications/science/biology/vcftools/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/avogadro/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/gwyddion/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/jmol/default.nix53
-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.nix49
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/molden/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/molden/dont_register_file_types.patch29
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/octopus/default.nix49
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/openmolcas/default.nix72
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/pymol/default.nix51
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/quantum-espresso/default.nix49
-rw-r--r--nixpkgs/pkgs/applications/science/chemistry/siesta/default.nix69
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/adms/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/alliance/default.nix75
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/archimedes/default.nix17
-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.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/caneda/gcc6.patch13
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/dsview/default.nix47
-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/eagle/eagle.nix83
-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/fritzing/default.nix46
-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/gtkwave/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/kicad/default.nix72
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/kicad/unstable.nix56
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/librepcb/default.nix35
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/ngspice/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/pcb/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/pulseview/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/qfsm/default.nix29
-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/cmakelists.patch34
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/qucs/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/tkgate/1.x.nix42
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/verilator/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/verilog/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/xcircuit/default.nix35
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/xoscope/default.nix24
-rw-r--r--nixpkgs/pkgs/applications/science/electronics/xoscope/gtkdepre.diff58
-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/tetgen/1.4.nix22
-rw-r--r--nixpkgs/pkgs/applications/science/geometry/tetgen/default.nix24
-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.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/logic/aiger/default.nix55
-rw-r--r--nixpkgs/pkgs/applications/science/logic/alt-ergo/default.nix26
-rw-r--r--nixpkgs/pkgs/applications/science/logic/aspino/default.nix50
-rw-r--r--nixpkgs/pkgs/applications/science/logic/avy/0001-no-static-boost-libs.patch12
-rw-r--r--nixpkgs/pkgs/applications/science/logic/avy/default.nix53
-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.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/logic/boolector/default.nix50
-rw-r--r--nixpkgs/pkgs/applications/science/logic/btor2tools/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/logic/cedille/default.nix50
-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.nix151
-rw-r--r--nixpkgs/pkgs/applications/science/logic/coq2html/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/science/logic/cryptominisat/default.nix24
-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.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/logic/cvc4/default.nix43
-rw-r--r--nixpkgs/pkgs/applications/science/logic/cvc4/minisat-fenv.patch65
-rw-r--r--nixpkgs/pkgs/applications/science/logic/drat-trim/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/logic/ekrhyper/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/logic/ekrhyper/default.upstream3
-rw-r--r--nixpkgs/pkgs/applications/science/logic/elan/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/science/logic/eprover/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/logic/gappa/default.nix23
-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.nix88
-rw-r--r--nixpkgs/pkgs/applications/science/logic/hol_light/default.nix50
-rw-r--r--nixpkgs/pkgs/applications/science/logic/iprover/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/logic/isabelle/default.nix77
-rw-r--r--nixpkgs/pkgs/applications/science/logic/jonprl/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/logic/lci/default.nix16
-rw-r--r--nixpkgs/pkgs/applications/science/logic/lean/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/logic/lean2/default.nix36
-rw-r--r--nixpkgs/pkgs/applications/science/logic/leo2/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/logic/leo2/default.upstream6
-rw-r--r--nixpkgs/pkgs/applications/science/logic/leo3/binary.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/logic/lingeling/default.nix49
-rw-r--r--nixpkgs/pkgs/applications/science/logic/logisim/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/logic/ltl2ba/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/logic/mcrl2/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/logic/metis-prover/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/logic/minisat/clang.diff45
-rw-r--r--nixpkgs/pkgs/applications/science/logic/minisat/darwin.patch26
-rw-r--r--nixpkgs/pkgs/applications/science/logic/minisat/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/logic/minisat/unstable.nix23
-rw-r--r--nixpkgs/pkgs/applications/science/logic/monosat/default.nix67
-rw-r--r--nixpkgs/pkgs/applications/science/logic/open-wbo/default.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/logic/opensmt/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/science/logic/ott/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/science/logic/otter/default.nix53
-rw-r--r--nixpkgs/pkgs/applications/science/logic/picosat/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/science/logic/poly/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/science/logic/potassco/clingo.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/logic/potassco/clingo.upstream6
-rw-r--r--nixpkgs/pkgs/applications/science/logic/prooftree/default.nix43
-rw-r--r--nixpkgs/pkgs/applications/science/logic/prover9/default.nix45
-rw-r--r--nixpkgs/pkgs/applications/science/logic/proverif/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/logic/redprl/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/logic/sad/default.nix39
-rw-r--r--nixpkgs/pkgs/applications/science/logic/sad/monoid.patch51
-rw-r--r--nixpkgs/pkgs/applications/science/logic/sad/patch200
-rw-r--r--nixpkgs/pkgs/applications/science/logic/satallax/default.nix66
-rw-r--r--nixpkgs/pkgs/applications/science/logic/saw-tools/default.nix61
-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.nix36
-rw-r--r--nixpkgs/pkgs/applications/science/logic/symbiyosys/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/logic/tamarin-prover/default.nix107
-rw-r--r--nixpkgs/pkgs/applications/science/logic/tamarin-prover/sapic-native.patch77
-rw-r--r--nixpkgs/pkgs/applications/science/logic/tlaplus/default.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/logic/tlaplus/tlaps.nix54
-rw-r--r--nixpkgs/pkgs/applications/science/logic/tlaplus/toolbox.nix77
-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.nix59
-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.nix27
-rw-r--r--nixpkgs/pkgs/applications/science/logic/workcraft/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/logic/yices/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/science/logic/z3/0001-fix-2131.patch66
-rw-r--r--nixpkgs/pkgs/applications/science/logic/z3/default.nix46
-rw-r--r--nixpkgs/pkgs/applications/science/logic/z3/tptp.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/machine-learning/labelimg/default.nix23
-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.nix65
-rw-r--r--nixpkgs/pkgs/applications/science/machine-learning/torch/default.nix10
-rw-r--r--nixpkgs/pkgs/applications/science/machine-learning/torch/torch-distro.nix336
-rw-r--r--nixpkgs/pkgs/applications/science/math/LiE/default.nix47
-rw-r--r--nixpkgs/pkgs/applications/science/math/R/default.nix108
-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.nix34
-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.nix134
-rw-r--r--nixpkgs/pkgs/applications/science/math/caffe/python.patch70
-rw-r--r--nixpkgs/pkgs/applications/science/math/calc/default.nix49
-rw-r--r--nixpkgs/pkgs/applications/science/math/cbc/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/math/clp/default.nix22
-rw-r--r--nixpkgs/pkgs/applications/science/math/cntk/default.nix92
-rw-r--r--nixpkgs/pkgs/applications/science/math/cntk/fix_std_bind.patch11
-rw-r--r--nixpkgs/pkgs/applications/science/math/colpack/default.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/math/cplex/default.nix82
-rw-r--r--nixpkgs/pkgs/applications/science/math/csdp/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/math/ecm/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/math/eukleides/default.nix37
-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.nix194
-rw-r--r--nixpkgs/pkgs/applications/science/math/geogebra/default.nix63
-rw-r--r--nixpkgs/pkgs/applications/science/math/getdp/default.nix25
-rw-r--r--nixpkgs/pkgs/applications/science/math/gfan/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/math/giac/default.nix112
-rw-r--r--nixpkgs/pkgs/applications/science/math/ginac/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/math/glsurf/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/math/gmsh/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/math/gurobi/default.nix54
-rw-r--r--nixpkgs/pkgs/applications/science/math/hmetis/default.nix42
-rw-r--r--nixpkgs/pkgs/applications/science/math/jags/default.nix19
-rw-r--r--nixpkgs/pkgs/applications/science/math/lp_solve/default.nix49
-rw-r--r--nixpkgs/pkgs/applications/science/math/lp_solve/isnan.patch13
-rw-r--r--nixpkgs/pkgs/applications/science/math/lrcalc/default.nix41
-rw-r--r--nixpkgs/pkgs/applications/science/math/mathematica/10.nix136
-rw-r--r--nixpkgs/pkgs/applications/science/math/mathematica/9.nix122
-rw-r--r--nixpkgs/pkgs/applications/science/math/mathematica/default.nix148
-rw-r--r--nixpkgs/pkgs/applications/science/math/mathematica/l10ns.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/math/maxima/default.nix108
-rw-r--r--nixpkgs/pkgs/applications/science/math/maxima/known-ecl-failures.patch21
-rw-r--r--nixpkgs/pkgs/applications/science/math/msieve/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/math/mxnet/default.nix56
-rw-r--r--nixpkgs/pkgs/applications/science/math/nasc/default.nix62
-rw-r--r--nixpkgs/pkgs/applications/science/math/nauty/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/math/palp/default.nix86
-rw-r--r--nixpkgs/pkgs/applications/science/math/pari/default.nix94
-rw-r--r--nixpkgs/pkgs/applications/science/math/pari/gp2c.nix28
-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.nix48
-rw-r--r--nixpkgs/pkgs/applications/science/math/pspp/default.nix51
-rw-r--r--nixpkgs/pkgs/applications/science/math/pynac/default.nix48
-rw-r--r--nixpkgs/pkgs/applications/science/math/qalculate-gtk/default.nix30
-rw-r--r--nixpkgs/pkgs/applications/science/math/ratpoints/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/math/ries/default.nix21
-rw-r--r--nixpkgs/pkgs/applications/science/math/ripser/default.nix66
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/README.md78
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/default.nix169
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/env-locations.nix48
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/flask-oldsessions.nix36
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/flask-openid.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch35
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/fix-ecl-race.patch19
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/giac-1.5.0.patch14
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/ignore-pip-deprecation.patch22
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/pari-stackwarn.patch20
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/python-5755-hotpatch.patch28
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/patches/revert-sphinx-always-fork.patch71
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/pybrial.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/python-openid.nix40
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/sage-env.nix169
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/sage-src.nix143
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/sage-tests.nix57
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/sage-with-env.nix126
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/sage.nix68
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/sagedoc.nix81
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/sagelib.nix144
-rw-r--r--nixpkgs/pkgs/applications/science/math/sage/sagenb.nix53
-rw-r--r--nixpkgs/pkgs/applications/science/math/scilab-bin/default.nix106
-rw-r--r--nixpkgs/pkgs/applications/science/math/scilab/default.nix66
-rw-r--r--nixpkgs/pkgs/applications/science/math/scotch/default.nix36
-rw-r--r--nixpkgs/pkgs/applications/science/math/singular/default.nix118
-rw-r--r--nixpkgs/pkgs/applications/science/math/speedcrunch/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/math/symmetrica/default.nix62
-rw-r--r--nixpkgs/pkgs/applications/science/math/weka/default.nix31
-rw-r--r--nixpkgs/pkgs/applications/science/math/wxmaxima/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/math/yacas/default.nix39
-rw-r--r--nixpkgs/pkgs/applications/science/medicine/aliza/default.nix52
-rw-r--r--nixpkgs/pkgs/applications/science/misc/boinc/default.nix46
-rw-r--r--nixpkgs/pkgs/applications/science/misc/cytoscape/default.nix34
-rw-r--r--nixpkgs/pkgs/applications/science/misc/fityk/default.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/misc/gephi/default.nix64
-rw-r--r--nixpkgs/pkgs/applications/science/misc/golly/beta.nix51
-rw-r--r--nixpkgs/pkgs/applications/science/misc/golly/default.nix39
-rw-r--r--nixpkgs/pkgs/applications/science/misc/golly/default.upstream5
-rw-r--r--nixpkgs/pkgs/applications/science/misc/gplates/boostfix.patch612
-rw-r--r--nixpkgs/pkgs/applications/science/misc/gplates/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/misc/megam/default.nix46
-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/motu-client/default.nix23
-rw-r--r--nixpkgs/pkgs/applications/science/misc/netlogo/default.nix58
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/default.nix57
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/fakegit.nix81
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/src-libs-git.nix71
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/src-libs-svn.nix5
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmodelica/src-main.nix6
-rwxr-xr-xnixpkgs/pkgs/applications/science/misc/openmodelica/update-src-libs-git.sh64
-rwxr-xr-xnixpkgs/pkgs/applications/science/misc/openmodelica/update-src-libs-svn.sh50
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmvg/default.nix51
-rw-r--r--nixpkgs/pkgs/applications/science/misc/openmvs/default.nix62
-rw-r--r--nixpkgs/pkgs/applications/science/misc/rink/cargo-lock.patch1725
-rw-r--r--nixpkgs/pkgs/applications/science/misc/rink/default.nix29
-rw-r--r--nixpkgs/pkgs/applications/science/misc/root/5.nix80
-rw-r--r--nixpkgs/pkgs/applications/science/misc/root/default.nix77
-rw-r--r--nixpkgs/pkgs/applications/science/misc/root/setup-hook.sh9
-rw-r--r--nixpkgs/pkgs/applications/science/misc/root/sw_vers.patch90
-rw-r--r--nixpkgs/pkgs/applications/science/misc/root/sw_vers_root5.patch104
-rw-r--r--nixpkgs/pkgs/applications/science/misc/sasview/default.nix75
-rw-r--r--nixpkgs/pkgs/applications/science/misc/sasview/local_config.patch22
-rw-r--r--nixpkgs/pkgs/applications/science/misc/sasview/pyparsing-fix.patch13
-rw-r--r--nixpkgs/pkgs/applications/science/misc/sasview/xhtml2pdf.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/misc/simgrid/default.nix112
-rw-r--r--nixpkgs/pkgs/applications/science/misc/snakemake/default.nix42
-rw-r--r--nixpkgs/pkgs/applications/science/misc/tulip/default.nix38
-rw-r--r--nixpkgs/pkgs/applications/science/misc/vite/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/science/molecular-dynamics/dl-poly-classic/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/molecular-dynamics/gromacs/default.nix55
-rw-r--r--nixpkgs/pkgs/applications/science/molecular-dynamics/lammps/default.nix67
-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.nix47
-rw-r--r--nixpkgs/pkgs/applications/science/physics/sherpa/default.nix33
-rw-r--r--nixpkgs/pkgs/applications/science/physics/xfitter/default.nix56
-rw-r--r--nixpkgs/pkgs/applications/science/physics/xfitter/undefined_behavior.patch454
-rw-r--r--nixpkgs/pkgs/applications/science/programming/fdr/default.nix69
-rw-r--r--nixpkgs/pkgs/applications/science/programming/plm/default.nix36
-rw-r--r--nixpkgs/pkgs/applications/science/programming/scyther/cli.nix32
-rw-r--r--nixpkgs/pkgs/applications/science/programming/scyther/default.nix79
-rw-r--r--nixpkgs/pkgs/applications/science/robotics/apmplanner2/default.nix44
-rw-r--r--nixpkgs/pkgs/applications/science/robotics/gazebo/6.nix8
-rw-r--r--nixpkgs/pkgs/applications/science/robotics/gazebo/default.nix84
-rw-r--r--nixpkgs/pkgs/applications/science/robotics/qgroundcontrol/0001-fix-gcc-cmath-namespace-issues.patch140
-rw-r--r--nixpkgs/pkgs/applications/science/robotics/qgroundcontrol/default.nix73
-rw-r--r--nixpkgs/pkgs/applications/science/robotics/yarp/default.nix37
-rw-r--r--nixpkgs/pkgs/applications/science/spyder/default.nix75
372 files changed, 20086 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..3150d41ca9f6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/astrolabe-generator/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchurl, jre, makeWrapper, unzip }:
+
+stdenv.mkDerivation rec {
+  name = "astrolabe-generator-${version}";
+  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 stdenv.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 = [ maintainers.genesis ];
+    platforms = platforms.all;
+  };
+}
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..e3ceffd34c19
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/celestia/default.nix
@@ -0,0 +1,75 @@
+{ stdenv, fetchurl, freeglut, gtk2, gtkglext, libjpeg_turbo, libtheora, libXmu
+, lua, libGLU_combined, pkgconfig, perl, autoreconfHook
+}:
+
+let
+  name = "celestia-1.6.1";
+
+  gcc46Patch = fetchurl {
+    url = "https://projects.archlinux.org/svntogit/packages.git/plain/trunk/celestia-1.6.1-gcc46.patch?h=packages/celestia";
+    sha256 = "0my7dpyh5wpz5df7bjhwb4db3ci2rn8ib1nkjv15fbp1g76bxfaz";
+    name = "celestia-1.6.1-gcc46.patch";
+  };
+
+  libpng15Patch = fetchurl {
+    url = "https://projects.archlinux.org/svntogit/packages.git/plain/trunk/celestia-1.6.1-libpng15.patch?h=packages/celestia";
+    sha256 = "1jrmbwmvs9b6k2b2g4104q22v4vqi0wfpz6hmfhniaq34626jcms";
+    name = "celestia-1.6.1-libpng15.patch";
+  };
+
+  libpng16Patch = fetchurl {
+    url = "https://projects.archlinux.org/svntogit/packages.git/plain/trunk/celestia-1.6.1-libpng16.patch?h=packages/celestia";
+    sha256 = "1q85prw4ci6d50lri8w1jm19pghxw96qizf5dl4g0j86rlhlkc8f";
+    name = "celestia-1.6.1-libpng16.patch";
+  };
+
+  linkingPatch = fetchurl {
+    url = "https://projects.archlinux.org/svntogit/packages.git/plain/trunk/celestia-1.6.1-linking.patch?h=packages/celestia";
+    sha256 = "1m8xyq26nm352828bp12c3b8f6m9bys9fwfxbfzqppllk7il2f24";
+    name = "celestia-1.6.1-linking.patch";
+  };
+
+  gcc47Patch = fetchurl {
+    url = "https://projects.archlinux.org/svntogit/packages.git/plain/trunk/gcc-4.7-fixes.diff?h=packages/celestia";
+    sha256 = "1na26c7pv9qfv8a981m1zvglhv05r3h8513xqjra91qhhzx8wr8n";
+    name = "gcc-4.7-fixes.diff";
+  };
+in
+stdenv.mkDerivation {
+  inherit name;
+
+  src = fetchurl {
+    url = "mirror://sourceforge/celestia/${name}.tar.gz";
+    sha256 = "1i1lvhbgllsh2z8i6jj4mvrjak4a7r69psvk7syw03s4p7670mfk";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ freeglut gtk2 gtkglext libjpeg_turbo libtheora libXmu libGLU_combined lua
+    perl autoreconfHook ];
+
+  patchPhase = ''
+    patch -Np0 -i "${gcc46Patch}"
+    patch -Np0 -i "${libpng15Patch}"
+    patch -Np2 -i "${libpng16Patch}"
+    patch -Np1 -i "${linkingPatch}"
+    patch -Np1 -i "${gcc47Patch}"
+  '';
+
+  configureFlags = [
+    "--with-gtk"
+    "--with-lua=${lua}"
+  ];
+
+  installPhase = ''make MKDIR_P="mkdir -p" install'';
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "Free space simulation";
+    homepage = https://celestia.space/;
+    license = stdenv.lib.licenses.gpl2;
+
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.peti ];
+  };
+}
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..57cecb3cb4cd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/gildas/default.nix
@@ -0,0 +1,69 @@
+{ stdenv, fetchurl, gtk2-x11 , pkgconfig , python27 , gfortran , lesstif
+, cfitsio , getopt , perl , groff , which
+}:
+
+let
+  python27Env = python27.withPackages(ps: with ps; [ numpy ]);
+in
+
+stdenv.mkDerivation rec {
+  srcVersion = "feb19b";
+  version = "20190201_b";
+  name = "gildas-${version}";
+
+  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.gz"
+      "http://www.iram.fr/~gildas/dist/archive/gildas/gildas-src-${srcVersion}.tar.gz" ];
+    sha256 = "5b6da12ac869176d7a9a3d6a6620db1dbaa44a4785e2dd59dd1a8c38ea9cab87";
+  };
+
+  enableParallelBuilding = true;
+
+  nativeBuildInputs = [ pkgconfig groff perl getopt gfortran which ];
+
+  buildInputs = [ gtk2-x11 lesstif cfitsio python27Env ];
+
+  patches = [ ./wrapper.patch ./clang.patch ./aarch64.patch ];
+
+  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.cc.isClang "-Wno-unused-command-line-argument";
+
+  configurePhase=''
+    substituteInPlace admin/wrapper.sh --replace '%%OUT%%' $out
+    substituteInPlace admin/wrapper.sh --replace '%%PYTHONHOME%%' ${python27Env}
+    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 = stdenv.lib.licenses.free;
+    maintainers = [ stdenv.lib.maintainers.bzizou stdenv.lib.maintainers.smaret ];
+    platforms = stdenv.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..2e470a1e9cdc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/gildas/wrapper.patch
@@ -0,0 +1,19 @@
+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,15 @@
++#!/bin/sh -e
++
++export GAG_ROOT_DIR="%%OUT%%"
++export GAG_PATH="${GAG_ROOT_DIR}/etc"
++export GAG_EXEC_SYSTEM="libexec"
++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..9bacf6d90417
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/gpredict/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, pkgconfig, intltool
+, gtk3, glib, curl, goocanvas2, gpsd
+, hamlib, wrapGAppsHook
+}:
+
+let
+  version = "2.2.1";
+in stdenv.mkDerivation {
+  name = "gpredict-${version}";
+
+  src = fetchurl {
+    url = "https://github.com/csete/gpredict/releases/download/v${version}/gpredict-${version}.tar.bz2";
+    sha256 = "0hwf97kng1zy8rxyglw04x89p0bg07zq30hgghm20yxiw2xc8ng7";
+  };
+
+  nativeBuildInputs = [ pkgconfig intltool wrapGAppsHook ];
+  buildInputs = [ curl glib gtk3 goocanvas2 gpsd hamlib ];
+
+  meta = with stdenv.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.gpl2;
+    platforms = platforms.linux;
+    homepage = http://gpredict.oz9aec.net/;
+    maintainers = [ maintainers.markuskowa maintainers.cmcdragonkai ];
+  };
+}
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..03d0018f237b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/gravit/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchurl, SDL, SDL_ttf, SDL_image, libSM, libICE, libGLU_combined, libpng, lua5, autoconf, automake }:
+
+stdenv.mkDerivation rec {
+  name = "gravit-0.5.1";
+
+  src = fetchurl {
+    url = "https://gravit.slowchop.com/media/downloads/${name}.tgz";
+    sha256 = "14vf7zj2bgrl96wsl3f1knsggc8h9624354ajzd72l46y09x5ky7";
+  };
+
+  buildInputs = [ libGLU_combined 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://gravit.slowchop.com;
+    description = "Beautiful OpenGL-based gravity simulator";
+    license = stdenv.lib.licenses.gpl2;
+
+    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 = stdenv.lib.platforms.mesaPlatforms;
+    hydraPlatforms = stdenv.lib.platforms.linux; # darwin times out
+  };
+}
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..ee3a71cf1813
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/openspace/default.nix
@@ -0,0 +1,89 @@
+{ stdenv, fetchFromGitHub, fetchurl, makeWrapper, cmake
+, curl, boost, gdal, glew, soil
+, libX11, libXi, libXxf86vm, libXcursor, libXrandr, libXinerama }:
+
+stdenv.mkDerivation rec {
+  version = "0.11.1";
+  name    = "openspace-${version}";
+  
+  src = fetchFromGitHub {
+    owner  = "OpenSpace";
+    repo   = "OpenSpace";
+    rev    = "a65eea61a1b8807ce3d69e9925e75f8e3dfb085d";
+    sha256 = "0msqixf30r0d41xmfmzkdfw6w9jkx2ph5clq8xiwrg1jc3z9q7nv";
+    fetchSubmodules = true;
+  };
+  
+  buildInputs = [
+    makeWrapper cmake
+    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   = stdenv.lib.licenses.mit;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
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/stellarium/default.nix b/nixpkgs/pkgs/applications/science/astronomy/stellarium/default.nix
new file mode 100644
index 000000000000..eb7ba2a8c9c4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/stellarium/default.nix
@@ -0,0 +1,38 @@
+{ mkDerivation, lib, fetchFromGitHub
+, cmake, freetype, libpng, libGLU_combined, openssl, perl, libiconv
+, qtscript, qtserialport, qttools
+, qtmultimedia, qtlocation, makeWrapper, qtbase
+}:
+
+mkDerivation rec {
+  name = "stellarium-${version}";
+  version = "0.18.3";
+
+  src = fetchFromGitHub {
+    owner = "Stellarium";
+    repo = "stellarium";
+    rev = "v${version}";
+    sha256 = "1cnwfk3vdsxh8gacw22qik401z0kpzd1ralbg9ph2cjqx9x2m1s1";
+  };
+
+  nativeBuildInputs = [ cmake perl ];
+
+  buildInputs = [
+    freetype libpng libGLU_combined openssl libiconv qtscript qtserialport qttools
+    qtmultimedia qtlocation qtbase makeWrapper
+  ];
+
+  postInstall = ''
+    wrapProgram $out/bin/stellarium \
+      --prefix QT_PLUGIN_PATH : "${qtbase}/lib/qt-5.${lib.versions.minor qtbase.version}/plugins"
+  '';
+
+  meta = with lib; {
+    description = "Free open-source planetarium";
+    homepage = http://stellarium.org/;
+    license = licenses.gpl2;
+
+    platforms = platforms.linux; # should be mesaPlatforms, but we don't have qt on darwin
+    maintainers = with maintainers; [ peti 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..fef4ca1907fd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/xearth/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchurl, imake, gccmakedep, libXt, libXext }:
+
+stdenv.mkDerivation rec {
+  name = "xearth-${version}";
+  version = "1.1";
+
+  src = fetchurl {
+    url = "http://xearth.org/${name}.tar.gz";
+    sha256 = "bcb1407cc35b3f6dd3606b2c6072273b6a912cbd9ed1ae22fb2d26694541309c";
+  };
+
+  nativeBuildInputs = [ imake gccmakedep ];
+  buildInputs = [ libXt libXext ];
+
+  installFlags=[ "DESTDIR=$(out)/" "BINDIR=bin" "MANDIR=man/man1"];
+  installTargets="install install.man";
+
+  meta = with stdenv.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..7abd83b6dc12
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/xplanet/default.nix
@@ -0,0 +1,27 @@
+{stdenv, fetchurl, pkgconfig, freetype, pango, libpng, libtiff, giflib
+, libjpeg, netpbm}:
+
+stdenv.mkDerivation rec {
+  name = "xplanet-1.3.0";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/xplanet/${name}.tar.gz";
+    sha256 = "0hml2v228wi2r61m1pgka7h96rl92b6apk0iigm62miyp4mp9ys4";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ freetype pango libpng libtiff giflib libjpeg netpbm ];
+
+  patches = [
+    ./giflib.patch
+    ./gcc6.patch
+  ];
+
+  meta = {
+    description = "Renders an image of the earth or other planets into the X root window";
+    homepage = http://xplanet.sourceforge.net;
+    license = "GPL";
+    maintainers = [ stdenv.lib.maintainers.sander ];
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/astronomy/xplanet/gcc6.patch b/nixpkgs/pkgs/applications/science/astronomy/xplanet/gcc6.patch
new file mode 100644
index 000000000000..b30385a50f83
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/xplanet/gcc6.patch
@@ -0,0 +1,128 @@
+diff --git c/src/libannotate/addArcs.cpp i/src/libannotate/addArcs.cpp
+index 2ee06c0..0ff5478 100644
+--- c/src/libannotate/addArcs.cpp
++++ i/src/libannotate/addArcs.cpp
+@@ -258,7 +258,7 @@ addArcs(PlanetProperties *planetProperties, Planet *planet,
+         {
+             ifstream inFile(arcFile.c_str());
+             char *line = new char[MAX_LINE_LENGTH];
+-            while (inFile.getline (line, MAX_LINE_LENGTH, '\n') != NULL)
++            while (inFile.getline (line, MAX_LINE_LENGTH, '\n'))
+                 readArcFile(line, planet, view, projection,
+                             planetProperties, annotationMap);
+             
+@@ -292,7 +292,7 @@ addArcs(View *view, multimap<double, Annotation *> &annotationMap)
+         {
+             ifstream inFile(arcFile.c_str());
+             char *line = new char[256];
+-            while (inFile.getline (line, 256, '\n') != NULL)
++            while (inFile.getline (line, 256, '\n'))
+                 readArcFile(line, NULL, view, NULL, NULL, annotationMap);
+ 
+             inFile.close();
+diff --git c/src/libannotate/addMarkers.cpp i/src/libannotate/addMarkers.cpp
+index 6a8a835..b35d820 100644
+--- c/src/libannotate/addMarkers.cpp
++++ i/src/libannotate/addMarkers.cpp
+@@ -423,7 +423,7 @@ addMarkers(PlanetProperties *planetProperties, Planet *planet,
+         {
+             ifstream inFile(markerFile.c_str());
+             char *line = new char[MAX_LINE_LENGTH];
+-            while (inFile.getline (line, MAX_LINE_LENGTH, '\n') != NULL)
++            while (inFile.getline (line, MAX_LINE_LENGTH, '\n'))
+             {
+                 unsigned char color[3];
+                 memcpy(color, planetProperties->MarkerColor(), 3);
+@@ -469,7 +469,7 @@ addMarkers(View *view, const int width, const int height,
+         {
+             ifstream inFile(markerFile.c_str());
+             char *line = new char[MAX_LINE_LENGTH];
+-            while (inFile.getline (line, MAX_LINE_LENGTH, '\n') != NULL)
++            while (inFile.getline (line, MAX_LINE_LENGTH, '\n'))
+             {
+                 unsigned char color[3];
+                 memcpy(color, options->Color(), 3);
+diff --git c/src/libannotate/addSatellites.cpp i/src/libannotate/addSatellites.cpp
+index 2634339..c9ff0b0 100644
+--- c/src/libannotate/addSatellites.cpp
++++ i/src/libannotate/addSatellites.cpp
+@@ -488,10 +488,10 @@ loadSatelliteVector(PlanetProperties *planetProperties)
+         {
+             ifstream inFile(tleFile.c_str());
+             char lines[3][80];
+-            while (inFile.getline(lines[0], 80) != NULL)
++            while (inFile.getline(lines[0], 80))
+             {
+-                if ((inFile.getline(lines[1], 80) == NULL) 
+-                    || (inFile.getline(lines[2], 80) == NULL))
++                if ((inFile.getline(lines[1], 80))
++                    || (inFile.getline(lines[2], 80)))
+                 {
+                     ostringstream errStr;
+                     errStr << "Malformed TLE file (" << tleFile << ")?\n";
+@@ -542,7 +542,7 @@ addSatellites(PlanetProperties *planetProperties, Planet *planet,
+         {
+             ifstream inFile(satFile.c_str());
+             char *line = new char[MAX_LINE_LENGTH];
+-            while (inFile.getline (line, MAX_LINE_LENGTH, '\n') != NULL)
++            while (inFile.getline (line, MAX_LINE_LENGTH, '\n'))
+                 readSatelliteFile(line, planet, view, projection,
+                                   planetProperties, annotationMap);
+             
+diff --git c/src/libmultiple/RayleighScattering.cpp i/src/libmultiple/RayleighScattering.cpp
+index d885173..7c25c1c 100644
+--- c/src/libmultiple/RayleighScattering.cpp
++++ i/src/libmultiple/RayleighScattering.cpp
+@@ -369,7 +369,7 @@ RayleighScattering::readConfigFile(string configFile)
+ 
+     diskTemplate_.clear();
+     limbTemplate_.clear();
+-    while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
++    while (inFile.getline(line, MAX_LINE_LENGTH, '\n'))
+     {
+         int i = 0;
+         while (isDelimiter(line[i]))
+@@ -439,7 +439,7 @@ RayleighScattering::readBlock(ifstream &inFile,
+     values.clear();
+ 
+     char line[MAX_LINE_LENGTH];
+-    while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
++    while (inFile.getline(line, MAX_LINE_LENGTH, '\n'))
+     {
+         int i = 0;
+         while (isDelimiter(line[i]))
+@@ -470,7 +470,7 @@ RayleighScattering::readValue(ifstream &inFile,
+                               double &value)
+ {
+     char line[MAX_LINE_LENGTH];
+-    while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
++    while (inFile.getline(line, MAX_LINE_LENGTH, '\n'))
+     {
+         int i = 0;
+         while (isDelimiter(line[i]))
+diff --git c/src/libmultiple/drawStars.cpp i/src/libmultiple/drawStars.cpp
+index ff07c49..22e41a0 100644
+--- c/src/libmultiple/drawStars.cpp
++++ i/src/libmultiple/drawStars.cpp
+@@ -41,7 +41,7 @@ drawStars(DisplayBase *display, View *view)
+     ifstream inFile(starMap.c_str());
+ 
+     char line[MAX_LINE_LENGTH];
+-    while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
++    while (inFile.getline(line, MAX_LINE_LENGTH, '\n'))
+     {
+         if (line[0] == '#') continue;
+ 
+diff --git c/src/readConfig.cpp i/src/readConfig.cpp
+index cc1964f..2946690 100644
+--- c/src/readConfig.cpp
++++ i/src/readConfig.cpp
+@@ -550,7 +550,7 @@ readConfigFile(string configFile, PlanetProperties *planetProperties[])
+ 
+         ifstream inFile(configFile.c_str());
+         char *line = new char[256];
+-        while (inFile.getline(line, 256, '\n') != NULL)
++        while (inFile.getline(line, 256, '\n'))
+             readConfig(line, planetProperties);
+         
+         // This condition will only be true if [default] is the only
diff --git a/nixpkgs/pkgs/applications/science/astronomy/xplanet/giflib.patch b/nixpkgs/pkgs/applications/science/astronomy/xplanet/giflib.patch
new file mode 100644
index 000000000000..653b9c8dc7d6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/astronomy/xplanet/giflib.patch
@@ -0,0 +1,141 @@
+diff -wbBur xplanet-1.3.0/src/libimage/gif.c xplanet-1.3.0.my/src/libimage/gif.c
+--- xplanet-1.3.0/src/libimage/gif.c	2006-03-26 01:50:51.000000000 +0300
++++ xplanet-1.3.0.my/src/libimage/gif.c	2014-05-29 18:59:14.830652716 +0400
+@@ -20,7 +20,7 @@
+ 
+ #include <stdio.h>
+ #include <stdlib.h>
+-
++#define FALSE 0
+ #include <gif_lib.h>
+ 
+ /*
+@@ -42,11 +42,11 @@
+     int color_index;
+     unsigned char *ptr = NULL;
+ 
+-    infile = DGifOpenFileName(filename);
++    infile = DGifOpenFileName(filename, NULL);
+ 
+     if (infile == NULL)
+     {
+-        PrintGifError();
++        printf("%s\n", GifErrorString(GIF_ERROR));
+         return(0);
+     }
+ 
+@@ -54,7 +54,7 @@
+     {
+         if (DGifGetRecordType(infile, &record_type) == GIF_ERROR) 
+         {
+-            PrintGifError();
++            printf("%s\n", GifErrorString(GIF_ERROR));
+             return(0);
+         }
+ 
+@@ -63,7 +63,7 @@
+         case IMAGE_DESC_RECORD_TYPE:
+             if (DGifGetImageDesc(infile) == GIF_ERROR)
+             {
+-                PrintGifError();
++                printf("%s\n", GifErrorString(GIF_ERROR));
+                 return(0);
+             }
+ 
+@@ -107,14 +107,14 @@
+             GifByteType *ext;
+             if (DGifGetExtension(infile, &ext_code, &ext) == GIF_ERROR) 
+             {
+-                PrintGifError();
++                printf("%s\n", GifErrorString(GIF_ERROR));
+                 return(0);
+             }
+             while (ext != NULL) 
+             {
+                 if (DGifGetExtensionNext(infile, &ext) == GIF_ERROR) 
+                 {
+-                    PrintGifError();
++                    printf("%s\n", GifErrorString(GIF_ERROR));
+                     return(0);
+                 }
+             }
+@@ -154,7 +154,7 @@
+     
+     free(buffer);
+ 
+-    DGifCloseFile(infile);
++    DGifCloseFile(infile, NULL);
+     return(1);
+ }
+ 
+@@ -178,7 +178,7 @@
+         return(0);
+     }
+ 
+-    colormap = MakeMapObject(colormap_size, NULL);
++    colormap = GifMakeMapObject(colormap_size, NULL);
+ 
+     for (i = 0; i < width * height; i++)
+     {
+@@ -187,10 +187,10 @@
+         blue[i]  = (GifByteType) rgb[3*i+2];
+     }
+   
+-    if (QuantizeBuffer(width, height, &colormap_size, red, green, blue,   
++    if (GifQuantizeBuffer(width, height, &colormap_size, red, green, blue,   
+                        buffer, colormap->Colors) == GIF_ERROR)
+     {
+-        PrintGifError();
++        printf("%s\n", GifErrorString(GIF_ERROR));
+         return(0);
+     }
+ 
+@@ -198,24 +198,24 @@
+     free(green);
+     free(blue);
+ 
+-    outfile = EGifOpenFileName((char *) filename, FALSE);
++    outfile = EGifOpenFileName((char *) filename, FALSE, NULL);
+     if (outfile == NULL)
+     {
+-        PrintGifError();
++        printf("%s\n", GifErrorString(GIF_ERROR));
+         return(0);
+     }
+ 
+     if (EGifPutScreenDesc(outfile, width, height, colormap_size, 0, colormap)
+         == GIF_ERROR)
+     {
+-        PrintGifError();
++        printf("%s\n", GifErrorString(GIF_ERROR));
+         return(0);
+     }
+ 
+     if (EGifPutImageDesc(outfile, 0, 0, width, height, FALSE, NULL)
+         == GIF_ERROR)
+     {
+-        PrintGifError();
++        printf("%s\n", GifErrorString(GIF_ERROR));
+         return(0);
+     }
+ 
+@@ -224,7 +224,7 @@
+     {
+         if (EGifPutLine(outfile, ptr, width) == GIF_ERROR)
+         {
+-            PrintGifError();
++            printf("%s\n", GifErrorString(GIF_ERROR));
+             return(0);
+         }
+         ptr += width;
+@@ -232,8 +232,8 @@
+ 
+     EGifSpew(outfile);
+ 
+-    if (EGifCloseFile(outfile) == GIF_ERROR) 
+-        PrintGifError();
++    if (EGifCloseFile(outfile, NULL) == GIF_ERROR) 
++        printf("%s\n", GifErrorString(GIF_ERROR));
+ 
+     free(buffer);
+ 
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..dbcfead6b1ea
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/EZminc/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchFromGitHub, cmake, libminc, bicpl, itk, fftwFloat, gsl }:
+
+stdenv.mkDerivation rec { pname = "EZminc";
+  name  = "${pname}-2017-08-29";
+
+  src = fetchFromGitHub {
+    owner  = "BIC-MNI";
+    repo   = pname;
+    rev    = "4e017236cb6e7f6e07507446b18b759c584b6fc3";
+    sha256 = "1pg06x42pgsg7zy7dz9wf6ajakkm2n8by64lg9z64qi8qqy82b8v";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ itk libminc bicpl fftwFloat gsl ];
+
+  cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/"
+                 "-DEZMINC_BUILD_TOOLS=TRUE"
+                 "-DEZMINC_BUILD_MRFSEG=TRUE"
+                 "-DEZMINC_BUILD_DD=TRUE" ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.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/N3/default.nix b/nixpkgs/pkgs/applications/science/biology/N3/default.nix
new file mode 100644
index 000000000000..d2dbcf185330
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/N3/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchFromGitHub, cmake, makeWrapper,
+  perlPackages,
+  libminc, EBTKS }:
+
+stdenv.mkDerivation rec {
+  pname = "N3";
+  name  = "${pname}-2017-09-18";
+
+  src = fetchFromGitHub {
+    owner  = "BIC-MNI";
+    repo   = pname;
+    rev    = "2fdd939f0f2b24a4039bc6a8ade4a190a1d8e75d";
+    sha256 = "13z21c4r09hna3q1csvcn4i7ws5ixbdaja6ch421xv6nydjh2w5g";
+  };
+
+  nativeBuildInputs = [ cmake makeWrapper ];
+  buildInputs = [ libminc EBTKS ];
+  propagatedBuildInputs = with perlPackages; [ perl MNI-Perllib GetoptTabular ];
+
+  cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/" "-DEBTKS_DIR=${EBTKS}/lib/" ];
+
+  postFixup = ''
+    for p in $out/bin/*; do
+      wrapProgram $p --prefix PERL5LIB : $PERL5LIB
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/BIC-MNI/${pname}";
+    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/ants/default.nix b/nixpkgs/pkgs/applications/science/biology/ants/default.nix
new file mode 100644
index 000000000000..f54bd9af0288
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/ants/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchFromGitHub, cmake, makeWrapper, itk, vtk }:
+
+stdenv.mkDerivation rec {
+  _name    = "ANTs";
+  _version = "2.2.0";
+  name  = "${_name}-${_version}";
+
+  src = fetchFromGitHub {
+    owner  = "ANTsX";
+    repo   = "ANTs";
+    rev    = "37ad4e20be3a5ecd26c2e4e41b49e778a0246c3d";
+    sha256 = "1hrdwv3m9xh3yf7l0rm2ggxc2xzckfb8srs88g485ibfszx7i03q";
+  };
+
+  nativeBuildInputs = [ cmake makeWrapper ];
+  buildInputs = [ itk vtk ];
+
+  cmakeFlags = [ "-DANTS_SUPERBUILD=FALSE" "-DUSE_VTK=TRUE"
+                 # as cmake otherwise tries to download test data:
+                 "-DBUILD_TESTING=FALSE" ];
+
+  enableParallelBuilding = true;
+
+  postInstall = ''
+    for file in $out/bin/*; do
+      wrapProgram $file --set ANTSPATH "$out/bin"
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/ANTxS/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/bcftools/default.nix b/nixpkgs/pkgs/applications/science/biology/bcftools/default.nix
new file mode 100644
index 000000000000..539d7c224463
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/bcftools/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchurl, htslib, zlib, bzip2, lzma, curl, perl, python, bash }:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "bcftools";
+  version = "1.9";
+
+  src = fetchurl {
+    url = "https://github.com/samtools/bcftools/releases/download/${version}/${name}.tar.bz2";
+    sha256 = "1j3h638i8kgihzyrlnpj82xg1b23sijibys9hvwari3fy7kd0dkg";
+  };
+
+  buildInputs = [ htslib zlib bzip2 lzma curl perl python ];
+
+  makeFlags = [
+    "HSTDIR=${htslib}"
+    "prefix=$(out)"
+    "CC=cc"
+  ];
+
+  preCheck = ''
+    patchShebangs misc/
+    patchShebangs test/
+    sed -ie 's|/bin/bash|${bash}/bin/bash|' test/test.pl
+  '';
+
+  enableParallelBuilding = true;
+
+  doCheck = true;
+
+  meta = with stdenv.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.mimadrid ];
+  };
+}
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..406f42e9ad7b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/bedtools/default.nix
@@ -0,0 +1,26 @@
+{stdenv, fetchFromGitHub, zlib, python}:
+
+stdenv.mkDerivation rec {
+  name = "bedtools-${version}";
+  version = "2.27.1";
+
+  src = fetchFromGitHub {
+    owner = "arq5x";
+    repo = "bedtools2";
+    rev = "v${version}";
+    sha256 = "1pk68y052rm2m24yfmy82ms8p6kd6xcqxxgi7n0a1sbh89wllm6s";
+  };
+
+  buildInputs = [ zlib python ];
+  cc = if stdenv.cc.isClang then "clang++" else "g++";
+  buildPhase = "make prefix=$out SHELL=${stdenv.shell} CXX=${cc} -j $NIX_BUILD_CORES";
+  installPhase = "make prefix=$out SHELL=${stdenv.shell} CXX=${cc} install";
+
+  meta = with stdenv.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..24a6e052df9e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/bftools/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, lib, makeWrapper, fetchzip, jre }:
+
+stdenv.mkDerivation rec {
+  name = "bftools-${version}";
+  version = "5.9.2";
+
+  src = fetchzip {
+    url = "http://downloads.openmicroscopy.org/bio-formats/${version}/artifacts/bftools.zip";
+    sha256 = "08lmbg3kfxh17q6548il0i2h3f9a6ch8r0r067p14dajhzfpjyqj";
+  };
+
+  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 stdenv.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/bowtie2/default.nix b/nixpkgs/pkgs/applications/science/biology/bowtie2/default.nix
new file mode 100644
index 000000000000..e97b5d1a3f4f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/bowtie2/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchFromGitHub, zlib, tbb, python, perl }:
+
+stdenv.mkDerivation rec {
+  pname = "bowtie2";
+  version = "2.3.4.3";
+  name = "${pname}-${version}";
+
+  src = fetchFromGitHub {
+    owner = "BenLangmead";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "1zl3cf327y2p7p03cavymbh7b00djc7lncfaqih33n96iy9q8ibp";
+  };
+
+  buildInputs = [ zlib tbb python perl ];
+
+  installFlags = [ "prefix=$(out)" ];
+
+  meta = with stdenv.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;
+  };
+}
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..d1dbacf053fb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/bwa/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, zlib }:
+
+stdenv.mkDerivation rec {
+  name    = "bwa-${version}";
+  version = "0.7.17";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/bio-bwa/${name}.tar.bz2";
+    sha256 = "1zfhv2zg9v1icdlq4p9ssc8k01mca5d1bd87w71py2swfi74s6yy";
+  };
+
+  buildInputs = [ zlib ];
+
+  installPhase = ''
+    install -vD bwa $out/bin/bwa
+  '';
+
+  meta = with stdenv.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 = [ "x86_64-linux" ];
+  };
+}
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..ed661db23e0a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/cmtk/default.nix
@@ -0,0 +1,24 @@
+{stdenv, fetchurl, cmake}:
+
+stdenv.mkDerivation rec {
+  name = "cmtk-3.3.1";
+
+  src = fetchurl {
+    name = "cmtk-source.tar.gz";
+    url = "https://www.nitrc.org/frs/download.php/8198/CMTK-3.3.1-Source.tar.gz//?i_agree=1&download_now=1";
+    sha256 = "1nmsga9m7vcc4y4a6zl53ra3mwlgjwdgsq1j291awkn7zr1az6qs";
+  };
+
+  buildInputs = [cmake];
+
+  meta = with stdenv.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..23182fcadc6b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/conglomerate/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchFromGitHub, cmake, coreutils, perlPackages, bicpl, libminc, zlib, minc_tools,
+  makeWrapper }:
+
+stdenv.mkDerivation rec {
+  pname = "conglomerate";
+  name  = "${pname}-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/" "-DBICPL_DIR=${bicpl}/lib/" ];
+
+  postFixup = ''
+    for p in $out/bin/*; do
+      wrapProgram $p --prefix PERL5LIB : $PERL5LIB --set PATH "${stdenv.lib.makeBinPath [ coreutils minc_tools ]}";
+    done
+  '';
+
+  meta = with stdenv.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..781ceb3df59e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/dcm2niix/default.nix
@@ -0,0 +1,33 @@
+{ stdenv
+, fetchFromGitHub
+, cmake
+, libyamlcpp
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.0.20170130";
+  name = "dcm2niix-${version}";
+
+  src = fetchFromGitHub {
+    owner = "rordenlab";
+    repo = "dcm2niix";
+    rev = "v${version}";
+    sha256 = "1f2nzd8flp1rfn725bi64z7aw3ccxyyygzarxijw6pvgl476i532";
+  };
+
+  enableParallelBuilding = true;
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ libyamlcpp ];
+
+  meta = with stdenv.lib; {
+    description = "dcm2niix 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/diamond/default.nix b/nixpkgs/pkgs/applications/science/biology/diamond/default.nix
new file mode 100644
index 000000000000..854e91b2fcbb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/diamond/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchurl, cmake, zlib }:
+
+stdenv.mkDerivation rec {
+  name = "diamond-0.8.36";
+
+  src = fetchurl {
+    url = "https://github.com/bbuchfink/diamond/archive/v0.8.36.tar.gz";
+    sha256 = "092smzzjcg51n3x4h84k52ijpz9m40ri838j9k2i463ribc3c8rh";
+  };
+
+  patches = [
+    ./diamond-0.8.36-no-warning.patch
+  ];
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ zlib ];
+
+  meta = with stdenv.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..9e1b16ff9449
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/ecopcr/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchurl, gcc, zlib, python27 }:
+
+stdenv.mkDerivation rec {
+  name = "ecopcr-0.8.0";
+
+  src = fetchurl {
+    url = "https://git.metabarcoding.org/obitools/ecopcr/uploads/6f37991b325c8c171df7e79e6ae8d080/${name}.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 stdenv.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/emboss/default.nix b/nixpkgs/pkgs/applications/science/biology/emboss/default.nix
new file mode 100644
index 000000000000..2110a9bcfaba
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/emboss/default.nix
@@ -0,0 +1,28 @@
+{stdenv, fetchurl, readline, perl, libharu, libX11, libpng, libXt, zlib}:
+
+stdenv.mkDerivation {
+  name = "emboss-6.6.0";
+  src = fetchurl {
+    url = "ftp://emboss.open-bio.org/pub/EMBOSS/EMBOSS-6.6.0.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     = "GPL2";
+    homepage    = http://emboss.sourceforge.net/;
+  };
+}
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..1a15dcf6197d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/freebayes/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub, zlib, bzip2, lzma }:
+
+stdenv.mkDerivation rec {
+  name    = "freebayes-${version}";
+  version = "2017-08-23";
+
+  src = fetchFromGitHub {
+    name = "freebayes-${version}-src";
+    owner  = "ekg";
+    repo   = "freebayes";
+    rev    = "8d2b3a060da473e1f4f89be04edfce5cba63f1d3";
+    sha256 = "0yyrgk2639lz1yvg4jf0ccahnkic31dy77q05pb3i28rjf37v45z";
+    fetchSubmodules = true;
+  };
+
+  buildInputs = [ zlib bzip2 lzma ];
+
+  installPhase = ''
+    install -vD bin/freebayes bin/bamleftalign scripts/* -t $out/bin
+  '';
+
+  meta = with stdenv.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/hisat2/default.nix b/nixpkgs/pkgs/applications/science/biology/hisat2/default.nix
new file mode 100644
index 000000000000..9ccf54a81133
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/hisat2/default.nix
@@ -0,0 +1,49 @@
+{stdenv, fetchurl, unzip, which, python}:
+
+stdenv.mkDerivation rec {
+  name = "hisat2-${version}";
+  version = "2.1.0";
+
+  src = fetchurl {
+    url = "ftp://ftp.ccb.jhu.edu/pub/infphilo/hisat2/downloads/hisat2-${version}-source.zip";
+    sha256 = "10g73sdf6vqqfhhd92hliw7bbpkb8v4pp5012r5l21zws7p7d8l9";
+  };
+
+  buildInputs = [ unzip  which python ];
+
+  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 \
+       hisatgenotype_build_genome.py \
+       hisatgenotype_extract_reads.py \
+       hisatgenotype_extract_vars.py \
+       hisatgenotype_hla_cyp.py \
+       hisatgenotype_locus.py \
+       hisatgenotype.py \
+       $out/bin
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Graph based aligner";
+    license = licenses.gpl3;
+    homepage = https://ccb.jhu.edu/software/hisat2/index.shtml;
+    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..e43d48db55f3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/hmmer/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  version = "3.2.1";
+  name = "hmmer-${version}";
+
+  src = fetchurl {
+    url = "http://eddylab.org/software/hmmer/${name}.tar.gz";
+    sha256 = "171bivy6xhgjsz5nv53n81pc3frnwz29ylblawk2bv46szwjjqd5";
+  };
+
+  meta = with stdenv.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 ];
+    platforms = [ "x86_64-linux" "i686-linux" ];
+  };
+}
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..95dc2b612e22
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/igv/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, unzip, jre }:
+
+stdenv.mkDerivation rec {
+  name = "igv-${version}";
+  version = "2.4.19";
+
+  src = fetchurl {
+    url = "https://data.broadinstitute.org/igv/projects/downloads/2.4/IGV_${version}.zip";
+    sha256 = "048dgrhxcb854d24kyjkqz12bw04bsv49i5jawb75yzkswwfkb0z";
+  };
+
+  buildInputs = [ unzip jre ];
+
+  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#${jre}/bin/java#g' $out/share/igv.sh
+
+    ln -s $out/share/igv.sh $out/bin/igv
+
+    chmod +x $out/bin/igv
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://www.broadinstitute.org/igv/;
+    description = "A visualization tool for interactive exploration of genomic datasets";
+    license = licenses.lgpl21;
+    platforms = platforms.unix;
+    maintainers = [ maintainers.mimadrid ];
+  };
+}
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..9e63b92b24ed
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/inormalize/default.nix
@@ -0,0 +1,37 @@
+{ 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/" "-DEBTKS_DIR=${EBTKS}/lib/" ];
+
+  postFixup = ''
+    for p in $out/bin/*; do
+      wrapProgram $p --prefix PERL5LIB : $PERL5LIB
+    done
+  '';
+
+  meta = with stdenv.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/iv/default.nix b/nixpkgs/pkgs/applications/science/biology/iv/default.nix
new file mode 100644
index 000000000000..f204d9bbca96
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/iv/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchurl, neuron-version
+, libX11, libXext, patchelf
+}:
+
+stdenv.mkDerivation rec
+  { name = "iv-19";
+    src = fetchurl
+      { url = "https://www.neuron.yale.edu/ftp/neuron/versions/v${neuron-version}/${name}.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
+      patchelf --add-needed ${libX11}/lib/libX11.so $out/lib/libIVhines.so
+    '';
+    meta = with stdenv.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..d80ffea9a780
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/kallisto/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchFromGitHub, cmake, hdf5, zlib }:
+
+stdenv.mkDerivation rec {
+  name = "kallisto-${version}";
+  version = "0.43.1";
+
+  src = fetchFromGitHub {
+    repo = "kallisto";
+    owner = "pachterlab";
+    rev = "v${version}";
+    sha256 = "04697pf7jvy7vw126s1rn09q4iab9223jvb1nb0jn7ilwkq7pgwz";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  
+  buildInputs = [ hdf5 zlib ];
+
+  meta = with stdenv.lib; {
+    description = "kallisto is a program for quantifying abundances of transcripts from RNA-Seq data";
+    homepage = https://pachterlab.github.io/kallisto;
+    license = licenses.bsd2;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.arcadio ];
+  };
+}
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..033f78609e9a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/minc-tools/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchFromGitHub, cmake, makeWrapper, flex, bison, perlPackages, libminc, libjpeg, zlib }:
+
+stdenv.mkDerivation rec {
+  pname = "minc-tools";
+  name  = "${pname}-2017-09-11";
+
+  src = fetchFromGitHub {
+    owner  = "BIC-MNI";
+    repo   = pname;
+    rev    = "5b7c40425cd4f67a018055cb85c0157ee50a3056";
+    sha256 = "0zkcs05svp1gj5h0cdgc0k20c7lrk8m7wg3ks3xc5mkaiannj8g7";
+  };
+
+  nativeBuildInputs = [ cmake flex bison makeWrapper ];
+  buildInputs = [ libminc libjpeg zlib ];
+  propagatedBuildInputs = with perlPackages; [ perl TextFormat ];
+
+  cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/" ];
+
+  postFixup = ''
+    for prog in minccomplete minchistory mincpik; do
+      wrapProgram $out/bin/$prog --prefix PERL5LIB : $PERL5LIB
+    done
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.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..497c39a52a4c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/minc-widgets/default.nix
@@ -0,0 +1,34 @@
+{ 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 "${stdenv.lib.makeBinPath [ coreutils minc_tools ]}";
+    done
+  '';
+
+  meta = with stdenv.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/minimap2/default.nix b/nixpkgs/pkgs/applications/science/biology/minimap2/default.nix
new file mode 100644
index 000000000000..3f28b5e31ccd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/minimap2/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchFromGitHub, zlib }:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "minimap2";
+  version = "2.15";
+
+  src = fetchFromGitHub {
+    repo = pname;
+    owner = "lh3";
+    rev = "v${version}";
+    sha256 = "0dy3m2wjmi3whjnmkj3maa1aadz525h7736wm8vvdcwq71ijqb7v";
+  };
+
+  buildInputs = [ zlib ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp minimap2 $out/bin
+    mkdir -p $out/share/man/man1
+    cp minimap2.1 $out/share/man/man1
+  '';
+  
+  meta = with stdenv.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..5901b696d642
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/mni_autoreg/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, fetchFromGitHub, cmake, makeWrapper, perlPackages, libminc }:
+
+stdenv.mkDerivation rec {
+  pname = "mni_autoreg";
+  name  = "${pname}-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/" "-DBUILD_TESTING=FALSE" ];
+  # 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 stdenv.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..3cd83a5cdd27
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/mosdepth/default.nix
@@ -0,0 +1,45 @@
+{stdenv, fetchFromGitHub, nim, htslib, pcre}:
+
+let
+  hts-nim = fetchFromGitHub {
+    owner = "brentp";
+    repo = "hts-nim";
+    rev = "v0.2.5";
+    sha256 = "1fma99rjqxgg9dihkd10hm1jjp5amsk5wsxnvq1lk4mcsjix5xqb";
+  };
+
+  docopt = fetchFromGitHub {
+    owner = "docopt";
+    repo = "docopt.nim";
+    rev = "v0.6.5";
+    sha256 = "0yx79m4jkdcazwlky55nwf39zj5kdhymrrdrjq29mahiwx83x5zr";
+  };
+
+in stdenv.mkDerivation rec {
+  name = "mosdepth-${version}";
+  version = "0.2.3";
+
+  src = fetchFromGitHub {
+    owner = "brentp";
+    repo = "mosdepth";
+    rev = "v${version}";
+    sha256 = "1b9frrwhcvay3alhn0d02jccc2qlbij1732hzq9nhwnr4kvsvxx7";
+  };
+
+  buildInputs = [ nim ];
+
+  buildPhase = ''
+    HOME=$TMPDIR
+    nim -p:${hts-nim}/src -p:${docopt}/src c --nilseqs:on -d:release mosdepth.nim
+  '';
+  installPhase = "install -Dt $out/bin mosdepth";
+  fixupPhase = "patchelf --set-rpath ${stdenv.lib.makeLibraryPath [ stdenv.cc.cc htslib pcre ]} $out/bin/mosdepth";
+
+  meta = with stdenv.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/builder.sh b/nixpkgs/pkgs/applications/science/biology/mrbayes/builder.sh
new file mode 100644
index 000000000000..5b3a54946fc9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/mrbayes/builder.sh
@@ -0,0 +1,9 @@
+# builder for mrbayes - note: only builds on Unix
+
+source $stdenv/setup
+
+tar xvfz $src
+cd mrbayes-*
+make
+mkdir -p $out/bin
+cp -v mb $out/bin
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..1dd92af58eb1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/mrbayes/default.nix
@@ -0,0 +1,29 @@
+{stdenv, fetchurl, readline}:
+
+stdenv.mkDerivation rec {
+  # FIXME: replace Makefile so we can build MPI & MAC support
+
+  name = "mrbayes-3.1.2";
+  src = fetchurl {
+    url = "mirror://sourceforge/mrbayes/${name}.tar.gz";
+    sha256 = "1x7j8ca5wjrqrxmcpvd375ydm3s2pbkzykv8xfhg1jc037g560n6";
+  };
+  builder = ./builder.sh;
+  buildInputs = [readline];
+
+  meta = {
+    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.
+    '';
+    license     = "GPL2";
+    homepage    = http://mrbayes.csit.fsu.edu/;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
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..9cbabc7ab37e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/muscle/default.nix
@@ -0,0 +1,35 @@
+{ 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 stdenv.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   = stdenv.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..1c24ef092542
--- /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..35710fd1fe1f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/neuron/default.nix
@@ -0,0 +1,80 @@
+{ stdenv
+, fetchurl
+, pkgconfig
+, automake
+, autoconf
+, libtool
+, ncurses
+, readline
+, which
+, python ? null
+, mpi ? null
+, iv
+}:
+
+stdenv.mkDerivation rec {
+  name = "neuron-${version}";
+  version = "7.5";
+
+  nativeBuildInputs = [ which pkgconfig automake autoconf libtool ];
+  buildInputs = [ ncurses readline python mpi iv ];
+
+  src = fetchurl {
+    url = "https://www.neuron.yale.edu/ftp/neuron/versions/v${version}/nrn-${version}.tar.gz";
+    sha256 = "0f26v3qvzblcdjg7isq0m9j2q8q7x3vhmkfllv8lsr3gyj44lljf";
+  };
+
+  patches = (stdenv.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 = stdenv.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);' ""
+  '';
+
+  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 stdenv.lib;
+                    [ "--with-readline=${readline}" "--with-iv=${iv}" ]
+                    ++  optionals (python != null)  [ "--with-nrnpython=${python.interpreter}" ]
+                    ++ (if mpi != null then ["--with-mpi" "--with-paranrn"]
+                        else ["--without-mpi"]);
+
+
+  postInstall = stdenv.lib.optionals (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 stdenv.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 ];
+    platforms   = platforms.all;
+  };
+}
+
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..9f24046b3bf6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/niftyreg/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, lib, fetchurl, cmake, zlib }:
+
+stdenv.mkDerivation rec {
+  pname   = "niftyreg";
+  version = "1.3.9";
+  name    = "${pname}-${version}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/${pname}/nifty_reg-${version}/nifty_reg-${version}.tar.gz";
+    sha256 = "07v9v9s41lvw72wpb1jgh2nzanyc994779bd35p76vg8mzifmprl";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ zlib ];
+  enableParallelBuilding = true;
+
+  meta = with stdenv.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..671ee4b95c65
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/niftyseg/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, lib, fetchurl, cmake, eigen, zlib }:
+
+stdenv.mkDerivation rec {
+  pname   = "niftyseg";
+  version = "1.0";
+  name = "${pname}-${version}";
+  src = fetchurl {
+    url    = "https://github.com/KCL-BMEIS/NiftySeg/archive/v${version}.tar.gz";
+    sha256 = "11q6yldsxp3k6gfp94c0xhcan2y3finzv8lzizmrc79yps3wjkn0";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ eigen zlib ];
+  enableParallelBuilding = true;
+
+  meta = with stdenv.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.linux;
+    license   = licenses.bsd3;
+  };
+
+}
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..fe25a04c420a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/paml/default.nix
@@ -0,0 +1,33 @@
+{stdenv, fetchurl}:
+
+stdenv.mkDerivation rec {
+  version = "4.9h";
+  name = "paml-${version}";
+  src = fetchurl {
+    url = "http://abacus.gene.ucl.ac.uk/software/paml${version}.tgz";
+    sha256 = "1czdfb3naadq0d3y42isrbyja33c3p28k8dv9mxlx2h19b7zcfv2";
+  };
+
+  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..2ba5964d6104
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/picard-tools/default.nix
@@ -0,0 +1,31 @@
+{stdenv, fetchurl, jre, makeWrapper}:
+
+stdenv.mkDerivation rec {
+  name = "picard-tools-${version}";
+  version = "2.18.25";
+
+  src = fetchurl {
+    url = "https://github.com/broadinstitute/picard/releases/download/${version}/picard.jar";
+    sha256 = "03d3mnf3gddngn3dhwb00v8k40x6ncgprn22w4vyfr96917p2snx";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ jre ];
+
+  phases = [ "installPhase" ];
+
+  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 stdenv.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..323ca90f0a2a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/platypus/default.nix
@@ -0,0 +1,38 @@
+{stdenv, fetchFromGitHub, python27, htslib, zlib, makeWrapper}:
+
+let python = python27.withPackages (ps: with ps; [ cython ]);
+
+in stdenv.mkDerivation rec {
+  name = "platypus-unstable-${version}";
+  version = "2018-07-22";
+
+  src = fetchFromGitHub {
+    owner = "andyrimmer";
+    repo = "Platypus";
+    rev = "3e72641c69800da0cd4906b090298e654d316ee1";
+    sha256 = "0nah6r54b8xm778gqyb8b7rsd76z8ji4g73sm6rvpw5s96iib1vw";
+  };
+
+  buildInputs = [ htslib python zlib makeWrapper ];
+
+  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 stdenv.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..2efb59f536f6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/plink-ng/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchFromGitHub, zlib, openblas, darwin}:
+
+stdenv.mkDerivation rec {
+  name = "plink-ng-${version}";
+  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 [ openblas ]) ;
+
+  buildPhase = ''
+    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 ""}
+    make ZLIB=-lz ${if stdenv.isDarwin then "" else "BLASFLAGS=-lopenblas"} -f 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 = stdenv.lib.licenses.gpl3;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
+
diff --git a/nixpkgs/pkgs/applications/science/biology/plink/default.nix b/nixpkgs/pkgs/applications/science/biology/plink/default.nix
new file mode 100644
index 000000000000..cc48a0cb13a9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/plink/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, zlib, unzip }:
+
+stdenv.mkDerivation {
+  name = "plink-1.07";
+
+  src = fetchurl {
+    url = "http://pngu.mgh.harvard.edu/~purcell/plink/dist/plink-1.07-src.zip";
+    sha256 = "4af56348443d0c6a1db64950a071b1fcb49cc74154875a7b43cccb4b6a7f482b";
+  };
+
+  buildInputs = [ zlib unzip ] ;
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp plink $out/bin
+  '';
+  
+  meta = {
+    description = "Whole genome association toolkit";
+    homepage = http://pngu.mgh.harvard.edu/~purcell/plink/;
+    license = stdenv.lib.licenses.gpl2;
+    platforms = stdenv.lib.platforms.all;
+    broken = true;
+  };
+}
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..3bb9ea06fd46
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/poretools/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, pythonPackages, fetchFromGitHub }:
+
+pythonPackages.buildPythonPackage rec {
+  pname = "poretools";
+  version = "unstable-2016-07-10";
+  name = "${pname}-${version}";
+
+  src = fetchFromGitHub {
+    repo = pname;
+    owner = "arq5x";
+    rev = "e426b1f09e86ac259a00c261c79df91510777407";
+    sha256 = "0bglj833wxpp3cq430p1d3xp085ls221js2y90w7ir2x5ay8l7am";
+  };
+
+  propagatedBuildInputs = [pythonPackages.h5py pythonPackages.matplotlib pythonPackages.seaborn pythonPackages.pandas];
+
+  meta = {
+    description = "a toolkit for working with nanopore sequencing data from Oxford Nanopore";
+    license = stdenv.lib.licenses.mit;
+    homepage = http://poretools.readthedocs.io/en/latest/;
+    maintainers = [stdenv.lib.maintainers.rybern];
+  };
+}
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..140f70323194
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/raxml/default.nix
@@ -0,0 +1,41 @@
+{ stdenv
+, fetchFromGitHub
+, pkgs
+, mpi ? false
+}:
+
+stdenv.mkDerivation rec {
+  pname = "RAxML";
+  version = "8.2.12";
+  name = "${pname}-${version}";
+
+  src = fetchFromGitHub {
+    owner = "stamatak";
+    repo = "standard-${pname}";
+    rev = "v${version}";
+    sha256 = "1jqjzhch0rips0vp04prvb8vmc20c5pdmsqn8knadcf91yy859fh";
+  };
+
+  buildInputs = if mpi then [ pkgs.openmpi ] else [];
+
+  # TODO darwin, AVX and AVX2 makefile targets
+  buildPhase = if mpi then ''
+      make -f Makefile.MPI.gcc
+    '' else ''
+      make -f Makefile.SSE3.PTHREADS.gcc
+    '';
+
+  installPhase = if mpi then ''
+    mkdir -p $out/bin && cp raxmlHPC-MPI $out/bin
+  '' else ''
+    mkdir -p $out/bin && cp raxmlHPC-PTHREADS-SSE3 $out/bin
+  '';
+
+  meta = with stdenv.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/samtools/default.nix b/nixpkgs/pkgs/applications/science/biology/samtools/default.nix
new file mode 100644
index 000000000000..c4b4bb522c40
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/samtools/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchurl, zlib, htslib, perl, ncurses ? null }:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "samtools";
+  version = "1.9";
+
+  src = fetchurl {
+    url = "https://github.com/samtools/samtools/releases/download/${version}/${name}.tar.bz2";
+    sha256 = "10ilqbmm7ri8z431sn90lvbjwizd0hhkf9rcqw8j823hf26nhgq8";
+  };
+
+  nativeBuildInputs = [ perl ];
+
+  buildInputs = [ zlib ncurses htslib ];
+
+  configureFlags = [ "--with-htslib=${htslib}" ]
+    ++ stdenv.lib.optional (ncurses == null) "--without-curses";
+
+  preCheck = ''
+    patchShebangs test/
+  '';
+
+  enableParallelBuilding = true;
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "Tools for manipulating SAM/BAM/CRAM format";
+    license = licenses.mit;
+    homepage = http://www.htslib.org/;
+    platforms = platforms.unix;
+    maintainers = [ maintainers.mimadrid ];
+  };
+}
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..a811bc4412f2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/samtools/samtools_0_1_19.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, zlib }:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "samtools";
+  version = "0.1.19";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/samtools/${name}.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 stdenv.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..17cf903ae49c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/seaview/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchurl, coreutils, fltk, libjpeg }:
+
+stdenv.mkDerivation rec {
+  version = "4.7";
+  name = "seaview-${version}";
+
+  src = fetchurl {
+    url = "ftp://pbil.univ-lyon1.fr/pub/mol_phylogeny/seaview/archive/seaview_${version}.tar.gz";
+    sha256 = "0fhyq7dcn0izhwcfin9ajsr7kmmsqm9f1np1rmhzg4digfwqb29n";
+  };
+
+  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 stdenv.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..dc2246903349
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/snpeff/default.nix
@@ -0,0 +1,33 @@
+{stdenv, fetchurl, jre, unzip, makeWrapper}:
+
+stdenv.mkDerivation rec {
+  name = "snpeff-${version}";
+  version = "4.3t";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/project/snpeff/snpEff_v${builtins.replaceStrings [ "." ] [ "_" ] version}_core.zip";
+    sha256 = "0i12mv93bfv8xjwc3rs2x73d6hkvi7kgbbbx3ry984l3ly4p6nnm";
+  };
+
+  buildInputs = [ unzip jre makeWrapper ];
+
+  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 stdenv.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..4bbd6a320035
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/somatic-sniper/default.nix
@@ -0,0 +1,28 @@
+{stdenv, fetchFromGitHub, cmake, zlib, ncurses}:
+
+stdenv.mkDerivation rec {
+  name = "somatic-sniper-${version}";
+  version = "1.0.5.0";
+
+  src = fetchFromGitHub {
+    owner = "genome";
+    repo = "somatic-sniper";
+    rev = "v${version}";
+    sha256 = "0lk7p9sp6mp50f6w1nppqhr40fcwy1asw06ivw8w8jvvnwaqf987";
+  };
+
+  patches = [ ./somatic-sniper.patch ];
+
+  buildInputs = [ cmake zlib ncurses ];
+
+  enableParallelBuilding = false;
+
+  meta = with stdenv.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/star/default.nix b/nixpkgs/pkgs/applications/science/biology/star/default.nix
new file mode 100644
index 000000000000..eb62a8c331f8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/star/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchFromGitHub, zlib }:
+
+stdenv.mkDerivation rec {
+  name = "star-${version}";
+  version = "2.7.0c";
+
+  src = fetchFromGitHub {
+    repo = "STAR";
+    owner = "alexdobin";
+    rev = version;
+    sha256 = "0r5jcckr45f71jwhz8xazi1w6kfhszq3y6r7f6zl9963ms1q1gfv";
+  };
+
+  sourceRoot = "source/source";
+  
+  postPatch = "sed 's:/bin/rm:rm:g' -i Makefile";
+  
+  buildInputs = [ zlib ];
+  
+  buildPhase = "make STAR STARlong";
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp STAR STARlong $out/bin
+  '';
+  
+  meta = with stdenv.lib; {
+    description = "Spliced Transcripts Alignment to a Reference";
+    homepage = https://github.com/alexdobin/STAR;
+    license = licenses.gpl3Plus;
+    platforms = platforms.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..1527f5d3ddad
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/strelka/default.nix
@@ -0,0 +1,37 @@
+{stdenv, fetchFromGitHub, cmake, zlib, python2}:
+
+stdenv.mkDerivation rec {
+  name = "strelka-${version}";
+  version = "2.9.5";
+
+  src = fetchFromGitHub {
+    owner = "Illumina";
+    repo = "strelka";
+    rev = "v${version}";
+    sha256 = "0x4a6nkx1jnyag9svghsdjz1fz6q7qx5pn77wphdfnk81f9yspf8";
+  };
+
+  buildInputs = [ cmake zlib python2 ];
+
+  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 stdenv.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/varscan/default.nix b/nixpkgs/pkgs/applications/science/biology/varscan/default.nix
new file mode 100644
index 000000000000..f685031e87e4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/varscan/default.nix
@@ -0,0 +1,36 @@
+{stdenv, fetchurl, jre, makeWrapper}:
+
+stdenv.mkDerivation rec {
+  name = "varscan-${version}";
+  version = "2.4.2";
+
+  src = fetchurl {
+    url = "https://github.com/dkoboldt/varscan/releases/download/${version}/VarScan.v${version}.jar";
+    sha256 = "0cfhshinyqgwc6i7zf8lhbfybyly2x5anrz824zyvdhzz5i69zrl";
+  };
+
+  buildInputs = [ jre makeWrapper ];
+
+  phases = [ "installPhase" ];
+
+  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 stdenv.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..a6f52ae97b59
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/biology/vcftools/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchFromGitHub, zlib, autoreconfHook, pkgconfig, perl }:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "vcftools";
+  version = "0.1.16";
+
+  src = fetchFromGitHub {
+    repo = pname;
+    owner = "vcftools";
+    rev = "v${version}";
+    sha256 = "0msb09d2cnm8rlpg8bsc1lhjddvp3kf3i9dsj1qs4qgsdlzhxkyx";
+  };
+
+  buildInputs = [ autoreconfHook pkgconfig zlib perl ];
+
+  meta = with stdenv.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/chemistry/avogadro/default.nix b/nixpkgs/pkgs/applications/science/chemistry/avogadro/default.nix
new file mode 100644
index 000000000000..a569b82ff59d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/avogadro/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, cmake, qt4, zlib, eigen, openbabel, pkgconfig, libGLU_combined, libX11, doxygen }:
+
+stdenv.mkDerivation rec {
+  name = "avogadro-1.1.1";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/avogadro/${name}.tar.bz2";
+    sha256 = "050ag9p4vg7jg8hj1wqfv7lsm6ar2isxjw2vw85s49vsl7g7nvzy";
+  };
+
+  buildInputs = [ qt4 eigen zlib openbabel libGLU_combined libX11 ];
+
+  nativeBuildInputs = [ cmake pkgconfig doxygen ];
+
+  NIX_CFLAGS_COMPILE = "-include ${libGLU_combined}/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 = {
+    description = "Molecule editor and visualizer";
+    maintainers = [ ];
+    platforms = stdenv.lib.platforms.mesaPlatforms;
+  };
+}
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..92f997900d53
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/gwyddion/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchurl, gtk2, pkgconfig }:
+
+with stdenv.lib;
+
+let version = "2.48"; in
+stdenv.mkDerivation {
+  name = "gwyddion-${version}";
+  src = fetchurl {
+    url = "mirror://sourceforge/gwyddion/files/gwyddion/${version}/gwyddion-${version}.tar.xz";
+    sha256 = "119iw58ac2wn4cas6js8m7r1n4gmmkga6b1y711xzcyjp9hshgwx";
+  };
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ gtk2 ];
+  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 = stdenv.lib.licenses.gpl2;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
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..7f5eb7b76e8c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/jmol/default.nix
@@ -0,0 +1,53 @@
+{ stdenv
+, lib
+, fetchurl
+, unzip
+, makeDesktopItem
+, jre
+}:
+
+let
+  desktopItem = makeDesktopItem {
+    name = "jmol";
+    exec = "jmol";
+    desktopName = "JMol";
+    genericName = "Molecular Modeler";
+    mimeType = "chemical/x-pdb;chemical/x-mdl-molfile;chemical/x-mol2;chemical/seq-aa-fasta;chemical/seq-na-fasta;chemical/x-xyz;chemical/x-mdl-sdf;";
+    categories = "Graphics;Education;Science;Chemistry;";
+  };
+in
+stdenv.mkDerivation rec {
+  version = "14.29.31";
+  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 = "15mxifm1h145bhyrm9rvmipvg048q8rgwg1sn6jmfgrimy0cjraj";
+  };
+
+  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 stdenv.lib; {
+     description = "A Java 3D viewer for chemical structures";
+     homepage = https://sourceforge.net/projects/jmol;
+     license = licenses.lgpl2;
+     platforms = platforms.all;
+     maintainers = with maintainers; [ timokau mounium ];
+  };
+}
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..948aed03fe5e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/marvin/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, fetchurl, dpkg, makeWrapper, coreutils, gawk, gnugrep, gnused, jre }:
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "marvin";
+  version = "19.1.0";
+
+  src = fetchurl {
+    name = "marvin-${version}.deb";
+    url = "http://dl.chemaxon.com/marvin/${version}/marvin_linux_${versions.majorMinor version}.deb";
+    sha256 = "1ccsimfvms5q4prjyk6sg5hsc3hkcjjfq3gl7jjm8dgd2173zzyc";
+  };
+
+  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;
+  };
+}
\ No newline at end of file
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..99a8c777cd0e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/molden/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchurl, which, gfortran, libGLU, xorg } :
+
+stdenv.mkDerivation rec {
+  version = "5.9.3";
+  name = "molden-${version}";
+
+  src = fetchurl {
+    url = "ftp://ftp.cmbi.ru.nl/pub/molgraph/molden/molden${version}.tar.gz";
+    sha256 = "18fz44g7zkm0xcx3w9hm049jv13af67ww7mb5b3kdhmza333a16q";
+  };
+
+  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 stdenv.lib; {
+     description = "Display and manipulate molecular structures";
+     homepage = http://www.cmbi.ru.nl/molden/;
+     license = {
+       fullName = "Free for academic/non-profit use";
+       url = http://www.cmbi.ru.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..2dd3c9b64c43
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/octopus/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, fetchurl, symlinkJoin, gfortran, perl, procps
+, libyaml, libxc, fftw, openblas, gsl, netcdf, arpack
+}:
+
+let
+  version = "8.3";
+  fftwAll = symlinkJoin { name ="ftw-dev-out"; paths = [ fftw.dev fftw.out ]; };
+
+in stdenv.mkDerivation {
+  name = "octopus-${version}";
+
+  src = fetchurl {
+    url = "http://www.tddft.org/programs/octopus/down.php?file=${version}/octopus-${version}.tar.gz";
+    sha256 = "0nr3qmyfhp6fy8qrp4p43pl5xxfqgqg5g1c2775hxhpsi29xr7zf";
+  };
+
+  nativeBuildInputs = [ perl procps fftw.dev ];
+  buildInputs = [ libyaml gfortran libxc openblas gsl fftw.out netcdf arpack ];
+
+  configureFlags = [
+    "--with-yaml-prefix=${libyaml}"
+    "--with-blas=-lopenblas"
+    "--with-lapack=-lopenblas"
+    "--with-fftw-prefix=${fftwAll}"
+    "--with-gsl-prefix=${gsl}"
+    "--with-libxc-prefix=${libxc}"
+  ];
+
+  doCheck = false;
+  checkTarget = "check-short";
+
+  postPatch = ''
+    patchShebangs ./
+  '';
+
+  postConfigure = ''
+    patchShebangs testsuite/oct-run_testsuite.sh
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "Real-space time dependent density-functional theory code";
+    homepage = http://octopus-code.org;
+    maintainers = with maintainers; [ markuskowa ];
+    license = licenses.gpl2;
+    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..70e79023c0ff
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/openmolcas/default.nix
@@ -0,0 +1,72 @@
+{ stdenv, pkgs, fetchFromGitLab, cmake, gfortran, perl
+, openblas, hdf5-cpp, python3, texlive
+, armadillo, openmpi, globalarrays, openssh
+, makeWrapper
+} :
+
+let
+  version = "18.09";
+  gitLabRev = "v${version}";
+
+  python = python3.withPackages (ps : with ps; [ six pyparsing ]);
+
+in stdenv.mkDerivation {
+  name = "openmolcas-${version}";
+
+  src = fetchFromGitLab {
+    owner = "Molcas";
+    repo = "OpenMolcas";
+    rev = gitLabRev;
+    sha256 = "1di1ygifx7ycfpwh25mv76xlv15wqfdmqzjsg5nani2d5z0arri2";
+  };
+
+  nativeBuildInputs = [ perl cmake texlive.combined.scheme-minimal makeWrapper ];
+  buildInputs = [
+    gfortran
+    openblas
+    hdf5-cpp
+    python
+    armadillo
+    openmpi
+    globalarrays
+    openssh
+  ];
+
+  enableParallelBuilding = true;
+
+  cmakeFlags = [
+    "-DOPENMP=ON"
+    "-DGA=ON"
+    "-DMPI=ON"
+    "-DLINALG=OpenBLAS"
+    "-DTOOLS=ON"
+    "-DHDF5=ON"
+    "-DFDE=ON"
+    "-DOPENBLASROOT=${openblas}"
+  ];
+
+  GAROOT=globalarrays;
+
+  postConfigure = ''
+    # The Makefile will install pymolcas during the build grrr.
+    mkdir -p $out/bin
+    export PATH=$PATH:$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 stdenv.lib; {
+    description = "Advanced quantum chemistry software package";
+    homepage = https://gitlab.com/Molcas/OpenMolcas;
+    maintainers = [ maintainers.markuskowa ];
+    license = licenses.lgpl21;
+    platforms = platforms.linux;
+  };
+}
+
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..7b482d82e2fa
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/pymol/default.nix
@@ -0,0 +1,51 @@
+{ stdenv, fetchurl, makeDesktopItem
+, python3, python3Packages
+, glew, freeglut, libpng, libxml2, tk, freetype, msgpack }:
+
+
+with stdenv.lib;
+
+let
+  pname = "pymol";
+  ver_maj = "2";
+  ver_min = "1";
+  version = "${ver_maj}.${ver_min}.0";
+  description = "A Python-enhanced molecular graphics tool";
+
+  desktopItem = makeDesktopItem {
+    name = "${pname}";
+    exec = "${pname}";
+    desktopName = "PyMol Molecular Graphics System";
+    genericName = "Molecular Modeler";
+    comment = description;
+    mimeType = "chemical/x-pdb;chemical/x-mdl-molfile;chemical/x-mol2;chemical/seq-aa-fasta;chemical/seq-na-fasta;chemical/x-xyz;chemical/x-mdl-sdf;";
+    categories = "Graphics;Education;Science;Chemistry;";
+  };
+in
+python3Packages.buildPythonApplication {
+  name = "pymol-${version}";
+  src = fetchurl {
+    url = "mirror://sourceforge/project/pymol/pymol/${ver_maj}/pymol-v${version}.tar.bz2";
+    sha256 = "1qpacd5w4r9a0nm5iqmkd92ym3ai00dp7v61cwd6jgakk6wfps3s";
+  };
+
+  buildInputs = [ python3Packages.numpy glew freeglut libpng libxml2 tk freetype msgpack ];
+  NIX_CFLAGS_COMPILE = "-I ${libxml2.dev}/include/libxml2";
+
+  installPhase = ''
+    python setup.py install --home=$out
+    cp -r ${desktopItem}/share/ $out/
+    runHook postInstall
+  '';
+
+  postInstall = with python3Packages; ''
+    wrapProgram $out/bin/pymol \
+      --prefix PYTHONPATH : ${makeSearchPathOutput "lib" python3.sitePackages [ Pmw tkinter ]}
+  '';
+
+  meta = {
+    description = description;
+    homepage = https://www.pymol.org/;
+    license = licenses.psfl;
+  };
+}
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..7a7f1b3596d3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/quantum-espresso/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, fetchurl
+, gfortran, fftw, openblas
+, mpi ? null
+}:
+
+stdenv.mkDerivation rec {
+  version = "6.3";
+  name = "quantum-espresso-${version}";
+
+  src = fetchurl {
+    url = "https://gitlab.com/QEF/q-e/-/archive/qe-${version}/q-e-qe-${version}.tar.gz";
+    sha256 = "1738z3nhkzcrgnhnfg1r4lipbwvcrcprwhzjbjysnylmzbzwhrs0";
+  };
+
+  passthru = {
+    inherit mpi;
+  };
+
+  preConfigure = ''
+    patchShebangs configure
+  '';
+
+  # remove after 6.3 version:
+  # makefile needs to ignore install directory easier than applying patch
+  preInstall = ''
+    printf "\n.PHONY: install\n" >> Makefile
+  '';
+
+  buildInputs = [ fftw openblas gfortran ]
+    ++ (stdenv.lib.optionals (mpi != null) [ mpi ]);
+
+configureFlags = if (mpi != null) then [ "LD=${mpi}/bin/mpif90" ] else [ "LD=${gfortran}/bin/gfortran" ];
+
+  makeFlags = [ "all" ];
+
+  meta = with stdenv.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" ];
+    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..eb17a68b8aae
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/chemistry/siesta/default.nix
@@ -0,0 +1,69 @@
+{ stdenv, fetchurl
+, gfortran, openblas
+, mpi ? null, scalapack
+}:
+
+stdenv.mkDerivation rec {
+  version = "4.1-b3";
+  name = "siesta-${version}";
+
+  src = fetchurl {
+    url = "https://launchpad.net/siesta/4.1/4.1-b3/+download/siesta-4.1-b3.tar.gz";
+    sha256 = "1450jsxj5aifa0b5fcg7mxxq242fvqnp4zxpgzgbkdp99vrp06gm";
+  };
+
+  passthru = {
+    inherit mpi;
+  };
+
+  buildInputs = [ openblas gfortran ]
+    ++ (stdenv.lib.optionals (mpi != null) [ 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 (mpi != null) then ''
+    makeFlagsArray=(
+        CC="mpicc" FC="mpifort"
+        FPPFLAGS="-DMPI" MPI_INTERFACE="libmpi_f90.a" MPI_INCLUDE="."
+        COMP_LIBS="" LIBS="-lopenblas -lscalapack"
+    );
+  '' else ''
+    makeFlagsArray=(
+      COMP_LIBS="" LIBS="-lopenblas"
+    );
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp -a siesta $out/bin
+  '';
+
+  meta = with stdenv.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://www.quantum-espresso.org/;
+    license = licenses.gpl2;
+    platforms = [ "x86_64-linux" ];
+    maintainers = [ maintainers.costrouc ];
+  };
+}
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..236225959f7a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/adms/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, flex, bison, gperf,
+  libxml2, perl, perlPackages, gd }:
+
+stdenv.mkDerivation rec {
+  version = "2.3.6";
+  name = "adms-${version}";
+
+  src = fetchFromGitHub {
+    owner = "Qucs";
+    repo = "adms";
+    rev = "release-${version}";
+    sha256 = "1pcwq5khzdq4x33lid9hq967gv78dr5i4f2sk8m8rwkfqb9vdzrg";
+  };
+
+  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 = stdenv.lib.licenses.gpl3;
+    maintainers = with stdenv.lib.maintainers; [disassembler];
+    platforms = with stdenv.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..63bc0911d251
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/alliance/default.nix
@@ -0,0 +1,75 @@
+{ stdenv, fetchurl
+, xorgproto, motif, libX11, libXt, libXpm, bison
+, flex, automake, autoconf, libtool, runtimeShell
+}:
+
+stdenv.mkDerivation rec {
+  name = "alliance-${version}";
+  version = "5.1.1";
+
+  src = fetchurl {
+    url = "http://www-asim.lip6.fr/pub/alliance/distribution/5.0/${name}.tar.bz2";
+    sha256 = "046c9qwl1vbww0ljm4xyxf5jpz9nq62b2q0wdz9xjimgh4c207w1";
+  };
+
+
+  nativeBuildInputs = [ libtool automake autoconf flex ];
+  buildInputs = [ xorgproto motif libX11 libXt libXpm bison ];
+
+  sourceRoot = "alliance/src/";
+
+  configureFlags = [
+    "--prefix=$(out)"
+    "--disable-static"
+  ];
+
+  preConfigure = ''
+    mkdir -p $out/etc
+
+    #texlive for docs seems extreme
+    mkdir -p $out/share/alliance
+    mv ./documentation $out/share/alliance
+    substituteInPlace autostuff \
+      --replace "$newdirs documentation" "$newdirs" \
+      --replace documentation Solaris
+
+    substituteInPlace sea/src/DEF_grammar_lex.l \
+      --replace "ifndef FLEX_BETA" "if (YY_FLEX_MAJOR_VERSION <= 2) && (YY_FLEX_MINOR_VERSION < 6)"
+    ./autostuff
+  '';
+
+  allianceInstaller = ''
+    #!${runtimeShell}
+    cp -v -r -n --no-preserve=mode  $out/etc/* /etc/ > /etc/alliance-install.log
+  '';
+
+  allianceUnInstaller = ''
+    #!${runtimeShell}
+    awk '{print \$3}' /etc/alliance-install.log | xargs rm
+    awk '{print \$3}' /etc/alliance-install.log | xargs rmdir
+    rm /etc/alliance-install.log
+  '';
+
+  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/
+
+    echo "${allianceInstaller}" > $out/bin/alliance-install
+    chmod +x $out/bin/alliance-install
+
+    echo "${allianceUnInstaller}" > $out/bin/alliance-uninstall
+    chmod +x $out/bin/alliance-uninstall
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Complete set of free CAD tools and portable libraries for VLSI design";
+    homepage = http://www-asim.lip6.fr/recherche/alliance/;
+    license = with licenses; gpl2Plus;
+    maintainers = with maintainers; [ ];
+    platforms = with platforms; linux;
+    broken = true;
+  };
+}
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..016760bde020
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/archimedes/default.nix
@@ -0,0 +1,17 @@
+{stdenv, fetchurl}:
+
+stdenv.mkDerivation rec {
+  name = "archimedes-2.0.1";
+
+  src = fetchurl {
+    url = "mirror://gnu/archimedes/${name}.tar.gz";
+    sha256 = "0jfpnd3pns5wxcxbiw49v5sgpmm5b4v8s4q1a5292hxxk2hzmb3z";
+  };
+
+  meta = {
+    description = "GNU package for semiconductor device simulations";
+    homepage = https://www.gnu.org/software/archimedes;
+    license = stdenv.lib.licenses.gpl2Plus;
+    platforms = with stdenv.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..64777b5a0ac8
--- /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
+, stdenv
+, xorg
+}:
+
+{ src, toolName, version, ... } @ attrs:
+let
+  wrapBinary = libPaths: binaryName: ''
+    wrapProgram "$out/bin/${binaryName}" \
+      --prefix LD_LIBRARY_PATH : "${stdenv.lib.makeLibraryPath libPaths}"
+  '';
+  pkg = stdenv.mkDerivation (rec {
+    inherit (attrs) version src;
+
+    name = "${toolName}-${version}";
+
+    meta = with stdenv.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..58e01f4f9f49
--- /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 rec {
+    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..8f81a03044be
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/caneda/default.nix
@@ -0,0 +1,26 @@
+{stdenv, fetchFromGitHub, cmake, qtbase, qttools, qtsvg, qwt }:
+
+stdenv.mkDerivation rec {
+  name = "caneda-${version}";
+  version = "0.3.1";
+
+  src = fetchFromGitHub {
+    owner = "Caneda";
+    repo = "Caneda";
+    rev = version;
+    sha256 = "0hx8qid50j9xvg2kpbpqmbdyakgyjn6m373m1cvhp70v2gp1v8l2";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ qtbase qttools qtsvg qwt ];
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "Open source EDA software focused on easy of use and portability";
+    homepage = http://caneda.org;
+    license = stdenv.lib.licenses.gpl2Plus;
+    maintainers = with stdenv.lib.maintainers; [viric];
+    platforms = with stdenv.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/dsview/default.nix b/nixpkgs/pkgs/applications/science/electronics/dsview/default.nix
new file mode 100644
index 000000000000..af3844f47312
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/dsview/default.nix
@@ -0,0 +1,47 @@
+{ stdenv, fetchFromGitHub, pkgconfig, cmake, autoreconfHook,
+glib, libzip, boost, fftw, qtbase,
+libusb, makeWrapper, libsigrok4dsl, libsigrokdecode4dsl
+}:
+
+stdenv.mkDerivation rec {
+  name = "dsview-${version}";
+
+  version = "0.99";
+
+  src = fetchFromGitHub {
+      owner = "DreamSourceLab";
+      repo = "DSView";
+      rev = version;
+      sha256 = "189i3baqgn8k3aypalayss0g489xi0an9hmvyggvxmgg1cvcwka2";
+  };
+
+  postUnpack = ''
+    export sourceRoot=$sourceRoot/DSView
+  '';
+
+  patches = [
+    # Fix absolute install paths
+    ./install.patch
+  ];
+
+  nativeBuildInputs = [ cmake pkgconfig makeWrapper ];
+
+  buildInputs = [
+   boost fftw qtbase libusb libzip libsigrokdecode4dsl libsigrok4dsl
+  ];
+
+  enableParallelBuilding = true;
+
+  postFixup = ''
+    wrapProgram $out/bin/DSView --suffix QT_PLUGIN_PATH : \
+      ${qtbase.bin}/${qtbase.qtPluginPrefix}
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A GUI program for supporting various instruments from DreamSourceLab, including logic analyzer, oscilloscope, etc";
+    homepage = http://www.dreamsourcelab.com/;
+    license = licenses.gpl3Plus;
+    platforms = platforms.linux;
+    maintainers = [ 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..e30a28d80fa3
--- /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
+@@ -403,8 +403,8 @@ install(DIRECTORY res DESTINATION share/${PROJECT_NAME})
+ install(FILES icons/logo.png DESTINATION share/${PROJECT_NAME} RENAME logo.png)
+ install(FILES ../NEWS DESTINATION share/${PROJECT_NAME} RENAME NEWS)
+ install(FILES ../ug.pdf DESTINATION share/${PROJECT_NAME} RENAME ug.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..4a681907e192
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/dsview/libsigrok4dsl.nix
@@ -0,0 +1,28 @@
+{ stdenv, pkgconfig, autoreconfHook,
+glib, libzip, libserialport, check, libusb, libftdi,
+systemd, alsaLib, dsview
+}:
+
+stdenv.mkDerivation rec {
+  inherit (dsview) version src;
+
+  name = "libsigrok4dsl-${version}";
+
+  postUnpack = ''
+    export sourceRoot=$sourceRoot/libsigrok4DSL
+  '';
+
+  nativeBuildInputs = [ pkgconfig autoreconfHook ];
+
+  buildInputs = [
+    glib libzip libserialport libusb libftdi systemd check alsaLib
+  ];
+
+  meta = with stdenv.lib; {
+    description = "A fork of the sigrok library for usage with DSView";
+    homepage = http://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..58f32f2ae6cc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/dsview/libsigrokdecode4dsl.nix
@@ -0,0 +1,27 @@
+{ stdenv, pkgconfig, autoreconfHook,
+glib, check, python3, dsview
+}:
+
+stdenv.mkDerivation rec {
+  inherit (dsview) version src;
+
+  name = "libsigrokdecode4dsl-${version}";
+
+  postUnpack = ''
+    export sourceRoot=$sourceRoot/libsigrokdecode4DSL
+  '';
+
+  nativeBuildInputs = [ pkgconfig autoreconfHook ];
+
+  buildInputs = [
+    python3 glib check
+  ];
+
+  meta = with stdenv.lib; {
+    description = "A fork of the sigrokdecode library for usage with DSView";
+    homepage = http://www.dreamsourcelab.com/;
+    license = licenses.gpl3Plus;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.bachp ];
+  };
+}
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..b97ede413963
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/eagle/eagle.nix
@@ -0,0 +1,83 @@
+{ stdenv, fetchurl, makeDesktopItem, patchelf
+, libXrender, libXrandr, libXcursor, libX11, libXext, libXi, libxcb
+, cups , libGL, glib, nss, nspr, expat, alsaLib
+, qtbase, qtdeclarative, qtsvg, qtlocation, qtwebchannel, qtwebengine
+}:
+
+let
+  libPath = stdenv.lib.makeLibraryPath
+    [ libXrender libXrandr libXcursor libX11 libXext libXi libxcb
+      libGL glib nss nspr expat alsaLib
+      qtbase qtdeclarative qtsvg qtlocation qtwebchannel qtwebengine
+    ];
+  in
+  stdenv.mkDerivation rec {
+    name = "eagle-${version}";
+    version = "9.1.2";
+
+    src = fetchurl {
+      url = "https://eagle-updates.circuits.io/downloads/${builtins.replaceStrings ["."] ["_"] version}/Autodesk_EAGLE_${version}_English_Linux_64bit.tar.gz";
+      sha256 = "0y7ahl9z5a7l9cjk8hzmyv6ga8chlry5rr8v116q5mnsgs4i11an";
+    };
+
+    desktopItem = makeDesktopItem {
+      name = "eagle";
+      exec = "eagle";
+      icon = "eagle";
+      comment = "Schematic capture and PCB layout";
+      desktopName = "Eagle";
+      genericName = "Schematic editor";
+      categories = "Application;Development;";
+    };
+
+    buildInputs =
+      [ libXrender libXrandr libXcursor libX11 libXext libXi libxcb
+        libGL glib nss nspr expat alsaLib
+        qtbase qtdeclarative qtsvg qtlocation qtwebchannel qtwebengine
+      ];
+
+    doConfigure = false;
+    doBuild = false;
+
+    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/icons
+      ln -s "$out/eagle-${version}/bin/eagle-logo.png" "$out"/share/icons/eagle.png
+    '';
+
+    meta = with stdenv.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 = [ maintainers.rittelle ];
+    };
+  }
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..69b111562ab2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/eagle/eagle7.nix
@@ -0,0 +1,97 @@
+{ stdenv, fetchurl, makeDesktopItem, patchelf, zlib, freetype, fontconfig
+, openssl, libXrender, libXrandr, libXcursor, libX11, libXext, libXi
+, libxcb, cups, xkeyboardconfig, runtimeShell
+}:
+
+let
+
+  libPath = stdenv.lib.makeLibraryPath
+    [ zlib freetype fontconfig openssl libXrender libXrandr libXcursor libX11
+      libXext libXi libxcb cups
+    ];
+
+in
+
+stdenv.mkDerivation rec {
+  name = "eagle-${version}";
+  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 = "Application;Development;";
+  };
+
+  buildInputs =
+    [ patchelf zlib freetype fontconfig openssl libXrender libXrandr libXcursor
+      libX11 libXext libXi
+    ];
+
+  phases = [ "installPhase" ];
+
+  # 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 stdenv.lib; {
+    description = "Schematic editor and PCB layout tool from CadSoft";
+    homepage = http://www.cadsoftusa.com/;
+    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/fritzing/default.nix b/nixpkgs/pkgs/applications/science/electronics/fritzing/default.nix
new file mode 100644
index 000000000000..ab5088543102
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/fritzing/default.nix
@@ -0,0 +1,46 @@
+{ stdenv, fetchpatch, fetchFromGitHub, qmake, pkgconfig
+, qtbase, qtsvg, qtserialport, boost, libgit2
+}:
+
+stdenv.mkDerivation rec {
+  name = "fritzing-${version}";
+  version = "0.9.3b";
+
+  src = fetchFromGitHub {
+    owner = "fritzing";
+    repo = "fritzing-app";
+    rev = version;
+    sha256 = "0hpyc550xfhr6gmnc85nq60w00rm0ljm0y744dp0z88ikl04f4s3";
+  };
+
+  parts = fetchFromGitHub {
+    owner = "fritzing";
+    repo = "fritzing-parts";
+    rev = version;
+    sha256 = "1d2v8k7p176j0lczx4vx9n9gbg3vw09n2c4b6w0wj5wqmifywhc1";
+  };
+
+  patches = [(fetchpatch {
+    name = "0001-Squashed-commit-of-the-following.patch";
+    url = "https://aur.archlinux.org/cgit/aur.git/plain/0001-Squashed-commit-of-the-following.patch?h=fritzing";
+    sha256 = "1cv6myidxhy28i8m8v13ghzkvx5978p9dcd8v7885y0l1h3108mf";
+  })];
+
+  buildInputs = [ qtbase qtsvg qtserialport boost libgit2 ];
+
+  nativeBuildInputs = [ qmake pkgconfig ];
+
+  qmakeFlags = [ "phoenix.pro" ];
+
+  preConfigure = ''
+    ln -s "$parts" parts
+  '';
+
+  meta = {
+    description = "An open source prototyping tool for Arduino-based projects";
+    homepage = http://fritzing.org/;
+    license = stdenv.lib.licenses.gpl3;
+    maintainers = [ stdenv.lib.maintainers.robberer ];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
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..93fe7b6ba77a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/geda/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, pkgconfig, guile, gtk2, flex, gawk, perl }:
+
+stdenv.mkDerivation rec {
+  name = "geda-${version}";
+  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 = [ pkgconfig ];
+  buildInputs = [ guile gtk2 flex gawk perl ];
+
+  meta = with stdenv.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..c0821c8a9ab9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/gerbv/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchgit, pkgconfig, gettext, libtool, automake, autoconf, cairo, gtk2, autoreconfHook }:
+
+stdenv.mkDerivation rec {
+  name = "gerbv-${version}";
+  version = "2015-10-08";
+
+  src = fetchgit {
+    url = git://git.geda-project.org/gerbv.git;
+    rev = "76b8b67bfa10823ce98f1c4c3b49a2afcadf7659";
+    sha256 = "00jn1xhf6kblxc5gac1wvk8zm12fy6sk81nj3jwdag0z6wk3z446";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ gettext libtool automake autoconf cairo gtk2 ];
+
+  configureFlags = ["--disable-update-desktop-database"];
+
+  meta = with stdenv.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/gtkwave/default.nix b/nixpkgs/pkgs/applications/science/electronics/gtkwave/default.nix
new file mode 100644
index 000000000000..7d9d7a662f2f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/gtkwave/default.nix
@@ -0,0 +1,24 @@
+{stdenv, fetchurl, gtk2, gperf, pkgconfig, bzip2, tcl, tk, judy, xz}:
+
+stdenv.mkDerivation rec {
+  name = "gtkwave-${version}";
+  version = "3.3.99";
+
+  src = fetchurl {
+    url    = "mirror://sourceforge/gtkwave/${name}.tar.gz";
+    sha256 = "0lc4y2vizrbxldjk5yw2i4y7pyprjdjqx3iafzjfnin694zp2630";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ gtk2 gperf bzip2 tcl tk judy xz ];
+
+  configureFlags = [ "--with-tcl=${tcl}/lib" "--with-tk=${tk}/lib" "--enable-judy" ];
+
+  meta = {
+    description = "VCD/Waveform viewer for Unix and Win32";
+    homepage    = http://gtkwave.sourceforge.net;
+    license     = stdenv.lib.licenses.gpl2Plus;
+    maintainers = with stdenv.lib.maintainers; [ thoughtpolice ];
+    platforms   = stdenv.lib.platforms.linux;
+  };
+}
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..e77f4a603a81
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/kicad/default.nix
@@ -0,0 +1,72 @@
+{ wxGTK, lib, stdenv, fetchurl, cmake, libGLU_combined, zlib
+, libX11, gettext, glew, glm, cairo, curl, openssl, boost, pkgconfig
+, doxygen, pcre, libpthreadstubs, libXdmcp
+, wrapGAppsHook
+, oceSupport ? true, opencascade
+, ngspiceSupport ? true, libngspice
+, swig, python, pythonPackages
+}:
+
+assert ngspiceSupport -> libngspice != null;
+
+with lib;
+stdenv.mkDerivation rec {
+  name = "kicad-${version}";
+  series = "5.0";
+  version = "5.0.2";
+
+  src = fetchurl {
+    url = "https://launchpad.net/kicad/${series}/${version}/+download/kicad-${version}.tar.xz";
+    sha256 = "10605rr10x0353n6yk2z095ydnkd1i6j1ncbq64pfxdn5vkhcd1g";
+  };
+
+  postPatch = ''
+    substituteInPlace CMakeModules/KiCadVersion.cmake \
+      --replace no-vcs-found ${version}
+  '';
+
+  cmakeFlags = [
+    "-DKICAD_SCRIPTING=ON"
+    "-DKICAD_SCRIPTING_MODULES=ON"
+    "-DKICAD_SCRIPTING_WXPYTHON=ON"
+    # nix installs wxPython headers in wxPython package, not in wxwidget
+    # as assumed. We explicitely set the header location.
+    "-DCMAKE_CXX_FLAGS=-I${pythonPackages.wxPython}/include/wx-3.0"
+  ] ++ optionals (oceSupport) [ "-DKICAD_USE_OCE=ON" "-DOCE_DIR=${opencascade}" ]
+    ++ optional (ngspiceSupport) "-DKICAD_SPICE=ON";
+
+  nativeBuildInputs = [
+    cmake
+    doxygen
+    pkgconfig
+    wrapGAppsHook
+    pythonPackages.wrapPython
+  ];
+  pythonPath = [ pythonPackages.wxPython ];
+  propagatedBuildInputs = [ pythonPackages.wxPython ];
+
+  buildInputs = [
+    libGLU_combined zlib libX11 wxGTK pcre libXdmcp gettext glew glm libpthreadstubs
+    cairo curl openssl boost
+    swig python
+  ] ++ optional (oceSupport) opencascade
+    ++ optional (ngspiceSupport) libngspice;
+
+  # this breaks other applications in kicad
+  dontWrapGApps = true;
+
+  preFixup = ''
+    buildPythonPath "$out $pythonPath"
+    gappsWrapperArgs+=(--set PYTHONPATH "$program_PYTHONPATH")
+
+    wrapProgram "$out/bin/kicad" "''${gappsWrapperArgs[@]}"
+  '';
+
+  meta = {
+    description = "Free Software EDA Suite";
+    homepage = http://www.kicad-pcb.org/;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ berce ];
+    platforms = with platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/kicad/unstable.nix b/nixpkgs/pkgs/applications/science/electronics/kicad/unstable.nix
new file mode 100644
index 000000000000..a9a4c32a0b45
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/kicad/unstable.nix
@@ -0,0 +1,56 @@
+{ wxGTK, lib, stdenv, fetchFromGitHub, cmake, libGLU_combined, zlib
+, libX11, gettext, glew, glm, cairo, curl, openssl, boost, pkgconfig
+, doxygen, pcre, libpthreadstubs, libXdmcp
+
+, oceSupport ? true, opencascade
+, ngspiceSupport ? true, libngspice
+, scriptingSupport ? true, swig, python, wxPython
+}:
+
+assert ngspiceSupport -> libngspice != null;
+
+with lib;
+stdenv.mkDerivation rec {
+  name = "kicad-unstable-${version}";
+  version = "2018-06-12";
+
+  src = fetchFromGitHub {
+    owner = "KICad";
+    repo = "kicad-source-mirror";
+    rev = "bc7bd107d980da147ad515aeae0469ddd55c2368";
+    sha256 = "11nsx52pd3jr2wbzr11glmcs1a9r7z1mqkqx6yvlm0awbgd8qlv8";
+  };
+
+  postPatch = ''
+    substituteInPlace CMakeModules/KiCadVersion.cmake \
+      --replace no-vcs-found ${version}
+  '';
+
+  cmakeFlags =
+    optionals (oceSupport) [ "-DKICAD_USE_OCE=ON" "-DOCE_DIR=${opencascade}" ]
+    ++ optional (ngspiceSupport) "-DKICAD_SPICE=ON"
+    ++ optionals (scriptingSupport) [
+      "-DKICAD_SCRIPTING=ON"
+      "-DKICAD_SCRIPTING_MODULES=ON"
+      "-DKICAD_SCRIPTING_WXPYTHON=ON"
+      # nix installs wxPython headers in wxPython package, not in wxwidget
+      # as assumed. We explicitely set the header location.
+      "-DCMAKE_CXX_FLAGS=-I${wxPython}/include/wx-3.0"
+    ];
+
+  nativeBuildInputs = [ cmake doxygen pkgconfig ];
+  buildInputs = [
+    libGLU_combined zlib libX11 wxGTK pcre libXdmcp gettext glew glm libpthreadstubs
+    cairo curl openssl boost
+  ] ++ optional (oceSupport) opencascade
+    ++ optional (ngspiceSupport) libngspice
+    ++ optionals (scriptingSupport) [ swig python wxPython ];
+
+  meta = {
+    description = "Free Software EDA Suite, Nightly Development Build";
+    homepage = http://www.kicad-pcb.org/;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ berce ];
+    platforms = with platforms; linux;
+  };
+}
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..bc6e5e33ea24
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/librepcb/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchFromGitHub, qtbase, qttools, qmake }:
+
+stdenv.mkDerivation rec {
+  name = "librepcb-${version}";
+  version = "0.1.0";
+
+  src = fetchFromGitHub {
+    owner = "LibrePCB";
+    repo = "LibrePCB";
+    fetchSubmodules = true;
+    rev = "d7458d3b3e126499902e1a66a0ef889f516a7c97";
+    sha256 = "19wh0398fzzpd65nh4mmc4jllkrgcrwxvxdby0gb5wh1sqyaqac4";
+  };
+
+  enableParallelBuilding = true;
+
+  nativeBuildInputs = [ qmake qttools ];
+
+  buildInputs = [ qtbase ];
+
+  qmakeFlags = ["-r"];
+
+  postInstall = ''
+      mkdir -p $out/share/librepcb/fontobene
+      cp share/librepcb/fontobene/newstroke.bene $out/share/librepcb/fontobene/
+    '';
+
+  meta = with stdenv.lib; {
+    description = "A free EDA software to develop printed circuit boards";
+    homepage = http://librepcb.org/;
+    maintainers = with maintainers; [ luz ];
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+  };
+}
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..194804a21a67
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/ngspice/default.nix
@@ -0,0 +1,25 @@
+{stdenv, fetchurl, bison, flex
+, readline, libX11, libICE, libXaw, libXmu, libXext, libXt, fftw }:
+
+stdenv.mkDerivation rec {
+  name = "ngspice-${version}";
+  version = "30";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/ngspice/ngspice-${version}.tar.gz";
+    sha256 = "15v0jdfy2a2zxp8dmy04fdp7w7a4vwvffcwa688r81b86wphxzh8";
+  };
+
+  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 stdenv.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/pcb/default.nix b/nixpkgs/pkgs/applications/science/electronics/pcb/default.nix
new file mode 100644
index 000000000000..b9bbcd695f17
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/pcb/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchurl, pkgconfig, gtk2, bison, intltool, flex
+, netpbm, imagemagick, dbus, xlibsWrapper, libGLU_combined
+, shared-mime-info, tcl, tk, gnome2, pangox_compat, gd, xorg
+}:
+
+stdenv.mkDerivation rec {
+  name = "pcb-${version}";
+  version = "20140316";
+
+  src = fetchurl {
+    url = "http://ftp.geda-project.org/pcb/pcb-20140316/${name}.tar.gz";
+    sha256 = "0l6944hq79qsyp60i5ai02xwyp8l47q7xdm3js0jfkpf72ag7i42";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [
+    gtk2 bison intltool flex netpbm imagemagick dbus xlibsWrapper
+    libGLU_combined tcl shared-mime-info tk
+    gnome2.gtkglext pangox_compat gd xorg.libXmu
+  ];
+
+  configureFlags = ["--disable-update-desktop-database"];
+
+  meta = with stdenv.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/pulseview/default.nix b/nixpkgs/pkgs/applications/science/electronics/pulseview/default.nix
new file mode 100644
index 000000000000..4e86d1d917f8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/pulseview/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchurl, pkgconfig, cmake, glib, boost, libsigrok
+, libsigrokdecode, libserialport, libzip, udev, libusb1, libftdi1, glibmm
+, pcre, librevisa, python3, qtbase, qtsvg
+}:
+
+stdenv.mkDerivation rec {
+  name = "pulseview-0.4.0";
+
+  src = fetchurl {
+    url = "https://sigrok.org/download/source/pulseview/${name}.tar.gz";
+    sha256 = "1f8f2342d5yam98mmcb8f9g2vslcwv486bmi4x45pxn68l82ky3q";
+  };
+
+  nativeBuildInputs = [ cmake pkgconfig ];
+
+  buildInputs = [
+    glib boost libsigrok libsigrokdecode libserialport libzip udev libusb1 libftdi1 glibmm
+    pcre librevisa python3 qtbase qtsvg
+  ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "Qt-based LA/scope/MSO GUI for sigrok (a signal analysis software suite)";
+    homepage = https://sigrok.org/;
+    license = licenses.gpl3Plus;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.bjornfor ];
+  };
+}
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..6ca3f80cefd3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/qfsm/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, qt4, cmake, graphviz, pkgconfig }:
+
+stdenv.mkDerivation rec {
+  name = "qfsm-0.54.0";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/qfsm/${name}-Source.tar.bz2";
+    sha256 = "0rl7bc5cr29ng67yij4akciyid9z7npal812ys4c3m229vjvflrb";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ qt4 cmake graphviz ];
+
+  patches = [
+    ./drop-hardcoded-prefix.patch
+    ./gcc6-fixes.patch
+  ];
+
+  hardeningDisable = [ "format" ];
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "Graphical editor for finite state machines";
+    homepage = http://qfsm.sourceforge.net/;
+    license = stdenv.lib.licenses.gpl3Plus;
+    platforms = stdenv.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/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..1a5fbf90d10b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/qucs/default.nix
@@ -0,0 +1,29 @@
+{stdenv, fetchFromGitHub, flex, bison, qt4, libX11, cmake, gperf, adms }:
+
+stdenv.mkDerivation rec {
+  version = "0.0.19";
+  name = "qucs-${version}";
+
+  src = fetchFromGitHub {
+    owner = "Qucs";
+    repo = "qucs";
+    rev = "qucs-${version}";
+    sha256 = "106h3kjyg7c0hkmzkin7h8fcl32n60835121b2qqih8ixi6r5id6";
+  };
+
+  QTDIR=qt4;
+
+  patches = [
+    ./cmakelists.patch
+  ];
+
+  buildInputs = [ flex bison qt4 libX11 cmake gperf adms ];
+
+  meta = {
+    description = "Integrated circuit simulator";
+    homepage = http://qucs.sourceforge.net;
+    license = stdenv.lib.licenses.gpl2Plus;
+    maintainers = with stdenv.lib.maintainers; [viric];
+    platforms = with stdenv.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..2c346b0e74a0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/tkgate/1.x.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchurl, tcl, tk, libX11, glibc, which, yacc, flex, imake, xorgproto, gccmakedep }:
+
+let
+  libiconvInc = stdenv.lib.optionalString stdenv.isLinux "${glibc.dev}/include";
+  libiconvLib = stdenv.lib.optionalString stdenv.isLinux "${glibc.out}/lib";
+in
+stdenv.mkDerivation rec {
+  name = "tkgate-1.8.7";
+
+  src = fetchurl {
+    url = "http://www.tkgate.org/downloads/${name}.tgz";
+    sha256 = "1pqywkidfpdbj18i03h97f4cimld4fb3mqfy8jjsxs12kihm18fs";
+  };
+
+  nativeBuildInputs = [ which yacc 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 = stdenv.lib.licenses.gpl2Plus;
+    maintainers = [ stdenv.lib.maintainers.peti ];
+    hydraPlatforms = stdenv.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..d2246f656db0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/verilator/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl, perl, flex, bison }:
+
+stdenv.mkDerivation rec {
+  name    = "verilator-${version}";
+  version = "4.010";
+
+  src = fetchurl {
+    url    = "https://www.veripool.org/ftp/${name}.tgz";
+    sha256 = "0wfmazhxb6bf6qznh7v756fv7jayjgkzar33gazkwdwfwa7p8lan";
+  };
+
+  enableParallelBuilding = true;
+  buildInputs = [ perl flex bison ];
+
+  postInstall = ''
+    sed -i -e '3a\#!/usr/bin/env perl' -e '1,3d' $out/bin/{verilator,verilator_coverage,verilator_profcfunc}
+  '';
+
+  meta = {
+    description = "Fast and robust (System)Verilog simulator/compiler";
+    homepage    = "https://www.veripool.org/wiki/verilator";
+    license     = stdenv.lib.licenses.lgpl3;
+    platforms   = stdenv.lib.platforms.unix;
+    maintainers = with stdenv.lib.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..c4268b54c20b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/verilog/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub, autoconf, gperf, flex, bison }:
+
+stdenv.mkDerivation rec {
+  name = "iverilog-${version}";
+  version = "2018.12.15";
+
+  src = fetchFromGitHub {
+    owner = "steveicarus";
+    repo = "iverilog";
+    rev = "7cd078e7ab184069b3b458fe6df7e83962254816";
+    sha256 = "1zc7lsa77dbsxjfz7vdgclmg97r0kw08xss7yfs4vyv5v5gnn98d";
+  };
+
+  patchPhase = ''
+    chmod +x $PWD/autoconf.sh
+    $PWD/autoconf.sh
+  '';
+
+  buildInputs = [ autoconf gperf flex bison ];
+
+  meta = {
+    description = "Icarus Verilog compiler";
+    repositories.git = https://github.com/steveicarus/iverilog.git;
+    homepage = http://www.icarus.com;
+    license = stdenv.lib.licenses.gpl2Plus;
+    maintainers = with stdenv.lib.maintainers; [winden];
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
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..418144e6af7b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/xcircuit/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchurl, autoreconfHook, automake, pkgconfig
+, cairo, ghostscript, ngspice, tcl, tk, xorg, zlib }:
+
+let
+  version = "3.9.73";
+  name = "xcircuit-${version}";
+  inherit (stdenv.lib) getBin;
+
+in stdenv.mkDerivation {
+  inherit name version;
+
+  src = fetchurl {
+    url = "http://opencircuitdesign.com/xcircuit/archive/${name}.tgz";
+    sha256 = "1kj9hayipplzm4960kx48vxddqj154qnxkccaqj9cnkp62b7q3jg";
+  };
+
+  nativeBuildInputs = [ autoreconfHook automake pkgconfig ];
+  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 stdenv.lib; {
+    description = "Generic drawing program tailored to circuit diagrams";
+    homepage = http://opencircuitdesign.com/xcircuit;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.spacefrogg ];
+  };
+}
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..829caacb55cb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/xoscope/default.nix
@@ -0,0 +1,24 @@
+{stdenv, fetchurl, gtk2, pkgconfig}:
+
+stdenv.mkDerivation rec {
+  name = "xoscope-2.0";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/xoscope/${name}.tgz";
+    sha256 = "00xlvvqyw6l1ljbsx1vgx2v1jfh0xacz1a0yhq1dj6yxf5wh58x8";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ gtk2 ];
+
+  # from: https://aur.archlinux.org/packages.php?ID=12140&detail=1
+  patches = [ ./gtkdepre.diff ];
+
+  meta = {
+    description = "Oscilloscope through the sound card";
+    homepage = http://xoscope.sourceforge.net;
+    license = stdenv.lib.licenses.gpl2Plus;
+    maintainers = with stdenv.lib.maintainers; [viric];
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/electronics/xoscope/gtkdepre.diff b/nixpkgs/pkgs/applications/science/electronics/xoscope/gtkdepre.diff
new file mode 100644
index 000000000000..993df9cb5503
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/electronics/xoscope/gtkdepre.diff
@@ -0,0 +1,58 @@
+diff -ru xoscope-2.0-old//gtkdatabox-0.6.0.0/gtk/gtkdatabox.c xoscope-2.0/gtkdatabox-0.6.0.0/gtk/gtkdatabox.c
+--- xoscope-2.0-old//gtkdatabox-0.6.0.0/gtk/gtkdatabox.c	2010-06-07 10:42:24.000000000 +0200
++++ xoscope-2.0/gtkdatabox-0.6.0.0/gtk/gtkdatabox.c	2010-06-07 10:45:40.000000000 +0200
+@@ -661,7 +661,7 @@
+ static void
+ gtk_databox_calculate_hcanvas (GtkDatabox *box)
+ {
+-   if (!GTK_WIDGET_VISIBLE (box))
++   if (!gtk_widget_get_visible (box))
+       return;
+    
+    if (box->priv->adjX->page_size == 1.0)
+@@ -698,7 +698,7 @@
+ static void
+ gtk_databox_calculate_vcanvas (GtkDatabox *box)
+ {
+-   if (!GTK_WIDGET_VISIBLE (box))
++   if (!gtk_widget_get_visible (box))
+       return;
+    
+    if (box->priv->adjY->page_size == 1.0)
+@@ -780,7 +780,7 @@
+    gtk_databox_draw (box, event);
+ 
+    gdk_draw_drawable (widget->window,
+-                      widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
++                      widget->style->fg_gc[gtk_widget_get_state (widget)],
+                       box->priv->canvas.pixmap, event->area.x, event->area.y,
+                       event->area.x, event->area.y, event->area.width,
+                       event->area.height);
+@@ -940,7 +940,7 @@
+    GtkWidget *widget = GTK_WIDGET (box);
+ 
+    g_return_if_fail (GTK_IS_DATABOX (box));
+-   g_return_if_fail (GTK_WIDGET_VISIBLE (widget));
++   g_return_if_fail (gtk_widget_get_visible (widget));
+ 
+    gdk_draw_rectangle (box->priv->canvas.pixmap, widget->style->bg_gc[0], 
+                        TRUE, 0, 0,
+@@ -1150,7 +1150,7 @@
+    /* Copy a part of the pixmap to the screen */
+    if (pixmapCopyRect)
+       gdk_draw_drawable (widget->window,
+-                         widget->style->fg_gc[GTK_WIDGET_STATE (box)],
++                         widget->style->fg_gc[gtk_widget_get_state (box)],
+                          box->priv->canvas.pixmap,
+                          pixmapCopyRect->x,
+                          pixmapCopyRect->y,
+--- xoscope-2.0-old//gtkdatabox-0.6.0.0/gtk/Makefile.in	2011-09-02 16:43:43.000000000 +0200
++++ xoscope-2.0/gtkdatabox-0.6.0.0/gtk/Makefile.in	2011-09-02 16:43:57.000000000 +0200
+@@ -196,7 +196,6 @@
+ 			-DG_DISABLE_DEPRECATED\
+ 			-DGDK_DISABLE_DEPRECATED\
+ 			-DGDK_PIXBUF_DISABLE_DEPRECATED\
+-			-DGTK_DISABLE_DEPRECATED\
+ 			`pkg-config gtk+-2.0 --cflags`
+ 
+ all: all-am
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..e233b91bbc91
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/geometry/drgeo/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, libglade, gtk2, guile, libxml2, perl
+, intltool, libtool, pkgconfig }:
+
+stdenv.mkDerivation rec {
+  name = "drgeo-${version}";
+  version = "1.1.0";
+
+  hardeningDisable = [ "format" ];
+
+  src = fetchurl {
+    url = "mirror://sourceforge/ofset/${name}.tar.gz";
+    sha256 = "05i2czgzhpzi80xxghinvkyqx4ym0gm9f38fz53idjhigiivp4wc";
+  };
+  patches = [ ./struct.patch ];
+
+  buildInputs = [libglade gtk2 guile libxml2
+    perl intltool libtool pkgconfig];
+
+  prebuild = ''
+    cp drgeo.desktop.in drgeo.desktop
+  '';
+
+  meta = with stdenv.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/tetgen/1.4.nix b/nixpkgs/pkgs/applications/science/geometry/tetgen/1.4.nix
new file mode 100644
index 000000000000..3a2dbf180ee3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/geometry/tetgen/1.4.nix
@@ -0,0 +1,22 @@
+{stdenv, fetchurl}:
+
+stdenv.mkDerivation rec {
+  name = "tetgen-1.4.3";
+
+  src = fetchurl {
+    url = "${meta.homepage}/files/tetgen1.4.3.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 = stdenv.lib.licenses.mit;
+    platforms = stdenv.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..b655cc48c731
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/geometry/tetgen/default.nix
@@ -0,0 +1,24 @@
+{stdenv, fetchurl}: 
+
+let version = "1.5.0"; in
+stdenv.mkDerivation {
+  name = "tetgen-${version}";
+
+  src = fetchurl {
+    url = "http://wias-berlin.de/software/tetgen/1.5/src/tetgen${version}.tar.gz";
+    sha256 = "1www3x2r6r7pck43ismlwy82x0j6xj2qiwvfs2pn687gsmhlh4ad";
+  };
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp tetgen $out/bin
+  '';
+
+  meta = {
+    inherit version;
+    description = "Quality Tetrahedral Mesh Generator and 3D Delaunay Triangulator";
+    homepage = http://tetgen.org/;
+    license = stdenv.lib.licenses.agpl3Plus;
+    platforms = stdenv.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..6e7a3cfc88ac
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/abc/default.nix
@@ -0,0 +1,31 @@
+{ fetchFromGitHub, stdenv, readline, cmake }:
+
+stdenv.mkDerivation rec {
+  name = "abc-verifier-${version}";
+  version = "2018-07-08";
+
+  src = fetchFromGitHub {
+    owner = "berkeley-abc";
+    repo = "abc";
+    rev    = "24407e13db4b8ca16c3996049b2d33ec3722de39";
+    sha256 = "1rckji7nk81n6v1yajz7daqwipxacv7zlafknvmbiwji30j47sq5";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ readline ];
+
+  enableParallelBuilding = true;
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mv abc $out/bin
+  '';
+
+  meta = {
+    description = "A tool for squential logic synthesis and formal verification";
+    homepage    = https://people.eecs.berkeley.edu/~alanmi/abc;
+    license     = stdenv.lib.licenses.mit;
+    platforms   = stdenv.lib.platforms.unix;
+    maintainers = [ stdenv.lib.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..bc23454edfc7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/abella/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchurl, rsync, ocamlPackages }:
+
+stdenv.mkDerivation rec {
+  name = "abella-${version}";
+  version = "2.0.6";
+
+  src = fetchurl {
+    url = "http://abella-prover.org/distributions/${name}.tar.gz";
+    sha256 = "164q9gngckg6q69k13lwx2pq3cnc9ckw1qi8dnpxqfjgwfqr7xyi";
+  };
+
+  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 = stdenv.lib.licenses.gpl3;
+    maintainers = with stdenv.lib.maintainers; [ bcdarwin ciil ];
+    platforms = stdenv.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..729aef4e21c2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/acgtk/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchurl, dune, ocamlPackages }:
+
+stdenv.mkDerivation {
+
+  name = "acgtk-1.5.0";
+
+  src = fetchurl {
+    url = http://calligramme.loria.fr/acg/software/acg-1.5.0-20181019.tar.gz;
+    sha256 = "14n003gxzw5w79hlpw1ja4nq97jqf9zqyg00ihvpxw4bv9jlm8jm";
+  };
+
+  buildInputs = [ dune ] ++ (with ocamlPackages; [
+    ocaml findlib ansiterminal cairo2 fmt logs menhir mtime ocf
+  ]);
+
+  buildPhase = "dune build";
+
+  inherit (dune) installPhase;
+
+  meta = with stdenv.lib; {
+    homepage = http://calligramme.loria.fr/acg/;
+    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..03524fc6b222
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/aiger/default.nix
@@ -0,0 +1,55 @@
+{ stdenv, fetchurl, picosat }:
+
+stdenv.mkDerivation rec {
+  name = "aiger-${version}";
+  version = "1.9.9";
+
+  src = fetchurl {
+    url    = "http://fmv.jku.at/aiger/${name}.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     = stdenv.lib.licenses.mit;
+    maintainers = with stdenv.lib.maintainers; [ thoughtpolice ];
+    platforms   = stdenv.lib.platforms.linux;
+  };
+}
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..234b74749977
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/alt-ergo/default.nix
@@ -0,0 +1,26 @@
+{ fetchurl, stdenv, which, dune, ocamlPackages }:
+
+stdenv.mkDerivation rec {
+  name = "alt-ergo-${version}";
+  version = "2.3.0";
+
+  src = fetchurl {
+    url    = "https://alt-ergo.ocamlpro.com/download_manager.php?target=${name}.tar.gz";
+    name   = "${name}.tar.gz";
+    sha256 = "1ycr3ff0gacq1aqzs16n6swgfniwpim0m7rvhcam64kj0a80c6bz";
+  };
+
+  buildInputs = [ dune which ] ++ (with ocamlPackages; [
+    ocaml findlib camlzip lablgtk menhir num ocplib-simplex psmt2-frontend seq zarith
+  ]);
+
+  preConfigure = "patchShebangs ./configure";
+
+  meta = {
+    description = "High-performance theorem prover and SMT solver";
+    homepage    = "https://alt-ergo.ocamlpro.com/";
+    license     = stdenv.lib.licenses.ocamlpro_nc;
+    platforms   = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
+    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
+  };
+}
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..bf8d3cf03b83
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/aspino/default.nix
@@ -0,0 +1,50 @@
+{ 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 rec {
+  name = "aspino-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 stdenv.lib; {
+    description = "SAT/PseudoBoolean/MaxSat/ASP solver using glucose";
+    maintainers = with maintainers; [ gebner ma27 ];
+    platforms = platforms.unix;
+    license = licenses.asl20;
+    homepage = http://alviano.net/software/maxino/;
+    # See pkgs/applications/science/logic/glucose/default.nix
+    badPlatforms = [ "aarch64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/avy/0001-no-static-boost-libs.patch b/nixpkgs/pkgs/applications/science/logic/avy/0001-no-static-boost-libs.patch
new file mode 100644
index 000000000000..a53142faba66
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/avy/0001-no-static-boost-libs.patch
@@ -0,0 +1,12 @@
+diff --git a/avy/CMakeLists.txt b/avy/CMakeLists.txt
+index 5913076..b0453b5 100644
+--- a/avy/CMakeLists.txt
++++ b/avy/CMakeLists.txt
+@@ -23,7 +23,6 @@ if (CUSTOM_BOOST_ROOT)
+   set (Boost_NO_SYSTEM_PATHS "ON")
+ endif()
+ 
+-set (Boost_USE_STATIC_LIBS ON)
+ find_package (Boost 1.46.1 REQUIRED program_options)
+ IF (Boost_FOUND)
+   include_directories (${Boost_INCLUDE_DIRS})
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..6c2d2f0a062f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/avy/default.nix
@@ -0,0 +1,53 @@
+{ stdenv, fetchgit, cmake, zlib, boost }:
+
+stdenv.mkDerivation rec {
+  name = "avy-${version}";
+  version = "2017.10.16";
+
+  src = fetchgit {
+    url    = "https://bitbucket.org/arieg/extavy";
+    rev    = "c75c83379c38d6ea1046d0caee95aef77283ffe3";
+    sha256 = "0zcycnypg4q5g710bnkjpycaawmibc092vmyhgfbixkgq9fb5lfh";
+    fetchSubmodules = true;
+  };
+
+  buildInputs = [ cmake zlib boost.out boost.dev ];
+  NIX_CFLAGS_COMPILE = [ "-Wno-narrowing" ]
+    # Squelch endless stream of warnings on same few things
+    ++ stdenv.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}
+  '';
+
+  patches =
+    [ ./0001-no-static-boost-libs.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     = stdenv.lib.licenses.mit;
+    maintainers = with stdenv.lib.maintainers; [ thoughtpolice ];
+    platforms   = stdenv.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..da0e9bf1c1dd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/beluga/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchFromGitHub, ocamlPackages, omake }:
+
+stdenv.mkDerivation {
+  name = "beluga-20180403";
+
+  src = fetchFromGitHub {
+    owner  = "Beluga-lang";
+    repo   = "Beluga";
+    rev    = "046aa59f008be70a7c4700b723bed0214ea8b687";
+    sha256 = "0m68y0r0wdw3mg2jks68bihaww7sg305zdfnic1rkndq2cxv0mld";
+  };
+
+  nativeBuildInputs = with ocamlPackages; [ findlib ocamlbuild omake ];
+  buildInputs = with ocamlPackages; [ ocaml ulex ocaml_extlib ];
+
+  installPhase = ''
+    mkdir -p $out
+    cp -r bin $out/
+
+    mkdir -p $out/share/beluga
+    cp -r tools/ examples/ $out/share/beluga
+
+    mkdir -p $out/share/emacs/site-lisp/beluga/
+    cp -r tools/beluga-mode.el $out/share/emacs/site-lisp/beluga
+  '';
+
+  meta = {
+    description = "A functional language for reasoning about formal systems";
+    homepage    = http://complogic.cs.mcgill.ca/beluga/;
+    license     = stdenv.lib.licenses.gpl3Plus;
+    maintainers = [ stdenv.lib.maintainers.bcdarwin ];
+    platforms   = stdenv.lib.platforms.unix;
+  };
+}
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..8e0ad22bba18
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/boolector/default.nix
@@ -0,0 +1,50 @@
+{ stdenv, fetchFromGitHub
+, cmake, lingeling, btor2tools
+}:
+
+stdenv.mkDerivation rec {
+  name    = "boolector-${version}";
+  version = "3.0.0";
+
+  src = fetchFromGitHub {
+    owner  = "boolector";
+    repo   = "boolector";
+    rev    = "refs/tags/${version}";
+    sha256 = "15i3ni5klss423m57wcy1gx0m5wfrjmglapwg85pm7fb3jj1y7sz";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ lingeling btor2tools ];
+
+  cmakeFlags =
+    [ "-DSHARED=ON"
+      "-DUSE_LINGELING=YES"
+      "-DBTOR2_INCLUDE_DIR=${btor2tools.dev}/include"
+      "-DBTOR2_LIBRARIES=${btor2tools.lib}/lib/libbtor2parser.so"
+      "-DLINGELING_INCLUDE_DIR=${lingeling.dev}/include"
+      "-DLINGELING_LIBRARIES=${lingeling.lib}/lib/liblgl.a"
+    ];
+
+  installPhase = ''
+    mkdir -p $out/bin $lib/lib $dev/include
+
+    cp -vr bin/* $out/bin
+    cp -vr lib/* $lib/lib
+
+    rm -rf $out/bin/{examples,test}
+
+    cd ../src
+    find . -iname '*.h' -exec cp --parents '{}' $dev/include \;
+    rm -rf $dev/include/tests
+  '';
+
+  outputs = [ "out" "dev" "lib" ];
+
+  meta = with stdenv.lib; {
+    description = "An extremely fast SMT solver for bit-vectors and arrays";
+    homepage    = https://boolector.github.io;
+    license     = licenses.mit;
+    platforms   = platforms.linux;
+    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..ed3d9e638121
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/btor2tools/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  name = "btor2tools-${version}";
+  version = "pre55_8c150b39";
+
+  src = fetchFromGitHub {
+    owner  = "boolector";
+    repo   = "btor2tools";
+    rev    = "8c150b39cdbcdef4247344acf465d75ef642365d";
+    sha256 = "1r5pid4x567nms02ajjrz3v0zj18k0fi5pansrmc2907rnx2acxx";
+  };
+
+  configurePhase = "./configure.sh -shared";
+
+  installPhase = ''
+    mkdir -p $out $dev/include/btor2parser/ $lib/lib
+
+    cp -vr bin $out
+    cp -v  src/btor2parser/btor2parser.h $dev/include/btor2parser
+    cp -v  build/libbtor2parser.* $lib/lib
+  '';
+
+  outputs = [ "out" "dev" "lib" ];
+
+  meta = with stdenv.lib; {
+    description = "Fast SAT solver";
+    homepage    = http://fmv.jku.at/lingeling/;
+    license     = licenses.mit;
+    platforms   = platforms.linux;
+    maintainers = with maintainers; [ thoughtpolice ];
+  };
+}
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..0817ebe0654b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/cedille/default.nix
@@ -0,0 +1,50 @@
+{ stdenv, lib, fetchFromGitHub, alex, happy, Agda, agdaIowaStdlib,
+  buildPlatform, buildPackages, ghcWithPackages, fetchpatch }:
+let
+  options-patch =
+    fetchpatch {
+      url = https://github.com/cedille/cedille/commit/ee62b0fabde6c4f7299a3778868519255cc4a64f.patch;
+      name = "options.patch";
+      sha256 = "19xzn9sqpfnfqikqy1x9lb9mb6722kbgvrapl6cf8ckcw8cfj8cz";
+      };
+in
+stdenv.mkDerivation rec {
+  version = "1.0.0";
+  name = "cedille-${version}";
+  src = fetchFromGitHub {
+    owner = "cedille";
+    repo = "cedille";
+    rev = "v${version}";
+    sha256 = "08c2vgg8i6l3ws7hd5gsj89mki36lxm7x7s8hi1qa5gllq04a832";
+  };
+  buildInputs = [ alex happy Agda (ghcWithPackages (ps: [ps.ieee])) ];
+
+  patches = [options-patch];
+
+  LANG = "en_US.UTF-8";
+  LOCALE_ARCHIVE =
+    lib.optionalString (buildPlatform.libc == "glibc")
+      "${buildPackages.glibcLocales}/lib/locale/locale-archive";
+
+  postPatch = ''
+    patchShebangs create-libraries.sh
+    cp -r ${agdaIowaStdlib.src} ial
+    chmod -R 755 ial
+  '';
+
+  outputs = ["out" "lib"];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mv cedille $out/bin/cedille
+    mv lib $lib
+  '';
+
+  meta = {
+    description = "An interactive theorem-prover and dependently typed programming language, based on extrinsic (aka Curry-style) type theory.";
+    homepage = https://cedille.github.io/;
+    license = stdenv.lib.licenses.mit;
+    maintainers = [ stdenv.lib.maintainers.mpickering ];
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
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..708270f772fd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/celf/default.nix
@@ -0,0 +1,36 @@
+{ 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 stdenv.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..b6ebce681937
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/clprover/clprover.nix
@@ -0,0 +1,27 @@
+{ stdenv, pkgs, fetchzip }:
+
+stdenv.mkDerivation rec {
+  name = "clprover-${version}";
+  version = "1.0.3";
+
+  src = fetchzip {
+    url = "http://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 stdenv.lib; {
+    description = "Resolution-based theorem prover for Coalition Logic implemented in C++";
+    homepage = http://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..0a4e1dddcae3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/coq/default.nix
@@ -0,0 +1,151 @@
+# - 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.
+
+{ stdenv, fetchFromGitHub, writeText, pkgconfig
+, ocamlPackages, ncurses
+, buildIde ? true
+, csdp ? null
+, version
+}:
+
+let
+  sha256 = {
+   "8.5pl1"    = "1976ki5xjg2r907xj9p7gs0kpdinywbwcqlgxqw75dgp0hkgi00n";
+   "8.5pl2"    = "109rrcrx7mz0fj7725kjjghfg5ydwb24hjsa5hspa27b4caah7rh";
+   "8.5pl3"    = "15c3rdk59nifzihsp97z4vjxis5xmsnrvpb86qiazj143z2fmdgw";
+   "8.6"       = "148mb48zpdax56c0blfi7v67lx014lnmrvxxasi28hsibyz2lvg4";
+   "8.6.1"     = "0llrxcxwy5j87vbbjnisw42rfw1n1pm5602ssx64xaxx3k176g6l";
+   "8.7.0"     = "1h18b7xpnx3ix9vsi5fx4zdcbxy7bhra7gd5c5yzxmk53cgf1p9m";
+   "8.7.1"     = "0gjn59jkbxwrihk8fx9d823wjyjh5m9gvj9l31nv6z6bcqhgdqi8";
+   "8.7.2"     = "0a0657xby8wdq4aqb2xsxp3n7pmc2w4yxjmrb2l4kccs1aqvaj4w";
+   "8.8.0" = "13a4fka22hdxsjk11mgjb9ffzplfxyxp1sg5v1c8nk1grxlscgw8";
+   "8.8.1" = "1hlf58gwazywbmfa48219amid38vqdl94yz21i11b4map6jfwhbk";
+   "8.8.2" = "1lip3xja924dm6qblisk1bk0x8ai24s5xxqxphbdxj6djglj68fd";
+   "8.9.0" = "1dkgdjc4n1m15m1p724hhi5cyxpqbjw6rxc5na6fl3v4qjjfnizh";
+  }."${version}";
+  coq-version = builtins.substring 0 3 version;
+  ideFlags = if buildIde then "-lablgtkdir ${ocamlPackages.lablgtk}/lib/ocaml/*/site-lib/lablgtk2 -coqide opt" else "";
+  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 "";
+self = stdenv.mkDerivation {
+  name = "coq-${version}";
+
+  passthru = {
+    inherit coq-version;
+    inherit ocamlPackages;
+    # 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")))) '(${stdenv.lib.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)
+    '';
+  };
+
+  src = fetchFromGitHub {
+    owner = "coq";
+    repo = "coq";
+    rev = "V${version}";
+    inherit sha256;
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ ncurses ] ++ (with ocamlPackages; [ ocaml findlib camlp5 num ])
+  ++ stdenv.lib.optional buildIde ocamlPackages.lablgtk;
+
+  postPatch = ''
+    UNAME=$(type -tp uname)
+    RM=$(type -tp rm)
+    substituteInPlace configure --replace "/bin/uname" "$UNAME"
+    substituteInPlace tools/beautify-archive --replace "/bin/rm" "$RM"
+    substituteInPlace configure.ml --replace '"md5 -q"' '"md5sum"'
+    ${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 = ''
+    configureFlagsArray=(
+      ${ideFlags}
+    )
+  '';
+
+  prefixKey = "-prefix ";
+
+  buildFlags = "revision coq coqide bin/votour";
+
+  createFindlibDestdir = true;
+
+  postInstall = ''
+    cp bin/votour $out/bin/
+    ln -s $out/lib/coq $OCAMLFIND_DESTDIR/coq
+  '';
+
+  meta = with stdenv.lib; {
+    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;
+  };
+}; in self
diff --git a/nixpkgs/pkgs/applications/science/logic/coq2html/default.nix b/nixpkgs/pkgs/applications/science/logic/coq2html/default.nix
new file mode 100644
index 000000000000..d76462ca9380
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/coq2html/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, fetchgit, ocaml }:
+
+let 
+  version = "20170720";
+in
+
+stdenv.mkDerivation {
+  name = "coq2html-${version}";
+
+  src = fetchgit {
+    url = "https://github.com/xavierleroy/coq2html";
+    rev = "e2b94093c6b9a877717f181765e30577de22439e";
+    sha256 = "1x466j0pyjggyz0870pdllv9f5vpnfrgkd0w7ajvm9rkwyp3f610";
+  };
+
+  buildInputs = [ ocaml ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp coq2html $out/bin
+  '';
+
+  meta = with stdenv.lib; {
+    description = "coq2html is an HTML documentation generator for Coq source files";
+    longDescription = ''
+      coq2html is an HTML documentation generator for Coq source files. It is
+      an alternative to the standard coqdoc documentation generator
+      distributed along with Coq. The major feature of coq2html is its ability
+      to fold proof scripts: in the generated HTML, proof scripts are
+      initially hidden, but can be revealed one by one by clicking on the
+      "Proof" keyword.
+    '';
+    homepage = https://github.com/xavierleroy/coq2html;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ jwiegley ];
+    platforms = platforms.unix;
+  };
+}
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..c6b7b918eac8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/cryptominisat/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchFromGitHub, fetchpatch, cmake, python3, xxd, boost }:
+
+stdenv.mkDerivation rec {
+  name = "cryptominisat-${version}";
+  version = "5.6.8";
+
+  src = fetchFromGitHub {
+    owner  = "msoos";
+    repo   = "cryptominisat";
+    rev    = version;
+    sha256 = "0csimmy1nvkfcsxjra9bm4mlcyxa3ac8zarm88zfb7640ca0d0wv";
+  };
+
+  buildInputs = [ python3 boost ];
+  nativeBuildInputs = [ cmake xxd ];
+
+  meta = with stdenv.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..df9e58af08bb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/cryptoverif/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchurl, ocaml }:
+
+stdenv.mkDerivation rec {
+  name = "cryptoverif-${version}";
+  version = "2.00";
+
+  src = fetchurl {
+    url    = "http://prosecco.gforge.inria.fr/personal/bblanche/cryptoverif/cryptoverif${version}.tar.gz";
+    sha256 = "0g8pkj58b48zk4c0sgpln0qhbj82v75mz3w6cl3w5bvmxsbkwvy1";
+  };
+
+  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/settings.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    = "http://prosecco.gforge.inria.fr/personal/bblanche/cryptoverif/";
+    license     = stdenv.lib.licenses.cecill-b;
+    platforms   = stdenv.lib.platforms.unix;
+    maintainers = [ stdenv.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..91eaaeeb0e40
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/cubicle/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, ocamlPackages }:
+
+stdenv.mkDerivation rec {
+  name = "cubicle-${version}";
+  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 stdenv.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; [ lucas8 ];
+  };
+}
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..703ce6fd5086
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/cvc3/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, flex, bison, gmp, perl }:
+
+stdenv.mkDerivation rec {
+    name = "cvc3-${version}";
+    version = "2.4.1";
+
+    src = fetchurl {
+      url = "http://www.cs.nyu.edu/acsys/cvc3/releases/${version}/${name}.tar.gz";
+      sha256 = "1xxcwhz3y6djrycw8sm6xz83wb4hb12rd1n0skvc7fng0rh1snym";
+    };
+
+  buildInputs = [ gmp flex bison perl ];
+
+  patches = [ ./cvc3-2.4.1-gccv6-fix.patch ];
+
+  preConfigure = ''
+    sed -e "s@ /bin/bash@bash@g" -i Makefile.std
+    find . -exec sed -e "s@/usr/bin/perl@${perl}/bin/perl@g" -i '{}' ';'
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A prover for satisfiability modulo theory (SMT)";
+    maintainers = with maintainers;
+      [ raskin ];
+    platforms = platforms.linux;
+    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..cddcbef7a035
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/cvc4/default.nix
@@ -0,0 +1,43 @@
+{ stdenv, fetchurl, cln, gmp, swig, pkgconfig
+, readline, libantlr3c, boost, jdk, autoreconfHook
+, python3, antlr3_4
+}:
+
+stdenv.mkDerivation rec {
+  name = "cvc4-${version}";
+  version = "1.6";
+
+  src = fetchurl {
+    url = "https://cvc4.cs.stanford.edu/downloads/builds/src/cvc4-${version}.tar.gz";
+    sha256 = "1iw793zsi48q91lxpf8xl8lnvv0jsj4whdad79rakywkm1gbs62w";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ gmp 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/
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.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..50454847baf1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/drat-trim/default.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  name = "drat-trim-2017-08-31";
+
+  src = fetchFromGitHub {
+    owner = "marijnheule";
+    repo = "drat-trim";
+    rev = "37ac8f874826ffa3500a00698910e137498defac";
+    sha256 = "1m9q47dfnvdli1z3kb1jvvbm0dgaw725k1aw6h9w00bggqb91bqh";
+  };
+
+  postPatch = ''
+    substituteInPlace Makefile --replace gcc cc
+  '';
+
+  installPhase = ''
+    install -Dt $out/bin drat-trim
+  '';
+
+  meta = with stdenv.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.
+    '';
+    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..e1eb9a2dcc3b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/ekrhyper/default.nix
@@ -0,0 +1,32 @@
+{stdenv, fetchurl, ocaml, perl}:
+let
+  s = # Generated upstream information
+  rec {
+    baseName="ekrhyper";
+    version="1_4_21022014";
+    name="${baseName}-${version}";
+    hash="14xaaxyvfli1nd4vd9fp4j1s8k76z2bhazxzzc7br3q6hc6b8ivw";
+    url="http://userpages.uni-koblenz.de/~bpelzer/ekrhyper/ekrh_1_4_21022014.tar.gz";
+    sha256="14xaaxyvfli1nd4vd9fp4j1s8k76z2bhazxzzc7br3q6hc6b8ivw";
+  };
+  buildInputs = [
+    ocaml perl
+  ];
+in
+stdenv.mkDerivation {
+  inherit (s) name version;
+  inherit buildInputs;
+  src = fetchurl {
+    inherit (s) url sha256;
+  };
+  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 = {
+    inherit (s) version;
+    description = "Automated first-order theorem prover";
+    license = stdenv.lib.licenses.gpl2 ;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/ekrhyper/default.upstream b/nixpkgs/pkgs/applications/science/logic/ekrhyper/default.upstream
new file mode 100644
index 000000000000..310e93ea53fd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/ekrhyper/default.upstream
@@ -0,0 +1,3 @@
+url http://userpages.uni-koblenz.de/~bpelzer/ekrhyper/
+ensure_choice
+version '.*[^0-9]_([-0-9_]+)[.].*' '\1'
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..b5a6a5b963e5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/elan/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, pkgconfig, curl, openssl, zlib, fetchFromGitHub, rustPlatform }:
+
+rustPlatform.buildRustPackage rec {
+  name = "elan-${version}";
+  version = "0.7.2";
+
+  cargoSha256 = "0vv7kr7rc3lvas7ngp5dp99ajjd5v8k5937ish7zqz1k4970q2f1";
+
+  src = fetchFromGitHub {
+    owner = "kha";
+    repo = "elan";
+    rev = "v${version}";
+    sha256 = "0844fydfxvacyx02gwxbzpmiamsp22malyy5m4wpvrky4dkpn3qj";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+
+  buildInputs = [ curl zlib openssl ];
+
+  cargoBuildFlags = [ "--features no-self-update" ];
+
+  postInstall = ''
+    pushd $out/bin
+    mv elan-init elan
+    for link in lean leanpkg leanchecker; 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 stdenv.lib; {
+    description = "Small tool to manage your installations of the Lean theorem prover";
+    homepage = "https://github.com/Kha/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..4d8e7b17b2bc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/eprover/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, which }:
+
+stdenv.mkDerivation rec {
+  name = "eprover-${version}";
+  version = "2.2";
+
+  src = fetchurl {
+    url = "https://wwwlehre.dhbw-stuttgart.de/~sschulz/WORK/E_DOWNLOAD/V_${version}/E.tgz";
+    sha256 = "08ihpwgkz0l7skr42iw8lm202kqr51i792bs61qsbnk9gsjlab1c";
+  };
+
+  buildInputs = [ which ];
+
+  preConfigure = ''
+    sed -e 's/ *CC *= *gcc$//' -i Makefile.vars
+  '';
+  configureFlags = [
+    "--exec-prefix=$(out)"
+    "--man-prefix=$(out)/share/man"
+  ];
+
+  meta = with stdenv.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/gappa/default.nix b/nixpkgs/pkgs/applications/science/logic/gappa/default.nix
new file mode 100644
index 000000000000..71114d2f9e12
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/gappa/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchurl, gmp, mpfr, boost }:
+
+stdenv.mkDerivation {
+  name = "gappa-1.2";
+
+  src = fetchurl {
+    url = https://gforge.inria.fr/frs/download.php/file/34787/gappa-1.2.0.tar.gz;
+    sha256 = "03hfzmaf5jm54sjpbks20q7qixpmagrfbnyyc276vgmiyslk4dkh";
+  };
+
+  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 stdenv.lib.licenses; [ cecill20 gpl2 ];
+    maintainers = with stdenv.lib.maintainers; [ vbgl ];
+    platforms = stdenv.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..bc8d372ce42c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/glucose/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, zlib }:
+stdenv.mkDerivation rec {
+  name = "glucose-${version}";
+  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/${name}/"
+    install -Dm0755 ../{LICEN?E,README*,Changelog*} "$out/share/doc/${name}/"
+  '';
+
+  meta = with stdenv.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..30af3216737c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/glucose/syrup.nix
@@ -0,0 +1,24 @@
+{ stdenv, zlib, glucose }:
+stdenv.mkDerivation rec {
+  name = "glucose-syrup-${version}";
+  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/${name}/"
+    install -Dm0755 ../{LICEN?E,README*,Changelog*} "$out/share/doc/${name}/"
+  '';
+
+  meta = with stdenv.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..d6a1eb6cbf71
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/hol/default.nix
@@ -0,0 +1,88 @@
+{stdenv, pkgs, fetchurl, graphviz, fontconfig, liberation_ttf,
+ experimentalKernel ? true}:
+
+let
+  pname = "hol4";
+  vnum = "10";
+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 = "0x2wxksr305h1lrbklf6p42lp09rbhb4rsh74g0l70sgapyiac9b";
+  };
+
+  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/mv\"" "\"mv\"" \
+      --replace "\"/bin/cp\"" "\"cp\""
+
+    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} -symlink
+
+    mkdir -p "$out/bin"
+    ln -st $out/bin  $out/src/${holsubdir}/bin/*
+    # ln -s $out/src/hol4.${version}/bin $out/bin
+  '';
+
+  meta = with stdenv.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;
+    maintainers = with maintainers; [ mudri ];
+    platforms = with platforms; linux;
+    broken = true;
+  };
+}
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..099e2102c517
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/hol_light/default.nix
@@ -0,0 +1,50 @@
+{ stdenv, runtimeShell, fetchFromGitHub, 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 {
+  name     = "hol_light-2018-09-30";
+
+  src = fetchFromGitHub {
+    owner  = "jrh13";
+    repo   = "hol-light";
+    rev    = "27e09dd27834de46e917057710e9d8ded51a4c9f";
+    sha256 = "1p0rm08wnc2lsrh3xzhlq3zdhzqcv1lbqnkwx3aybrqhbg1ixc1d";
+  };
+
+  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 stdenv.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 z77z 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..46b29e3dd271
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/iprover/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, ocaml, eprover, zlib }:
+
+stdenv.mkDerivation rec {
+  name = "iprover-${version}";
+  version = "2018_Jul_24_11h";
+
+  src = fetchurl {
+    url = "http://www.cs.man.ac.uk/~korovink/iprover/iprover_${version}.tar.gz";
+    sha256 = "1iqim11flzm56aaysasl5whajcv1gq31hkidaqfr8ww7kwl1h06p";
+  };
+
+  buildInputs = [ ocaml eprover zlib ];
+
+  preConfigure = ''patchShebangs .'';
+
+  installPhase = ''
+    mkdir -p "$out/bin"
+    cp iproveropt "$out/bin"
+
+    mkdir -p "$out/share/${name}"
+    cp *.p "$out/share/${name}"
+    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 stdenv.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..ffe508569553
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/isabelle/default.nix
@@ -0,0 +1,77 @@
+{ stdenv, fetchurl, perl, nettools, java, polyml, z3 }:
+# nettools needed for hostname
+
+let
+  dirname = "Isabelle2017";
+in
+
+stdenv.mkDerivation {
+  name = "isabelle-2017";
+  inherit dirname;
+
+  src = if stdenv.isDarwin
+    then fetchurl {
+      url = "http://isabelle.in.tum.de/website-${dirname}/dist/${dirname}.dmg";
+      sha256 = "1awgg39i72pivwfijdwffvil3glnpimjz2x04qbl5la2j6la48nb";
+    }
+    else fetchurl {
+      url = "https://isabelle.in.tum.de/website-${dirname}/dist/${dirname}_linux.tar.gz";
+      sha256 = "01v1zrajyfamjq5b8v18qr3ffivjckifsvvx2vs13di6wsnmm9gw";
+    };
+
+  buildInputs = [ perl polyml z3 ]
+             ++ stdenv.lib.optionals (!stdenv.isDarwin) [ nettools java ];
+
+  sourceRoot = dirname;
+
+  postPatch = ''
+    ENV=$(type -p env)
+    patchShebangs "."
+    substituteInPlace lib/Tools/env \
+      --replace /usr/bin/env $ENV
+    substituteInPlace lib/Tools/install \
+      --replace /usr/bin/env $ENV
+    sed -i 's|isabelle_java java|${java}/bin/java|g' lib/Tools/java
+    substituteInPlace etc/settings \
+      --subst-var-by ML_HOME "${polyml}/bin"
+    substituteInPlace contrib/jdk/etc/settings \
+      --replace ISABELLE_JDK_HOME= '#ISABELLE_JDK_HOME='
+    substituteInPlace contrib/polyml-*/etc/settings \
+      --replace '$POLYML_HOME/$ML_PLATFORM' ${polyml}/bin \
+      --replace '$POLYML_HOME/$PLATFORM/polyml' ${polyml}/bin/poly
+    substituteInPlace lib/scripts/run-polyml* lib/scripts/polyml-version \
+      --replace '$ML_HOME/poly' ${polyml}/bin/poly
+    substituteInPlace contrib/z3*/etc/settings \
+      --replace '$Z3_HOME/z3' '${z3}/bin/z3'
+
+    for comp in contrib/jdk contrib/polyml*; do
+      rm -rf $comp/x86*
+    done
+    '' + (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,eprover,nunchaku,SPASS}; do
+      patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f"
+    done
+    '');
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mv $TMP/$dirname $out
+    cd $out/$dirname
+    bin/isabelle install $out/bin
+  '';
+
+  meta = {
+    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 = http://isabelle.in.tum.de/;
+    license = "LGPL";
+    maintainers = [ stdenv.lib.maintainers.jwiegley ];
+    platforms = stdenv.lib.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..a95d1201cbd6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/jonprl/default.nix
@@ -0,0 +1,34 @@
+{ fetchgit, stdenv, smlnj, which }:
+
+stdenv.mkDerivation rec {
+  name    = "jonprl-${version}";
+  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 = stdenv.lib.licenses.mit;
+    maintainers = with stdenv.lib.maintainers; [ puffnfresh ];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
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..d7f047b84e0f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/lci/default.nix
@@ -0,0 +1,16 @@
+{stdenv, fetchurl, readline}: 
+stdenv.mkDerivation rec {
+  version = "0.6";
+  name = "lci-${version}";
+  src = fetchurl {
+    url = "mirror://sourceforge/lci/${name}.tar.gz";
+    sha256="204f1ca5e2f56247d71ab320246811c220ed511bf08c9cb7f305cf180a93948e";
+  };
+  buildInputs = [readline];
+  meta = {
+    description = ''Lambda calculus interpreter'';
+    maintainers = with stdenv.lib.maintainers; [raskin];
+    platforms = with stdenv.lib.platforms; linux;
+    license = stdenv.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..407244ef1830
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/lean/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub, cmake, gmp }:
+
+stdenv.mkDerivation rec {
+  name = "lean-${version}";
+  version = "3.4.2";
+
+  src = fetchFromGitHub {
+    owner  = "leanprover";
+    repo   = "lean";
+    rev    = "v${version}";
+    sha256 = "0zpnfg6kyg120rrdr336i1lymmzz4xgcqpn96iavhzhlaanmx55l";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ gmp ];
+  enableParallelBuilding = true;
+
+  preConfigure = ''
+    cd src
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Automatic and interactive theorem prover";
+    homepage    = https://leanprover.github.io/;
+    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..4e1415d3961d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/lean2/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, fetchFromGitHub, cmake, gmp, mpfr, python
+, gperftools, ninja, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "lean2-${version}";
+  version = "2017-07-22";
+
+  src = fetchFromGitHub {
+    owner  = "leanprover";
+    repo   = "lean2";
+    rev    = "34dbd6c3ae612186b8f0f80d12fbf5ae7a059ec9";
+    sha256 = "1xv3j487zhh1zf2b4v19xzw63s2sgjhg8d62a0kxxyknfmdf3khl";
+  };
+
+  buildInputs = [ gmp mpfr cmake python gperftools ninja makeWrapper ];
+  enableParallelBuilding = true;
+
+  preConfigure = ''
+    patchShebangs bin/leantags
+    cd src
+  '';
+
+  cmakeFlags = [ "-GNinja" ];
+
+  postInstall = ''
+    wrapProgram $out/bin/linja --prefix PATH : $out/bin:${ninja}/bin
+  '';
+
+  meta = with stdenv.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 ];
+  };
+}
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..be337a1c258e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/leo2/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchurl, makeWrapper, eprover, ocaml, perl, zlib }:
+
+stdenv.mkDerivation rec {
+  name = "leo2-${version}";
+  version = "1.6.2";
+
+  src = fetchurl {
+    url = "https://page.mi.fu-berlin.de/cbenzmueller/leo/leo2_v${version}.tgz";
+    sha256 = "1wjpmizb181iygnd18lx7p77fwaci2clgzs5ix5j51cc8f3pazmv";
+  };
+
+  buildInputs = [ makeWrapper eprover ocaml perl zlib ];
+
+  sourceRoot = "leo2/src";
+
+  preConfigure = "patchShebangs configure";
+
+  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 stdenv.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/leo2/default.upstream b/nixpkgs/pkgs/applications/science/logic/leo2/default.upstream
new file mode 100644
index 000000000000..52b8ed1cdaa2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/leo2/default.upstream
@@ -0,0 +1,6 @@
+url http://page.mi.fu-berlin.de/cbenzmueller/leo/download.html
+version_link '[.]tgz'
+version '.*_v([0-9.]+)[.][a-z0-9]+$' '\1'
+do_overwrite () {
+  do_overwrite_just_version
+}
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..dcea9c27acb4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/leo3/binary.nix
@@ -0,0 +1,29 @@
+{stdenv, fetchurl, openjdk, runtimeShell}:
+stdenv.mkDerivation rec {
+  pname = "leo3";
+  version = "1.2";
+
+  jar = fetchurl {
+    url = "https://github.com/leoprover/Leo-III/releases/download/v${version}/leo3.jar";
+    sha256 = "1lgwxbr1rnk72rnvc8raq5i1q71ckhn998pwd9xk6zf27wlzijk7";
+  };
+
+  phases=["installPhase" "fixupPhase"];
+
+  installPhase = ''
+    mkdir -p "$out"/{bin,lib/java/leo3}
+    cp "${jar}" "$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 = {
+    inherit version;
+    description = "An automated theorem prover for classical higher-order logic with choice";
+    license = stdenv.lib.licenses.bsd3;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.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..000587a22e67
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/lingeling/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, fetchFromGitHub
+, aiger
+}:
+
+stdenv.mkDerivation rec {
+  name = "lingeling-${version}";
+  # This is the version used in satcomp2018, which was
+  # relicensed, and also known as version 'bcj'
+  version = "pre1_03b4860d";
+
+  src = fetchFromGitHub {
+    owner  = "arminbiere";
+    repo   = "lingeling";
+    rev    = "03b4860d14016f42213ea271014f2f13d181f504";
+    sha256 = "1lw1yfy219p7rrk88sbq4zl24b70040zapbjdrpv5a6i0jsblksx";
+  };
+
+  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 stdenv.lib; {
+    description = "Fast SAT solver";
+    homepage    = http://fmv.jku.at/lingeling/;
+    license     = licenses.mit;
+    platforms   = platforms.linux;
+    maintainers = with maintainers; [ thoughtpolice ];
+  };
+}
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..db784237ea91
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/logisim/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchurl, jre, makeWrapper }:
+
+let version = "2.7.1"; in
+
+stdenv.mkDerivation {
+  name = "logisim-${version}";
+  
+  src = fetchurl {
+    url = "mirror://sourceforge/project/circuit/2.7.x/${version}/logisim-generic-${version}.jar";
+    sha256 = "1hkvc9zc7qmvjbl9579p84hw3n8wl3275246xlzj136i5b0phain";
+  };
+  
+  phases = [ "installPhase" ];
+
+  nativeBuildInputs = [makeWrapper];
+
+  installPhase = ''
+    mkdir -pv $out/bin
+    makeWrapper ${jre}/bin/java $out/bin/logisim --add-flags "-jar $src"
+  '';
+  
+  meta = {
+    homepage = http://ozark.hendrix.edu/~burch/logisim;
+    description = "Educational tool for designing and simulating digital logic circuits";
+    license = stdenv.lib.licenses.gpl2Plus;
+    platforms = stdenv.lib.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..c77e0327fb6b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/ltl2ba/default.nix
@@ -0,0 +1,31 @@
+{ fetchurl, stdenv }:
+
+stdenv.mkDerivation rec {
+  name = "ltl2ba-${version}";
+  version = "1.2";
+
+  src = fetchurl {
+    url    = "http://www.lsv.ens-cachan.fr/~gastin/ltl2ba/${name}.tar.gz";
+    sha256 = "0vzv5g7v87r41cvdafxi6yqnk7glzxrzgavy8213k59f6v11dzlx";
+  };
+
+  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     = stdenv.lib.licenses.gpl2Plus;
+    platforms   = stdenv.lib.platforms.darwin ++ stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.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..dc32e84279a8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/mcrl2/default.nix
@@ -0,0 +1,29 @@
+{stdenv, fetchurl, cmake, libGLU_combined, qt5, boost}:
+
+stdenv.mkDerivation rec {
+  version = "201707";
+  build_nr = "1";
+  name = "mcrl2-${version}";
+
+  src = fetchurl {
+    url = "https://www.mcrl2.org/download/release/mcrl2-${version}.${build_nr}.tar.gz";
+    sha256 = "1c8h94ja7271ph61zrcgnjgblxppld6v22f7f900prjgzbcfy14m";
+  };
+
+  buildInputs = [ cmake libGLU_combined qt5.qtbase boost ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.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/metis-prover/default.nix b/nixpkgs/pkgs/applications/science/logic/metis-prover/default.nix
new file mode 100644
index 000000000000..1601a74e1899
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/metis-prover/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchFromGitHub, perl, mlton }:
+
+stdenv.mkDerivation rec {
+  name = "metis-prover-${version}";
+  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 stdenv.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/clang.diff b/nixpkgs/pkgs/applications/science/logic/minisat/clang.diff
new file mode 100644
index 000000000000..5b5072c71f3f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/minisat/clang.diff
@@ -0,0 +1,45 @@
+diff -aur minisat/core/SolverTypes.h minisat.clang/core/SolverTypes.h
+--- minisat/core/SolverTypes.h	2010-07-10 18:07:36.000000000 +0200
++++ minisat.clang/core/SolverTypes.h	2016-05-13 12:14:50.759671959 +0200
+@@ -47,7 +47,7 @@
+     int     x;
+ 
+     // Use this as a constructor:
+-    friend Lit mkLit(Var var, bool sign = false);
++    //friend Lit mkLit(Var var, bool sign = false);
+ 
+     bool operator == (Lit p) const { return x == p.x; }
+     bool operator != (Lit p) const { return x != p.x; }
+@@ -55,7 +55,7 @@
+ };
+ 
+ 
+-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 -aur minisat/utils/Options.h minisat.clang/utils/Options.h
+--- minisat/utils/Options.h	2010-07-10 18:07:36.000000000 +0200
++++ minisat.clang/utils/Options.h	2016-05-13 12:14:50.759671959 +0200
+@@ -282,15 +282,15 @@
+         if (range.begin == INT64_MIN)
+             fprintf(stderr, "imin");
+         else
+-            fprintf(stderr, "%4"PRIi64, range.begin);
++            fprintf(stderr, "%4" PRIi64, range.begin);
+ 
+         fprintf(stderr, " .. ");
+         if (range.end == INT64_MAX)
+             fprintf(stderr, "imax");
+         else
+-            fprintf(stderr, "%4"PRIi64, range.end);
++            fprintf(stderr, "%4" PRIi64, range.end);
+ 
+-        fprintf(stderr, "] (default: %"PRIi64")\n", value);
++        fprintf(stderr, "] (default: %" PRIi64 ")\n", value);
+         if (verbose){
+             fprintf(stderr, "\n        %s\n", description);
+             fprintf(stderr, "\n");
+Only in minisat.clang/utils: Options.o
+Only in minisat.clang/utils: System.o
diff --git a/nixpkgs/pkgs/applications/science/logic/minisat/darwin.patch b/nixpkgs/pkgs/applications/science/logic/minisat/darwin.patch
new file mode 100644
index 000000000000..f2b618d6bb3a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/minisat/darwin.patch
@@ -0,0 +1,26 @@
+https://github.com/fasterthanlime/homebrew-mingw/blob/master/Library/Formula/minisat.rb
+
+diff --git a/utils/System.cc b/utils/System.cc
+index a7cf53f..feeaf3c 100644
+--- a/utils/System.cc
++++ b/utils/System.cc
+@@ -78,16 +78,17 @@ double Minisat::memUsed(void) {
+     struct rusage ru;
+     getrusage(RUSAGE_SELF, &ru);
+     return (double)ru.ru_maxrss / 1024; }
+-double MiniSat::memUsedPeak(void) { return memUsed(); }
++double Minisat::memUsedPeak(void) { return memUsed(); }
+ 
+ 
+ #elif defined(__APPLE__)
+ #include <malloc/malloc.h>
+ 
+-double Minisat::memUsed(void) {
++double Minisat::memUsed() {
+     malloc_statistics_t t;
+     malloc_zone_statistics(NULL, &t);
+     return (double)t.max_size_in_use / (1024*1024); }
++double Minisat::memUsedPeak() { return memUsed(); }
+ 
+ #else
+ double Minisat::memUsed() { 
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..4b2116680d50
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/minisat/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchurl, zlib }:
+
+stdenv.mkDerivation rec {
+  name = "minisat-${version}";
+  version = "2.2.0";
+
+  src = fetchurl {
+    url = "http://minisat.se/downloads/${name}.tar.gz";
+    sha256 = "023qdnsb6i18yrrawlhckm47q8x0sl7chpvvw3gssfyw3j2pv5cj";
+  };
+
+  patches =
+    [ ./darwin.patch ]
+    ++ stdenv.lib.optionals stdenv.cc.isClang [ ./clang.diff ];
+
+  buildInputs = [ zlib ];
+
+  preBuild = "cd simp";
+  makeFlags = [ "r" "MROOT=.." ];
+  installPhase = ''
+    mkdir -p $out/bin
+    cp minisat_release $out/bin/minisat
+  '';
+
+  meta = with stdenv.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/minisat/unstable.nix b/nixpkgs/pkgs/applications/science/logic/minisat/unstable.nix
new file mode 100644
index 000000000000..f1a42f8215e3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/minisat/unstable.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchFromGitHub, zlib, cmake }:
+
+stdenv.mkDerivation rec {
+  name = "minisat-unstable-2013-09-25";
+
+  src = fetchFromGitHub {
+    owner = "niklasso";
+    repo = "minisat";
+    rev = "37dc6c67e2af26379d88ce349eb9c4c6160e8543";
+    sha256 = "091hf3qkm197s5r7xcr3m07xsdwyz2rqk1hc9kj0hn13imz09irq";
+  };
+
+  buildInputs = [ zlib ];
+  nativeBuildInputs =  [ cmake ];
+
+  meta = with stdenv.lib; {
+    description = "Compact and readable SAT solver";
+    maintainers = with maintainers; [ mic92 ];
+    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..54bedc7c5e97
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/monosat/default.nix
@@ -0,0 +1,67 @@
+{ stdenv, 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 stdenv.lib;
+
+let
+  boolToCmake = x: if x then "ON" else "OFF";
+
+  rev    = "2deeadeff214e975c9f7508bc8a24fa05a1a0c32";
+  sha256 = "09yhym2lxmn3xbhw5fcxawnmvms5jd9fw9m7x2wzil7yvy4vwdjn";
+
+  pname   = "monosat";
+  version = substring 0 7 sha256;
+
+  src = fetchFromGitHub {
+    owner = "sambayless";
+    repo  = pname;
+    inherit rev sha256;
+  };
+
+  core = stdenv.mkDerivation rec {
+    name = "${pname}-${version}";
+    inherit src;
+    buildInputs = [ cmake zlib gmp jdk8 ];
+
+    cmakeFlags = [ "-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;
+    };
+  };
+
+  python = { buildPythonPackage, cython }: buildPythonPackage {
+    inherit pname version src;
+
+    # The top-level "source" is what fetchFromGitHub gives us. The rest is inside the repo
+    sourceRoot = "source/src/monosat/api/python/";
+
+    propagatedBuildInputs = [ core cython ];
+
+    # This tells setup.py to use cython
+    MONOSAT_CYTHON = true;
+
+    # The relative paths here don't make sense for our Nix build
+    # Also, let's use cython since it should produce faster bindings
+    # 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...
+    postPatch = ''
+
+      substituteInPlace setup.py \
+        --replace '../../../../libmonosat.dylib' '${core}/lib/libmonosat.dylib' \
+        --replace '../../../../libmonosat.so'  '${core}/lib/libmonosat.so'
+    '';
+  };
+in core
\ No newline at end of file
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..48546a86112b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/open-wbo/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchFromGitHub, zlib, gmp }:
+
+stdenv.mkDerivation rec {
+  name = "open-wbo-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 stdenv.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..f9f021b15f07
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/opensmt/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, automake, libtool, autoconf, intltool, perl
+, gmpxx, flex, bison
+}:
+
+stdenv.mkDerivation rec {
+  name = "opensmt-${version}";
+  version = "20101017";
+
+  src = fetchurl {
+    url = "http://opensmt.googlecode.com/files/opensmt_src_${version}.tgz";
+    sha256 = "0xrky7ixjaby5x026v7hn72xh7d401w9jhccxjn0khhn1x87p2w1";
+  };
+
+  buildInputs = [ automake libtool autoconf intltool perl gmpxx flex bison ];
+
+  meta = with stdenv.lib; {
+    description = "A satisfiability modulo theory (SMT) solver";
+    maintainers = [ maintainers.raskin ];
+    platforms = platforms.linux;
+    license = licenses.gpl3;
+    homepage = http://code.google.com/p/opensmt/;
+    broken = true;
+    downloadPage = "http://code.google.com/p/opensmt/downloads/list";
+  };
+}
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..d21487ef92fa
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/ott/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchFromGitHub, pkgconfig, ocaml }:
+
+stdenv.mkDerivation rec {
+  name = "ott-${version}";
+  version = "0.28";
+
+  src = fetchFromGitHub {
+    owner = "ott-lang";
+    repo = "ott";
+    rev = version;
+    sha256 = "0mzbrvqayqpns9zzg4m1scxx24dv9askhn51dawyb9pisvlyvai0";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ ocaml ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp src/ott.opt $out/bin
+    ln -s $out/bin/ott.opt $out/bin/ott
+
+    mkdir -p $out/share/emacs/site-lisp
+    cp emacs/ott-mode.el $out/share/emacs/site-lisp
+    '';
+
+  meta = {
+    description = "Ott: 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 = stdenv.lib.licenses.bsd3;
+    maintainers = with stdenv.lib.maintainers; [ jwiegley ];
+    platforms = stdenv.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..b19650eb8630
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/otter/default.nix
@@ -0,0 +1,53 @@
+{stdenv, fetchurl, tcsh, libXaw, libXt, libX11}:
+let
+  s = # Generated upstream information
+  rec {
+    version = "3.3f";
+    name = "otter";
+    url = "http://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 = stdenv.lib.licenses.publicDomain ;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.linux;
+    broken = true;
+  };
+}
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..638996e853b8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/picosat/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name    = "picosat-${version}";
+  version = "965";
+
+  src = fetchurl {
+    url = "http://fmv.jku.at/picosat/${name}.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 = stdenv.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     = stdenv.lib.licenses.mit;
+    platforms   = stdenv.lib.platforms.unix;
+    maintainers = with stdenv.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..2f765572f9ad
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/poly/default.nix
@@ -0,0 +1,25 @@
+{stdenv, fetchFromGitHub, gmp, cmake, python}:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "libpoly";
+  version = "0.1.7";
+
+  src = fetchFromGitHub {
+    owner = "SRI-CSL";
+    repo = "libpoly";
+    rev = "v${version}";
+    sha256 = "0i5ar4lhs88glk0rvkmag656ii434i6i1q5dspx6d0kyg78fii64";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  buildInputs = [ gmp python ];
+
+  meta = with stdenv.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/clingo.nix b/nixpkgs/pkgs/applications/science/logic/potassco/clingo.nix
new file mode 100644
index 000000000000..4abfdf9162c0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/potassco/clingo.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchzip, cmake }:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "clingo";
+  version = "5.3.0";
+
+  src = fetchzip {
+    url = "https://github.com/potassco/clingo/archive/v${version}.tar.gz";
+    sha256 = "01czx26p8gv81ahrh650x208hjhd8bx1kb688fmk1m4pw4yg5bfv";
+  };
+
+  buildInputs = [];
+  nativeBuildInputs = [cmake];
+
+  cmakeFlags = [ "-DCLINGO_BUILD_WITH_PYTHON=OFF" ];
+
+  meta = {
+    inherit version;
+    description = "ASP system to ground and solve logic programs";
+    license = stdenv.lib.licenses.mit;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.unix;
+    homepage = "https://potassco.org/";
+    downloadPage = "https://github.com/potassco/clingo/releases/";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/logic/potassco/clingo.upstream b/nixpkgs/pkgs/applications/science/logic/potassco/clingo.upstream
new file mode 100644
index 000000000000..062577d1451b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/potassco/clingo.upstream
@@ -0,0 +1,6 @@
+target clingo.nix
+attribute_name clingo
+url https://github.com/potassco/clingo/releases/
+ensure_choice
+version '.*/v([0-9.]+)[.]tar[.].*' '\1'
+minimize_overwrite
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..1f6620a2872d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/prooftree/default.nix
@@ -0,0 +1,43 @@
+{ stdenv, fetchurl, pkgconfig, ncurses, ocamlPackages }:
+
+stdenv.mkDerivation rec {
+  name = "prooftree-${version}";
+  version = "0.13";
+
+  src = fetchurl {
+    url = "https://askra.de/software/prooftree/releases/prooftree-${version}.tar.gz";
+    sha256 = "0z1z4wqbqwgppkh2bm89fgy07a0y2m6g4lvcyzs09sm1ysklk2dh";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ ncurses ] ++ (with ocamlPackages; [
+    ocaml findlib camlp5 lablgtk ]);
+
+  dontAddPrefix = true;
+  configureFlags = [ "--prefix" "$(out)" ];
+
+  meta = with stdenv.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..f96532b7038b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/prover9/default.nix
@@ -0,0 +1,45 @@
+{stdenv, fetchurl}:
+
+stdenv.mkDerivation {
+  name = "prover9-2009-11a";
+
+  src = fetchurl {
+    url = https://www.cs.unm.edu/~mccune/mace4/download/LADR-2009-11A.tar.gz;
+    sha256 = "1l2i3d3h5z7nnbzilb6z92r0rbx0kh6yaxn2c5qhn3000xcfsay3";
+  };
+
+  hardeningDisable = [ "format" ];
+
+  patchPhase = ''
+    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 = {
+    homepage = http://www.cs.unm.edu/~mccune/mace4/;
+    license = "GPL";
+    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 = stdenv.lib.platforms.linux;
+    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..c70ee610199f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/proverif/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchurl, ocamlPackages }:
+
+stdenv.mkDerivation rec {
+  name = "proverif-${version}";
+  version = "2.00";
+
+  src = fetchurl {
+    url    = "http://prosecco.gforge.inria.fr/personal/bblanche/proverif/proverif${version}.tar.gz";
+    sha256 = "0vjphj85ch9q39vc7sd6n4vxy5bplp017vlshk989yhfwb00r37y";
+  };
+
+  buildInputs = with ocamlPackages; [ ocaml findlib lablgtk ];
+
+  buildPhase = "./build";
+  installPhase = ''
+    mkdir -p $out/bin
+    cp ./proverif      $out/bin
+    cp ./proveriftotex $out/bin
+  '';
+
+  meta = {
+    description = "Cryptographic protocol verifier in the Dolev-Yao model";
+    homepage    = "http://prosecco.gforge.inria.fr/personal/bblanche/proverif/";
+    license     = stdenv.lib.licenses.gpl2;
+    platforms   = stdenv.lib.platforms.unix;
+    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
+  };
+}
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..9da2647d1138
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/redprl/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchgit, mlton }:
+stdenv.mkDerivation {
+  name = "redprl-2017-03-28";
+  src = fetchgit {
+    url = "https://github.com/RedPRL/sml-redprl.git";
+    rev = "bdf027de732e4a8d10f9f954389dfff0c822f18b";
+    sha256 = "0cihwnd78d3ksxp6mppifm7xpi3fsii5mixvicajy87ggw8z305c";
+    fetchSubmodules = true;
+  };
+  buildInputs = [ mlton ];
+  patchPhase = ''
+    patchShebangs ./script/
+  '';
+  buildPhase = ''
+    ./script/mlton.sh
+  '';
+  installPhase = ''
+    mkdir -p $out/bin
+    mv ./bin/redprl $out/bin
+  '';
+  meta = {
+    description = "A proof assistant for Nominal Computational Type Theory";
+    homepage = http://www.redprl.org/;
+    license = stdenv.lib.licenses.mit;
+    maintainers = [ stdenv.lib.maintainers.acowley ];
+    platforms = stdenv.lib.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..426f1928938c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/sad/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchurl, ghc, spass }:
+
+stdenv.mkDerivation {
+  name = "system-for-automated-deduction-2.3.25";
+  src = fetchurl {
+    url = "http://nevidal.org/download/sad-2.3-25.tar.gz";
+    sha256 = "10jd93xgarik7xwys5lq7fx4vqp7c0yg1gfin9cqfch1k1v8ap4b";
+  };
+  buildInputs = [ ghc spass ];
+  patches = [
+    ./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 = stdenv.lib.licenses.gpl3Plus;
+    maintainers = [ stdenv.lib.maintainers.schmitthenner ];
+    homepage = http://nevidal.org/sad.en.html;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
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 b/nixpkgs/pkgs/applications/science/logic/sad/patch
new file mode 100644
index 000000000000..a5b1d6177083
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/sad/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..b9dd90f601f5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/satallax/default.nix
@@ -0,0 +1,66 @@
+{stdenv, fetchurl, ocaml, zlib, which, eprover, makeWrapper, coq}:
+stdenv.mkDerivation rec {
+  name = "satallax-${version}";
+  version = "2.7";
+
+  buildInputs = [ocaml zlib which eprover makeWrapper coq];
+  src = fetchurl {
+    url = "https://www.ps.uni-saarland.de/~cebrown/satallax/downloads/${name}.tar.gz";
+    sha256 = "1kvxn8mc35igk4vigi5cp7w3wpxk2z3bgwllfm4n3h2jfs0vkpib";
+  };
+
+  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 : "${stdenv.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 = {
+    inherit version;
+    description = ''Automated theorem prover for higher-order logic'';
+    license = stdenv.lib.licenses.mit ;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.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;
+    updateWalker = true;
+  };
+}
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..32ebdad51d94
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/saw-tools/default.nix
@@ -0,0 +1,61 @@
+{ stdenv, fetchurl, gmp4, ncurses, zlib, clang_35 }:
+
+let
+  libPath = stdenv.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 rec {
+  name    = "saw-tools-${version}";
+  version = "0.1.1-20150731";
+
+  src = saw-bin;
+
+  installPhase = ''
+    mkdir -p $out/lib $out/share
+
+    mv bin $out/bin
+    mv doc $out/share
+
+    # Hack around lack of libtinfo in NixOS
+    ln -s ${ncurses.out}/lib/libncursesw.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_35}/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
+  '';
+
+  phases = "unpackPhase installPhase fixupPhase";
+
+  meta = {
+    description = "Tools for software verification and analysis";
+    homepage    = "https://saw.galois.com";
+    license     = stdenv.lib.licenses.unfreeRedistributable;
+    platforms   = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.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..2bb2b911d491
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/spass/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchurl, bison, flex }:
+
+let
+  baseVersion="3";
+  minorVersion="9";
+
+  extraTools = "FLOTTER prolog2dfg dfg2otter dfg2dimacs dfg2tptp"
+    + " dfg2ascii dfg2dfg tptp2dfg dimacs2dfg pgen rescmp";
+in
+
+stdenv.mkDerivation rec {
+  name = "spass-${version}";
+  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 stdenv.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..9e51849a93b9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/statverif/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, ocaml }:
+
+stdenv.mkDerivation rec {
+  name = "statverif-${version}";
+  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    = "http://markryan.eu/research/statverif/";
+    license     = stdenv.lib.licenses.gpl2;
+    platforms   = stdenv.lib.platforms.unix;
+    maintainers = [ stdenv.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..081dc788163b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/stp/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, cmake, boost, bison, flex, fetchFromGitHub, perl, python3, python3Packages, zlib, minisatUnstable, cryptominisat }:
+
+stdenv.mkDerivation rec {
+  version = "2.2.0";
+  name = "stp-${version}";
+
+  src = fetchFromGitHub {
+    owner = "stp";
+    repo = "stp";
+    rev    = "stp-${version}";
+    sha256 = "1jh23wjm62nnqfx447g2y53bbangq04hjrvqc35v9xxpcjgj3i49";
+  };
+
+  buildInputs = [ boost zlib minisatUnstable 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"
+    )
+  '';
+
+  # `make -f lib/Interface/CMakeFiles/cppinterface.dir/build.make lib/Interface/CMakeFiles/cppinterface.dir/cpp_interface.cpp.o`:
+  # include/stp/AST/UsefulDefs.h:41:29: fatal error: stp/AST/ASTKind.h: No such file or directory
+  enableParallelBuilding = false;
+
+  meta = with stdenv.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..2047bb3fc9f8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/symbiyosys/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchFromGitHub, yosys, python3 }:
+
+stdenv.mkDerivation rec {
+  name = "symbiyosys-${version}";
+  version = "2018.12.09";
+
+  src = fetchFromGitHub {
+    owner  = "yosyshq";
+    repo   = "symbiyosys";
+    rev    = "0772456a15b5a474c3c90a06b48e46a67d8a6614";
+    sha256 = "00p2l1g9z8nnmkc57l1cfn9ignjjmxwnyaxj2xjd1fim4kzd5475";
+  };
+
+  buildInputs = [ python3 yosys ];
+
+  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
+
+    # Fix up shebang and Yosys imports
+    patchShebangs $out/bin/sby
+    substituteInPlace $out/bin/sby \
+      --replace "##yosys-sys-path##" \
+                "sys.path += [p + \"/share/yosys/python3/\" for p in [\"$out\", \"${yosys}\"]]"
+  '';
+  meta = {
+    description = "Tooling for Yosys-based verification flows";
+    homepage    = https://symbiyosys.readthedocs.io/;
+    license     = stdenv.lib.licenses.mit;
+    maintainers = with stdenv.lib.maintainers; [ thoughtpolice ];
+    platforms   = stdenv.lib.platforms.unix;
+  };
+}
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..40378f8c04d5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/tamarin-prover/default.nix
@@ -0,0 +1,107 @@
+{ haskellPackages, mkDerivation, fetchFromGitHub, lib
+# the following are non-haskell dependencies
+, makeWrapper, which, maude, graphviz, ocaml
+}:
+
+let
+  version = "1.4.1";
+  src = fetchFromGitHub {
+    owner  = "tamarin-prover";
+    repo   = "tamarin-prover";
+    rev    = "d2e1c57311ce4ed0ef46d0372c4995b8fdc25323";
+    sha256 = "1bf2qvb646jg3qxd6jgp9ja3wlr888wchxi9mfr3kg7hfn63vxbq";
+  };
+
+  # 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; [
+      base base64-bytestring binary blaze-builder bytestring containers
+      deepseq dlist fclabels mtl pretty safe SHA syb time transformers
+    ];
+  });
+
+  tamarin-prover-term = mkDerivation (common "tamarin-prover-term" (src + "/lib/term") // {
+    postPatch = replaceSymlinks;
+    libraryHaskellDepends = (with haskellPackages; [
+      attoparsec base binary bytestring containers deepseq dlist HUnit
+      mtl process safe
+    ]) ++ [ 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 base binary bytestring containers deepseq dlist
+      fclabels mtl parallel parsec process safe text transformers uniplate
+    ]) ++ [ tamarin-prover-utils tamarin-prover-term ];
+  });
+
+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";
+
+  # Fix problem with MonadBaseControl not being found
+  patchPhase = ''
+    sed -ie 's,\(import *\)Control\.Monad$,&\
+    \1Control.Monad.Trans.Control,' src/Web/Handler.hs
+
+    sed -ie 's~\( *, \)mtl~&\
+    \1monad-control~' tamarin-prover.cabal
+
+    patch -p1 < ${./sapic-native.patch}
+  '';
+
+  postBuild = ''
+    cd plugins/sapic && make sapic && cd ../..
+  '';
+
+  # 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/{spthy,sapic}.vim
+    install etc/filetype.vim -D $out/share/vim-plugins/tamarin-prover/ftdetect/tamarin.vim
+    install -m0755 ./plugins/sapic/sapic $out/bin/sapic
+  '';
+
+  checkPhase = "./dist/build/tamarin-prover/tamarin-prover test";
+
+  executableSystemDepends = [ ocaml ];
+  executableHaskellDepends = (with haskellPackages; [
+    base binary binary-orphans blaze-builder blaze-html bytestring
+    cmdargs conduit containers monad-control deepseq directory fclabels file-embed
+    filepath gitrev http-types HUnit lifted-base mtl monad-unlift parsec process
+    resourcet safe shakespeare tamarin-prover-term
+    template-haskell text threads time wai warp yesod-core yesod-static
+  ]) ++ [ tamarin-prover-utils
+          tamarin-prover-term
+          tamarin-prover-theory
+        ];
+})
diff --git a/nixpkgs/pkgs/applications/science/logic/tamarin-prover/sapic-native.patch b/nixpkgs/pkgs/applications/science/logic/tamarin-prover/sapic-native.patch
new file mode 100644
index 000000000000..6ab7e4e7594f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/tamarin-prover/sapic-native.patch
@@ -0,0 +1,77 @@
+diff --git a/plugins/sapic/Makefile b/plugins/sapic/Makefile
+index 8f1b1866..678accbe 100644
+--- a/plugins/sapic/Makefile
++++ b/plugins/sapic/Makefile
+@@ -1,18 +1,18 @@
+ TARGET = sapic
+-OBJS= color.cmo exceptions.cmo btree.cmo position.cmo positionplusinit.cmo var.cmo term.cmo fact.cmo atomformulaaction.cmo action.cmo atom.cmo formula.cmo tamarin.cmo sapicterm.cmo sapicvar.cmo sapicaction.cmo lexer.cmo  sapic.cmo annotatedsapicaction.cmo annotatedsapictree.cmo progressfunction.cmo restrictions.cmo annotatedrule.cmo translationhelper.cmo basetranslation.cmo firsttranslation.cmo main.cmo 
++OBJS= color.cmx exceptions.cmx btree.cmx position.cmx positionplusinit.cmx var.cmx term.cmx fact.cmx atomformulaaction.cmx action.cmx atom.cmx formula.cmx tamarin.cmx sapicterm.cmx sapicvar.cmx sapicaction.cmx lexer.cmx  sapic.cmx annotatedsapicaction.cmx annotatedsapictree.cmx progressfunction.cmx restrictions.cmx annotatedrule.cmx translationhelper.cmx basetranslation.cmx firsttranslation.cmx main.cmx
+ FLAGS=-g
+ 
+-OCAMLC    := $(shell command -v ocamlc    2> /dev/null)
++OCAMLOPT  := $(shell command -v ocamlopt  2> /dev/null)
+ OCAMLLEX  := $(shell command -v ocamllex  2> /dev/null)
+ OCAMLYACC := $(shell command -v ocamlyacc 2> /dev/null)
+ OCAMLDEP  := $(shell command -v ocamldep  2> /dev/null)
+-OCAMLC_GTEQ_402 := $(shell expr `ocamlc -version | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/'` \>= 40200)
++OCAMLC_GTEQ_402 := $(shell expr `ocamlopt -version | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/'` \>= 40200)
+ 
+ default: sapic
+ 
+ sapic:
+-ifdef OCAMLC
+-	@echo "Found ocamlc."
++ifdef OCAMLOPT
++	@echo "Found ocamlopt."
+ ifdef OCAMLLEX
+ 	@echo "Found ocamllex."
+ ifdef OCAMLYACC
+@@ -22,9 +22,9 @@ ifdef OCAMLDEP
+ ifeq "$(OCAMLC_GTEQ_402)" "1"
+ 	@echo "Building SAPIC."
+ 	$(MAKE) $(OBJS)
+-	ocamlc $(FLAGS) -o $@ str.cma $(OBJS)
+-	@echo "Installing SAPIC into ~/.local/bin/"
+-	cp sapic ~/.local/bin
++	ocamlopt $(FLAGS) -o $@ str.cmxa $(OBJS)
++#	@echo "Installing SAPIC into ~/.local/bin/"
++#	cp sapic ~/.local/bin
+ else
+ 	@echo "Found OCAML version < 4.02. SAPIC will not be installed."
+ endif
+@@ -38,7 +38,7 @@ else
+ 	@echo "ocamllex not found. SAPIC will not be installed."
+ endif
+ else
+-	@echo "ocamlc not found. SAPIC will not be installed."
++	@echo "ocamlopt not found. SAPIC will not be installed."
+ endif
+ 
+ depend:
+@@ -48,20 +48,20 @@ lexer.ml: sapic.cmi
+ 
+ .PHONY: clean
+ clean:
+-	rm -rf *.cmi *.cmo $(TARGET)
++	rm -rf *.cmi **.cmx $(TARGET)
+ 	rm -rf sapic.ml sapic.mli lexer.ml lexer.mli
+ 
+-.SUFFIXES: .ml .mli .mll .mly .cmo .cmi
++.SUFFIXES: .ml .mli .mll .mly .cmx .cmi
+ 
+-.ml.cmo:
+-	ocamlc $(FLAGS) -c $<
++.ml.cmx:
++	ocamlopt $(FLAGS) -c $<
+ .mli.cmi:
+-	ocamlc $(FLAGS) -c $<
++	ocamlopt $(FLAGS) -c $<
+ .mll.ml:
+ 	ocamllex $<
+ .mly.ml:
+ 	ocamlyacc $<
+ .ml.mli:
+-	ocamlc -i $< > $@
++	ocamlopt -i $< > $@
+ 
+ -include .depend
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..b1eb171b20b1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/tlaplus/default.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchFromGitHub, makeWrapper
+, jdk, jre, ant
+}:
+
+stdenv.mkDerivation rec {
+  name = "tlaplus-${version}";
+  version = "1.5.6";
+
+  src = fetchFromGitHub {
+    owner  = "tlaplus";
+    repo   = "tlaplus";
+    rev    = "refs/tags/v${version}";
+    sha256 = "0966mvgxamknj4hsp980qbxwda886w1dv309kn7isxn0420lfv4f";
+  };
+
+  buildInputs = [ makeWrapper jdk ant ];
+
+  buildPhase = "ant -f tlatools/customBuild.xml compile dist";
+  installPhase = ''
+    mkdir -p $out/share/java $out/bin
+    cp tlatools/dist/*.jar $out/share/java
+
+    makeWrapper ${jre}/bin/java $out/bin/tlc2 \
+      --add-flags "-cp $out/share/java/tla2tools.jar tlc2.TLC"
+    makeWrapper ${jre}/bin/java $out/bin/tla2sany \
+      --add-flags "-cp $out/share/java/tla2tools.jar tla2sany.SANY"
+    makeWrapper ${jre}/bin/java $out/bin/pcal \
+      --add-flags "-cp $out/share/java/tla2tools.jar pcal.trans"
+    makeWrapper ${jre}/bin/java $out/bin/tla2tex \
+      --add-flags "-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     = stdenv.lib.licenses.mit;
+    platforms   = stdenv.lib.platforms.unix;
+    maintainers = [ stdenv.lib.maintainers.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..7d35f5f91df3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/tlaplus/tlaps.nix
@@ -0,0 +1,54 @@
+{ fetchurl
+, stdenv
+, ocaml, isabelle, cvc3, perl, wget, which
+}:
+
+stdenv.mkDerivation rec {
+  name = "tlaps-${version}";
+  version = "1.4.3";
+  src = fetchurl {
+    url = "https://tla.msr-inria.inria.fr/tlaps/dist/current/tlaps-${version}.tar.gz";
+    sha256 = "1w5z3ns5xxmhmp8r4x2kjmy3clqam935gmvx82imyxrr1bamx6gf";
+  };
+
+  buildInputs = [ ocaml isabelle cvc3 perl wget which ];
+
+  phases = [ "unpackPhase" "installPhase" ];
+
+  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     = stdenv.lib.licenses.bsd2;
+    platforms   = stdenv.lib.platforms.unix;
+    maintainers = [ stdenv.lib.maintainers.badi ];
+  };
+
+}
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..f1116a27c0be
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/tlaplus/toolbox.nix
@@ -0,0 +1,77 @@
+{ lib, fetchzip, makeWrapper, makeDesktopItem, stdenv
+, jre, swt, gtk, libXtst, glib
+}:
+
+let
+  version = "1.5.7";
+  arch = "x86_64";
+
+  desktopItem = makeDesktopItem rec {
+    name = "TLA+Toolbox";
+    exec = "tla-toolbox";
+    icon = "tla-toolbox";
+    comment = "IDE for TLA+";
+    desktopName = name;
+    genericName = comment;
+    categories = "Application;Development";
+    extraEntries = ''
+      StartupWMClass=TLA+ Toolbox
+    '';
+  };
+
+
+in stdenv.mkDerivation {
+  name = "tla-toolbox-${version}";
+  src = fetchzip {
+    url = "https://tla.msr-inria.inria.fr/tlatoolbox/products/TLAToolbox-${version}-linux.gtk.${arch}.zip";
+    sha256 = "0lg9sizpw5mkcnwwvmgqigkizjyz2lf1wrg48h7mg7wcv3macy4q";
+  };
+
+  buildInputs = [ makeWrapper  ];
+
+  phases = [ "installPhase" ];
+
+  installPhase = ''
+    mkdir -p "$out/bin"
+    cp -r "$src" "$out/toolbox"
+    chmod +w "$out/toolbox" "$out/toolbox/toolbox"
+
+    patchelf \
+      --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
+      "$out/toolbox/toolbox"
+
+    makeWrapper $out/toolbox/toolbox $out/bin/tla-toolbox \
+      --run "set -x; cd $out/toolbox" \
+      --add-flags "-data ~/.tla-toolbox" \
+      --prefix PATH : "${jre}/bin" \
+      --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ swt gtk libXtst glib ]}"
+
+    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"
+  '';
+
+  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 = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.badi ];
+  };
+}
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..24971b500d3f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/tptp/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, fetchurl, yap, tcsh, perl, patchelf }:
+
+stdenv.mkDerivation rec {
+  name = "TPTP-${version}";
+  version = "7.2.0";
+
+  src = fetchurl {
+    urls = [
+      "http://www.cs.miami.edu/~tptp/TPTP/Distribution/TPTP-v${version}.tgz"
+      "http://www.cs.miami.edu/~tptp/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 stdenv.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..74f8875fcebe
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/twelf/default.nix
@@ -0,0 +1,51 @@
+{ stdenv, fetchurl, pkgconfig, smlnj, rsync }:
+
+stdenv.mkDerivation rec {
+  name = "twelf-${version}";
+  version = "1.7.1";
+
+  src = fetchurl {
+    url = "http://twelf.plparty.org/releases/twelf-src-${version}.tar.gz";
+    sha256 = "0fi1kbs9hrdrm1x4k13angpjasxlyd1gc3ys8ah54i75qbcd9c4i";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  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 = stdenv.lib.licenses.mit;
+    maintainers = with stdenv.lib.maintainers; [ jwiegley ];
+    platforms = stdenv.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..8ad70531d543
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/vampire/default.nix
@@ -0,0 +1,59 @@
+{ stdenv, fetchFromGitHub, fetchpatch, z3, zlib, git }:
+
+stdenv.mkDerivation rec {
+  version = "4.2.2";
+  name = "vampire-${version}";
+
+  src = fetchFromGitHub {
+    owner = "vprover";
+    repo = "vampire";
+    rev = version;
+    sha256 = "0d1klprlgqrcn8r5ywgvsahr4qz96ayl67ry5jks946v0k94m1k1";
+    fetchSubmodules = true;
+    leaveDotGit = true;
+  };
+
+  nativeBuildInputs = [ git ];
+  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 stdenv.lib; {
+    homepage = "https://vprover.github.io/";
+    description = "The Vampire Theorem Prover";
+    platforms = platforms.unix;
+    license = licenses.unfree;
+    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..22eb5d07f1c1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/verifast/default.nix
@@ -0,0 +1,50 @@
+{ stdenv, fetchurl, gtk2, gdk_pixbuf, atk, pango, glib, cairo, freetype
+, fontconfig, libxml2, gnome2 }:
+
+let
+
+  libPath = stdenv.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 {
+  name    = "verifast-${version}";
+  version = "18.02";
+
+  src = fetchurl {
+    url    = "https://github.com/verifast/verifast/releases/download/${version}/${name}-linux.tar.gz";
+    sha256 = "19050be23b6d5e471690421fee59f84c58b29e38379fb86b8f3713a206a4423e";
+  };
+
+  dontStrip = true;
+  phases = "unpackPhase installPhase";
+  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    = "http://people.cs.kuleuven.be/~bart.jacobs/verifast/";
+    license     = stdenv.lib.licenses.msrla;
+    platforms   = [ "x86_64-linux" ];
+    maintainers = [ stdenv.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..ca3673d7bf97
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/verit/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchurl, autoreconfHook, gmp, flex, bison }:
+
+stdenv.mkDerivation rec {
+  name = "veriT-${version}";
+  version = "2016";
+
+  src = fetchurl {
+    url = "http://www.verit-solver.org/distrib/veriT-stable2016.tar.gz";
+    sha256 = "0gvp4diz0qjg0y5ry0p1z7dkdkxw8l7jb8cdhvcnhl06jx977v4b";
+  };
+
+  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 stdenv.lib; {
+    description = "An open, trustable and efficient SMT-solver";
+    homepage = http://www.verit-solver.org/;
+    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..a3b369ad54a3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/why3/default.nix
@@ -0,0 +1,27 @@
+{ fetchurl, stdenv, ocamlPackages, coq }:
+
+stdenv.mkDerivation rec {
+  name    = "why3-${version}";
+  version = "1.2.0";
+
+  src = fetchurl {
+    url = https://gforge.inria.fr/frs/download.php/file/37903/why3-1.2.0.tar.gz;
+    sha256 = "0xz001jhi71ja8vqrjz27v63bidrzj4qvg1yqarq6p4dmpxhk348";
+  };
+
+  buildInputs = (with ocamlPackages; [
+      ocaml findlib num lablgtk ocamlgraph zarith menhir ]) ++
+    stdenv.lib.optionals (ocamlPackages.ocaml == coq.ocamlPackages.ocaml ) [
+      coq ocamlPackages.camlp5
+    ];
+
+  installTargets = [ "install" "install-lib" ];
+
+  meta = with stdenv.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/workcraft/default.nix b/nixpkgs/pkgs/applications/science/logic/workcraft/default.nix
new file mode 100644
index 000000000000..313fe5a9f1dd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/workcraft/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, jre, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "workcraft-${version}";
+  version = "3.1.9";
+
+  src = fetchurl {
+    url = "https://github.com/workcraft/workcraft/releases/download/v${version}/workcraft-v${version}-linux.tar.gz";
+    sha256 = "0d1mi8jffwr7irp215j9rfpa3nmwxrx6mv13bh7vn0qf6i0aw0xi";
+  };
+
+  buildInputs = [ makeWrapper ];
+
+  phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
+
+  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 = stdenv.lib.platforms.linux;
+    license = stdenv.lib.licenses.mit;
+    maintainers = with stdenv.lib.maintainers; [ timor ];
+    inherit version;
+  };
+}
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..40a4c391e1d5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/yices/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchFromGitHub, gmp-static, gperf, autoreconfHook, libpoly }:
+
+stdenv.mkDerivation rec {
+  name    = "yices-${version}";
+  version = "2.6.1";
+
+  src = fetchFromGitHub {
+    owner  = "SRI-CSL";
+    repo   = "yices2";
+    rev    = "Yices-${version}";
+    sha256 = "04vf468spsh00jh7gj94cjnq8kjyfwy9l6r4z7l2pm0zgwkqgyhm";
+  };
+
+  nativeBuildInputs = [ autoreconfHook ];
+  buildInputs       = [ 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;
+
+  # Usual shenanigans
+  patchPhase = ''patchShebangs tests/regress/check.sh'';
+
+  # Includes a fix for the embedded soname being libyices.so.2.5, but
+  # only installing the libyices.so.2.5.x file.
+  installPhase = let
+    ver_XdotY = builtins.concatStringsSep "." (stdenv.lib.take 2 (stdenv.lib.splitString "." version));
+  in ''
+      make install LDCONFIG=true
+      ln -sfr $out/lib/libyices.so.{${version},${ver_XdotY}}
+  '';
+
+  meta = with stdenv.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/z3/0001-fix-2131.patch b/nixpkgs/pkgs/applications/science/logic/z3/0001-fix-2131.patch
new file mode 100644
index 000000000000..0b21b8fffd40
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/z3/0001-fix-2131.patch
@@ -0,0 +1,66 @@
+From c5df6ce96e068eceb77019e48634721c6a5bb607 Mon Sep 17 00:00:00 2001
+From: Nikolaj Bjorner <nbjorner@microsoft.com>
+Date: Sun, 10 Feb 2019 10:07:24 -0800
+Subject: [PATCH 1/1] fix #2131
+
+Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
+---
+ src/api/python/README.txt    | 10 +++-------
+ src/api/python/setup.py      |  2 +-
+ src/ast/recfun_decl_plugin.h |  2 +-
+ 3 files changed, 5 insertions(+), 9 deletions(-)
+
+diff --git a/src/api/python/README.txt b/src/api/python/README.txt
+index 9312b1119..561b8dedc 100644
+--- a/src/api/python/README.txt
++++ b/src/api/python/README.txt
+@@ -1,8 +1,4 @@
+-You can learn more about Z3Py at:
+-http://rise4fun.com/Z3Py/tutorial/guide
+-
+-On Windows, you must build Z3 before using Z3Py.
+-To build Z3, you should executed the following command
++On Windows, to build Z3, you should executed the following command
+ in the Z3 root directory at the Visual Studio Command Prompt
+ 
+        msbuild /p:configuration=external
+@@ -12,8 +8,8 @@ If you are using a 64-bit Python interpreter, you should use
+        msbuild /p:configuration=external /p:platform=x64
+ 
+ 
+-On Linux and macOS, you must install Z3Py, before trying example.py.
+-To install Z3Py on Linux and macOS, you should execute the following
++On Linux and macOS, you must install python bindings, before trying example.py.
++To install python on Linux and macOS, you should execute the following
+ command in the Z3 root directory
+ 
+         sudo make install-z3py
+diff --git a/src/api/python/setup.py b/src/api/python/setup.py
+index 2a750fee6..063680e2b 100644
+--- a/src/api/python/setup.py
++++ b/src/api/python/setup.py
+@@ -178,7 +178,7 @@ setup(
+     name='z3-solver',
+     version=_z3_version(),
+     description='an efficient SMT solver library',
+-    long_description='Z3 is a theorem prover from Microsoft Research with support for bitvectors, booleans, arrays, floating point numbers, strings, and other data types.\n\nFor documentation, please read http://z3prover.github.io/api/html/z3.html\n\nIn the event of technical difficulties related to configuration, compiliation, or installation, please submit issues to https://github.com/angr/angr-z3',
++    long_description='Z3 is a theorem prover from Microsoft Research with support for bitvectors, booleans, arrays, floating point numbers, strings, and other data types.\n\nFor documentation, please read http://z3prover.github.io/api/html/z3.html\n\nIn the event of technical difficulties related to configuration, compilation, or installation, please submit issues to https://github.com/angr/angr-z3',
+     author="The Z3 Theorem Prover Project",
+     maintainer="Audrey Dutcher",
+     maintainer_email="audrey@rhelmot.io",
+diff --git a/src/ast/recfun_decl_plugin.h b/src/ast/recfun_decl_plugin.h
+index 0247335e8..b294cdfce 100644
+--- a/src/ast/recfun_decl_plugin.h
++++ b/src/ast/recfun_decl_plugin.h
+@@ -56,7 +56,7 @@ namespace recfun {
+         friend class def;
+         func_decl_ref       m_pred; //<! predicate used for this case
+         expr_ref_vector     m_guards; //<! conjunction that is equivalent to this case
+-        expr_ref            m_rhs; //<! if guard is true, `f(t1…tn) = rhs` holds
++        expr_ref            m_rhs; //<! if guard is true, `f(t1...tn) = rhs` holds
+         def *               m_def; //<! definition this is a part of
+         bool                m_immediate; //<! does `rhs` contain no defined_fun/case_pred?
+ 
+-- 
+2.19.2
+
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..8c1c0ca23024
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/z3/default.nix
@@ -0,0 +1,46 @@
+{ stdenv, fetchFromGitHub, python, fixDarwinDylibNames }:
+
+stdenv.mkDerivation rec {
+  name = "z3-${version}";
+  version = "4.8.4";
+
+  src = fetchFromGitHub {
+    owner  = "Z3Prover";
+    repo   = "z3";
+    rev    = name;
+    sha256 = "014igqm5vwswz0yhz0cdxsj3a6dh7i79hvhgc3jmmmz3z0xm1gyn";
+  };
+
+  patches = [
+    ./0001-fix-2131.patch
+  ];
+
+  buildInputs = [ python fixDarwinDylibNames ];
+  propagatedBuildInputs = [ python.pkgs.setuptools ];
+  enableParallelBuilding = true;
+
+  configurePhase = ''
+    ${python.interpreter} scripts/mk_make.py --prefix=$out --python --pypkgdir=$out/${python.sitePackages}
+    cd build
+  '';
+
+  postInstall = ''
+    mkdir -p $dev $lib $python/lib
+
+    mv $out/lib/python*  $python/lib/
+    mv $out/lib          $lib/lib
+    mv $out/include      $dev/include
+
+    ln -sf $lib/lib/libz3${stdenv.hostPlatform.extensions.sharedLibrary} $python/${python.sitePackages}/z3/lib/libz3${stdenv.hostPlatform.extensions.sharedLibrary}
+  '';
+
+  outputs = [ "out" "lib" "dev" "python" ];
+
+  meta = {
+    description = "A high-performance theorem prover and SMT solver";
+    homepage    = "https://github.com/Z3Prover/z3";
+    license     = stdenv.lib.licenses.mit;
+    platforms   = stdenv.lib.platforms.x86_64;
+    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
+  };
+}
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..34449542abb2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/logic/z3/tptp.nix
@@ -0,0 +1,31 @@
+{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 version;
+    inherit (z3.meta) license homepage platforms;
+    description = ''TPTP wrapper for Z3 prover'';
+    maintainers = [stdenv.lib.maintainers.raskin];
+  };
+}
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..802a03bd4c7a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/labelimg/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, python2Packages, fetchurl }:
+  python2Packages.buildPythonApplication rec {
+    name = "labelImg-${version}";
+    version = "1.6.0";
+    src = fetchurl {
+      url = "https://github.com/tzutalin/labelImg/archive/v${version}.tar.gz";
+      sha256 = "126kc4r7xm9170kh7snqsfkkc868m5bcnswrv7b4cq9ivlrdwbm4";
+    };
+    propagatedBuildInputs = with python2Packages; [
+      pyqt4
+      lxml
+    ];
+    preBuild = ''
+      make qt4py2
+    '';
+    meta = with stdenv.lib; {
+      description = "LabelImg is 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/sc2-headless/default.nix b/nixpkgs/pkgs/applications/science/machine-learning/sc2-headless/default.nix
new file mode 100644
index 000000000000..c0536b36cfe3
--- /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";
+  name = "sc2-headless-${version}";
+
+  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 = stdenv.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..b4ff9fc18218
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/sc2-headless/maps.nix
@@ -0,0 +1,63 @@
+{ fetchzip, unzip
+}:
+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..8de78092bd84
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/shogun/default.nix
@@ -0,0 +1,65 @@
+{ stdenv, lib, fetchFromGitHub, fetchpatch, ccache, cmake, ctags, swig
+# data, compression
+, bzip2, curl, hdf5, json_c, lzma, lzo, protobuf, snappy
+# maths
+, openblasCompat, eigen, nlopt, lp_solve, colpack
+# libraries
+, libarchive, libxml2
+# extra support
+, pythonSupport ? true, pythonPackages ? null
+, opencvSupport ? false, opencv ? null
+}:
+
+assert pythonSupport -> pythonPackages != null;
+assert opencvSupport -> opencv != null;
+
+stdenv.mkDerivation rec {
+  pname = "shogun";
+  version = "6.0.0";
+  name = pname + "-" + version;
+
+  src = fetchFromGitHub {
+    owner = pname + "-toolbox";
+    repo = pname;
+    rev = pname + "_" + version;
+    sha256 = "0f2zwzvn5apvwypkfkq371xp7c5bdb4g1fwqfh8c2d57ysjxhmgf";
+    fetchSubmodules = true;
+  };
+
+  patches = [
+    (fetchpatch {
+      name = "Fix-meta-example-parser-bug-in-parallel-builds.patch";
+      url = "https://github.com/shogun-toolbox/shogun/commit/ecd6a8f11ac52748e89d27c7fab7f43c1de39f05.patch";
+      sha256 = "1hrwwrj78sxhwcvgaz7n4kvh5y9snfcc4jf5xpgji5hjymnl311n";
+    })
+    (fetchpatch {
+      url = "https://github.com/awild82/shogun/commit/365ce4c4c700736d2eec8ba6c975327a5ac2cd9b.patch";
+      sha256 = "158hqv4xzw648pmjbwrhxjp7qcppqa7kvriif87gn3zdn711c49s";
+    })
+  ];
+
+  CCACHE_DIR=".ccache";
+
+  buildInputs = with lib; [
+      openblasCompat bzip2 ccache cmake colpack curl ctags eigen hdf5 json_c lp_solve lzma lzo
+      protobuf nlopt snappy swig (libarchive.dev) libxml2
+    ]
+    ++ optionals (pythonSupport) (with pythonPackages; [ python ply numpy ])
+    ++ optional  (opencvSupport) opencv;
+
+  cmakeFlags = with lib; []
+    ++ (optional (pythonSupport) "-DPythonModular=ON")
+    ++ (optional (opencvSupport) "-DOpenCV=ON")
+    ;
+
+  # Previous attempts to fix parallel builds (see patch above) were not entirely successful.
+  # Sporadic build failures still exist. Dislable parallel builds for now.
+  enableParallelBuilding = false;
+
+  meta = with stdenv.lib; {
+    description = "A toolbox which offers a wide range of efficient and unified machine learning methods";
+    homepage = "http://shogun-toolbox.org/";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ edwtjo ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/machine-learning/torch/default.nix b/nixpkgs/pkgs/applications/science/machine-learning/torch/default.nix
new file mode 100644
index 000000000000..bdeeaad189a7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/torch/default.nix
@@ -0,0 +1,10 @@
+{ callPackage, fetchgit, lua } :
+let
+  src = fetchgit {
+    url = "https://github.com/grwlf/torch-distro";
+    rev = "f972c4253b14b95b53aefe7b24efa496223e73f2";
+    sha256 = "1lhjhivhyypaic33vj1nsghshsajf7vi6gwsclaf3nqdl27d1h1s";
+  };
+
+in
+  callPackage (import ./torch-distro.nix) { inherit lua src; }
diff --git a/nixpkgs/pkgs/applications/science/machine-learning/torch/torch-distro.nix b/nixpkgs/pkgs/applications/science/machine-learning/torch/torch-distro.nix
new file mode 100644
index 000000000000..9c4f24021430
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/machine-learning/torch/torch-distro.nix
@@ -0,0 +1,336 @@
+{ luarocks, lib , stdenv,  readline,  makeWrapper,
+  less, ncurses, cmake, coreutils, fetchgit, libuuid, czmq, openssl,
+  gnuplot, lua, src, libjpeg, libpng
+} :
+
+let
+
+  common_meta = {
+    homepage = http://torch.ch;
+    license = stdenv.lib.licenses.bsd3;
+    maintainers = with stdenv.lib.maintainers; [ smironov ];
+    platforms = stdenv.lib.platforms.gnu ++ stdenv.lib.platforms.linux;
+  };
+
+  distro_src = src;
+
+  default_luarocks = luarocks;
+
+  pkgs_gnuplot = gnuplot;
+
+  luapkgs = rec {
+
+    luarocks = default_luarocks.override {
+      inherit lua;
+    };
+
+    buildLuaRocks = { rockspec ? "", luadeps ? [] , buildInputs ? []
+                    , preBuild ? "" , postInstall ? ""
+                    , runtimeDeps ? [] ,  ... }@args :
+      let
+
+        luadeps_ =
+          luadeps ++
+          (lib.concatMap (d : if d ? luadeps then d.luadeps else []) luadeps);
+
+        runtimeDeps_ =
+          runtimeDeps ++
+          (lib.concatMap (d : if d ? runtimeDeps then d.runtimeDeps else []) luadeps) ++
+          [ lua coreutils ];
+
+        mkcfg = ''
+          export LUAROCKS_CONFIG=config.lua
+          cat >config.lua <<EOF
+            rocks_trees = {
+                 { name = [[system]], root = [[${luarocks}]] }
+               ${lib.concatImapStrings (i : dep :  ", { name = [[dep${toString i}]], root = [[${dep}]] }") luadeps_}
+            };
+
+            variables = {
+              LUA_BINDIR = "$out/bin";
+              LUA_INCDIR = "$out/include";
+              LUA_LIBDIR = "$out/lib/lua/${lua.luaversion}";
+            };
+          EOF
+        '';
+
+      in
+      stdenv.mkDerivation (args // {
+
+        name = "${args.name}-${lua.luaversion}";
+
+        inherit preBuild postInstall;
+
+        inherit luadeps runtimeDeps;
+
+        phases = [ "unpackPhase" "patchPhase" "buildPhase"];
+
+        buildInputs = runtimeDeps ++ buildInputs ++ [ makeWrapper lua ];
+
+        buildPhase = ''
+          eval "$preBuild"
+          ${mkcfg}
+          eval "`${luarocks}/bin/luarocks --deps-mode=all --tree=$out path`"
+          ${luarocks}/bin/luarocks make --deps-mode=all --tree=$out ${rockspec}
+
+          for p in $out/bin/*; do
+            wrapProgram $p \
+              --suffix LD_LIBRARY_PATH ';' "${lib.makeLibraryPath runtimeDeps_}" \
+              --suffix PATH ';' "${lib.makeBinPath runtimeDeps_}" \
+              --suffix LUA_PATH ';' "\"$LUA_PATH\"" \
+              --suffix LUA_PATH ';' "\"$out/share/lua/${lua.luaversion}/?.lua;$out/share/lua/${lua.luaversion}/?/init.lua\"" \
+              --suffix LUA_CPATH ';' "\"$LUA_CPATH\"" \
+              --suffix LUA_CPATH ';' "\"$out/lib/lua/${lua.luaversion}/?.so;$out/lib/lua/${lua.luaversion}/?/init.so\""
+          done
+
+          eval "$postInstall"
+        '';
+      });
+
+    # FIXME: doesn't installs lua-files for some reason
+    # lua-cjson = buildLuaPackage {
+    #   name = "lua-cjson";
+    #   src = ./extra/lua-cjson;
+    #   rockspec = "lua-cjson-2.1devel-1.rockspec";
+    # };
+
+    lua-cjson = stdenv.mkDerivation rec {
+      name = "lua-cjson";
+      src = "${distro_src}/extra/lua-cjson";
+
+      preConfigure = ''
+        makeFlags="PREFIX=$out LUA_LIBRARY=$out/lib/lua"
+      '';
+
+      buildInputs = [lua];
+
+      installPhase = ''
+        make install-extra $makeFlags
+      '';
+      meta.broken = true;
+    };
+
+    luafilesystem = buildLuaRocks {
+      name = "filesystem";
+      src = "${distro_src}/extra/luafilesystem";
+      luadeps = [lua-cjson];
+      rockspec = "rockspecs/luafilesystem-1.6.3-1.rockspec";
+    };
+
+    penlight = buildLuaRocks {
+      name = "penlight";
+      src = "${distro_src}/extra/penlight";
+      luadeps = [luafilesystem];
+    };
+
+    luaffifb = buildLuaRocks {
+      name = "luaffifb";
+      src = "${distro_src}/extra/luaffifb";
+      meta.broken = true;
+    };
+
+    sundown = buildLuaRocks rec {
+      name = "sundown";
+      src = "${distro_src}/pkg/sundown";
+      rockspec = "rocks/${name}-scm-1.rockspec";
+      meta.broken = true; # 2018-04-11
+    };
+
+    cwrap = buildLuaRocks rec {
+      name = "cwrap";
+      src = "${distro_src}/pkg/cwrap";
+      rockspec = "rocks/${name}-scm-1.rockspec";
+    };
+
+    paths = buildLuaRocks rec {
+      name = "paths";
+      src = "${distro_src}/pkg/paths";
+      buildInputs = [cmake];
+      rockspec = "rocks/${name}-scm-1.rockspec";
+    };
+
+    torch = buildLuaRocks rec {
+      name = "torch";
+      src = "${distro_src}/pkg/torch";
+      luadeps = [ paths cwrap ];
+      buildInputs = [ cmake ];
+      rockspec = "rocks/torch-scm-1.rockspec";
+      preBuild = ''
+        substituteInPlace ${rockspec} \
+          --replace '"sys >= 1.0"' ' '
+        export LUA_PATH="$src/?.lua;$LUA_PATH"
+      '';
+      meta = common_meta // {
+        description = "Torch is a machine-learning library";
+        longDescription = ''
+          Torch is the main package in [Torch7](http://torch.ch) where data
+          structures for multi-dimensional tensors and mathematical operations
+          over these are defined. Additionally, it provides many utilities for
+          accessing files, serializing objects of arbitrary types and other
+          useful utilities.
+        '';
+      };
+    };
+
+    dok = buildLuaRocks rec {
+      name = "dok";
+      src = "${distro_src}/pkg/dok";
+      luadeps = [sundown];
+      rockspec = "rocks/${name}-scm-1.rockspec";
+    };
+
+    sys = buildLuaRocks rec {
+      name = "sys";
+      luadeps = [torch];
+      buildInputs = [readline cmake];
+      src = "${distro_src}/pkg/sys";
+      rockspec = "sys-1.1-0.rockspec";
+      preBuild = ''
+        export Torch_DIR=${torch}/share/cmake/torch
+      '';
+    };
+
+    xlua = buildLuaRocks rec {
+      name = "xlua";
+      luadeps = [torch sys];
+      src = "${distro_src}/pkg/xlua";
+      rockspec = "xlua-1.0-0.rockspec";
+    };
+
+    nn = buildLuaRocks rec {
+      name = "nn";
+      luadeps = [torch luaffifb];
+      buildInputs = [cmake];
+      src = "${distro_src}/extra/nn";
+      rockspec = "rocks/nn-scm-1.rockspec";
+      preBuild = ''
+        export Torch_DIR=${torch}/share/cmake/torch
+      '';
+    };
+
+    graph = buildLuaRocks rec {
+      name = "graph";
+      luadeps = [ torch ];
+      buildInputs = [cmake];
+      src = "${distro_src}/extra/graph";
+      rockspec = "rocks/graph-scm-1.rockspec";
+      preBuild = ''
+        export Torch_DIR=${torch}/share/cmake/torch
+      '';
+    };
+
+    nngraph = buildLuaRocks rec {
+      name = "nngraph";
+      luadeps = [ torch nn graph ];
+      buildInputs = [cmake];
+      src = "${distro_src}/extra/nngraph";
+      preBuild = ''
+        export Torch_DIR=${torch}/share/cmake/torch
+      '';
+    };
+
+    image = buildLuaRocks rec {
+      name = "image";
+      luadeps = [ torch dok sys xlua ];
+      buildInputs = [cmake libjpeg libpng];
+      src = "${distro_src}/pkg/image";
+      rockspec = "image-1.1.alpha-0.rockspec";
+      preBuild = ''
+        export Torch_DIR=${torch}/share/cmake/torch
+      '';
+    };
+
+    optim = buildLuaRocks rec {
+      name = "optim";
+      luadeps = [ torch ];
+      buildInputs = [cmake];
+      src = "${distro_src}/pkg/optim";
+      rockspec = "optim-1.0.5-0.rockspec";
+      preBuild = ''
+        export Torch_DIR=${torch}/share/cmake/torch
+      '';
+    };
+
+    gnuplot = buildLuaRocks rec {
+      name = "gnuplot";
+      luadeps = [ torch paths ];
+      runtimeDeps = [ pkgs_gnuplot less ];
+      src = "${distro_src}/pkg/gnuplot";
+      rockspec = "rocks/gnuplot-scm-1.rockspec";
+    };
+
+    unsup = buildLuaRocks rec {
+      name = "unsup";
+      luadeps = [ torch xlua optim ];
+      buildInputs = [ cmake ];
+      src = fetchgit {
+        url = "https://github.com/koraykv/unsup";
+        rev = "1d4632e716dc3c82feecc7dd4b22549df442859f";
+        sha256 = "0npjq3y1cfmk026sdijcw3f766innrmb3qggnxsz62grczhfvgls";
+      };
+      rockspec = "unsup-0.1-0.rockspec";
+      preBuild = ''
+        export Torch_DIR=${torch}/share/cmake/torch
+      '';
+      meta.broken = true;
+    };
+
+    trepl = buildLuaRocks rec {
+      name = "trepl";
+      luadeps = [torch gnuplot paths penlight graph nn nngraph image gnuplot optim sys dok unsup];
+      runtimeDeps = [ ncurses readline ];
+      src = "${distro_src}/exe/trepl";
+      meta = common_meta // {
+        description = "A pure Lua REPL for Lua(JIT), with heavy support for Torch types.";
+      };
+    };
+
+    lbase64 = buildLuaRocks rec {
+      name = "lbase64";
+      src = fetchgit {
+        url = "https://github.com/LuaDist2/lbase64";
+        rev = "1e9e4f1e0bf589a0ed39f58acc185ec5e213d207";
+        sha256 = "1i1fpy9v6r4w3lrmz7bmf5ppq65925rv90gx39b3pykfmn0hcb9c";
+      };
+      meta.broken = true; # 2018-04-11
+    };
+
+    luuid = stdenv.mkDerivation rec {
+      name = "luuid";
+      src = fetchgit {
+        url = "https://github.com/LuaDist/luuid";
+        sha256 = "062gdf1rild11jg46vry93hcbb36b4527pf1dy7q9fv89f7m2nav";
+      };
+
+      preConfigure = ''
+        cmakeFlags="-DLUA_LIBRARY=${lua}/lib/lua/${lua.luaversion} -DINSTALL_CMOD=$out/lib/lua/${lua.luaversion} -DINSTALL_MOD=$out/lib/lua/${lua.luaversion}"
+      '';
+
+      buildInputs = [cmake libuuid lua];
+      meta = {
+        # FIXME: set the exact revision for src
+        broken = true;
+      };
+    };
+
+    # Doesn't work due to missing deps (according to luarocs).
+    itorch = buildLuaRocks rec {
+      name = "itorch";
+      luadeps = [torch gnuplot paths penlight graph nn nngraph image gnuplot
+                  optim sys dok lbase64 lua-cjson luuid];
+      buildInputs = [czmq openssl];
+      src = "${distro_src}/extra/iTorch";
+      meta = {
+        # FIXME: figure out whats wrong with deps
+        broken = true;
+      };
+    };
+
+
+  };
+
+in
+
+luapkgs
+
+
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..e0b0bc11f05f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/LiE/default.nix
@@ -0,0 +1,47 @@
+{ stdenv, fetchurl
+, bison, readline }:
+
+stdenv.mkDerivation rec {
+  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.
+  name = "lie-${version}";
+
+  meta = {
+    description = "A Computer algebra package for Lie group computations";
+    homepage = http://wwwmathlabo.univ-poitiers.fr/~maavl/LiE/;
+    license = stdenv.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 = stdenv.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..4283ebd931a4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/R/default.nix
@@ -0,0 +1,108 @@
+{ stdenv, fetchurl, bzip2, gfortran, libX11, libXmu, libXt, libjpeg, libpng
+, libtiff, ncurses, pango, pcre, perl, readline, tcl, texLive, tk, xz, zlib
+, less, texinfo, graphviz, icu, pkgconfig, bison, imake, which, jdk, openblas
+, curl, Cocoa, Foundation, libobjc, libcxx, tzdata
+, withRecommendedPackages ? true
+, enableStrictBarrier ? false
+, javaSupport ? (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64)
+}:
+
+stdenv.mkDerivation rec {
+  name = "R-3.5.2";
+
+  src = fetchurl {
+    url = "https://cran.r-project.org/src/base/R-3/${name}.tar.gz";
+    sha256 = "0qjvdic1qd5vndc4f0wjndpm0x18lbvbcc8nkix8saqgy8y8qgg5";
+  };
+
+  dontUseImakeConfigure = true;
+
+  buildInputs = [
+    bzip2 gfortran libX11 libXmu libXt libXt libjpeg libpng libtiff ncurses
+    pango pcre perl readline texLive xz zlib less texinfo graphviz icu
+    pkgconfig bison imake which openblas curl
+  ] ++ stdenv.lib.optionals (!stdenv.isDarwin) [ tcl tk ]
+    ++ stdenv.lib.optionals stdenv.isDarwin [ Cocoa Foundation libobjc libcxx ]
+    ++ stdenv.lib.optional javaSupport jdk;
+
+  patches = [ ./no-usr-local-search-paths.patch ];
+
+  prePatch = stdenv.lib.optionalString stdenv.isDarwin ''
+    substituteInPlace configure --replace "-install_name libR.dylib" "-install_name $out/lib/R/lib/libR.dylib"
+  '';
+
+  preConfigure = ''
+    configureFlagsArray=(
+      --disable-lto
+      --with${stdenv.lib.optionalString (!withRecommendedPackages) "out"}-recommended-packages
+      --with-blas="-L${openblas}/lib -lopenblas"
+      --with-lapack="-L${openblas}/lib -lopenblas"
+      --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
+      ${stdenv.lib.optionalString enableStrictBarrier "--enable-strict-barrier"}
+      --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"
+      ${stdenv.lib.optionalString javaSupport "JAVA_HOME=\"${jdk}\""}
+      RANLIB=$(type -p ranlib)
+      R_SHELL="${stdenv.shell}"
+  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+      --without-tcltk
+      --without-aqua
+      --disable-R-framework
+      OBJC="clang"
+      CPPFLAGS="-isystem ${libcxx}/include/c++/v1"
+      LDFLAGS="-L${libcxx}/lib"
+  '' + ''
+    )
+    echo >>etc/Renviron.in "TCLLIBPATH=${tk}/lib"
+    echo >>etc/Renviron.in "TZDIR=${tzdata}/share/zoneinfo"
+  '';
+
+  installTargets = [ "install" "install-info" "install-pdf" ];
+
+  doCheck = true;
+  preCheck = "export TZ=CET; bin/Rscript -e 'sessionInfo()'";
+
+  enableParallelBuilding = true;
+
+  setupHook = ./setup-hook.sh;
+
+  meta = with stdenv.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;
+    hydraPlatforms = platforms.linux;
+
+    maintainers = [ maintainers.peti ];
+  };
+}
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..b5d9632c551d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/almonds/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, 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 stdenv.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..61eb1fd3ce4e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/bcal/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchFromGitHub, python3Packages, readline }:
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  name = "bcal-${version}";
+  version = "1.9";
+
+  src = fetchFromGitHub {
+    owner = "jarun";
+    repo = "bcal";
+    rev = "v${version}";
+    sha256 = "0h6qi5rvzl6c6fsfdpdb3l4jcgip03l18i0b1x08z1y89i56y8mm";
+  };
+
+  nativeBuildInputs = [ python3Packages.pytest ];
+
+  buildInputs = [ readline ];
+
+  doCheck = true;
+  checkPhase = ''
+    python3 -m pytest test.py
+  '';
+
+  installFlags = [ "DESTDIR=$(out)" "PREFIX=" ];
+
+  meta = {
+    description = "Storage conversion and expression calculator";
+    homepage = https://github.com/jarun/bcal;
+    license = licenses.gpl3;
+    platforms = [ "aarch64-linux" "x86_64-darwin" "x86_64-linux" ];
+    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..1b7a97360079
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/bliss/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchurl, unzip, doxygen }:
+
+stdenv.mkDerivation rec {
+  name = "bliss-${version}";
+  version = "0.73";
+
+  src = fetchurl {
+    url = "http://www.tcs.hut.fi/Software/bliss/${name}.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 stdenv.lib; {
+    description = "bliss is 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..9ee56041ed38
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/caffe/default.nix
@@ -0,0 +1,134 @@
+{ config, stdenv, lib, runCommand
+, fetchFromGitHub
+, fetchurl
+, cmake
+, boost
+, google-gflags
+, glog
+, hdf5-cpp
+, opencv3
+, protobuf
+, doxygen
+, openblas
+, 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 {
+  name = "caffe-${version}";
+  version = "1.0";
+
+  src = fetchFromGitHub {
+    owner = "BVLC";
+    repo = "caffe";
+    rev = version;
+    sha256 = "104jp3cm823i3cdph7hgsnj6l77ygbwsy35mdmzhmsi4jxprd9j3";
+  };
+
+  enableParallelBuilding = true;
+
+  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=3${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 google-gflags glog protobuf hdf5-cpp opencv3 openblas ]
+                ++ 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.optional pythonSupport python.pkgs.protobuf;
+
+  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 = 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 stdenv.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..b1bed6c174b8
--- /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..24cddfb9a1c2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/calc/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, lib, fetchurl, utillinux, makeWrapper
+, enableReadline ? true, readline, ncurses }:
+
+stdenv.mkDerivation rec {
+  name = "calc-${version}";
+  version = "2.12.7.2";
+
+  src = fetchurl {
+    urls = [
+      "https://github.com/lcn2/calc/releases/download/${version}/${name}.tar.bz2"
+      "http://www.isthe.com/chongo/src/calc/${name}.tar.bz2"
+    ];
+    sha256 = "147wmbajcxv6wp92j6pizq4plrr1sb7jirifr1477bx33hc49bsp";
+  };
+
+  patchPhase = ''
+    substituteInPlace Makefile \
+      --replace 'all: check_include' 'all:' \
+      --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}'
+  '';
+
+  buildInputs = [ utillinux makeWrapper ]
+             ++ lib.optionals enableReadline [ readline ncurses ];
+
+  makeFlags = [
+    "T=$(out)"
+    "INCDIR=${lib.getDev stdenv.cc.libc}/include"
+    "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/;
+    license = licenses.lgpl21;
+    maintainers = with maintainers; [ matthewbauer ];
+    platforms = platforms.all;
+  };
+}
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..93aefbca2160
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/cbc/default.nix
@@ -0,0 +1,28 @@
+{ lib, stdenv, fetchurl, zlib, bzip2 }:
+
+stdenv.mkDerivation {
+  name = "cbc-2.9.9";
+
+  src = fetchurl {
+    url = "https://www.coin-or.org/download/source/Cbc/Cbc-2.9.9.tgz";
+    sha256 = "1w8axdzm05xf5y13c31w7rc5z6ywxqxiwafnxcq3p195kgj0915a";
+  };
+
+  configureFlags = [ "-C" ];
+
+  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/clp/default.nix b/nixpkgs/pkgs/applications/science/math/clp/default.nix
new file mode 100644
index 000000000000..4899ebe42d77
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/clp/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, zlib }:
+
+stdenv.mkDerivation rec {
+  version = "1.16.11";
+  name = "clp-${version}";
+  src = fetchurl {
+    url = "https://www.coin-or.org/download/source/Clp/Clp-${version}.tgz";
+    sha256 = "0fazlqpp845186nmixa9f1xfxqqkdr1xj4va7q29m8594ca4a9dm";
+  };
+
+  propagatedBuildInputs = [ zlib ];
+
+  doCheck = true;
+
+  meta = {
+    license = stdenv.lib.licenses.epl10;
+    homepage = https://projects.coin-or.org/Clp;
+    description = "An open-source linear programming solver written in C++";
+    platforms = stdenv.lib.platforms.all;
+    maintainers = [ stdenv.lib.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..4bf922c4e169
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/cntk/default.nix
@@ -0,0 +1,92 @@
+{ config, lib, stdenv, fetchgit, fetchFromGitHub, cmake
+, openblas, opencv3, libzip, boost, protobuf, openmpi
+, onebitSGDSupport ? false
+, cudaSupport ? config.cudaSupport or false, cudatoolkit, nvidia_x11
+, cudnnSupport ? cudaSupport, cudnn
+}:
+
+assert cudnnSupport -> cudaSupport;
+
+let
+  # Old specific version required for CNTK.
+  cub = fetchFromGitHub {
+    owner = "NVlabs";
+    repo = "cub";
+    rev = "1.7.4";
+    sha256 = "0ksd5n1lxqhm5l5cd2lps4cszhjkf6gmzahaycs7nxb06qci8c66";
+  };
+
+in stdenv.mkDerivation rec {
+  name = "CNTK-${version}";
+  version = "2.4";
+
+  # Submodules
+  src = fetchgit {
+    url = "https://github.com/Microsoft/CNTK";
+    rev = "v${version}";
+    sha256 = "0m28wb0ljixcpi14g3gcfiraimh487yxqhd9yrglgyvjb69x597y";
+  };
+
+  patches = [ ./fix_std_bind.patch ];
+
+  nativeBuildInputs = [ cmake ];
+
+  buildInputs = [ openblas opencv3 libzip boost protobuf openmpi ]
+             ++ lib.optional cudaSupport cudatoolkit
+             ++ lib.optional cudnnSupport cudnn;
+
+  configureFlags = [
+    "--with-opencv=${opencv3}"
+    "--with-libzip=${libzip.dev}"
+    "--with-openblas=${openblas}"
+    "--with-boost=${boost.dev}"
+    "--with-protobuf=${protobuf}"
+    "--with-mpi=${openmpi}"
+    "--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
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    homepage = https://github.com/Microsoft/CNTK;
+    description = "An open source deep-learning toolkit";
+    license = if onebitSGDSupport then licenses.unfreeRedistributable else licenses.mit;
+    maintainers = with maintainers; [ abbradar ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/cntk/fix_std_bind.patch b/nixpkgs/pkgs/applications/science/math/cntk/fix_std_bind.patch
new file mode 100644
index 000000000000..df97a0c66669
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/cntk/fix_std_bind.patch
@@ -0,0 +1,11 @@
+diff -ru3 CNTK-old/Source/CNTKv2LibraryDll/EvaluatorWrapper.h CNTK-new/Source/CNTKv2LibraryDll/EvaluatorWrapper.h
+--- CNTK-old/Source/CNTKv2LibraryDll/EvaluatorWrapper.h	1970-01-01 03:00:01.000000000 +0300
++++ CNTK-new/Source/CNTKv2LibraryDll/EvaluatorWrapper.h	2018-02-25 18:16:16.330269647 +0300
+@@ -9,6 +9,7 @@
+ #include <boost/noncopyable.hpp>
+ #include <memory>
+ #include <vector>
++#include <functional>
+ 
+ #include "CNTKLibrary.h"
+ #include "CNTKLibraryC.h"
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..94e0a44226d4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/colpack/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchFromGitHub, autoconf, automake, libtool, gettext }:
+
+stdenv.mkDerivation rec {
+
+  pname = "ColPack";
+  version = "1.0.10";
+  name = pname + "-" + version;
+
+  src = fetchFromGitHub {
+    owner = "CSCsw";
+    repo = pname;
+    rev = "v" + version;
+    sha256 = "1p05vry940mrjp6236c0z83yizmw9pk6ly2lb7d8rpb7j9h03glr";
+  };
+
+  buildInputs = [ autoconf automake gettext libtool ];
+
+  configurePhase = ''
+    autoreconf -vif
+    ./configure --prefix=$out --enable-openmp
+  '';
+
+  meta = with stdenv.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.lgpl3;
+    platforms = platforms.linux;
+    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..dae5e1b76d35
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/cplex/default.nix
@@ -0,0 +1,82 @@
+{ 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 {
+  name = "cplex-${version}";
+  version = "128";
+  
+  src =
+    if builtins.isNull releasePath 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 = stdenv.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
+  '';
+  
+  meta = with stdenv.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..9b402fe0ac94
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/csdp/default.nix
@@ -0,0 +1,29 @@
+{ lib, stdenv, fetchurl, blas, gfortran, liblapack }:
+
+stdenv.mkDerivation {
+  name = "csdp-6.1.1";
+
+  src = fetchurl {
+    url = "https://www.coin-or.org/download/source/Csdp/Csdp-6.1.1.tgz";
+    sha256 = "1f9ql6cjy2gwiyc51ylfan24v1ca9sjajxkbhszlds1lqmma8n05";
+  };
+
+  buildInputs = [ blas gfortran.cc.lib liblapack ];
+
+  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 = stdenv.lib.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..7b768f7077e7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/ecm/default.nix
@@ -0,0 +1,31 @@
+{ 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 = stdenv.lib.optional stdenv.isDarwin "--disable-asm-redc";
+
+  buildInputs = [ m4 gmp ];
+
+  doCheck = true;
+
+  meta = {
+    description = "Elliptic Curve Method for Integer Factorization";
+    license = stdenv.lib.licenses.gpl2Plus;
+    homepage = http://ecm.gforge.inria.fr/;
+    maintainers = [ stdenv.lib.maintainers.roconnor ];
+    platforms = with stdenv.lib.platforms; linux ++ darwin;
+  };
+}
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..6d1c778d1e0e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/eukleides/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchurl, bison, flex, texinfo, readline, texLive }:
+
+let
+  name    = "eukleides";
+  version = "1.5.4";
+in
+stdenv.mkDerivation {
+  name = "${name}-${version}";
+
+  src = fetchurl {
+    url = "http://www.eukleides.org/files/${name}-${version}.tar.bz2";
+    sha256 = "0s8cyh75hdj89v6kpm3z24i48yzpkr8qf0cwxbs9ijxj1i38ki0q";
+  };
+
+  buildInputs = [bison flex texinfo readline texLive];
+
+  preConfigure = "sed -i 's/ginstall-info/install-info/g' doc/Makefile";
+  installPhase = "mkdir -p $out/bin ; make PREFIX=$out install";
+
+  meta = {
+    description = "Geometry Drawing Language";
+    homepage = http://www.eukleides.org/;
+    license = stdenv.lib.licenses.gpl2;
+
+    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 = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.peti ];
+  };
+}
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..23ab2184266a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/form/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, gmp, zlib }:
+
+stdenv.mkDerivation rec {
+  version = "4.2.1";
+  name = "form-${version}";
+
+  # 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 stdenv.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..7d1f738641a6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/fricas/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchurl, sbcl, libX11, libXpm, libICE, libSM, libXt, libXau, libXdmcp }:
+
+let
+  version = "1.3.4";
+  name = "fricas-" + version;
+in
+stdenv.mkDerivation {
+  inherit name;
+
+  src = fetchurl {
+    url    = "mirror://sourceforge/fricas/files/fricas/${version}/${name}-full.tar.bz2";
+    sha256 = "156k9az1623y5808j845c56z2nvvdrm48dzg1v0ivpplyl7vp57x";
+  };
+
+  buildInputs = [ sbcl libX11 libXpm libICE libSM libXt libXau libXdmcp ];
+
+  dontStrip = true;
+
+  meta = {
+    homepage = http://fricas.sourceforge.net/;
+    description = "An advanced computer algebra system";
+    license = stdenv.lib.licenses.bsd3;
+
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.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..e12353878149
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/gap/default.nix
@@ -0,0 +1,194 @@
+{ stdenv
+, lib
+, fetchurl
+, fetchpatch
+, makeWrapper
+, m4
+, gmp
+# 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-*"
+  ];
+  standardPackages = requiredPackages ++ autoloadedPackages;
+  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.10.0";
+
+  src = fetchurl {
+    url = "https://www.gap-system.org/pub/gap/gap-${lib.versions.major version}.${lib.versions.minor version}/tar.bz2/gap-${version}.tar.bz2";
+    sha256 = "1dmb8v4p7j1nnf7sx8sg54b49yln36bi9acwp7w1d3a1nxj17ird";
+  };
+
+  # remove all non-essential packages (which take up a lot of space)
+  preConfigure = lib.optionalString (!keepAll) (removeNonWhitelistedPkgs packagesToKeep) + ''
+    patchShebangs .
+  '';
+
+  configureFlags = [ "--with-gmp=system" ];
+
+  buildInputs = [
+    m4
+    gmp
+  ];
+
+  nativeBuildInputs = [
+    makeWrapper
+  ];
+
+  patches = [
+    # bugfix: https://github.com/gap-system/gap/pull/3102
+    (fetchpatch {
+      name = "fix-infinite-loop-in-writeandcheck.patch";
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/gap/patches/0001-a-version-of-the-writeandcheck.patch-from-Sage-that-.patch?id=5e61d7b6a0da3aa53d8176fa1fb9353cc559b098";
+      sha256 = "1zkv8bbiw3jdn54sqqvfkdkfsd7jxzq0bazwsa14g4sh2265d28j";
+    })
+
+    # needed for libgap (sage): https://github.com/gap-system/gap/pull/3043
+    (fetchpatch {
+      name = "add-error-messages-helper.patch";
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/gap/patches/0002-kernel-add-helper-function-for-writing-error-message.patch?id=5e61d7b6a0da3aa53d8176fa1fb9353cc559b098";
+      sha256 = "0c4ry5znb6hwwp8ld6k62yw8w6cqldflw3x49bbzizbmipfpidh5";
+    })
+
+    # needed for libgap (sage): https://github.com/gap-system/gap/pull/3096
+    (fetchpatch {
+      name = "gap-enter.patch";
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/gap/patches/0003-Prototype-for-GAP_Enter-Leave-macros-to-bracket-use-.patch?id=5e61d7b6a0da3aa53d8176fa1fb9353cc559b098";
+      sha256 = "12fg8mb8rm6khsz1r4k3k26jrkx4q1rv13hcrfnlhn0m7iikvc3q";
+    })
+  ];
+
+  # "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 = "testinstall";
+
+  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"
+    )
+  '';
+
+  postCheck = ''
+    # The testsuite doesn't exit with a non-zero exit code on failure.
+    # It leaves its logs in dev/log however.
+
+    # grep for error messages
+    if grep ^##### dev/log/*; then
+        exit 1
+    fi
+  '';
+
+  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/"
+
+    mkdir -p "$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;
+    # keeping all packages increases the package size considerably, wchich
+    # 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 = http://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..755a60940388
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/geogebra/default.nix
@@ -0,0 +1,63 @@
+{ stdenv, fetchurl, jre, makeDesktopItem, makeWrapper, language ? "en_US" }:
+
+stdenv.mkDerivation rec {
+  name = "geogebra-${version}";
+  version = "5-0-472-0";
+
+  preferLocalBuild = true;
+
+  src = fetchurl {
+    urls = [
+      "https://download.geogebra.org/installers/5.0/GeoGebra-Linux-Portable-${version}.tar.bz2"
+      "http://web.archive.org/https://download.geogebra.org/installers/5.0/GeoGebra-Linux-Portable-${version}.tar.bz2"
+    ];
+    sha256 = "1f56k5r5wf2l27sgp2vjpvx7wl72gizwxs0a6hngk15nzzka87v9";
+  };
+
+  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;";
+    mimeType = "application/vnd.geogebra.file;application/vnd.geogebra.tool;";
+  };
+
+  buildInputs = [ 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"
+  '';
+
+  meta = with stdenv.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; [ ma27 ];
+    license = with licenses; [ gpl3 cc-by-nc-sa-30 geogebra ];
+    platforms = platforms.all;
+    hydraPlatforms = [];
+  };
+}
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..74e4b052fdb5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/getdp/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, cmake, gfortran, openblas, openmpi, python3 }:
+
+stdenv.mkDerivation rec {
+  name = "getdp-${version}";
+  version = "3.0.4";
+  src = fetchurl {
+    url = "http://getdp.info/src/getdp-${version}-source.tgz";
+    sha256 = "0v3hg03lzw4hz28hm45hpv0gyydqz0wav7xvb5n0v0jrm47mrspv";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ gfortran openblas openmpi python3 ];
+
+  meta = with stdenv.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 = stdenv.lib.licenses.gpl2Plus;
+    maintainers = with maintainers; [ wucke13 ];
+    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..d2d1ddb65846
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/gfan/default.nix
@@ -0,0 +1,28 @@
+{stdenv, fetchurl, gmp, mpir, cddlib}:
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "gfan";
+  version = "0.6.2";
+
+  src = fetchurl {
+    url = "http://home.math.au.dk/jensen/software/gfan/gfan${version}.tar.gz";
+    sha256 = "02pihqb1lb76a0xbfwjzs1cd6ay3ldfxsm8dvsbl6qs3vkjxax56";
+  };
+
+  patchPhase = stdenv.lib.optionalString stdenv.isDarwin ''
+    substituteInPlace Makefile --replace "-fno-guess-branch-probability" ""
+  '';
+
+  buildFlags = [ "CC=cc" "CXX=c++" "cddnoprefix=1" ];
+  installFlags = [ ''PREFIX=$(out)'' ];
+  buildInputs = [ gmp mpir cddlib ];
+
+  meta = {
+    inherit version;
+    description = ''A software package for computing Gröbner fans and tropical varieties'';
+    license = stdenv.lib.licenses.gpl2 ;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.unix;
+    homepage = http://home.math.au.dk/jensen/software/gfan/gfan.html;
+  };
+}
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..ad82d7572e34
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/giac/default.nix
@@ -0,0 +1,112 @@
+{ stdenv, fetchurl, fetchpatch, texlive, bison, flex, liblapack
+, gmp, mpfr, pari, ntl, gsl, blas, mpfi, ecm, glpk, nauty
+, readline, gettext, libpng, libao, gfortran, perl
+, enableGUI ? false, libGLU_combined ? null, xorg ? null, fltk ? null
+}:
+
+assert enableGUI -> libGLU_combined != null && xorg != null && fltk != null;
+
+stdenv.mkDerivation rec {
+  name = "${attr}-${version}";
+  attr = if enableGUI then "giac-with-xcas" else "giac";
+  version = "1.5.0-21"; # 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 = "1b9khiv0mk2xzw1rblm2jy6qsf8y6f9k7qy15sxpb21d72hzzbl2";
+  };
+
+  patches = stdenv.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 {
+      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*; do
+      substituteInPlace "$i" --replace "/bin/cp" "cp";
+    done;
+  '';
+
+  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
+    (stdenv.lib.getLib gfortran.cc)
+    liblapack
+  ] ++ stdenv.lib.optionals enableGUI [
+    libGLU_combined fltk xorg.libX11
+  ];
+
+  /* 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" ] ++ stdenv.lib.optional (!enableGUI) "doc";
+
+  doCheck = true;
+  preCheck = ''
+    # One test in this file fails. That test just tests a part of the pari
+    # interface that isn't actually used in giac. Of course it would be better
+    # to only remove that one test, but that would require a patch.
+    # Removing the whole test set should be good enough for now.
+    # Upstream report: https://xcas.univ-grenoble-alpes.fr/forum/viewtopic.php?f=4&t=2102#p10326
+    echo > check/chk_fhan11
+  '';
+
+  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"
+  ] ++ stdenv.lib.optionals enableGUI [
+    "--enable-gui" "--with-x"
+  ];
+
+  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
+  '' + stdenv.lib.optionalString (!enableGUI) ''
+    for i in pixmaps application-registry applications icons; do
+      rm -r "$out/share/$i";
+    done;
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A free computer algebra system (CAS)";
+    homepage = "https://www-fourier.ujf-grenoble.fr/~parisse/giac.html";
+    license = licenses.gpl3Plus;
+    ## xcas is buildable on darwin but there are specific instructions I could
+    ## not test
+    platforms = platforms.linux;
+    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..18a5281bebb0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/ginac/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchurl, cln, pkgconfig, readline, gmp, python }:
+
+stdenv.mkDerivation rec {
+  name = "ginac-1.7.4";
+
+  src = fetchurl {
+    url    = "${meta.homepage}/${name}.tar.bz2";
+    sha256 = "1vvqv73yk9klbq0mz239zzw77rlp72qcvzci4j1v6rafvji1616n";
+  };
+
+  propagatedBuildInputs = [ cln ];
+
+  buildInputs = [ readline ] ++ stdenv.lib.optional stdenv.isDarwin gmp;
+
+  nativeBuildInputs = [ pkgconfig python ];
+
+  preConfigure = "patchShebangs ginsh";
+
+  configureFlags = [ "--disable-rpath" ];
+
+  meta = with stdenv.lib; {
+    description = "GiNaC is Not a CAS";
+    homepage    = http://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..4de683cdce90
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/glsurf/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchurl, ocamlPackages, libGLU_combined, freeglut
+, mysql, mpfr, gmp, libtiff, libjpeg, libpng, giflib
+}:
+
+stdenv.mkDerivation {
+  name = "glsurf-3.3.1";
+
+  src = fetchurl {
+    url = "https://lama.univ-savoie.fr/~raffalli/glsurf/glsurf-3.3.1.tar.gz";
+    sha256 = "0w8xxfnw2snflz8wdr2ca9f5g91w5vbyp1hwlx1v7vg83d4bwqs7";
+  };
+
+  buildInputs = [ freeglut libGLU_combined mysql.connector-c mpfr gmp
+    libtiff libjpeg libpng giflib ]
+  ++ (with ocamlPackages; [
+    ocaml findlib ocaml_mysql lablgl camlimages_4_0 mlgmpidl
+  ]);
+
+  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
+  '';
+
+  meta = {
+    homepage = http://www.lama.univ-savoie.fr/~raffalli/glsurf;
+    description = "A program to draw implicit surfaces and curves";
+    license = stdenv.lib.licenses.lgpl21;
+  };
+}
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..76e5071908f1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/gmsh/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, cmake, openblasCompat, gfortran, gmm, fltk, libjpeg
+, zlib, libGLU_combined, libGLU, xorg }:
+
+let version = "4.1.5"; in
+
+stdenv.mkDerivation {
+  name = "gmsh-${version}";
+
+  src = fetchurl {
+    url = "http://gmsh.info/src/gmsh-${version}-source.tgz";
+    sha256 = "654d38203f76035a281006b77dcb838987a44fd549287f11c53a1e9cdf598f46";
+  };
+
+  buildInputs = [ cmake openblasCompat gmm fltk libjpeg zlib libGLU_combined
+    libGLU xorg.libXrender xorg.libXcursor xorg.libXfixes xorg.libXext
+    xorg.libXft xorg.libXinerama xorg.libX11 xorg.libSM xorg.libICE
+  ];
+
+  nativeBuildInputs = [ gfortran ];
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "A three-dimensional finite element mesh generator";
+    homepage = http://gmsh.info/;
+    platforms = [ "x86_64-linux" ];
+    license = stdenv.lib.licenses.gpl2Plus;
+  };
+}
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..be14d1411285
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/gurobi/default.nix
@@ -0,0 +1,54 @@
+{ stdenv, fetchurl, autoPatchelfHook, python }:
+
+stdenv.mkDerivation rec {
+  name = "gurobi-${version}";
+  version = "8.1.0";
+
+  src = with stdenv.lib; fetchurl {
+    url = "http://packages.gurobi.com/${versions.majorMinor version}/gurobi${version}_linux64.tar.gz";
+    sha256 = "1yjqbzqnq4jjkjm616d36bgd3rmqr0a1ii17n0prpdjzmdlq63dz";
+  };
+
+  sourceRoot = "gurobi${builtins.replaceStrings ["."] [""] version}/linux64";
+
+  nativeBuildInputs = [ autoPatchelfHook ];
+  buildInputs = [ (python.withPackages (ps: [ ps.gurobipy ])) ];
+
+  buildPhase = ''
+    cd src/build
+    make
+    cd ../..
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp bin/* $out/bin/
+    rm $out/bin/gurobi.env
+    rm $out/bin/gurobi.sh
+    rm $out/bin/python2.7
+
+    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/
+  '';
+
+  meta = with stdenv.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..9eab9ca39992
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/hmetis/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchurl, ghostscript }:
+
+stdenv.mkDerivation rec {
+  name = "hmetis-${version}";
+  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 stdenv.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..1d1fb96a4739
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/jags/default.nix
@@ -0,0 +1,19 @@
+{stdenv, fetchurl, gfortran, openblas}:
+
+stdenv.mkDerivation rec {
+  name = "JAGS-4.3.0";
+  src = fetchurl {
+    url = "mirror://sourceforge/mcmc-jags/${name}.tar.gz";
+    sha256 = "1z3icccg2ic56vmhyrpinlsvpq7kcaflk1731rgpvz9bk1bxvica";
+  };
+  buildInputs = [gfortran openblas];
+  configureFlags = [ "--with-blas=-lopenblas" "--with-lapack=-lopenblas" ];
+
+  meta = with stdenv.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..0cf834c8cdea
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/lp_solve/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+
+  name = "lp_solve-${version}";
+  version = "5.5.2.5";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/project/lpsolve/lpsolve/${version}/lp_solve_${version}_source.tar.gz";
+    sha256 = "12pj1idjz31r7c2mb5w03vy1cmvycvbkx9z29s40qdmkp1i7q6i0";
+  };
+
+  patches = [ ./isnan.patch ];
+
+  buildCommand = ''
+    . $stdenv/setup
+    tar xvfz $src
+    (
+    cd lp_solve*
+    eval patchPhase
+    )
+    (
+    cd lp_solve*/lpsolve55
+    bash ccc
+    mkdir -pv $out/lib
+    cp -v bin/*/* $out/lib
+    )
+    (
+    cd lp_solve*/lp_solve
+    bash ccc
+    mkdir -pv $out/bin
+    cp -v bin/*/* $out/bin
+    )
+    (
+    mkdir -pv $out/include
+    cp -v lp_solve*/*.h $out/include
+    )
+  '';
+
+  meta = with stdenv.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/lp_solve/isnan.patch b/nixpkgs/pkgs/applications/science/math/lp_solve/isnan.patch
new file mode 100644
index 000000000000..bc1983d4423d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/lp_solve/isnan.patch
@@ -0,0 +1,13 @@
+diff -u a/lp_lib.h b/lp_lib.h
+--- a/lp_lib.h	2016-05-04 19:45:15.753143720 +0900
++++ b/lp_lib.h	2016-05-04 19:53:59.536920722 +0900
+@@ -59,9 +59,6 @@
+ # if defined _WIN32 && !defined __GNUC__
+ #  define isnan _isnan
+ # endif
+-#if defined NOISNAN
+-# define isnan(x) FALSE
+-#endif
+ 
+ #define SETMASK(variable, mask)     variable |= mask
+ #define CLEARMASK(variable, mask)   variable &= ~(mask)
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..9e02b08c8ad0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/lrcalc/default.nix
@@ -0,0 +1,41 @@
+{ stdenv
+, fetchFromBitbucket
+, fetchpatch
+, autoreconfHook
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.2";
+  pname = "lrcalc";
+  name = "${pname}-${version}";
+
+  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 stdenv.lib; {
+    description = "Littlewood-Richardson calculator";
+    homepage = http://math.rutgers.edu/~asbuch/lrcalc/;
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.linux;
+  };
+}
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..c6802c3719e9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/mathematica/10.nix
@@ -0,0 +1,136 @@
+{ stdenv
+, coreutils
+, patchelf
+, requireFile
+, alsaLib
+, fontconfig
+, freetype
+, gcc
+, glib
+, ncurses
+, opencv
+, 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";
+
+  name = "mathematica-${version}";
+
+  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
+    alsaLib
+    coreutils
+    fontconfig
+    freetype
+    gcc.cc
+    gcc.libc
+    glib
+    ncurses
+    opencv
+    openssl
+    unixODBC
+    libxml2
+    libuuid
+  ] ++ (with xorg; [
+    libX11
+    libXext
+    libXtst
+    libXi
+    libXmu
+    libXrender
+    libxcb
+    libXcursor
+    libXfixes
+    libXrandr
+    libICE
+    libSM
+  ]);
+
+  ldpath = stdenv.lib.makeLibraryPath buildInputs
+    + stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
+      (":" + stdenv.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 = stdenv.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..1023e7ca3d5c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/mathematica/9.nix
@@ -0,0 +1,122 @@
+{ stdenv
+, coreutils
+, patchelf
+, requireFile
+, alsaLib
+, fontconfig
+, freetype
+, gcc
+, glib
+, ncurses
+, opencv
+, 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 {
+
+  name = "mathematica-9.0.0";
+
+  src = requireFile rec {
+    name = "Mathematica_9.0.0_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
+    alsaLib
+    coreutils
+    fontconfig
+    freetype
+    gcc.cc
+    gcc.libc
+    glib
+    ncurses
+    opencv
+    openssl
+    unixODBC
+  ] ++ (with xorg; [
+    libX11
+    libXext
+    libXtst
+    libXi
+    libXmu
+    libXrender
+    libxcb
+  ]);
+
+  ldpath = stdenv.lib.makeLibraryPath buildInputs
+    + stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
+      (":" + stdenv.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 = stdenv.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..165a56605579
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/mathematica/default.nix
@@ -0,0 +1,148 @@
+{ stdenv
+, coreutils
+, patchelf
+, callPackage
+, alsaLib
+, dbus
+, fontconfig
+, freetype
+, gcc
+, glib
+, ncurses
+, opencv
+, openssl
+, unixODBC
+, xkeyboard_config
+, xorg
+, zlib
+, libxml2
+, libuuid
+, lang ? "en"
+, libGL
+, libGLU
+}:
+
+let
+  l10n =
+    with stdenv.lib;
+    with callPackage ./l10ns.nix {};
+    flip (findFirst (l: l.lang == lang)) l10ns
+      (throw "Language '${lang}' not supported");
+in
+stdenv.mkDerivation rec {
+  inherit (l10n) version name src;
+
+  buildInputs = [
+    coreutils
+    patchelf
+    alsaLib
+    coreutils
+    dbus
+    fontconfig
+    freetype
+    gcc.cc
+    gcc.libc
+    glib
+    ncurses
+    opencv
+    openssl
+    unixODBC
+    xkeyboard_config
+    libxml2
+    libuuid
+    zlib
+    libGL
+    libGLU
+  ] ++ (with xorg; [
+    libX11
+    libXext
+    libXtst
+    libXi
+    libXmu
+    libXrender
+    libxcb
+    libXcursor
+    libXfixes
+    libXrandr
+    libICE
+    libSM
+  ]);
+
+  ldpath = stdenv.lib.makeLibraryPath buildInputs
+    + stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
+      (":" + stdenv.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 = stdenv.lib.licenses.unfree;
+  };
+}
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..065360a112d8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/mathematica/l10ns.nix
@@ -0,0 +1,33 @@
+{ lib, requireFile }:
+
+with lib;
+{
+  l10ns = flip map
+  [
+    {
+      version = "11.3.0";
+      lang = "en";
+      language = "English";
+      sha256 = "0fcfe208c1eac8448e7be3af0bdb84370b17bd9c5d066c013928c8ee95aed10e";
+    }
+    {
+      version = "11.2.0";
+      lang = "ja";
+      language = "Japanese";
+      sha256 = "916392edd32bed8622238df435dd8e86426bb043038a3336f30df10d819b49b1";
+    }
+  ]
+  ({ version, lang, language, sha256 }: {
+    inherit version lang;
+    name = "mathematica-${version}" + optionalString (lang != "en") "-${lang}";
+    src = requireFile rec {
+      name = "Mathematica_${version}" + optionalString (lang != "en") "_${language}" + "_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>.
+      '';
+      inherit sha256;
+    };
+  });
+}
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..39ed763413be
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/maxima/default.nix
@@ -0,0 +1,108 @@
+{ stdenv, fetchurl, fetchpatch, sbcl, texinfo, perl, python, makeWrapper, rlwrap ? null
+, tk ? null, gnuplot ? null, ecl ? null, ecl-fasl ? false
+}:
+
+let
+  name    = "maxima";
+  version = "5.42.2";
+
+  searchPath =
+    stdenv.lib.makeBinPath
+      (stdenv.lib.filter (x: x != null) [ sbcl ecl rlwrap tk gnuplot ]);
+in
+stdenv.mkDerivation ({
+  inherit version;
+  name = "${name}-${version}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/${name}/${name}-${version}.tar.gz";
+    sha256 = "0kdncy6137sg3rradirxzj10mkcvafxd892zlclwhr9sa7b12zhn";
+  };
+
+  buildInputs = stdenv.lib.filter (x: x != null) [
+    sbcl ecl texinfo perl python makeWrapper
+    gnuplot   # required in the test suite
+  ];
+
+  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
+  ''
+   + (stdenv.lib.optionalString ecl-fasl ''
+     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 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";
+    })
+
+    # upstream bug https://sourceforge.net/p/maxima/bugs/2520/ (not fixed)
+    # introduced in https://trac.sagemath.org/ticket/13364
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/maxima/patches/0001-taylor2-Avoid-blowing-the-stack-when-diff-expand-isn.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "0xa0b6cr458zp7lc7qi0flv5ar0r3ivsqhjl0c3clv86di2y522d";
+    })
+  ] ++ stdenv.lib.optionals ecl-fasl [
+    # 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";
+    })
+    # There are some transient test failures. I hope this disables all those tests.
+    # If those test failures ever happen in the non-ecl version, that should be
+    # reportetd upstream.
+    ./known-ecl-failures.patch
+  ];
+
+  # The test suite is disabled since 5.42.2 because of the following issues:
+  #
+  #   Errors found in /build/maxima-5.42.2/share/linearalgebra/rtest_matrixexp.mac, problems:
+  #   (20 21 22)
+  #   Error found in rtest_arag, problem:
+  #   (error break)
+  #   3 tests failed out of 3,881 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;
+
+  meta = {
+    description = "Computer algebra system";
+    homepage = http://maxima.sourceforge.net;
+    license = stdenv.lib.licenses.gpl2;
+
+    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.
+    '';
+
+    platforms = stdenv.lib.platforms.unix;
+    maintainers = [ stdenv.lib.maintainers.peti ];
+  };
+})
diff --git a/nixpkgs/pkgs/applications/science/math/maxima/known-ecl-failures.patch b/nixpkgs/pkgs/applications/science/math/maxima/known-ecl-failures.patch
new file mode 100644
index 000000000000..f1d612d993e6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/maxima/known-ecl-failures.patch
@@ -0,0 +1,21 @@
+diff --git a/tests/testsuite.lisp b/tests/testsuite.lisp
+index 45a81f4..36c35b8 100644
+--- a/tests/testsuite.lisp
++++ b/tests/testsuite.lisp
+@@ -25,13 +25,14 @@
+         ((mlist simp) "rtest10" 24 25)
+         ((mlist) "rtest11" #+(or gcl cmucl ccl64) 158 #+(or gcl cmucl ccl64) 174 #+gcl 175)
+         "rtest13" "rtest13s"
+-        "rtest14"
++        ;; "rtest14" ;; some tests sometimes fail with ecl, hard to reproduce. Observed failing: 250, 267, 297, 307, 310, 312, 315, 319
+         "rtest15"
+ 	;; ccl versions 1.11 and earlier fail test 50.  Mark it as a
+ 	;; known failure.  Presumably 1.12 will have this fixed.
+         ((mlist simp) "rtest16" #+ccl 50)
+         "rtestode" "rtestode_zp"
+-        "rtest3" "rtest8"
++        "rtest3"
++        ((mlist simp) "rtest8" 104) ;; fails with ecl
+         ((mlist simp) "rtest12" 76 78)
+         "rexamples"
+         ((mlist simp) "rtesthyp" 105 112 113 123 124 128)
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..6e1926810df0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/msieve/default.nix
@@ -0,0 +1,30 @@
+{stdenv, fetchurl, zlib, gmp, ecm }:
+
+stdenv.mkDerivation {
+  name = "msieve-1.53";
+
+  src = fetchurl {
+    url = mirror://sourceforge/msieve/msieve/Msieve%20v1.53/msieve153_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=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 = stdenv.lib.licenses.publicDomain;
+    homepage = http://msieve.sourceforge.net/;
+    maintainers = [ stdenv.lib.maintainers.roconnor ];
+    platforms = [ "x86_64-linux" ] ++ stdenv.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..061f48bb3d93
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/mxnet/default.nix
@@ -0,0 +1,56 @@
+{ config, stdenv, lib, fetchurl, bash, cmake
+, opencv, gtest, openblas, liblapack, perl
+, cudaSupport ? config.cudaSupport or false, cudatoolkit, nvidia_x11
+, cudnnSupport ? cudaSupport, cudnn
+}:
+
+assert cudnnSupport -> cudaSupport;
+
+stdenv.mkDerivation rec {
+  name = "mxnet-${version}";
+  version = "1.2.1";
+
+  # Fetching from git does not work at the time (1.2.1) due to an
+  # incorrect hash in one of the submodules. The provided tarballs
+  # contain all necessary sources.
+  src = fetchurl {
+    url = "https://github.com/apache/incubator-mxnet/releases/download/${version}/apache-mxnet-src-${version}-incubating.tar.gz";
+    sha256 = "053zbdgs4j8l79ipdz461zc7wyfbfcflmi5bw7lj2q08zm1glnb2";
+  };
+
+  nativeBuildInputs = [ cmake perl ];
+
+  buildInputs = [ opencv gtest openblas liblapack ]
+              ++ lib.optionals cudaSupport [ cudatoolkit nvidia_x11 ]
+              ++ lib.optional cudnnSupport cudnn;
+
+  cmakeFlags =
+    (if cudaSupport then [
+      "-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
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.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.linux;
+  };
+}
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..aef18abaedfb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/nasc/default.nix
@@ -0,0 +1,62 @@
+{ stdenv
+, fetchFromGitHub
+, pkgconfig
+, gtk3
+, pantheon
+, gnome3
+, gtksourceview
+, libgee
+, cmake
+, libqalculate
+, gobject-introspection
+, wrapGAppsHook }:
+
+stdenv.mkDerivation rec {
+  name = "nasc-${version}";
+  version = "0.5.1";
+
+  src = fetchFromGitHub {
+    owner = "parnold-x";
+    repo = "nasc";
+    rev = version;
+    sha256 = "13y5fnm7g3xgdxmdydlgly73nigh8maqbf9d6c9bpyzxkxq1csy5";
+  };
+
+  postPatch = ''
+    # libqalculatenasc.so is not installed, and nasc fails to start
+    substituteInPlace libqalculatenasc/CMakeLists.txt --replace SHARED STATIC
+  '';
+
+  nativeBuildInputs = [
+    cmake
+    pantheon.vala
+    gobject-introspection # for setup-hook
+    pkgconfig
+    wrapGAppsHook
+  ];
+
+  buildInputs = [
+    pantheon.elementary-icon-theme
+    gtksourceview
+    libgee
+    gnome3.libsoup
+    pantheon.granite
+    gtk3
+    libqalculate
+  ];
+
+  meta = with stdenv.lib; {
+    description = "Do maths like a normal person";
+    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 = with maintainers; [ samdroid-apps ];
+    platforms = platforms.linux;
+    license = licenses.gpl3Plus;
+  };
+}
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..5b431f419261
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/nauty/default.nix
@@ -0,0 +1,31 @@
+{stdenv, fetchurl}:
+stdenv.mkDerivation rec {
+  name = "nauty-${version}";
+  version = "26r11";
+  src = fetchurl {
+    url = "http://pallini.di.uniroma1.it/nauty${version}.tar.gz";
+    sha256 = "05z6mk7c31j70md83396cdjmvzzip1hqb88pfszzc6k4gy8h3m2y";
+  };
+  outputs = [ "out" "dev" ];
+  buildInputs = [];
+  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 = {
+    inherit version;
+    description = ''Programs for computing automorphism groups of graphs and digraphs'';
+    license = stdenv.lib.licenses.asl20;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.linux;
+    homepage = http://pallini.di.uniroma1.it/;
+  };
+}
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..e9fd21b46d8a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/palp/default.nix
@@ -0,0 +1,86 @@
+{ 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)
+}:
+
+stdenv.mkDerivation rec {
+  version = "2.1";
+  dim = toString dimensions;
+  name = "palp-${dim}d-${version}";
+
+  src = fetchurl {
+    url = "http://hep.itp.tuwien.ac.at/~kreuzer/CY/palp/palp-${version}.tar.gz";
+    sha256 = "1s7s2lc5f0ig1yy7ygsh3sddm3sbq4mxwybqsj8lp9wjdxs7qfrs";
+  };
+
+  hardeningDisable = [
+    "format"
+    "strictoverflow" # causes runtime failure (tested in checkPhase)
+  ];
+
+  patchPhase = stdenv.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
+  '' + stdenv.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 stdenv.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;
+    # 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 = with maintainers; [ timokau ];
+    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..72827112c50c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/pari/default.nix
@@ -0,0 +1,94 @@
+{ stdenv
+, fetchurl
+, fetchpatch
+, gmp
+, readline
+, libX11
+, tex
+, perl
+, withThread ? true, libpthreadstubs
+}:
+
+assert withThread -> libpthreadstubs != null;
+
+stdenv.mkDerivation rec {
+  pname = "pari";
+  version = "2.11.1";
+
+  src = fetchurl {
+    url = "https://pari.math.u-bordeaux.fr/pub/pari/unix/${pname}-${version}.tar.gz";
+    sha256 = "1jfax92jpydjd02fwl30r6b8kfzqqd6sm4yx94gidyz9lqjb7a94";
+  };
+
+  patches = [
+    # Fix a off-by-one bug that can potentially lead to segfaults (accepted upstream)
+    # https://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=2117
+    # https://trac.sagemath.org/ticket/27335
+    (fetchpatch {
+      name = "fix-off-by-one-error.patch";
+      # only relevant parts of https://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=pari.git;a=patch;h=aa1ee6e0898d177e6bcf49237d82c804bc410985
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/pari/patches/red_montgomery.patch?id=bbea55c96e1f05302b3c7f593cf64492497047c5";
+      sha256 = "0vqkmhgv9splsdswp6zjnkj50z76rc1m6k9iy3cf9dxwqw3h3nr6";
+    })
+  ];
+
+  buildInputs = [
+    gmp
+    readline
+    libX11
+    tex
+    perl
+  ] ++ stdenv.lib.optionals withThread [
+    libpthreadstubs
+  ];
+
+  configureScript = "./Configure";
+  configureFlags = [
+    "--with-gmp=${gmp.dev}"
+    "--with-readline=${readline.dev}"
+  ] ++ stdenv.lib.optional stdenv.isDarwin "--host=x86_64-darwin"
+  ++ stdenv.lib.optional withThread "--mt=pthread";
+
+  preConfigure = ''
+    export LD=$CC
+  '';
+
+  postConfigure = stdenv.lib.optionalString stdenv.isDarwin ''
+    echo 'echo x86_64-darwin' > config/arch-osname
+  '';
+
+  makeFlags = [ "all" ];
+
+  meta = with stdenv.lib; {
+    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.
+    '';
+    homepage    = http://pari.math.u-bordeaux.fr;
+    downloadPage = http://pari.math.u-bordeaux.fr/download.html;
+    license     = licenses.gpl2Plus;
+    maintainers = with maintainers; [ ertes raskin AndersonTorres timokau ];
+    platforms   = platforms.linux ++ platforms.darwin;
+    updateWalker = true;
+  };
+}
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..4915e42025b5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/pari/gp2c.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchurl
+, pari, perl }:
+
+stdenv.mkDerivation rec {
+
+  name = "gp2c-${version}";
+  version = "0.0.11pl1";
+
+  src = fetchurl {
+    url = "https://pari.math.u-bordeaux.fr/pub/pari/GP2C/${name}.tar.gz";
+    sha256 = "1c6f6vmncw032kfzrfyr8bynw6yd3faxpy2285r009fmr0zxfs5s";
+  };
+
+  buildInputs = [ pari perl ];
+
+  configureFlags = [
+    "--with-paricfg=${pari}/lib/pari/pari.cfg"
+    "--with-perl=${perl}/bin/perl" ];
+
+  meta = with stdenv.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 ];
+  };
+}
+# TODO: add it as "source file" for default package
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..3e7d9898a656
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/pcalc/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchgit, bison2, flex }:
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  name = "pcalc-${version}";
+  version = "20141224";
+
+  src = fetchgit {
+    url = git://git.code.sf.net/p/pcalc/code;
+    rev = "181d60d3c880da4344fef7138065943eb3b9255f";
+    sha256 = "1hd5bh20j5xzvv6qa0fmzmv0h8sf38r7zgi7y0b6nk17pjq33v90";
+  };
+
+  makeFlags = [ "DESTDIR= BINDIR=$(out)/bin" ];
+  buildInputs = [ bison2 flex ];
+
+  meta = {
+    homepage = http://pcalc.sourceforge.net/;
+    description = "Programmer's calculator";
+    license = licenses.gpl2;
+    maintainers = with stdenv.lib.maintainers; [ ftrvxmtrx ];
+    platforms = stdenv.lib.platforms.linux;
+    inherit version;
+  };
+}
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..2d150d0c30e9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/perseus/default.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchurl, unzip }:
+
+stdenv.mkDerivation {
+  name = "perseus-4-beta";
+  version = "4-beta";
+  buildInputs = [ 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 = stdenv.lib.licenses.gpl3;
+    maintainers = with stdenv.lib.maintainers; [erikryb];
+    platforms = stdenv.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..4fba231f094d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/polymake/default.nix
@@ -0,0 +1,48 @@
+{ stdenv, fetchurl
+, ninja, libxml2, libxslt, readline, perl, gmp, mpfr, boost
+, bliss, ppl, singular, cddlib, lrs, nauty
+, ant, openjdk
+, perlPackages
+, makeWrapper
+}:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "polymake";
+  version = "3.2.rc4";
+
+  src = fetchurl {
+    url = "https://polymake.org/lib/exe/fetch.php/download/polymake-3.2r4.tar.bz2";
+    sha256 = "02jpkvy1cc6kc23vkn7nkndzr40fq1gkb3v257bwyi1h5d37fyqy";
+  };
+
+  buildInputs = [
+    libxml2 libxslt readline perl gmp mpfr boost
+    bliss ppl singular cddlib lrs nauty
+    openjdk
+  ] ++
+  (with perlPackages; [
+    XMLLibXML XMLLibXSLT XMLWriter TermReadLineGnu TermReadKey
+  ]);
+
+  nativeBuildInputs = [
+    makeWrapper ninja ant perl
+  ];
+
+  ninjaFlags = "-C build/Opt";
+
+  postInstall = ''
+    for i in "$out"/bin/*; do
+      wrapProgram "$i" --prefix PERL5LIB : "$PERL5LIB"
+    done
+  '';
+
+  meta = {
+    inherit version;
+    description = "Software for research in polyhedral geometry";
+    license = stdenv.lib.licenses.gpl2 ;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.linux;
+    homepage = "https://www.polymake.org/doku.php";
+  };
+}
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..c53e87caa9ad
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/pspp/default.nix
@@ -0,0 +1,51 @@
+{ stdenv, fetchurl, libxml2, readline, zlib, perl, cairo, gtk3, gsl
+, pkgconfig, gtksourceview, pango, gettext
+, makeWrapper, gsettings-desktop-schemas, hicolor-icon-theme
+, gnome3
+}:
+
+stdenv.mkDerivation rec {
+  name = "pspp-1.0.1";
+
+  src = fetchurl {
+    url = "mirror://gnu/pspp/${name}.tar.gz";
+    sha256 = "1r8smr5057993h90nx0mdnff8nxw9x546zzh6qpy4h3xblp1la5s";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ libxml2 readline zlib perl cairo gtk3 gsl
+    gtksourceview pango gettext
+    makeWrapper gsettings-desktop-schemas hicolor-icon-theme ];
+
+  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 : "${stdenv.lib.getLib gnome3.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 = stdenv.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 = stdenv.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..032b2ef09643
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/pynac/default.nix
@@ -0,0 +1,48 @@
+{ stdenv
+, fetchFromGitHub
+, autoreconfHook
+, pkgconfig
+, flint
+, gmp
+, python2
+, singular
+}:
+
+stdenv.mkDerivation rec {
+  version = "0.7.23";
+  name = "pynac-${version}";
+
+  src = fetchFromGitHub {
+    owner = "pynac";
+    repo = "pynac";
+    rev = "pynac-${version}";
+    sha256 = "02yhl8v9l6aj3wl6dk9iacz4hdv08i1d750rxpygjp43nlgvvb2h";
+  };
+
+  buildInputs = [
+    flint
+    gmp
+    singular
+    singular
+    python2
+  ];
+
+  nativeBuildInputs = [
+    autoreconfHook
+    pkgconfig
+  ];
+
+  meta = with stdenv.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.gpl3;
+    maintainers = with maintainers; [ timokau ];
+    platforms   = platforms.linux;
+  };
+}
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..5104d1012b2f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/qalculate-gtk/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchFromGitHub, intltool, autoreconfHook, pkgconfig, libqalculate, gtk3, wrapGAppsHook }:
+
+stdenv.mkDerivation rec {
+  name = "qalculate-gtk-${version}";
+  version = "2.9.0";
+
+  src = fetchFromGitHub {
+    owner = "qalculate";
+    repo = "qalculate-gtk";
+    rev = "v${version}";
+    sha256 = "0c5s7mz8xwwmzc22yai8vqiww7paafkyi7khp8a2yws78m2nirdx";
+  };
+
+  patchPhase = ''
+    substituteInPlace src/main.cc --replace 'getPackageDataDir().c_str()' \"$out/share\"
+  '';
+
+  hardeningDisable = [ "format" ];
+
+  nativeBuildInputs = [ intltool pkgconfig autoreconfHook wrapGAppsHook ];
+  buildInputs = [ libqalculate gtk3 ];
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "The ultimate desktop calculator";
+    homepage = http://qalculate.github.io;
+    maintainers = with maintainers; [ gebner ];
+    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..2dd4778234df
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/ratpoints/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchurl, fetchpatch, gmp }:
+stdenv.mkDerivation rec {
+  name = "ratpoints-${version}";
+  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=cc" ];
+  buildFlags = stdenv.lib.optional stdenv.isDarwin ["CCFLAGS2=-lgmp -lc -lm" "CCFLAGS=-UUSE_SSE"];
+  installFlags = [ "INSTALL_DIR=$(out)" ];
+
+  preInstall = ''mkdir -p "$out"/{bin,share,lib,include}'';
+
+  meta = {
+    inherit version;
+    description = ''A program to find rational points on hyperelliptic curves'';
+    license = stdenv.lib.licenses.gpl2Plus;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.unix;
+    homepage = http://www.mathe2.uni-bayreuth.de/stoll/programs/;
+    updateWalker = true;
+  };
+}
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..4b237a01a3e5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/ries/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, fetchzip }:
+stdenv.mkDerivation {
+  name = "ries-2018-04-11";
+
+  # upstream does not provide a stable link
+  src = fetchzip {
+    url = "https://salsa.debian.org/debian/ries/-/archive/debian/2018.04.11-1/ries-debian-2018.04.11-1.zip";
+    sha256 = "1h2wvd4k7f0l0i1vm9niz453xdbcs3nxccmri50qyrzzzc1b0842";
+  };
+
+  makeFlags = "PREFIX=$(out)";
+
+  meta = with stdenv.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..5e0b7fc300ba
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/ripser/default.nix
@@ -0,0 +1,66 @@
+{ stdenv, fetchurl, fetchFromGitHub
+, assembleReductionMatrix ? false
+, useCoefficients ? false
+, indicateProgress ? false
+, useGoogleHashmap ? false, sparsehash ? null
+, fileFormat ? "lowerTriangularCsv"
+}:
+
+with stdenv.lib;
+
+assert assertOneOf "fileFormat" fileFormat
+  ["lowerTriangularCsv" "upperTriangularCsv" "dipha"];
+assert useGoogleHashmap -> sparsehash != null;
+
+let
+  inherit (stdenv.lib) optional;
+  version = "1.0";
+in
+stdenv.mkDerivation {
+  name = "ripser-${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 = stdenv.lib.licenses.lgpl3;
+    maintainers = with stdenv.lib.maintainers; [erikryb];
+    platforms = stdenv.lib.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..ddb22bcb1ef2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/default.nix
@@ -0,0 +1,169 @@
+{ pkgs
+, withDoc ? false
+}:
+
+# 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) fetchurl symlinkJoin callPackage nodePackages;
+
+  # https://trac.sagemath.org/ticket/15980 for tracking of python3 support
+  python = pkgs.python2.override {
+    packageOverrides = self: super: {
+      # python packages that appear unmaintained and were not accepted into the nixpkgs
+      # tree because of that. These packages are only dependencies of the more-or-less
+      # deprecated sagenb. However sagenb is still a default dependency and the doctests
+      # depend on it.
+      # See https://github.com/NixOS/nixpkgs/pull/38787 for a discussion.
+      # The dependency on the sage notebook (and therefore these packages) will be
+      # removed in the future:
+      # https://trac.sagemath.org/ticket/25837
+      flask-oldsessions = self.callPackage ./flask-oldsessions.nix {};
+      flask-openid = self.callPackage ./flask-openid.nix {};
+      python-openid = self.callPackage ./python-openid.nix {};
+      sagenb = self.callPackage ./sagenb.nix {
+        mathjax = nodePackages.mathjax;
+      };
+
+      # Package with a cyclic dependency with sage
+      pybrial = self.callPackage ./pybrial.nix {};
+
+      # `sagelib`, i.e. all of sage except some wrappers and runtime dependencies
+      sagelib = self.callPackage ./sagelib.nix {
+        inherit flint ecl arb;
+        inherit sage-src pynac singular;
+        linbox = pkgs.linbox.override { withSage = true; };
+        pkg-config = pkgs.pkgconfig; # not to confuse with pythonPackages.pkgconfig
+      };
+    };
+  };
+
+  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}/doc/common/themes/sage/static/sageicon.png";
+    logo64 = "${sage-src}/doc/common/themes/sage/static/sageicon.png";
+  };
+
+  # 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 ecl;
+    inherit singular;
+    cysignals = python.pkgs.cysignals;
+    three = nodePackages.three;
+    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 = python.pkgs.sagelib;
+    inherit env-locations;
+    inherit python ecl singular palp flint pynac pythonEnv;
+    pkg-config = pkgs.pkgconfig; # not to confuse with pythonPackages.pkgconfig
+  };
+
+  # The documentation for sage, building it takes a lot of ram.
+  sagedoc = callPackage ./sagedoc.nix {
+    inherit sage-with-env;
+    inherit python;
+  };
+
+  # 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 pythonEnv;
+    inherit sage-env;
+    inherit pynac singular;
+    pkg-config = pkgs.pkgconfig; # not to confuse with pythonPackages.pkgconfig
+    three = nodePackages.three;
+  };
+
+  # 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 python.pkgs; [
+    sagelib
+    pybrial
+    sagenb
+    cvxopt
+    networkx
+    service-identity
+    psutil
+    sympy
+    fpylll
+    matplotlib
+    tkinter # optional, as a matplotlib backend (use with `%matplotlib tk`)
+    scipy
+    ipywidgets
+    rpy2
+    sphinx
+    typing
+    pillow
+  ];
+
+  pythonEnv = python.buildEnv.override {
+    extraLibs = pythonRuntimeDeps;
+    ignoreCollisions = true;
+  } // { extraLibs = pythonRuntimeDeps; }; # make the libs accessible
+
+  arb = pkgs.arb.override { inherit flint; };
+
+  singular = pkgs.singular.override { inherit flint; };
+
+  # *not* to confuse with the python package "pynac"
+  pynac = pkgs.pynac.override { inherit singular flint; };
+
+  # 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
+    ];
+  };
+
+  # https://trac.sagemath.org/ticket/22191
+  ecl = pkgs.ecl_16_1_2;
+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;
+}
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..8354629cab55
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/env-locations.nix
@@ -0,0 +1,48 @@
+{ writeTextFile
+, pari_data
+, pari
+, singular
+, maxima-ecl
+, conway_polynomials
+, graphs
+, elliptic_curves
+, polytopes_db
+, gap
+, ecl
+, 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 SINGULAR_EXECUTABLE='${singular}/bin/Singular'
+    export MAXIMA_FAS='${maxima-ecl}/lib/maxima/${maxima-ecl.version}/binary-ecl/maxima.fas'
+    export MAXIMA_PREFIX="${maxima-ecl}"
+    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='${ecl}/lib/ecl-${ecl.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}/lib/python2.7/site-packages"
+  '';
+}
diff --git a/nixpkgs/pkgs/applications/science/math/sage/flask-oldsessions.nix b/nixpkgs/pkgs/applications/science/math/sage/flask-oldsessions.nix
new file mode 100644
index 000000000000..85e35736d030
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/flask-oldsessions.nix
@@ -0,0 +1,36 @@
+{ stdenv
+, buildPythonPackage
+, fetchFromGitHub
+, python
+, flask
+}:
+
+buildPythonPackage rec {
+  pname = "Flask-OldSessions";
+  version = "0.10";
+
+  # no artifact on pypi: https://github.com/mitsuhiko/flask-oldsessions/issues/1
+  src = fetchFromGitHub {
+    owner = "mitsuhiko";
+    repo = "flask-oldsessions";
+    rev = "${version}";
+    sha256 = "04b5m8njjiwld9a0zw55iqwvyjgwcpdbhz1cic8nyhgcmypbicqn";
+  };
+
+  propagatedBuildInputs = [
+    flask
+  ];
+
+  # missing module flask.testsuite, probably assumes an old version of flask
+  doCheck = false;
+  checkPhase = ''
+    ${python.interpreter} run-tests.py
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Provides a session class that works like the one in Flask before 0.10.";
+    license = licenses.bsd2;
+    maintainers = with maintainers; [ timokau ];
+    homepage = https://github.com/mitsuhiko/flask-oldsessions;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/sage/flask-openid.nix b/nixpkgs/pkgs/applications/science/math/sage/flask-openid.nix
new file mode 100644
index 000000000000..9043fabd9b4a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/flask-openid.nix
@@ -0,0 +1,28 @@
+{ stdenv
+, buildPythonPackage
+, fetchPypi
+, flask
+, python-openid
+}:
+
+buildPythonPackage rec {
+  pname = "Flask-OpenID";
+  version = "1.2.5";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "1aycwmwi7ilcaa5ab8hm0bp6323zl8z25q9ha0gwrl8aihfgx3ss";
+  };
+
+  propagatedBuildInputs = [
+    flask
+    python-openid
+  ];
+
+  meta = with stdenv.lib; {
+    description = "Adds openid support to flask applications";
+    license = licenses.bsd2;
+    maintainers = with maintainers; [ timokau ];
+    homepage = https://pythonhosted.org/Flask-OpenID/;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/sage/patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch b/nixpkgs/pkgs/applications/science/math/sage/patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch
new file mode 100644
index 000000000000..8cd80281d0e4
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch
@@ -0,0 +1,35 @@
+From 8218bd4fdeb4c92de8af0d3aabec55980fc4fb3d Mon Sep 17 00:00:00 2001
+From: Timo Kaufmann <timokau@zoho.com>
+Date: Sun, 21 Oct 2018 17:52:40 +0200
+Subject: [PATCH] Only test py2/py3 optional tests when all of sage is tested
+
+---
+ src/sage/doctest/control.py | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
+index bf18df8b2b..935c67abf7 100644
+--- a/src/sage/doctest/control.py
++++ b/src/sage/doctest/control.py
+@@ -362,7 +362,8 @@ class DocTestController(SageObject):
+                     if not optionaltag_regex.search(o):
+                         raise ValueError('invalid optional tag {!r}'.format(o))
+ 
+-                options.optional |= auto_optional_tags
++                if "sage" in options.optional:
++                    options.optional |= auto_optional_tags
+ 
+         self.options = options
+ 
+@@ -765,7 +766,7 @@ class DocTestController(SageObject):
+             sage: DC = DocTestController(DD, [dirname])
+             sage: DC.expand_files_into_sources()
+             sage: sorted(DC.sources[0].options.optional)  # abs tol 1
+-            ['guava', 'magma', 'py2']
++            ['guava', 'magma']
+ 
+         We check that files are skipped appropriately::
+ 
+-- 
+2.18.1
+
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/giac-1.5.0.patch b/nixpkgs/pkgs/applications/science/math/sage/patches/giac-1.5.0.patch
new file mode 100644
index 000000000000..58090b241d2d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/patches/giac-1.5.0.patch
@@ -0,0 +1,14 @@
+--- a/src/sage/interfaces/giac.py	2018-12-08 22:11:56.285500644 +0100
++++ b/src/sage/interfaces/giac.py	2018-12-08 22:11:56.285500644 +0100
+@@ -617,10 +617,7 @@
+             '4\n3'
+             sage: s='g(x):={\nx+1;\nx+2;\n}'
+             sage: giac(s)
+-            (x)->{
+-            x+1;
+-            x+2;
+-            }
++            (x)->[x+1,x+2]
+             sage: giac.g(5)
+             7
+         """
diff --git a/nixpkgs/pkgs/applications/science/math/sage/patches/ignore-pip-deprecation.patch b/nixpkgs/pkgs/applications/science/math/sage/patches/ignore-pip-deprecation.patch
new file mode 100644
index 000000000000..95b377dc9550
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/patches/ignore-pip-deprecation.patch
@@ -0,0 +1,22 @@
+diff --git a/src/sage/misc/package.py b/src/sage/misc/package.py
+index 689e5a23b9..4e16fe3a8d 100644
+--- a/src/sage/misc/package.py
++++ b/src/sage/misc/package.py
+@@ -142,9 +142,14 @@ def pip_installed_packages():
+         sage: d['beautifulsoup']   # optional - beautifulsoup
+         u'...'
+     """
+-    proc = subprocess.Popen(["pip", "list", "--no-index", "--format", "json"], stdout=subprocess.PIPE)
+-    stdout = proc.communicate()[0].decode()
+-    return {package['name'].lower():package['version'] for package in json.loads(stdout)}
++    with open(os.devnull, 'w')  as devnull:
++        proc = subprocess.Popen(
++            ["pip", "list", "--no-index", "--format", "json"],
++            stdout=subprocess.PIPE,
++            stderr=devnull,
++        )
++        stdout = proc.communicate()[0].decode()
++        return {package['name'].lower():package['version'] for package in json.loads(stdout)}
+ 
+ def list_packages(*pkg_types, **opts):
+     r"""
diff --git a/nixpkgs/pkgs/applications/science/math/sage/patches/pari-stackwarn.patch b/nixpkgs/pkgs/applications/science/math/sage/patches/pari-stackwarn.patch
new file mode 100644
index 000000000000..49cdfd189b92
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/patches/pari-stackwarn.patch
@@ -0,0 +1,20 @@
+diff --git a/src/sage/doctest/parsing.py b/src/sage/doctest/parsing.py
+index 6bdc9a0..31fc780 100644
+--- a/src/sage/doctest/parsing.py
++++ b/src/sage/doctest/parsing.py
+@@ -40,6 +40,7 @@ from .external import available_software
+ 
+ float_regex = re.compile('\s*([+-]?\s*((\d*\.?\d+)|(\d+\.?))([eE][+-]?\d+)?)')
+ optional_regex = re.compile(r'(py2|py3|long time|not implemented|not tested|known bug)|([^ a-z]\s*optional\s*[:-]*((\s|\w)*))')
++pari_stack_warning_regex = re.compile(r'\s*\*\*\*.*(Warning: increasing stack size to )\d+\.')
+ find_sage_prompt = re.compile(r"^(\s*)sage: ", re.M)
+ find_sage_continuation = re.compile(r"^(\s*)\.\.\.\.:", re.M)
+ random_marker = re.compile('.*random', re.I)
+@@ -935,6 +936,7 @@ class SageOutputChecker(doctest.OutputChecker):
+             <type 'float'>
+         """
+         got = self.human_readable_escape_sequences(got)
++        got = pari_stack_warning_regex.sub('', got)
+         if isinstance(want, MarkedOutput):
+             if want.random:
+                 return True
diff --git a/nixpkgs/pkgs/applications/science/math/sage/patches/python-5755-hotpatch.patch b/nixpkgs/pkgs/applications/science/math/sage/patches/python-5755-hotpatch.patch
new file mode 100644
index 000000000000..1b64f39fe60f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/patches/python-5755-hotpatch.patch
@@ -0,0 +1,28 @@
+diff --git a/src/sage/all.py b/src/sage/all.py
+index ca309ef..be3186b 100644
+--- a/src/sage/all.py
++++ b/src/sage/all.py
+@@ -298,6 +298,23 @@ warnings.filterwarnings('ignore', module='matplotlib[.]font_manager')
+ warnings.filterwarnings('default',
+     '[\s\S]*See http://trac.sagemath.org/[0-9]* for details.')
+ 
++# Hotpatch around https://bugs.python.org/issue5755 which won't be fixed for
++# python 2.7. Idea by https://stackoverflow.com/a/36293331.
++from distutils.command.build_ext import build_ext
++from distutils.sysconfig import customize_compiler
++
++_build_extensions = build_ext.build_extensions
++
++def build_extensions_patched(self):
++    customize_compiler(self.compiler)
++    try:
++        self.compiler.compiler_so.remove("-Wstrict-prototypes")
++    except (AttributeError, ValueError):
++        pass
++    _build_extensions(self)
++
++build_ext.build_extensions = build_extensions_patched
++
+ 
+ # Set a new random number seed as the very last thing
+ # (so that printing initial_seed() and using that seed
diff --git a/nixpkgs/pkgs/applications/science/math/sage/patches/revert-sphinx-always-fork.patch b/nixpkgs/pkgs/applications/science/math/sage/patches/revert-sphinx-always-fork.patch
new file mode 100644
index 000000000000..64dd6fd93777
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/patches/revert-sphinx-always-fork.patch
@@ -0,0 +1,71 @@
+commit f1c59929c3c180ac283334c2b3c901ac8c82f6b1
+Author: Timo Kaufmann <timokau@zoho.com>
+Date:   Sat Oct 20 20:07:41 2018 +0200
+
+    Revert "Something related to the sphinxbuild seems to be leaking memory"
+    
+    This reverts commit 7d85dc796c58c3de57401bc22d3587b94e205091.
+
+diff --git a/src/sage_setup/docbuild/__init__.py b/src/sage_setup/docbuild/__init__.py
+index 0b24b1a60b..084c3f89d7 100644
+--- a/src/sage_setup/docbuild/__init__.py
++++ b/src/sage_setup/docbuild/__init__.py
+@@ -265,29 +265,35 @@ class DocBuilder(object):
+     # import the customized builder for object.inv files
+     inventory = builder_helper('inventory')
+ 
+-def build_many(target, args):
+-    # Pool() uses an actual fork() to run each new instance. This is important
+-    # for performance reasons, i.e., don't use a forkserver when it becomes
+-    # available with Python 3: Here, sage is already initialized which is quite
+-    # costly, with a forkserver we would have to reinitialize it for every
+-    # document we build. At the same time, don't serialize this by taking the
+-    # pool (and thus the call to fork()) out completely: The call to Sphinx
+-    # leaks memory, so we need to build each document in its own process to
+-    # control the RAM usage.
+-    from multiprocessing import Pool
+-    pool = Pool(NUM_THREADS, maxtasksperchild=1)
+-    # map_async handles KeyboardInterrupt correctly. Plain map and
+-    # apply_async does not, so don't use it.
+-    x = pool.map_async(target, args, 1)
+-    try:
+-        ret = x.get(99999)
+-        pool.close()
+-        pool.join()
+-    except Exception:
+-        pool.terminate()
+-        if ABORT_ON_ERROR:
+-            raise
+-    return ret
++if NUM_THREADS > 1:
++    def build_many(target, args):
++        from multiprocessing import Pool
++        pool = Pool(NUM_THREADS, maxtasksperchild=1)
++        # map_async handles KeyboardInterrupt correctly. Plain map and
++        # apply_async does not, so don't use it.
++        x = pool.map_async(target, args, 1)
++        try:
++            ret = x.get(99999)
++            pool.close()
++            pool.join()
++        except Exception:
++            pool.terminate()
++            if ABORT_ON_ERROR:
++                raise
++        return ret
++else:
++    def build_many(target, args):
++        results = []
++
++        for arg in args:
++            try:
++                results.append(target(arg))
++            except Exception:
++                if ABORT_ON_ERROR:
++                    raise
++
++        return results
++
+ 
+ ##########################################
+ #      Parallel Building Ref Manual      #
diff --git a/nixpkgs/pkgs/applications/science/math/sage/pybrial.nix b/nixpkgs/pkgs/applications/science/math/sage/pybrial.nix
new file mode 100644
index 000000000000..f5cb39603c32
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/pybrial.nix
@@ -0,0 +1,29 @@
+{ stdenv
+, fetchFromGitHub
+, buildPythonPackage
+}:
+# This has a cyclic dependency with sage. I don't include sage in the
+# buildInputs and let python figure it out at runtime. Because of this,
+# I don't include the package in the main nipxkgs tree. It wouldn't be useful
+# outside of sage anyways (as you could just directly depend on sage and use
+# it).
+buildPythonPackage rec {
+    pname = "pyBRiAl";
+    version = "1.2.3";
+
+    # included with BRiAl source
+    src = fetchFromGitHub {
+      owner = "BRiAl";
+      repo = "BRiAl";
+      rev = "${version}";
+      sha256 = "0qy4cwy7qrk4zg151cmws5cglaa866z461cnj9wdnalabs7v7qbg";
+    };
+
+    sourceRoot = "source/sage-brial";
+
+    meta = with stdenv.lib; {
+      description = "python implementation of BRiAl";
+      license = licenses.gpl2;
+      maintainers = with maintainers; [ timokau ];
+    };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/sage/python-openid.nix b/nixpkgs/pkgs/applications/science/math/sage/python-openid.nix
new file mode 100644
index 000000000000..1bfe02f50df1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/python-openid.nix
@@ -0,0 +1,40 @@
+{ stdenv
+, buildPythonPackage
+, fetchPypi
+, isPy3k
+, django
+, nose
+, twill
+, pycrypto
+}:
+
+buildPythonPackage rec {
+  pname = "python-openid";
+  version = "2.2.5";
+
+  disabled = isPy3k;
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "1vvhxlghjan01snfdc4k7ykd80vkyjgizwgg9bncnin8rqz1ricj";
+  };
+
+  propagatedBuildInputs = [
+    pycrypto
+  ];
+
+  # Cannot access the djopenid example module.
+  # I don't know how to fix that (adding the examples dir to PYTHONPATH doesn't work)
+  doCheck = false;
+  checkInputs = [ nose django twill ];
+  checkPhase = ''
+    nosetests
+  '';
+
+  meta = with stdenv.lib; {
+    description = "OpenID library for Python";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ timokau ];
+    homepage = https://github.com/openid/python-openid/;
+  };
+}
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..8fd69f62171a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/sage-env.nix
@@ -0,0 +1,169 @@
+{ stdenv
+, lib
+, writeTextFile
+, python
+, sagelib
+, env-locations
+, gfortran
+, bash
+, coreutils
+, gnused
+, gnugrep
+, binutils
+, pythonEnv
+, python3
+, pkg-config
+, pari
+, gap
+, ecl
+, maxima-ecl
+, singular
+, giac
+, palp
+, rWrapper
+, gfan
+, cddlib
+, jmol
+, tachyon
+, glpk
+, eclib
+, sympow
+, nauty
+, sqlite
+, ppl
+, ecm
+, lcalc
+, rubiks
+, flintqs
+, openblasCompat
+, flint
+, gmp
+, mpfr
+, pynac
+, zlib
+, gsl
+, ntl
+, jdk
+}:
+
+# 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
+    # empty python env to add python wrapper that clears PYTHONHOME (see
+    # wrapper.nix). This is necessary because sage will call the python3 binary
+    # (from python2 code). The python2 PYTHONHOME (again set in wrapper.nix)
+    # will then confuse python3, if it is not overwritten.
+    python3.buildEnv
+    gfortran # for inline fortran
+    stdenv.cc # for cython
+    bash
+    coreutils
+    gnused
+    gnugrep
+    binutils.bintools
+    pkg-config
+    pari
+    gap
+    ecl
+    maxima-ecl
+    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
+  ]
+  ));
+in
+writeTextFile rec {
+  name = "sage-env";
+  destination = "/${name}";
+  text = ''
+    export PKG_CONFIG_PATH='${lib.concatStringsSep ":" (map (pkg: "${pkg}/lib/pkgconfig") [
+        # This is only needed in the src/sage/misc/cython.py test and I'm not
+        # sure if there's really a usecase for it outside of the tests. However
+        # since singular and openblas are runtime dependencies anyways, it doesn't
+        # really hurt to include.
+        singular
+        openblasCompat
+      ])
+    }'
+    export SAGE_ROOT='${sagelib.src}'
+    export SAGE_LOCAL='@sage-local@'
+    export SAGE_SHARE='${sagelib}/share'
+    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
+        pynac
+        zlib
+        eclib
+        gsl
+        ntl
+        jmol
+        sympow
+      ])
+    }'
+    export CFLAGS='${
+      lib.concatStringsSep " " (map (pkg: "-isystem ${pkg}/include") [
+        singular
+        gmp.dev
+        glpk
+        flint
+        gap
+        pynac
+        mpfr.dev
+      ])
+    }'
+
+    export SAGE_LIB='${sagelib}/${python.sitePackages}'
+
+    export SAGE_EXTCODE='${sagelib.src}/src/ext'
+
+  # for find_library
+    export DYLD_LIBRARY_PATH="${lib.makeLibraryPath [stdenv.cc.libc singular]}:$DYLD_LIBRARY_PATH"
+  '';
+} // {
+  lib = sagelib; # equivalent of `passthru`, which `writeTextFile` doesn't support
+}
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..834590216870
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/sage-src.nix
@@ -0,0 +1,143 @@
+{ 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.
+
+stdenv.mkDerivation rec {
+  version = "8.6";
+  name = "sage-src-${version}";
+
+  src = fetchFromGitHub {
+    owner = "sagemath";
+    repo = "sage";
+    rev = version;
+    sha256 = "1vs3pbgbqpg0qnwr018bqsdmm7crgjp310cx8zwh7za3mv1cw5j3";
+  };
+
+  # 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 = [
+    # https://trac.sagemath.org/ticket/25358
+    (fetchpatch {
+      name = "safe-directory-test-without-patch.patch";
+      url = "https://git.sagemath.org/sage.git/patch?id2=8bdc326ba57d1bb9664f63cf165a9e9920cc1afc&id=dc673c17555efca611f68398d5013b66e9825463";
+      sha256 = "1hhannz7xzprijakn2w2d0rhd5zv2zikik9p51i87bas3nc658f7";
+    })
+
+    # Unfortunately inclusion in upstream sage was rejected. Instead the bug was
+    # fixed in python, but of course not backported to 2.7. So we'll probably
+    # have to keep this around until 2.7 is deprecated.
+    # https://trac.sagemath.org/ticket/25316
+    # https://github.com/python/cpython/pull/7476
+    ./patches/python-5755-hotpatch.patch
+
+    # Revert the commit that made the sphinx build fork even in the single thread
+    # case. For some yet unknown reason, that breaks the docbuild on nix and archlinux.
+    # See https://groups.google.com/forum/#!msg/sage-packaging/VU4h8IWGFLA/mrmCMocYBwAJ.
+    # https://trac.sagemath.org/ticket/26608
+    ./patches/revert-sphinx-always-fork.patch
+
+    # Make sure py2/py3 tests are only run when their expected context (all "sage"
+    # tests) are also run. That is necessary to test dochtml individually. See
+    # https://trac.sagemath.org/ticket/26110 for an upstream discussion.
+    ./patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch
+
+    # Fixes a potential race condition which can lead to transient doctest failures.
+    ./patches/fix-ecl-race.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 = 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, rev, name ? "sage-diff-${base}-${rev}.patch", ...}@args: (
+      fetchpatch ({
+        inherit name;
+        url = "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" ])
+    );
+  in [
+    # New glpk version has new warnings, filter those out until upstream sage has found a solution
+    # Should be fixed with glpk > 4.65.
+    # https://trac.sagemath.org/ticket/24824
+    ./patches/pari-stackwarn.patch # not actually necessary since the pari upgrade, but necessary for the glpk patch to apply
+    (fetchpatch {
+      url = "https://salsa.debian.org/science-team/sagemath/raw/58bbba93a807ca2933ca317501d093a1bb4b84db/debian/patches/dt-version-glpk-4.65-ignore-warnings.patch";
+      sha256 = "0b9293v73wb4x13wv5zwyjgclc01zn16msccfzzi6znswklgvddp";
+      stripLen = 1;
+    })
+
+    # https://trac.sagemath.org/ticket/26315
+    ./patches/giac-1.5.0.patch
+
+    # https://trac.sagemath.org/ticket/26442
+    (fetchSageDiff {
+      name = "cypari2-2.0.3.patch";
+      base = "8.6.rc1";
+      rev = "cd62d45bcef93fb4f7ed62609a46135e6de07051";
+      sha256 = "08l2b9w0rn1zrha6188j72f7737xs126gkgmydjd31baa6367np2";
+    })
+
+    # https://trac.sagemath.org/ticket/26949
+    (fetchpatch {
+      name = "sphinx-1.8.3-dependency.patch";
+      url = "https://git.sagemath.org/sage.git/patch?id=d305eda0fedc73fdbe0447b5d6d2b520b8d112c4";
+      sha256 = "1x3q5j8lq35vlj893gj5gq9fhzs60szm9r9rx6ri79yiy9apabph";
+    })
+    # https://trac.sagemath.org/ticket/26451
+    (fetchpatch {
+      name = "sphinx-1.8.3.patch";
+      url = "https://git.sagemath.org/sage.git/patch?id2=0cb494282d7b4cea50aba7f4d100e7932a4c00b1&id=62b989d5ee1d9646db85ea56053cd22e9ffde5ab";
+      sha256 = "1n5c61mvhalcr2wbp66wzsynwwk59aakvx3xqa5zw9nlkx3rd0h1";
+    })
+
+    # https://trac.sagemath.org/ticket/27061
+    (fetchpatch {
+      name = "numpy-1.16-inline-fortran.patch";
+      url = "https://git.sagemath.org/sage.git/patch?id=a05b6b038e1571ab15464e98f76d1927c0c3fd12";
+      sha256 = "05yq97pq84xi60wb1p9skrad5h5x770gq98ll4frr7hvvmlwsf58";
+    })
+
+    # https://trac.sagemath.org/ticket/27405
+    ./patches/ignore-pip-deprecation.patch
+  ];
+
+  patches = nixPatches ++ packageUpgradePatches;
+
+  postPatch = ''
+    # make sure shebangs etc are fixed, but sage-python23 still works
+    find . -type f -exec sed \
+      -e 's/sage-python23/python/g' \
+      -i {} \;
+
+    echo '#!${runtimeShell}
+    python "$@"' > build/bin/sage-python23
+
+    # Do not use sage-env-config (generated by ./configure).
+    # Instead variables are set manually.
+    echo '# do nothing' >  src/bin/sage-env-config
+  '';
+
+  configurePhase = "# do nothing";
+
+  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..12433e12fe90
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/sage-tests.nix
@@ -0,0 +1,57 @@
+{ 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 rec {
+  version = src.version;
+  name = "sage-tests-${version}";
+  inherit src;
+
+  buildInputs = [
+    makeWrapper
+    sage-with-env
+  ];
+
+  unpackPhase = "#do nothing";
+  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"
+
+    echo "Running sage tests with arguments ${timeSpecifier} ${patienceSpecifier} ${testArgs}"
+    "sage" -t --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..18060f342a92
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/sage-with-env.nix
@@ -0,0 +1,126 @@
+{ stdenv
+, lib
+, makeWrapper
+, sage-env
+, openblasCompat
+, pkg-config
+, three
+, singular
+, gap
+, giac
+, maxima-ecl
+, pari
+, gmp
+, gfan
+, python2
+, flintqs
+, eclib
+, ntl
+, ecm
+, pynac
+, pythonEnv
+}:
+
+# 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
+    openblasCompat # lots of segfaults with regular (64 bit) openblas
+    singular
+    three
+    pynac
+    giac
+    gap
+    pari
+    gmp
+    gfan
+    maxima-ecl
+    eclib
+    flintqs
+    ntl
+    ecm
+  ];
+
+  # remove python prefix, replace "-" in the name by "_", apply patch_names
+  # python2.7-some-pkg-1.0 -> some_pkg-1.0
+  pkg_to_spkg_name = pkg: patch_names: let
+    parts = lib.splitString "-" pkg.name;
+    # remove python2.7-
+    stripped_parts = if (builtins.head parts) == python2.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 isNull dep 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;
+  name = "sage-with-env-${version}";
+  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
+  '';
+
+  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"
+
+    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..541b9cb36dc2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/sage.nix
@@ -0,0 +1,68 @@
+{ stdenv
+, makeWrapper
+, sage-tests
+, sage-with-env
+, jupyter-kernel-definition
+, jupyter-kernel
+, sagedoc
+, withDoc
+}:
+
+# 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;
+  name = "sage-${version}";
+  src = sage-with-env.env.lib.src;
+
+  buildInputs = [
+    makeWrapper
+
+    # 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
+  ];
+
+  unpackPhase = "#do nothing";
+  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" ${
+        stdenv.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 stdenv.lib; {
+    description = "Open Source Mathematics Software, free alternative to Magma, Maple, Mathematica, and Matlab";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ timokau ];
+  };
+}
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..cc1a4fc61e0c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/sagedoc.nix
@@ -0,0 +1,81 @@
+{ stdenv
+, sage-with-env
+, python
+, maxima-ecl
+, tachyon
+, jmol
+, cddlib
+}:
+
+stdenv.mkDerivation rec {
+  version = src.version;
+  name = "sagedoc-${version}";
+  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
+    python
+    maxima-ecl
+    tachyon
+    jmol
+    cddlib
+  ] ++ (with python.pkgs; [
+    psutil
+    future
+    sphinx
+    sagenb
+    scipy
+    sympy
+    matplotlib
+    pillow
+    networkx
+    ipykernel
+    ipywidgets
+    jupyter_client
+    typing
+    pybrial
+  ]);
+
+  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"
+
+    ${sage-with-env}/bin/sage -python -m sage_setup.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 -s /share/doc/sage/html/en/_static $_dir
+    done
+    mv html/en/_static{.tmp,}
+  '';
+
+  doCheck = true;
+  checkPhase = ''
+    ${sage-with-env}/bin/sage -t --optional=dochtml --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..d7f9cb9ee321
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/sagelib.nix
@@ -0,0 +1,144 @@
+{ sage-src
+, perl
+, buildPythonPackage
+, arb
+, openblasCompat
+, brial
+, cliquer
+, cypari2
+, cysignals
+, cython
+, ecl
+, eclib
+, ecm
+, flint
+, gd
+, givaro
+, glpk
+, gsl
+, iml
+, jinja2
+, lcalc
+, lrcalc
+, gap
+, linbox
+, m4ri
+, m4rie
+, libmpc
+, mpfi
+, ntl
+, numpy
+, pari
+, pkgconfig
+, pkg-config
+, planarity
+, ppl
+, pynac
+, python
+, ratpoints
+, readline
+, rankwidth
+, symmetrica
+, zn_poly
+, fflas-ffpack
+, boost
+, singular
+, pip
+, jupyter_core
+, libhomfly
+, libbraiding
+}:
+
+# 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 {
+  format = "other";
+  version = src.version;
+  name = "sagelib-${version}";
+  src = sage-src;
+
+  nativeBuildInputs = [
+    iml
+    perl
+    jupyter_core
+    pkg-config
+    pip # needed to query installed packages
+  ];
+
+  buildInputs = [
+    gd
+    readline
+    iml
+  ];
+
+  propagatedBuildInputs = [
+    cypari2
+    jinja2
+    numpy
+    pkgconfig
+    boost
+    arb
+    brial
+    cliquer
+    ecl
+    eclib
+    ecm
+    fflas-ffpack
+    flint
+    givaro
+    glpk
+    gsl
+    lcalc
+    gap
+    libmpc
+    linbox
+    lrcalc
+    m4ri
+    m4rie
+    mpfi
+    ntl
+    openblasCompat
+    pari
+    planarity
+    ppl
+    pynac
+    rankwidth
+    ratpoints
+    singular
+    symmetrica
+    zn_poly
+    pip
+    cython
+    cysignals
+    libhomfly
+    libbraiding
+  ];
+
+  buildPhase = ''
+    export SAGE_ROOT="$PWD"
+    export SAGE_LOCAL="$SAGE_ROOT"
+    export SAGE_SHARE="$SAGE_LOCAL/share"
+    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 src
+    source bin/sage-dist-helpers
+
+    ${python.interpreter} -u setup.py --no-user-cfg build
+  '';
+
+  installPhase = ''
+    ${python.interpreter} -u setup.py --no-user-cfg install --prefix=$out
+
+    rm -r "$out/${python.sitePackages}/sage/cython_debug"
+  '';
+}
diff --git a/nixpkgs/pkgs/applications/science/math/sage/sagenb.nix b/nixpkgs/pkgs/applications/science/math/sage/sagenb.nix
new file mode 100644
index 000000000000..32335b452020
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/sage/sagenb.nix
@@ -0,0 +1,53 @@
+{ stdenv
+, fetchpatch
+, python
+, buildPythonPackage
+, fetchFromGitHub
+, mathjax
+, twisted
+, flask
+, flask-oldsessions
+, flask-openid
+, flask-autoindex
+, flask-babel
+}:
+
+# Has a cyclic dependency with sage (not expressed here) and is not useful outside of sage.
+# Deprecated, hopefully soon to be removed. See
+# https://trac.sagemath.org/ticket/25837
+
+buildPythonPackage rec {
+  pname = "sagenb";
+  version = "1.1.2";
+
+  src = fetchFromGitHub {
+    owner = "sagemath";
+    repo = "sagenb";
+    rev = version;
+    sha256 = "0bxvhr03qh2nsjdfc4pyfiqrn9jhp3vf7irsc9gqx0185jlblbxs";
+  };
+
+  propagatedBuildInputs = [
+    twisted
+    flask
+    flask-oldsessions
+    flask-openid
+    flask-autoindex
+    flask-babel
+  ];
+
+  # tests depend on sage
+  doCheck = false;
+
+  meta = with stdenv.lib; {
+    description = "Sage Notebook";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ timokau ];
+  };
+
+  # let sagenb use mathjax
+  postInstall = ''
+    mkdir -p "$out/${python.sitePackages}/sagenb/data"
+    ln -s ${mathjax}/lib/node_modules/mathjax "$out/${python.sitePackages}/sagenb/data/mathjax"
+  '';
+}
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..c3a74d14bc0a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/scilab-bin/default.nix
@@ -0,0 +1,106 @@
+{ stdenv, fetchurl, lib, xorg }:
+
+let
+  name = "scilab-bin-${ver}";
+
+  ver = "6.0.1";
+
+  majorVer = builtins.elemAt (lib.splitString "." ver) 0;
+
+  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 rec {
+  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
+        "1scswlznc14vyzg0gqa1q9gcpwx05kz1sbn563463mzkdp7nd35d"
+      else
+        badArch;
+  };
+
+  libPath = lib.makeLibraryPath [
+    stdenv.cc.cc
+    xorg.libX11
+    xorg.libXext
+    xorg.libXi
+    xorg.libXrender
+    xorg.libXtst
+    xorg.libXxf86vm
+  ];
+
+  phases = [ "unpackPhase" "fixupPhase" "installPhase" ];
+
+  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..01fb58403cad
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/scilab/default.nix
@@ -0,0 +1,66 @@
+{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";
+  name = "scilab-${version}";
+  src = fetchurl {
+    url = "https://www.scilab.org/download/${version}/${name}-src.tar.gz";
+    sha256 = "1adk6jqlj7i3gjklvlf1j3il1nb22axnp4rvwl314an62siih0sc";
+  };
+
+  buildInputs = [gfortran 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
+    (stdenv.lib.enableFeature withGtk "gtk")
+    (stdenv.lib.enableFeature withGtk "gtk2")
+    # compile with ocaml
+    (stdenv.lib.withFeature withOCaml "ocaml")
+    # do not compile Java interface
+    "--without-java"
+    # use the X Window System
+    (stdenv.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..8fa020ba07c9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/scotch/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, fetchurl, bison, openmpi, flex, zlib}:
+
+stdenv.mkDerivation rec {
+  version = "6.0.4";
+  name = "scotch-${version}";
+  src_name = "scotch_${version}";
+
+  buildInputs = [ bison openmpi flex zlib ];
+
+  src = fetchurl {
+    url = "https://gforge.inria.fr/frs/download.php/file/34618/${src_name}.tar.gz";
+    sha256 = "f53f4d71a8345ba15e2dd4e102a35fd83915abf50ea73e1bf6efe1bc2b4220c7";
+  };
+
+  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 = stdenv.lib.licenses.cecill-c;
+    maintainers = [ stdenv.lib.maintainers.bzizou ];
+    platforms = stdenv.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..24063216db04
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/singular/default.nix
@@ -0,0 +1,118 @@
+{ stdenv, fetchurl, gmp, bison, perl, ncurses, readline, coreutils, pkgconfig
+, lib
+, fetchpatch
+, autoreconfHook
+, file
+, flint
+, ntl
+, cddlib
+, enableFactory ? true
+, enableGfanlib ? true
+}:
+
+stdenv.mkDerivation rec {
+  name = "singular-${version}";
+  version = "4.1.1p2";
+
+  src = let
+    # singular sorts its tarballs in directories by base release (without patch version)
+    # for example 4.1.1p1 will be in the directory 4-1-1
+    baseVersion = builtins.head (lib.splitString "p" version);
+    urlVersion = builtins.replaceStrings [ "." ] [ "-" ] baseVersion;
+  in
+  fetchurl {
+    url = "http://www.mathematik.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${urlVersion}/singular-${version}.tar.gz";
+    sha256 = "07x9kri8vl4galik7lr6pscq3c51n8570pyw64i7gbj0m706f7wf";
+  };
+
+  configureFlags = [
+    "--with-ntl=${ntl}"
+  ] ++ lib.optionals enableFactory [
+    "--enable-factory"
+  ] ++ lib.optionals enableGfanlib [
+    "--enable-gfanlib"
+  ];
+
+  postUnpack = ''
+    patchShebangs .
+  '';
+
+  patches = [
+    # NTL error handler was introduced in the library part, preventing users of
+    # the library from implementing their own error handling
+    # https://www.singular.uni-kl.de/forum/viewtopic.php?t=2769
+    (fetchpatch {
+      name = "move_error_handler_out_of_libsingular.patch";
+      # rebased version of https://github.com/Singular/Sources/commit/502cf86d0bb2a96715be6764774b64a69c1ca34c.patch
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/singular/patches/singular-ntl-error-handler.patch?h=50b9ae2fd233c30860e1cbb3e63a26f2cc10560a";
+      sha256 = "0vgh4m9zn1kjl0br68n04j4nmn5i1igfn28cph0chnwf7dvr9194";
+    })
+  ];
+
+  # For reference (last checked on commit 75f460d):
+  # https://github.com/Singular/Sources/blob/spielwiese/doc/Building-Singular-from-source.md
+  # https://github.com/Singular/Sources/blob/spielwiese/doc/external-packages-dynamic-modules.md
+  buildInputs = [
+    # necessary
+    gmp
+    # by upstream recommended but optional
+    ncurses
+    readline
+    ntl
+    flint
+  ] ++ lib.optionals enableGfanlib [
+    cddlib
+  ];
+  nativeBuildInputs = [
+    bison
+    perl
+    pkgconfig
+    autoreconfHook
+  ];
+
+  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";
+
+  # The Makefile actually defaults to `make install` anyway
+  buildPhase = ''
+    # do nothing
+  '';
+
+  installPhase = ''
+    mkdir -p "$out"
+    cp -r Singular/LIB "$out/lib"
+    make install
+
+    # Make sure patchelf picks up the right libraries
+    rm -rf libpolys factory resources omalloc Singular
+  '';
+
+  # simple test to make sure singular starts and finds its libraries
+  doInstallCheck = true;
+  installCheckPhase = ''
+    "$out/bin/Singular" -c 'LIB "freegb.lib"; exit;'
+    if [ $? -ne 0 ]; then
+        echo >&2 "Error loading the freegb library in Singular."
+        exit 1
+    fi
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    description = "A CAS for polynomial computations";
+    maintainers = with maintainers; [ raskin timokau ];
+    # 32 bit x86 fails with some link error: `undefined reference to `__divmoddi4@GCC_7.0.0'`
+    platforms = subtractLists platforms.i686 platforms.linux;
+    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/";
+  };
+}
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..d36b135531c2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/speedcrunch/default.nix
@@ -0,0 +1,37 @@
+{ mkDerivation, lib, fetchgit, cmake, qtbase, qttools }:
+
+mkDerivation rec {
+  name = "speedcrunch-${version}";
+  version = "0.12.0";
+
+  src = fetchgit {
+    # the tagging is not standard, so you probably need to check this when updating
+    rev = "refs/tags/release-${version}";
+    url = "https://bitbucket.org/heldercorreia/speedcrunch";
+    sha256 = "0vh7cd1915bjqzkdp3sk25ngy8cq624mkh8c53c5bnzk357kb0fk";
+  };
+
+  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 ];
+    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..bc971606cd08
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/symmetrica/default.nix
@@ -0,0 +1,62 @@
+{ stdenv
+, fetchurl
+, fetchpatch
+}:
+stdenv.mkDerivation rec {
+  name = "symmetrica-${version}";
+  version = "2.0";
+
+  src = fetchurl {
+    url = "http://www.algorithm.uni-bayreuth.de/en/research/SYMMETRICA/SYM2_0_tar.gz";
+    sha256 = "1qhfrbd5ybb0sinl9pad64rscr08qvlfzrzmi4p4hk61xn6phlmz";
+    name = "symmetrica-2.0.tar.gz";
+  };
+
+  sourceRoot = ".";
+
+  patches = [
+      # don't show banner ("SYMMETRICA VERSION X - STARTING)
+      # it doesn't contain very much helpful information and a banner is not ideal for a library
+      (fetchpatch {
+        url = "https://git.sagemath.org/sage.git/plain/build/pkgs/symmetrica/patches/de.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+        sha256 = "0df0vqixcfpzny6dkhyj87h8aznz3xn3zfwwlj8pd10bpb90k6gb";
+      })
+
+      # use int32_t and uint32_t for type INT
+      # see https://trac.sagemath.org/ticket/13413
+      (fetchpatch {
+        name = "fix_64bit_integer_overflow.patch";
+        url = "https://git.sagemath.org/sage.git/plain/build/pkgs/symmetrica/patches/int32.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+        sha256 = "0p33c85ck4kd453z687ni4bdcqr1pqx2756j7aq11bf63vjz4cyz";
+      })
+
+      (fetchpatch {
+        url = "https://git.sagemath.org/sage.git/plain/build/pkgs/symmetrica/patches/return_values.patch?id=1615f58890e8f9881c4228c78a6b39b9aab1303a";
+        sha256 = "0dmczkicwl50sivc07w3wm3jpfk78wm576dr25999jdj2ipsb7nk";
+      })
+  ];
+
+  postPatch = ''
+    substituteInPlace makefile --replace gcc cc
+  '';
+
+  enableParallelBuilding = true;
+
+  installPhase = ''
+    mkdir -p "$out"/{lib,share/doc/symmetrica,include/symmetrica}
+    ar crs libsymmetrica.a *.o
+    ranlib libsymmetrica.a
+    cp libsymmetrica.a "$out/lib"
+    cp *.h "$out/include/symmetrica"
+    cp README *.doc "$out/share/doc/symmetrica"
+  '';
+
+  meta = {
+    inherit version;
+    description = ''A collection of routines for representation theory and combinatorics'';
+    license = stdenv.lib.licenses.publicDomain;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.unix;
+    homepage = http://www.algorithm.uni-bayreuth.de/en/research/SYMMETRICA/index.html;
+  };
+}
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..3bfb22dad936
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/weka/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchurl, jre, unzip, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "weka-${version}";
+  version = "3.9.2";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/weka/${stdenv.lib.replaceChars ["."]["-"] name}.zip";
+    sha256 = "0zwmhspmqb0a7cm6k6i0s6q3w19ws1g9dx3cp2v3g3vsif6cdh31";
+  };
+
+  buildInputs = [ unzip makeWrapper ];
+
+  # 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 = stdenv.lib.licenses.gpl2Plus;
+    maintainers = [ stdenv.lib.maintainers.mimadrid ];
+    platforms = stdenv.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..13ccd70c83f9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/wxmaxima/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchFromGitHub
+, wrapGAppsHook, cmake, gettext
+, maxima, wxGTK, gnome3 }:
+
+stdenv.mkDerivation rec {
+  name = "wxmaxima-${version}";
+  version = "19.03.0";
+
+  src = fetchFromGitHub {
+    owner = "andrejv";
+    repo = "wxmaxima";
+    rev = "Version-${version}";
+    sha256 = "0s7bdykc77slqix28cyaa6x8wvxrn8461mkdgxflvi2apwsl56aa";
+  };
+
+  buildInputs = [ wxGTK maxima gnome3.adwaita-icon-theme ];
+
+  nativeBuildInputs = [ wrapGAppsHook cmake gettext ];
+
+  preConfigure = ''
+    gappsWrapperArgs+=(--prefix PATH ":" ${maxima}/bin)
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "Cross platform GUI for the computer algebra system Maxima";
+    license = licenses.gpl2;
+    homepage = https://wxmaxima-developers.github.io/wxmaxima/;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.peti ];
+  };
+}
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..c02ef73df119
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/yacas/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchFromGitHub, cmake, perl
+, enableGui ? false, qt5
+, enableJupyter ? false, boost, jsoncpp, openssl, zmqpp
+}:
+
+stdenv.mkDerivation rec {
+  name = "yacas-${version}";
+  version = "1.6.1";
+
+  src = fetchFromGitHub {
+    owner = "grzegorzmazur";
+    repo = "yacas";
+    rev = "v${version}";
+    sha256 = "0awvlvf607r4hwl1vkhs6jq2s6ig46c66pmr4vspj2cdnypx99cc";
+  };
+
+  hardeningDisable = [ "format" ];
+
+  cmakeFlags = [
+    "-DENABLE_CYACAS_GUI=${if enableGui then "ON" else "OFF"}"
+    "-DENABLE_CYACAS_KERNEL=${if enableJupyter then "ON" else "OFF"}"
+  ];
+
+  # Perl is only for the documentation
+  nativeBuildInputs = [ cmake perl ];
+  buildInputs = [
+  ] ++ stdenv.lib.optionals enableGui (with qt5; [ qtbase qtwebkit ])
+    ++ stdenv.lib.optionals enableJupyter [ boost jsoncpp openssl zmqpp ]
+    ;
+
+  meta = {
+    description = "Easy to use, general purpose Computer Algebra System";
+    homepage = http://www.yacas.org/;
+    license = stdenv.lib.licenses.gpl2Plus;
+    maintainers = with stdenv.lib.maintainers; [viric];
+    platforms = with stdenv.lib.platforms; linux;
+    broken = enableGui || enableJupyter;
+  };
+}
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..ff25bc974900
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/medicine/aliza/default.nix
@@ -0,0 +1,52 @@
+{ stdenv, fetchurl, rpmextract, makeWrapper, patchelf, qt4, zlib, libX11, libXt, libSM, libICE, libXext, libGLU_combined }:
+
+with stdenv.lib;
+stdenv.mkDerivation {
+  name = "aliza";
+  src = fetchurl {
+    # Hosted on muoniurn's google drive
+    url = "https://drive.google.com/uc?export=download&id=1zMYfSUqMaYuvuF41zAFUC5ndR55wD7Ip";
+    sha256 = "0prlmzz8qbqqkr0plk781afq25dvy4pv89vlgccpim79psqlchl3";
+    name = "aliza.rpm";
+  };
+
+  buildInputs = [ rpmextract makeWrapper ];
+
+  unpackCmd = "rpmextract $curSrc";
+
+  patchPhase = ''
+    sed -i 's/^Exec.*$/Exec=aliza %F/' share/applications/aliza.desktop
+  '';
+
+  installPhase = ''
+    mkdir -p $out
+    cp -r bin share $out
+
+    runHook postInstall
+  '';
+
+  postInstall = let
+    libs = stdenv.lib.makeLibraryPath [ qt4 zlib stdenv.cc.cc libSM libICE libX11 libXext libXt libGLU_combined ];
+  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 = http://www.aliza-dicom-viewer.com;
+    license = licenses.unfreeRedistributable;
+    maintainers = with maintainers; [ mounium ];
+  };
+}
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..3571d705e311
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/boinc/default.nix
@@ -0,0 +1,46 @@
+{ fetchFromGitHub, stdenv, autoconf, automake, pkgconfig, m4, curl,
+libGLU_combined, libXmu, libXi, freeglut, libjpeg, libtool, wxGTK30, xcbutil,
+sqlite, gtk2, patchelf, libXScrnSaver, libnotify, libX11, libxcb }:
+
+let
+  majorVersion = "7.14";
+  minorVersion = "2";
+in
+
+stdenv.mkDerivation rec {
+  version = "${majorVersion}.${minorVersion}";
+  name = "boinc-${version}";
+
+  src = fetchFromGitHub {
+    name = "${name}-src";
+    owner = "BOINC";
+    repo = "boinc";
+    rev = "client_release/${majorVersion}/${version}";
+    sha256 = "0nicpkag18xq0libfqqvs0im22mijpsxzfk272iwdd9l0lmgfvyd";
+  };
+
+  nativeBuildInputs = [ libtool automake autoconf m4 pkgconfig ];
+
+  buildInputs = [
+    curl libGLU_combined 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" ];
+
+  meta = {
+    description = "Free software for distributed and grid computing";
+    homepage = http://boinc.berkeley.edu/;
+    license = stdenv.lib.licenses.lgpl2Plus;
+    platforms = stdenv.lib.platforms.linux;  # arbitrary choice
+  };
+}
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..36c7884d108b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/cytoscape/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, jre, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "cytoscape-${version}";
+  version = "3.6.1";
+
+  src = fetchurl {
+    url = "http://chianti.ucsd.edu/${name}/${name}.tar.gz";
+    sha256 = "1pkdilv1nw6vvdxk71bwjngr8yafrsqwaqvlakhp8yb342r1jd4s";
+  };
+
+  buildInputs = [jre makeWrapper];
+
+  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 = stdenv.lib.licenses.lgpl21;
+    maintainers = [stdenv.lib.maintainers.mimadrid];
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
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..8d0336f58282
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/fityk/default.nix
@@ -0,0 +1,28 @@
+{ 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 = stdenv.lib.licenses.gpl2;
+    homepage = http://fityk.nieto.pl/;
+    platforms = stdenv.lib.platforms.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..b81f188a91bf
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/gephi/default.nix
@@ -0,0 +1,64 @@
+{ 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 rec {
+  name = "gephi-${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 stdenv.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..99159fba5b43
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/golly/beta.nix
@@ -0,0 +1,51 @@
+{stdenv, fetchgit
+, wxGTK, perl, python2, zlib, libGLU_combined, 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_combined 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 = {
+    inherit version;
+    description = "Cellular automata simulation program";
+    license = stdenv.lib.licenses.gpl2;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.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..74fa4cc02ed5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/golly/default.nix
@@ -0,0 +1,39 @@
+{stdenv, fetchurl, wxGTK, perl, python2, zlib, libGLU_combined, libX11}:
+stdenv.mkDerivation rec {
+  pname = "golly";
+  version = "3.2";
+
+  src = fetchurl {
+    sha256 = "0cg9mbwmf4q6qxhqlnzrxh9y047banxdb8pd3hgj3smmja2zf0jd";
+    url="mirror://sourceforge/project/golly/golly/golly-${version}/golly-${version}-src.tar.gz";
+  };
+
+  buildInputs = [
+    wxGTK perl python2 zlib libGLU_combined libX11
+  ];
+
+  setSourceRoot = ''
+    sourceRoot=$(echo */gui-wx/configure)
+  '';
+
+  # Link against Python explicitly as it is needed for scripts
+  makeFlags=[
+    "AM_LDFLAGS="
+  ];
+  NIX_LDFLAGS="-l${python2.libPrefix} -lperl";
+  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)")"
+  '';
+
+  meta = {
+    inherit version;
+    description = "Cellular automata simulation program";
+    license = stdenv.lib.licenses.gpl2;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.linux;
+    downloadPage = "https://sourceforge.net/projects/golly/files/golly";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/golly/default.upstream b/nixpkgs/pkgs/applications/science/misc/golly/default.upstream
new file mode 100644
index 000000000000..e8ce81586a8d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/golly/default.upstream
@@ -0,0 +1,5 @@
+url https://sourceforge.net/projects/golly/files/golly/
+version_link '[-][0-9.]+/$'
+SF_version_tarball 'src'
+SF_redirect
+minimize_overwrite
diff --git a/nixpkgs/pkgs/applications/science/misc/gplates/boostfix.patch b/nixpkgs/pkgs/applications/science/misc/gplates/boostfix.patch
new file mode 100644
index 000000000000..e429600b7095
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/gplates/boostfix.patch
@@ -0,0 +1,612 @@
+--- a/src/app-logic/ApplicationState.h
++++ b/src/app-logic/ApplicationState.h
+@@ -33,6 +33,7 @@
+ #include <boost/shared_ptr.hpp>

+ #include <QObject>

+ 

++#ifndef Q_MOC_RUN

+ #include "FeatureCollectionFileState.h"

+ #include "Layer.h"

+ #include "LayerTaskRegistry.h"

+@@ -48,6 +49,7 @@
+ #include "model/ModelInterface.h"

+ #include "model/types.h"

+ #include "model/WeakReferenceCallback.h"

++#endif

+ 

+ ////////////////////////////////////////////////////////////////////////////////////////////////

+ // NOTE: Please use forward declarations (and boost::scoped_ptr) instead of including headers

+--- a/src/app-logic/CoRegistrationLayerTask.h
++++ b/src/app-logic/CoRegistrationLayerTask.h
+@@ -32,11 +32,13 @@
+ #include <QObject>

+ #include <QString>

+ 

++#ifndef Q_MOC_RUN

+ #include "CoRegistrationLayerParams.h"

+ #include "CoRegistrationLayerProxy.h"

+ #include "LayerTask.h"

+ 

+ #include "model/FeatureCollectionHandle.h"

++#endif

+ 

+ namespace GPlatesAppLogic

+ {

+--- a/src/app-logic/RasterLayerTask.h
++++ b/src/app-logic/RasterLayerTask.h
+@@ -32,11 +32,13 @@
+ #include <QObject>

+ #include <QString>

+ 

++#ifndef Q_MOC_RUN

+ #include "LayerTask.h"

+ #include "RasterLayerParams.h"

+ #include "RasterLayerProxy.h"

+ 

+ #include "model/FeatureCollectionHandle.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/app-logic/ReconstructGraph.h
++++ b/src/app-logic/ReconstructGraph.h
+@@ -46,6 +46,7 @@
+ #include <boost/lambda/construct.hpp>

+ #include <QObject>

+ 

++#ifndef Q_MOC_RUN

+ #include "FeatureCollectionFileState.h"

+ #include "Layer.h"

+ #include "Reconstruction.h"

+@@ -53,6 +54,7 @@
+ 

+ #include "model/FeatureCollectionHandle.h"

+ #include "model/WeakReferenceCallback.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/app-logic/ReconstructLayerTask.h
++++ b/src/app-logic/ReconstructLayerTask.h
+@@ -33,6 +33,7 @@
+ #include <QObject>

+ #include <QString>

+ 

++#ifndef Q_MOC_RUN

+ #include "LayerTask.h"

+ #include "ReconstructLayerProxy.h"

+ #include "ReconstructLayerParams.h"

+@@ -42,6 +43,7 @@
+ #include "maths/types.h"

+ 

+ #include "model/FeatureCollectionHandle.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/app-logic/ReconstructScalarCoverageLayerParams.h
++++ b/src/app-logic/ReconstructScalarCoverageLayerParams.h
+@@ -30,6 +30,7 @@
+ #include <boost/optional.hpp>

+ #include <QObject>

+ 

++#ifndef Q_MOC_RUN

+ #include "LayerParams.h"

+ #include "ReconstructScalarCoverageLayerProxy.h"

+ #include "ReconstructScalarCoverageParams.h"

+@@ -38,6 +39,7 @@
+ #include "property-values/ValueObjectType.h"

+ 

+ #include "utils/SubjectObserverToken.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/app-logic/ReconstructScalarCoverageLayerTask.h
++++ b/src/app-logic/ReconstructScalarCoverageLayerTask.h
+@@ -30,12 +30,14 @@
+ #include <boost/shared_ptr.hpp>

+ #include <QObject>

+ 

++#ifndef Q_MOC_RUN

+ #include "LayerTask.h"

+ #include "ReconstructScalarCoverageLayerParams.h"

+ #include "ReconstructScalarCoverageLayerProxy.h"

+ #include "ScalarCoverageFeatureProperties.h"

+ 

+ #include "model/FeatureCollectionHandle.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/app-logic/TopologyNetworkResolverLayerTask.h
++++ b/src/app-logic/TopologyNetworkResolverLayerTask.h
+@@ -33,6 +33,7 @@
+ #include <QObject>

+ #include <QString>

+ 

++#ifndef Q_MOC_RUN

+ #include "LayerParams.h"

+ #include "LayerTask.h"

+ #include "ReconstructLayerProxy.h"

+@@ -41,6 +42,7 @@
+ #include "TopologyNetworkResolverLayerProxy.h"

+ 

+ #include "model/FeatureCollectionHandle.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/app-logic/VelocityFieldCalculatorLayerTask.h
++++ b/src/app-logic/VelocityFieldCalculatorLayerTask.h
+@@ -32,9 +32,11 @@
+ #include <QObject>

+ #include <QString>

+ 

++#ifndef Q_MOC_RUN

+ #include "LayerTask.h"

+ #include "VelocityFieldCalculatorLayerParams.h"

+ #include "VelocityFieldCalculatorLayerProxy.h"

++#endif

+ 

+ #include "model/FeatureCollectionHandle.h"

+ 

+--- a/src/data-mining/CoRegConfigurationTable.h
++++ b/src/data-mining/CoRegConfigurationTable.h
+@@ -28,6 +28,7 @@
+ 

+ #include <vector>

+ #include <map>

++#ifndef Q_MOC_RUN

+ #include <boost/operators.hpp>

+ 

+ #include "CoRegFilter.h"

+@@ -44,6 +45,7 @@
+ #include "scribe/Transcribe.h"

+ #include "scribe/TranscribeContext.h"

+ 

++#endif

+ 

+ namespace GPlatesDataMining

+ {

+--- a/src/gui/CommandServer.h
++++ b/src/gui/CommandServer.h
+@@ -38,9 +38,11 @@
+ #include <QRegExp>

+ #include <QtXml/QXmlStreamReader>

+ 

++#ifndef Q_MOC_RUN

+ #include "app-logic/ApplicationState.h"

+ 

+ #include "presentation/ViewState.h"

++#endif

+ 

+ namespace GPlatesGui

+ {

+--- a/src/gui/FeatureTableModel.h
++++ b/src/gui/FeatureTableModel.h
+@@ -32,8 +32,10 @@
+ #include <QItemSelection>

+ #include <QHeaderView>

+ 

++#ifndef Q_MOC_RUN

+ #include "app-logic/Layer.h"

+ #include "app-logic/ReconstructionGeometry.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/gui/TopologyTools.h
++++ b/src/gui/TopologyTools.h
+@@ -35,6 +35,7 @@
+ #include <QDebug>

+ #include <QObject>

+ 

++#ifndef Q_MOC_RUN

+ #include "TopologySectionsContainer.h"

+ 

+ #include "app-logic/Layer.h"

+@@ -64,6 +65,7 @@
+ #include "utils/UnicodeStringUtils.h"

+ 

+ #include "view-operations/RenderedGeometryCollection.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/opengl/GLVisualLayers.h
++++ b/src/opengl/GLVisualLayers.h
+@@ -35,6 +35,7 @@
+ #include <boost/shared_ptr.hpp>

+ #include <QObject>

+ 

++#ifndef Q_MOC_RUN

+ #include "GLAgeGridMaskSource.h"

+ #include "GLContext.h"

+ #include "GLLight.h"

+@@ -79,6 +80,7 @@
+ 

+ #include "view-operations/RenderedGeometry.h"

+ #include "view-operations/ScalarField3DRenderParameters.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/presentation/VisualLayer.h
++++ b/src/presentation/VisualLayer.h
+@@ -32,6 +32,7 @@
+ #include <QString>

+ #include <QObject>

+ 

++#ifndef Q_MOC_RUN

+ #include "VisualLayerParams.h"

+ #include "VisualLayerType.h"

+ 

+@@ -42,6 +43,7 @@
+ #include "model/FeatureCollectionHandle.h"

+ 

+ #include "view-operations/RenderedGeometryCollection.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/presentation/VisualLayers.h
++++ b/src/presentation/VisualLayers.h
+@@ -34,6 +34,7 @@
+ #include <boost/weak_ptr.hpp>

+ #include <QObject>

+ 

++#ifndef Q_MOC_RUN

+ #include "VisualLayer.h"

+ 

+ #include "app-logic/FeatureCollectionFileState.h"

+@@ -42,6 +43,7 @@
+ #include "gui/Symbol.h"

+ 

+ #include "view-operations/RenderedGeometryCollection.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/qt-widgets/AssignReconstructionPlateIdsDialog.h
++++ b/src/qt-widgets/AssignReconstructionPlateIdsDialog.h
+@@ -39,6 +39,7 @@
+ #include "GPlatesDialog.h"

+ #include "InformationDialog.h"

+ 

++#ifndef Q_MOC_RUN

+ #include "app-logic/AssignPlateIds.h"

+ 

+ #include "file-io/File.h"

+@@ -47,6 +48,7 @@
+ #include "model/ModelInterface.h"

+ 

+ #include "presentation/VisualLayer.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/qt-widgets/CoRegistrationLayerConfigurationDialog.h
++++ b/src/qt-widgets/CoRegistrationLayerConfigurationDialog.h
+@@ -38,6 +38,7 @@
+ 

+ #include "OpenDirectoryDialog.h"

+ 

++#ifndef Q_MOC_RUN

+ #include "app-logic/ApplicationState.h"

+ #include "app-logic/Layer.h"

+ #include "app-logic/LayerInputChannelName.h"

+@@ -45,6 +46,7 @@
+ 

+ #include "data-mining/CheckAttrTypeVisitor.h"

+ #include "data-mining/CoRegConfigurationTable.h"

++#endif

+ 

+ #include "global/PointerTraits.h"

+ 

+--- a/src/qt-widgets/CoRegistrationOptionsWidget.h
++++ b/src/qt-widgets/CoRegistrationOptionsWidget.h
+@@ -31,6 +31,7 @@
+ #include "CoRegistrationLayerConfigurationDialog.h"

+ #include "CoRegistrationOptionsWidgetUi.h"

+ #include "LayerOptionsWidget.h"

++#ifndef Q_MOC_RUN

+ #include "CoRegistrationResultTableDialog.h"

+ 

+ #include "app-logic/CoRegistrationLayerTask.h"

+@@ -41,7 +42,7 @@
+ #include "file-io/File.h"

+ 

+ #include "presentation/VisualLayer.h"

+-

++#endif

+ 

+ namespace GPlatesAppLogic

+ {

+--- a/src/qt-widgets/CoRegistrationResultTableDialog.h
++++ b/src/qt-widgets/CoRegistrationResultTableDialog.h
+@@ -36,6 +36,7 @@
+ #include <QEvent>

+ #include <qevent.h>

+ 

++#ifndef Q_MOC_RUN

+ #include "CoRegistrationResultTableDialogUi.h"

+ #include "SaveFileDialog.h"

+ 

+@@ -43,6 +44,7 @@
+ #include "data-mining/OpaqueDataToQString.h"

+ 

+ #include "presentation/VisualLayer.h"

++#endif

+ 

+ namespace GPlatesPresentation

+ {

+--- a/src/qt-widgets/DrawStyleDialog.h
++++ b/src/qt-widgets/DrawStyleDialog.h
+@@ -33,6 +33,7 @@
+ #include <QMutex>

+ #include <QMutexLocker>

+ 

++#ifndef Q_MOC_RUN

+ #include "DrawStyleDialogUi.h"

+ #include "GPlatesDialog.h"

+ #include "PythonArgumentWidget.h"

+@@ -41,6 +42,7 @@
+ #include "gui/PythonConfiguration.h"

+ 

+ #include "presentation/Application.h"

++#endif

+ 

+ namespace GPlatesAppLogic

+ {

+--- a/src/qt-widgets/EditTableActionWidget.h
++++ b/src/qt-widgets/EditTableActionWidget.h
+@@ -27,8 +27,11 @@
+ #define GPLATES_QTWIDGETS_EDITTABLEACTIONWIDGET_H

+ 

+ #include <QWidget>

++

++#ifndef Q_MOC_RUN

+ #include "app-logic/ApplicationState.h"

+ #include "EditTableActionWidgetUi.h"

++#endif

+ 

+ namespace GPlatesQtWidgets

+ {

+--- a/src/qt-widgets/GlobeCanvas.h
++++ b/src/qt-widgets/GlobeCanvas.h
+@@ -41,6 +41,7 @@
+ #include <QPainter>

+ #include <QtOpenGL/qgl.h>

+ 

++#ifndef Q_MOC_RUN

+ #include "gui/ColourScheme.h"

+ #include "gui/Globe.h"

+ #include "gui/ViewportZoom.h"

+@@ -58,6 +59,7 @@
+ #include "qt-widgets/SceneView.h"

+ 

+ #include "view-operations/RenderedGeometryFactory.h"

++#endif

+ 

+ 

+ namespace GPlatesGui

+--- a/src/qt-widgets/LogDialog.h
++++ b/src/qt-widgets/LogDialog.h
+@@ -34,7 +34,9 @@
+ #include "GPlatesDialog.h"

+ #include "LogDialogUi.h"

+ 

++#ifndef Q_MOC_RUN

+ #include "app-logic/ApplicationState.h"

++#endif

+ 

+ 

+ namespace GPlatesGui

+--- a/src/qt-widgets/MapCanvas.h
++++ b/src/qt-widgets/MapCanvas.h
+@@ -39,6 +39,7 @@
+ #include <QSize>

+ #include <QTransform>

+ 

++#ifndef Q_MOC_RUN

+ #include "gui/ColourScheme.h"

+ #include "gui/Map.h"

+ #include "gui/TextOverlay.h"

+@@ -47,6 +48,7 @@
+ #include "opengl/GLMatrix.h"

+ #include "opengl/GLOffScreenContext.h"

+ #include "opengl/GLVisualLayers.h"

++#endif

+ 

+ 

+ namespace GPlatesGui

+--- a/src/qt-widgets/MapView.h
++++ b/src/qt-widgets/MapView.h
+@@ -36,6 +36,7 @@
+ #include <QGLWidget>

+ #include <QMouseEvent>

+ 

++#ifndef Q_MOC_RUN

+ #include "gui/ColourScheme.h"

+ 

+ #include "maths/LatLonPoint.h"

+@@ -44,6 +45,7 @@
+ #include "opengl/GLVisualLayers.h"

+ 

+ #include "qt-widgets/SceneView.h"

++#endif

+ 

+ 

+ namespace GPlatesGui

+--- a/src/qt-widgets/MergeReconstructionLayersDialog.h
++++ b/src/qt-widgets/MergeReconstructionLayersDialog.h
+@@ -33,7 +33,9 @@
+ 

+ #include "MergeReconstructionLayersDialogUi.h"

+ 

++#ifndef Q_MOC_RUN

+ #include "app-logic/Layer.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/qt-widgets/RasterLayerOptionsWidget.h
++++ b/src/qt-widgets/RasterLayerOptionsWidget.h
+@@ -31,6 +31,7 @@
+ #include <QString>

+ #include <QToolButton>

+ 

++#ifndef Q_MOC_RUN

+ #include "RasterLayerOptionsWidgetUi.h"

+ 

+ #include "LayerOptionsWidget.h"

+@@ -40,6 +41,7 @@
+ 

+ #include "gui/BuiltinColourPaletteType.h"

+ #include "gui/RasterColourPalette.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/qt-widgets/ReconstructScalarCoverageLayerOptionsWidget.h
++++ b/src/qt-widgets/ReconstructScalarCoverageLayerOptionsWidget.h
+@@ -28,6 +28,7 @@
+ 

+ #include <utility>

+ 

++#ifndef Q_MOC_RUN

+ #include "ReconstructScalarCoverageLayerOptionsWidgetUi.h"

+ 

+ #include "LayerOptionsWidget.h"

+@@ -37,6 +38,7 @@
+ 

+ #include "gui/BuiltinColourPaletteType.h"

+ #include "gui/RasterColourPalette.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/qt-widgets/ScalarField3DLayerOptionsWidget.h
++++ b/src/qt-widgets/ScalarField3DLayerOptionsWidget.h
+@@ -30,6 +30,7 @@
+ #include <vector>

+ #include <QSlider>

+ 

++#ifndef Q_MOC_RUN

+ #include "ScalarField3DLayerOptionsWidgetUi.h"

+ 

+ #include "LayerOptionsWidget.h"

+@@ -41,6 +42,7 @@
+ #include "gui/RasterColourPalette.h"

+ 

+ #include "view-operations/ScalarField3DRenderParameters.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/qt-widgets/TotalReconstructionPolesDialog.h
++++ b/src/qt-widgets/TotalReconstructionPolesDialog.h
+@@ -32,12 +32,14 @@
+ #include <boost/weak_ptr.hpp>

+ #include <QDialog>

+ 

++#ifndef Q_MOC_RUN

+ #include "TotalReconstructionPolesDialogUi.h"

+ 

+ #include "GPlatesDialog.h"

+ #include "SaveFileDialog.h"

+ 

+ #include "presentation/VisualLayer.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/qt-widgets/VisualLayersComboBox.h
++++ b/src/qt-widgets/VisualLayersComboBox.h
+@@ -32,8 +32,10 @@
+ #include <QComboBox>

+ #include <QObject>

+ 

++#ifndef Q_MOC_RUN

+ #include "presentation/VisualLayer.h"

+ #include "presentation/VisualLayerType.h"

++#endif

+ 

+ 

+ namespace GPlatesPresentation

+--- a/src/qt-widgets/VisualLayerWidget.h
++++ b/src/qt-widgets/VisualLayerWidget.h
+@@ -36,11 +36,13 @@
+ #include <QMenu>

+ #include <QStackedWidget>

+ 

++#ifndef Q_MOC_RUN

+ #include "VisualLayerWidgetUi.h"

+ 

+ #include "app-logic/Layer.h"

+ 

+ #include "gui/Colour.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/view-operations/InternalGeometryBuilder.h
++++ b/src/view-operations/InternalGeometryBuilder.h
+@@ -30,9 +30,11 @@
+ #include <vector>

+ #include <boost/optional.hpp>

+ 

++#ifndef Q_MOC_RUN

+ #include "maths/GeometryOnSphere.h"

+ #include "maths/GeometryType.h"

+ #include "maths/PointOnSphere.h"

++#endif

+ 

+ namespace GPlatesViewOperations

+ {

+--- a/src/view-operations/RenderedGeometryCollection.h
++++ b/src/view-operations/RenderedGeometryCollection.h
+@@ -39,7 +39,9 @@
+ #include <boost/foreach.hpp>

+ #include <QObject>

+ 

++#ifndef Q_MOC_RUN

+ #include "RenderedGeometryLayer.h"

++#endif

+ 

+ namespace GPlatesViewOperations

+ {

+--- a/src/view-operations/RenderedGeometryFactory.h
++++ b/src/view-operations/RenderedGeometryFactory.h
+@@ -33,6 +33,7 @@
+ #include <QString>

+ #include <QFont>

+ 

++#ifndef Q_MOC_RUN

+ #include "RenderedGeometry.h"

+ #include "RenderedColouredEdgeSurfaceMesh.h"

+ #include "RenderedColouredTriangleSurfaceMesh.h"

+@@ -62,6 +63,7 @@
+ #include "property-values/TextContent.h"

+ 

+ #include "view-operations/ScalarField3DRenderParameters.h"

++#endif

+ 

+ 

+ namespace GPlatesAppLogic

+--- a/src/view-operations/RenderedGeometryLayer.h
++++ b/src/view-operations/RenderedGeometryLayer.h
+@@ -35,10 +35,12 @@
+ #include <boost/optional.hpp>

+ #include <QObject>

+ 

++#ifndef Q_MOC_RUN

+ #include "RenderedGeometry.h"

+ 

+ #include "maths/CubeQuadTreeLocation.h"

+ 

++#endif

+ 

+ namespace GPlatesMaths

+ {

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..8b6c7497e547
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/gplates/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, qt4, qwt6_qt4, libGLU_combined, glew, gdal_1_11, cgal
+, proj, boost, cmake, python2, doxygen, graphviz, gmp }:
+
+stdenv.mkDerivation rec {
+  name = "gplates-${version}";
+  version = "2.0.0";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/gplates/${name}-unixsrc.tar.bz2";
+    sha256 = "02scnjj5nlc2d2c8lbx0xvj8gg1bgkjliv3wxsx564c55a9x69qw";
+  };
+
+  patches = [
+    ./boostfix.patch
+  ];
+
+  buildInputs = [
+    qt4 qwt6_qt4 libGLU_combined glew gdal_1_11 cgal proj boost cmake python2
+    doxygen graphviz gmp
+  ];
+
+  meta = with stdenv.lib; {
+    description = "Desktop software for the interactive visualisation of plate-tectonics";
+    homepage = https://www.gplates.org;
+    license = licenses.gpl2;
+    platforms = platforms.all;
+    broken = true;
+  };
+}
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..8cd119c7b7b0
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/megam/default.nix
@@ -0,0 +1,46 @@
+{ fetchurl, stdenv, ocaml, makeWrapper, ncurses }:
+
+let version = "0.92"; in
+stdenv.mkDerivation rec {
+  name = "megam-${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 = stdenv.lib.platforms.gnu ++ stdenv.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/motu-client/default.nix b/nixpkgs/pkgs/applications/science/misc/motu-client/default.nix
new file mode 100644
index 000000000000..d4367ef7e2d3
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/motu-client/default.nix
@@ -0,0 +1,23 @@
+{ python27Packages, fetchurl, lib } :
+python27Packages.buildPythonApplication rec {
+  pname = "motu-client";
+  version = "1.5.00";
+
+  src = fetchurl {
+    url = "https://github.com/quiet-oceans/motuclient-setuptools/archive/${version}.tar.gz";
+    sha256 = "1iqsws3wa2gpb36ms21xmaxfi83i8p8cdya4cxpn4r47c8mz74x8";
+  };
+
+  meta = with lib; {
+    homepage = https://github.com/quiet-oceans/motuclient-setuptools;
+    description = "CLI to query oceanographic data to Motu servers";
+    longDescription = ''
+      Access data from (motu)[https://sourceforge.net/projects/cls-motu/] servers.
+      This is a refactored fork of the original release in order to simplify integration,
+      deployment and packaging. Upstream code can be found at
+      https://sourceforge.net/projects/cls-motu/ .
+    '';
+    license = licenses.lgpl3Plus;
+    maintainers = [ maintainers.lsix ];
+  };
+}
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..76f958cc3a81
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/netlogo/default.nix
@@ -0,0 +1,58 @@
+{ jre, 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 {
+  name = "netlogo-${version}";
+  version = "6.0.4";
+
+  src = fetchurl {
+    url = "https://ccl.northwestern.edu/netlogo/${version}/NetLogo-${version}-64.tgz";
+    sha256 = "0dcd9df4dfb218826a74f9df42163fa588908a1dfe58864106936f8dfb76acec";
+  };
+
+  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 stdenv.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/openmodelica/default.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/default.nix
new file mode 100644
index 000000000000..1a1ae3df9425
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/default.nix
@@ -0,0 +1,57 @@
+{stdenv, fetchgit, fetchsvn, autoconf, automake, libtool, gfortran, clang, cmake, gnumake,
+hwloc, jre, liblapack, blas, hdf5, expat, ncurses, readline, qt4, webkitgtk, which,
+lp_solve, omniorb, sqlite, libatomic_ops, pkgconfig, file, gettext, flex, bison,
+doxygen, boost, openscenegraph, gnome2, pangox_compat, xorg, git, bash, gtk2, makeWrapper }:
+
+let
+
+  fakegit = import ./fakegit.nix {inherit stdenv fetchgit fetchsvn bash;} ;
+
+in
+
+stdenv.mkDerivation {
+  name = "openmodelica";
+
+  src = fetchgit (import ./src-main.nix);
+
+  buildInputs = [autoconf cmake automake libtool gfortran clang gnumake
+    hwloc jre liblapack blas hdf5 expat ncurses readline qt4 webkitgtk which
+    lp_solve omniorb sqlite libatomic_ops pkgconfig file gettext flex bison
+    doxygen boost openscenegraph gnome2.gtkglext pangox_compat xorg.libXmu
+    git gtk2 makeWrapper];
+
+  hardeningDisable = [ "format" ];
+
+  enableParallelBuilding = true;
+
+  patchPhase = ''
+    cp -fv ${fakegit}/bin/checkout-git.sh libraries/checkout-git.sh
+    cp -fv ${fakegit}/bin/checkout-svn.sh libraries/checkout-svn.sh
+  '';
+
+  configurePhase = ''
+    export NIX_LDFLAGS="$NIX_LDFLAGS -L${gfortran.cc.lib}/lib"
+
+    autoconf
+    ./configure CC=${clang}/bin/clang CXX=${clang}/bin/clang++ --prefix=$out
+  '';
+
+  postFixup = ''
+    for e in $(cd $out/bin && ls); do
+      wrapProgram $out/bin/$e \
+        --prefix PATH : "${gnumake}/bin" \
+        --prefix LIBRARY_PATH : "${stdenv.lib.makeLibraryPath [ liblapack blas ]}"
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    description = "OpenModelica is an open-source Modelica-based modeling and simulation environment";
+    homepage    = "https://openmodelica.org";
+    license     = licenses.gpl3;
+    maintainers = with maintainers; [ smironov ];
+    platforms   = platforms.linux;
+    broken      = true;
+  };
+}
+
+
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/fakegit.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/fakegit.nix
new file mode 100644
index 000000000000..de69626cd3ee
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/fakegit.nix
@@ -0,0 +1,81 @@
+{stdenv, fetchgit, fetchsvn, 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 = stdenv.lib.replaceChars [":" "/"] ["_" "_"];
+  in
+    (rpl r.url) + "-" + (rpl r.rev);
+
+in
+
+stdenv.mkDerivation {
+  name = "fakegit";
+
+  buildCommand = ''
+    mkdir -pv $out/repos
+    ${stdenv.lib.concatMapStrings
+       (r : ''
+        cp -r ${fetchgit r} $out/repos/${hashname r}
+       ''
+       ) (import ./src-libs-git.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
+
+      L=`echo $REVISION | wc -c`
+      if expr $L '<' 10 >/dev/null; then
+        REVISION=refs/tags/$REVISION
+      fi
+
+      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
+    ''}
+
+    ${stdenv.lib.concatMapStrings
+       (r : ''
+        cp -r ${fetchsvn r} $out/repos/${hashname r}
+       ''
+       ) (import ./src-libs-svn.nix)
+    }
+
+    ${mkscript "$out/bin/checkout-svn.sh" ''
+      if test "$#" -ne 3; then
+        echo "Usage: $0 DESTINATION URL REVISION"
+        exit 1
+      fi
+      DEST=$1
+      URL=`echo $2 | tr :/ __`
+      REVISION=`echo $4 | tr :/ __`
+
+      rm -rf $DEST
+      mkdir -pv $DEST
+      echo "FAKE COPY %out/repos/$URL-$REVISION $DEST"
+      cp -r %out/repos/$URL-$REVISION/* $DEST
+      chmod u+w -R $DEST
+    ''}
+  '';
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/src-libs-git.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/src-libs-git.nix
new file mode 100644
index 000000000000..aae5ab321fbe
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/src-libs-git.nix
@@ -0,0 +1,71 @@
+[
+{ url = "https://github.com/modelica-3rdparty/ADGenKinetics.git"; rev = "42428db6e84bcde28543a3bba9bccee581309bb1"; sha256="14l005jwj1wz35gq8xlbzfz0bpsx99rs4q3dxkfh76yhnv1jh9h3"; }
+{ url = "https://github.com/modelica-3rdparty/ADMSL.git"; rev = "ed0305603f86b46d9af03e7d37dcb8b6704915b4"; sha256="15b0nqxyh8444az56ydjn594jikdl1ina5wamabk3nzm1yx218cl"; }
+{ url = "https://github.com/iea-annex60/modelica-annex60.git"; rev = "8015a01591bb24d219f57e7b69cdfcde66e39b47"; sha256="05k4pa007a6p628fq1xac0cfv8g8dnpy2bgy8h99rqpmlaa072z7"; }
+{ url = "https://github.com/OpenModelica/BioChem.git"; rev = "b5f3cb999f3cfad2bbb6fb429b496f61ecf2f628"; sha256="1l52dg888vwx4668spn59hqvfkpl9g06g8n2cdxiap7lvsyh6w9x"; }
+{ url = "https://github.com/modelica-3rdparty/BondGraph.git"; rev = "20c23e60d12989bd4668ccac47659d82d39d29cc"; sha256="1i9cmiy1ya04h2ld0gy0x2gvdrfksl66fmcrgdm1vpsnbb6pviv9"; }
+{ url = "https://github.com/modelica-3rdparty/BondLib.git"; rev = "df7a40fe612617da22e27d39edfa4b27d65f23d0"; sha256="005djwxd568zyk3ndss9hv165dci9x0dgjmcdjhnqmsap3w83hlz"; }
+{ url = "https://github.com/modelica-3rdparty/BrineProp.git"; rev = "fed013cdeec0fb9552964376b575a8e3635539ab"; sha256="020hm2q65d5iv3h8b3lhgl6j930vi2pbh4lvxv3b3k7i9z02q43a"; }
+{ url = "https://github.com/lbl-srg/modelica-buildings.git"; rev = "ef89361cc8673b077b9221efbf78aa63b4d7babd"; sha256="04gclknhl2f5z7w9fsbhwawisd0ibmvwpplx0siqwzvjx7nsmdg4"; }
+{ url = "https://github.com/lbl-srg/modelica-buildings.git"; rev = "444aa231f423b8d04225bf8672e3212d089fbfe4"; sha256="0q754mlkwqj0jcqsmxksvcz4ak2i86f9s41fhffh5jvra27cvq01"; }
+{ url = "https://github.com/modelica-3rdparty/Chemical.git"; rev = "aa2642608e587ddb6897e8c3ffabb3aa099510bd"; sha256="0y46spcb6rw0jpj4v20nlw8xlvi5kypij46f1msvwgr7dfgy4gl4"; }
+{ url = "https://github.com/modelica-3rdparty/ComplexLib.git"; rev = "0b78942ee4fa95ae71347a0d552dd869fdf4c708"; sha256="18llf5ccrq3b0f4cjznfycskwf78pik8370xv45w9gb51gamszrn"; }
+{ url = "https://github.com/lochel/ConPNlib.git"; rev = "bbf6e9711665d55e5a8cf2f7235fa013c2315104"; sha256="0g3ll44sn2ff14qxwdyakw9h5b8b7vzabxp8cb8km16wcdqzgcxx"; }
+{ url = "https://github.com/modelica-3rdparty/DESLib.git"; rev = "7a473d8d16b118c3ea05761c6f43b17fd9838e4e"; sha256="19f2121n8rdc9svcjk8irivsd9wqcb9ai9jx72s2r85fkbvm8jc3"; }
+{ url = "https://github.com/modelica-3rdparty/ExtendedPetriNets.git"; rev = "2f4eac0651c1ab0ed56b75ec61424e0ef15181d3"; sha256="0wwj756pg33qwb90ycbfkrk5xsiwsbrqvq3i16i4pisi21vl6jk9"; }
+{ url = "https://github.com/modelica-3rdparty/ExternData.git"; rev = "396164fa708cc7c7e64da55ac0b3cba23939f790"; sha256="09052qmv91a9wawsl93b5b3q47awrxhnsbb9mrv39kpnwygfh7dq"; }
+{ url = "https://github.com/modelica/ExternalMedia.git"; rev = "1b77869b31dc3509defeccb1236db4b05d2f6f5b"; sha256="05sszn4bn8r78syydyjq8csn9xv4az56mm9lrarqykqdh78pvlqp"; }
+{ url = "https://github.com/kdavies4/FCSys.git"; rev = "cb4b17f34313b9d8f2d4223d5365684b4dc1ab65"; sha256="114p7ja6b3fwlkvkkjhbx78fxc7v4af2sbs783hkdga86m1v4ib6"; }
+{ url = "https://github.com/modelica-3rdparty/FastBuildings.git"; rev = "1f5cfebc2f42c13e272bff639ffa3449d5740bf7"; sha256="0sry1n2pliddz0pjv8dp899fx98f16n1arc8zvq36k5grvi52fby"; }
+{ url = "https://github.com/modelica-3rdparty/FaultTriggering.git"; rev = "10c226b7e5b2af901b356ac437c90d6616a6e9a4"; sha256="0a9j18qjwigq11nghl97syxa9bscs1aj6vwpkldh50csnj5h6g2s"; }
+{ url = "https://github.com/modelica-3rdparty/FuzzyControl.git"; rev = "19ff67ff129a440482cc85f216f287b05ea6ec0d"; sha256="0ijcqns7pijsavijn4wlrdsz64k5ks626sly7r28wvrk9af2m2cx"; }
+{ url = "https://github.com/modelica-3rdparty/HelmholtzMedia.git"; rev = "e54fcd0e436d65c85de6c6b935983e363cdc9f6c"; sha256="05afh0379fx4mjjn7jb8j5p4am6qi62hjxvasb38b6fcp9rnysn4"; }
+{ url = "https://github.com/modelica-3rdparty/IdealizedContact.git"; rev = "8ebac550d913f6d2b3af4d1aea5044e72c7eb6b0"; sha256="03gh2a7hf44clshwkiyz786w847hmyr3bicdqd9969fbirgcqn6m"; }
+{ url = "https://github.com/modelica-3rdparty/IndustrialControlSystems.git"; rev = "6a2414307d5998c6d081efe803c2b575a532b3ba"; sha256="09la9h07x8bkh7zhrwykgj1467qdryjvxhvnnm8qvsim0dl9inc4"; }
+{ url = "https://github.com/modelica-3rdparty/LinearMPC.git"; rev = "1e91a5dcaa662cd30c5b09a9d0267289703f933b"; sha256="12094fqmwi65h0mc65b96krbj6b8dgn6jiww3fnv6khglb21kwvd"; }
+{ url = "https://github.com/modelica/Modelica.git"; rev = "refs/tags/v1.6"; sha256="106w83ylgbxf63wr7p9z5q8vqz2qcsaw0zwaad7d3saq6rdbj30c"; }
+{ url = "https://github.com/modelica/Modelica.git"; rev = "d442bcd461b8db9873e33b6141bdbd37bcff9de8"; sha256="1icnd0fxix5khnsvdhy7kmzn6lnqkggbvfrbln98a2h5zqd6s32w"; }
+{ url = "https://github.com/modelica/Modelica.git"; rev = "af2a3e1597d648d6826665c89cf9eaf5c2a632bc"; sha256="0ryk0iwakdazhsjqvan41w6f9bvgl329zkqchcdg6nkidiigziwh"; }
+{ url = "https://github.com/modelica/Modelica.git"; rev = "48943d87db45a6c312b5a5789d384acde44a934b"; sha256="1hi2vkpmx734baa9m1lqzallcykhh3snd68r387gndiv96f6zx3n"; }
+{ url = "https://github.com/modelica/Modelica.git"; rev = "164af873cc5955c50f9592a7d2f3c155f703849c"; sha256="071svqwd72sy85sngbg5r22ab693c0gw2xx29gk1sqrk2nchmvia"; }
+{ url = "https://github.com/OpenModelica/modelica3d.git"; rev = "daf5669b03ad33fc6999671d1c0e7521134a282b"; sha256="1scs6v2cp2r4jz4diszwbqf9kvzf49pid50dmpsz0gfhx06j9y2v"; }
+{ url = "https://github.com/modelica-deprecated/ModelicaAdditions.git"; rev = "568db43766186826b880f9d4bfafeff25cc2c4ab"; sha256="1py5i3afxdvz1dmxxwb2mqj8kyzdhg4jnnqwl8h50akizg4i49pl"; }
+{ url = "https://github.com/xogeny/ModelicaBook.git"; rev = "0e670cfae4db653bd34ea777d6b56423e9be2c9f"; sha256="0lxh08w6nii4p5yk7c0xmfi5y4xkjkzz4hirr3kqdhdfybcwq824"; }
+{ url = "https://github.com/modelica-compliance/compliance.git"; rev = "ca5092c14bb7af4507a10700ee49181a3a3ee199"; sha256="12ja6dhwlbq412kxjdviypgchipxpsg8l0sf6r17g6lbsi19i2b6"; }
+{ url = "https://github.com/modelica-3rdparty/ModelicaDEVS.git"; rev = "a987aa9552fbbe71b2ee2e8c28958f9d213087ae"; sha256="0qcw7vw28xadim0h8kr2km09d8vdj05ibdpzcnpny9n43pm9s5hx"; }
+{ url = "https://github.com/modelica/Modelica_DeviceDrivers.git"; rev = "db912ba7e1317b8f6a776ccf9a19f69c77a9c477"; sha256="052h2lr7xgfag5fks19wbldqmb985kxlc5fzysl7c9w3fnijp0ml"; }
+{ url = "https://github.com/modelica/Modelica_EnergyStorages.git"; rev = "9f057365232364e31a31a8e525f96284b98c7de3"; sha256="195m5b3z8qgg9kih9zsdx1h8zgrm37q63890r59akka05a97j48h"; }
+{ url = "https://github.com/modelica/Modelica_LinearSystems2.git"; rev = "18916fdc485285baab12481701b53d4eb606a3f1"; sha256="0fhvdwcgk8q3z1a98l2bxv8a6dysrs4ll6xfyzpni7yq8gp4mg4q"; }
+{ url = "https://github.com/modelica/Modelica_Synchronous.git"; rev = "d0f5ee57bc7b639738e88026674a87343b33dbe1"; sha256="0l75v4d0fgf07ify0h3skh4y9pfw9gxh9hbj1lbsdgglmzlrcvbg"; }
+{ url = "https://github.com/modelica-3rdparty/MotorcycleDynamics.git"; rev = "2be2667f9936d88ffb9b8a8246c5af9ccb0b307f"; sha256="0jazwmpqpyhhgs9qdn9drmplgp2yjs0ky7wll5x9929dkgy80m6x"; }
+{ url = "https://github.com/modelica-3rdparty/NCLib.git"; rev = "ed3d72f176ac6b7031ce73be9d80101141e74a69"; sha256="1pbpv8w1lsa9vdwp7qbih8iim91ms22b01wz376b548d0x2r95la"; }
+{ url = "https://github.com/modelica-3rdparty/NeuralNetwork.git"; rev = "c44e4d1fe97fd4f86dafcd05ad3713692e3f1806"; sha256="0s1v8k71zq1s9gjlvi3zr23nwfknp4x17cxm64a0y3vsi3kahj2s"; }
+{ url = "https://github.com/DLR-SR/Noise.git"; rev = "9b57476845539e56769cf76ea0fe7bf3c7eb5d11"; sha256="0icrb63f6dm4gww2nyby9i7s7qxvhvialp36xzcgmi7nlq7crjr2"; }
+{ url = "https://github.com/modelica-3rdparty/ObjectStab.git"; rev = "2a723e0b223af50f4ffdd62f8ac901e0f87b9323"; sha256="1b6zi27slzzfbkmbcqxygsn5i5w0zkq0hfrfb72vf7mbgz07j19j"; }
+{ url = "https://github.com/cparedis/OpenHydraulics.git"; rev = "d3173d1f06f7d14c9d7c41769f143617ff03a3ad"; sha256="1hn5rcnmzcbiaqdnxfn02wddmrpj9bcdi9p680f31hbh3vb0i3r6"; }
+{ url = "https://github.com/lochel/PNlib.git"; rev = "44c7d277980b7a88b449b72edec0a56416b40fa9"; sha256="026wdhbxnzarmj8gw0as70vj8f1gwc51z38hjqpswxkl0xd6mfvp"; }
+{ url = "https://github.com/MarekMatejak/Physiolibrary.git"; rev = "49d59060f6e5b4cb68560c6d7467e84ea4318056"; sha256="0klqs2axjm3s780sq4plq4wmbf9mszz2jmq9fprgxy9pw7iszbhc"; }
+{ url = "https://github.com/dzimmer/PlanarMechanics.git"; rev = "d998a1b27355e83d2ff4849d71281a919a3234aa"; sha256="0vyq6mninn38wy2d60rk753xbkfqim2y6y31py7kq2mm170jfqf4"; }
+{ url = "https://github.com/modelica/PowerSystems.git"; rev = "7b551888089277a0dd979db636d47aba0279e8f0"; sha256="0y13f1nllc7riksnly25wmmp6mc30c1b48dbq2lr1nag6yg3blwm"; }
+{ url = "https://github.com/modelica/PowerSystems.git"; rev = "3abd48aa53bbcd3f3e2ddfa2371680febf8baf48"; sha256="1nr2nbpaxywk8cpwnk9rr2zr87mm2gb9b4plqipjdlrrkjlk9fka"; }
+{ url = "https://github.com/modelica-3rdparty/PraxisSimulationstechnik.git"; rev = "f7db177786f84033f3a50b7474988b190a1dfb46"; sha256="08bdm7k7w35kg9gkrvcn382zkwf5h3iwkkx60d5fj64j5d5klray"; }
+{ url = "https://github.com/modelica-3rdparty/QCalc.git"; rev = "af6c34dda691a9bdf7ca1de10650974b2d5cecf5"; sha256="0p0zhl27cnr492byrzib0dyn7zp5yb7wcr0spv10ngm6j90cij6y"; }
+{ url = "https://github.com/modelica-3rdparty/QSSFluidFlow.git"; rev = "d84a2c107132f2cd47ea3c3751238d69e4b1f64b"; sha256="02cdvv33pi0qlmg8n401s4cxf59l9b4ff4ixf7gwn4w4n1y9bw0g"; }
+{ url = "https://github.com/modelica-3rdparty/RealTimeCoordinationLibrary.git"; rev = "655ac1a22aa6deb04ea8e3869dd0aa9fb9540754"; sha256="19crf8pl9vpqq3pq1rhcbl49kkmnm4jrzpwrpqp8qc6dj8096za4"; }
+{ url = "https://github.com/modelica-3rdparty/ScalableTestSuite.git"; rev = "c6319908d45ac97ffb10e96cd42654bce36ffb97"; sha256="1g79d88bfmzcqvaghyyj86ajs38v0qnmjxbj8d53yp6nmgnaasx5"; }
+{ url = "https://github.com/modelica-3rdparty/Servomechanisms.git"; rev = "22e1874ef9ad46156617817c67a4fb1238621bf5"; sha256="0nwb7apayk7ba9iv27yv67wi4b934dy57kkvn0acxy393jhd8jqd"; }
+{ url = "https://openmodelica.org/git/SiemensPower.git"; rev = "73a3bfc6d2ddd72165bb0f3e7e9df48b643a5ed0"; sha256="0mvrkpkmr0bx2cvsb23syg7cs8k6a15vjf4n1hivdcigq4x8g2nc"; }
+{ url = "https://openmodelica.org/git/SiemensPower.git"; rev = "5ef2e38b64ff481801c0db19d52f0bef21f85f77"; sha256="1llnpl2x1g28gari1rk34hdnnwf7a4fwwxlf7i18d8bl1vsrfaja"; }
+{ url = "https://openmodelica.org/git/SiemensPower.git"; rev = "2bd9e367baaa8d44946897c3c3a32a4050ad2a2a"; sha256="1shm9blpn9m87ci6wwkinpmihr1fik9j0a0pj2nxy0cjrr2jzbn4"; }
+{ url = "https://github.com/modelica-3rdparty/Spot.git"; rev = "2f74417f1681570900a1ed373dcbe4b42634ec7b"; sha256="0k5h2k6x98zvvsafpw7y16xs9d6lxz0csa0mlm4wwggaywadn255"; }
+{ url = "https://github.com/modelica-3rdparty/SystemDynamics.git"; rev = "c58a26dc3e62a50e64fd336dc4aa499b2d5ad314"; sha256="0ra3a2vgqmry92kmm060gfa41mrpkgbs4swzl78ih3icawfzjz8q"; }
+{ url = "https://github.com/modelica-3rdparty/ThermoPower.git"; rev = "e012268625dd1645fe5570cf31d64129d83a8192"; sha256="1rlkli48kc9hnkplgb0bjkb6ajn7agiw4yh9l5sfvlv7k7k2gc8l"; }
+{ url = "https://openmodelica.org/git/ThermoSysPro.git"; rev = "d4f9c3ed35f7520f82439eb6e9f4057ae0f82b73"; sha256="0hxbn26g479qkr6rrglx9ljdxnpzd5ll1sf2v08skghrdjjb8jcx"; }
+{ url = "https://openmodelica.org/git/ThermoSysPro.git"; rev = "51e7ea2d2e121ee640e7897335c294923f8eaeb0"; sha256="0l11mzjkaxndsqrnnr0z7qvk08svv229119qkm81yb53ich9wnyw"; }
+{ url = "https://github.com/modelica/VehicleInterfaces.git"; rev = "ad956a35643d53e207ee126d67ea1f3f38337a39"; sha256="0g90cqwjpi06gn7vca5kqnz56im76s2hrdqjhsj2bl43rza8mhr0"; }
+{ url = "https://github.com/modelica-3rdparty/WasteWater.git"; rev = "90ff44ac791ba5ed98444c8597efbd2a2af01cad"; sha256="1icrn0y389rhxmf6i0mnsfgw9v9j5innpkz3q069rfm2ji268b12"; }
+{ url = "https://github.com/xogeny/XogenyTest.git"; rev = "9b98981e8ff0f440dd319d1a806e1fd2f0ab3436"; sha256="18glaxrlxfml26w7ljlf0yj3ah1fnhpbg01py28nplsgnrfwfwqj"; }
+{ url = "https://github.com/modelica-3rdparty/msgpack-modelica.git"; rev = "6ce2ca600c4902038c0f20b43ed442f1ee204310"; sha256="01x5a9y11yf62sc0j2y49yxwm24imj2lfl3z5mwvi9038gwn0lkx"; }
+{ url = "https://github.com/modelica-3rdparty/netCDF-DataReader.git"; rev = "3d2cc8272abfbc4b667d8868f851bf3e11c6f00e"; sha256="194810a4rn0flxgirrlnxsbxarnm97309dkp1w7nva9zv1q3wj7h"; }
+{ url = "https://github.com/joewa/open-bldc-modelica.git"; rev = "7817cd703b88fc1f433269d32c31e75eb50a21c6"; sha256="1plkxkx51f9yi99ysarmx2ymldizvyr0m66k996y5lj5h81jv8a8"; }
+]
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/src-libs-svn.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/src-libs-svn.nix
new file mode 100644
index 000000000000..244da64fb4e6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/src-libs-svn.nix
@@ -0,0 +1,5 @@
+[
+{ url = "https://svn.modelica.org/projects/Modelica_ElectricalSystems/InstantaneousSymmetricalComponents"; rev = "7978"; sha256="0f100c7bz4ai3ryhpkbbszw8z6mykvg40p03ic92n2qq58wjk37z"; }
+{ url = "https://svn.modelica.org/projects/Modelica_EmbeddedSystems/trunk/Modelica_StateGraph2"; rev = "8121"; sha256="1cys57nc1yzkr5admc139qs5pa48rj3g69pb3j3s9xcmpd483hzp"; }
+{ url = "https://svn.modelica.org/projects/Modelica_ElectricalSystems/Modelica_PowerFlow/trunk"; rev = "3174"; sha256="0yviw1b8psn8vfyl4q1naylak3lcqi2q1bqplqg3gg9iw4aiymxl"; }
+]
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/src-main.nix b/nixpkgs/pkgs/applications/science/misc/openmodelica/src-main.nix
new file mode 100644
index 000000000000..99e82259bfe6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/src-main.nix
@@ -0,0 +1,6 @@
+{
+  url = "https://openmodelica.org/git-readonly/OpenModelica.git";
+  fetchSubmodules = true;
+  rev = "8c5d48eb31a638d5220621b20377bfe6f9e9535e";
+  sha256 = "0i5cznkh4wwayjqms14f3phizqm493nrr1yjgs9747nfw7vnwsff";
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/openmodelica/update-src-libs-git.sh b/nixpkgs/pkgs/applications/science/misc/openmodelica/update-src-libs-git.sh
new file mode 100755
index 000000000000..481a89796415
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/update-src-libs-git.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+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/src-main.nix`
+EOF
+nix-build check.nix
+cat result/libraries/Makefile.libs
+) }
+
+getsha256() { (
+T=`mktemp -d`
+trap "rm -rf $T" EXIT INT PIPE
+cd $T
+
+L=`echo $2 | wc -c`
+if expr $L '<' 10 >/dev/null; then
+T=`echo $2 | sed 's@"\(.*\)"@"refs/tags/\1"@'`
+cat >check.nix <<EOF
+with import <nixpkgs> {};
+fetchgit {
+  url = $1;
+  rev = $T;
+  sha256 = "0000000000000000000000000000000000000000000000000000";
+}
+EOF
+SHA=`nix-build check.nix 2>&1 | sed -n 's/.*instead has ‘\(.*\)’.*/\1/g p'`
+echo "{ url = $1; rev = $T; sha256=\"$SHA\"; }"
+else
+cat >check.nix <<EOF
+with import <nixpkgs> {};
+fetchgit {
+  url = $1;
+  rev = $2;
+  sha256 = "0000000000000000000000000000000000000000000000000000";
+}
+EOF
+SHA=`nix-build check.nix 2>&1 | sed -n 's/.*instead has ‘\(.*\)’.*/\1/g p'`
+echo "{ url = $1; rev = $2; sha256=\"$SHA\"; }"
+fi
+
+# nix-build check.nix
+) }
+
+OUT=src-libs-git.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/update-src-libs-svn.sh b/nixpkgs/pkgs/applications/science/misc/openmodelica/update-src-libs-svn.sh
new file mode 100755
index 000000000000..972bc7d61f13
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmodelica/update-src-libs-svn.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+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/src-main.nix`
+EOF
+nix-build check.nix
+cat result/libraries/Makefile.libs
+) }
+
+getsha256() { (
+T=`mktemp -d`
+trap "rm -rf $T" EXIT INT PIPE
+cd $T
+
+L=`echo $2 | wc -c`
+cat >check.nix <<EOF
+with import <nixpkgs> {};
+fetchsvn {
+  url = $1;
+  rev = $2;
+  sha256 = "0000000000000000000000000000000000000000000000000000";
+}
+EOF
+SHA=`nix-build check.nix 2>&1 | sed -n 's/.*instead has ‘\(.*\)’.*/\1/g p'`
+echo "{ url = $1; rev = $2; sha256=\"$SHA\"; }"
+
+# nix-build check.nix
+) }
+
+OUT=src-libs-svn.nix
+
+echo '[' > $OUT
+
+chko |
+grep checkout-svn.sh |
+tr \' \" |
+while read NM TGT URL 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/openmvg/default.nix b/nixpkgs/pkgs/applications/science/misc/openmvg/default.nix
new file mode 100644
index 000000000000..c3e1cd60bf0b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmvg/default.nix
@@ -0,0 +1,51 @@
+{ stdenv, fetchgit, pkgconfig, cmake
+, libjpeg ? null
+, zlib ? null
+, libpng ? null
+, eigen ? null
+, libtiff ? null
+, enableExamples ? false
+, enableDocs ? false }:
+
+stdenv.mkDerivation rec {
+  version = "1.3";
+  name = "openmvg-${version}";
+
+  src = fetchgit {
+    url = "https://www.github.com/openmvg/openmvg.git";
+
+    # Tag v1.1
+    rev = "refs/tags/v${version}";
+    sha256 = "1cf1gbcl8zvxp4rr6f6vaxwcg0yzc4xban2b5p9zy1m4k1f81zyb";
+    fetchSubmodules = true;
+  };
+
+  buildInputs = [ libjpeg zlib libpng eigen libtiff ];
+
+  nativeBuildInputs = [ cmake pkgconfig ];
+
+  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 = http://openmvg.readthedocs.io/en/latest/;
+    license = stdenv.lib.licenses.mpl20;
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = with stdenv.lib.maintainers; [ mdaiter ];
+    broken = true; # 2018-04-11
+  };
+}
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..b665d5f4f687
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/openmvs/default.nix
@@ -0,0 +1,62 @@
+{ stdenv, fetchFromGitHub, pkgconfig, cmake
+, eigen, opencv, ceres-solver, cgal, boost, vcg
+, gmp, mpfr, glog, google-gflags, libjpeg_turbo }:
+
+stdenv.mkDerivation rec {
+  name = "openmvs-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 google-gflags libjpeg_turbo ];
+
+  nativeBuildInputs = [ cmake pkgconfig ];
+
+  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;
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.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 ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/misc/rink/cargo-lock.patch b/nixpkgs/pkgs/applications/science/misc/rink/cargo-lock.patch
new file mode 100644
index 000000000000..39029713430c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/rink/cargo-lock.patch
@@ -0,0 +1,1725 @@
+diff --git a/Cargo.lock b/Cargo.lock
+new file mode 100644
+index 0000000..c67e9ed
+--- /dev/null
++++ b/Cargo.lock
+@@ -0,0 +1,1719 @@
++[[package]]
++name = "MacTypes-sys"
++version = "2.1.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "aho-corasick"
++version = "0.6.9"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "antidote"
++version = "1.0.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "autocfg"
++version = "0.1.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "base64"
++version = "0.9.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "bincode"
++version = "0.6.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
++ "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "bitflags"
++version = "0.4.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "bitflags"
++version = "0.7.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "bitflags"
++version = "1.0.4"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "bodyparser"
++version = "0.5.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "iron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "persistent 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)",
++ "serde_json 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "buf_redux"
++version = "0.3.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "byteorder"
++version = "1.3.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "bytes"
++version = "0.3.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "cc"
++version = "1.0.28"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "cfg-if"
++version = "0.1.6"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "chrono"
++version = "0.2.25"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
++ "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "chrono"
++version = "0.4.6"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
++ "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)",
++ "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "chrono-humanize"
++version = "0.0.6"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "chrono-tz"
++version = "0.2.5"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)",
++ "parse-zoneinfo 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "cloudabi"
++version = "0.0.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "conduit-mime-types"
++version = "0.7.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "core-foundation"
++version = "0.5.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "core-foundation-sys"
++version = "0.5.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "dtoa"
++version = "0.2.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "encoding"
++version = "0.2.33"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)",
++ "encoding-index-korean 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)",
++ "encoding-index-simpchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)",
++ "encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)",
++ "encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "encoding-index-japanese"
++version = "1.20141219.5"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "encoding-index-korean"
++version = "1.20141219.5"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "encoding-index-simpchinese"
++version = "1.20141219.5"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "encoding-index-singlebyte"
++version = "1.20141219.5"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "encoding-index-tradchinese"
++version = "1.20141219.5"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "encoding_index_tests"
++version = "0.1.4"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "error"
++version = "0.1.9"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "filetime"
++version = "0.1.15"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "foreign-types"
++version = "0.3.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "foreign-types-shared"
++version = "0.1.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "fsevent"
++version = "0.2.17"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "fsevent-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "fsevent-sys"
++version = "0.1.6"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "fuchsia-cprng"
++version = "0.1.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "glob"
++version = "0.2.11"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "handlebars"
++version = "0.25.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
++ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
++ "pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
++ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "handlebars-iron"
++version = "0.23.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "handlebars 0.25.3 (registry+https://github.com/rust-lang/crates.io-index)",
++ "iron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
++ "notify 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
++ "walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "httparse"
++version = "1.3.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "hyper"
++version = "0.10.15"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
++ "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
++ "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
++ "mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
++ "traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "hyper-native-tls"
++version = "0.3.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "hyper 0.10.15 (registry+https://github.com/rust-lang/crates.io-index)",
++ "native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "idna"
++version = "0.1.5"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
++ "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
++ "unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "inotify"
++version = "0.2.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "ipc-channel"
++version = "0.5.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "bincode 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
++ "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)",
++ "uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "irc"
++version = "0.11.8"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
++ "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "iron"
++version = "0.5.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "conduit-mime-types 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
++ "error 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
++ "hyper 0.10.15 (registry+https://github.com/rust-lang/crates.io-index)",
++ "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
++ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
++ "modifier 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
++ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "itoa"
++version = "0.1.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "json"
++version = "0.10.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "kernel32-sys"
++version = "0.2.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "language-tags"
++version = "0.2.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "lazy_static"
++version = "0.2.11"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "lazy_static"
++version = "1.2.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "libc"
++version = "0.2.48"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "limiter"
++version = "0.3.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "iron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "linefeed"
++version = "0.4.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "nix 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
++ "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "log"
++version = "0.3.9"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "log"
++version = "0.4.6"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "logger"
++version = "0.3.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "iron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
++ "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "matches"
++version = "0.1.8"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "memchr"
++version = "0.1.11"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "memchr"
++version = "2.1.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "mime"
++version = "0.2.6"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "mime_guess"
++version = "1.8.6"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)",
++ "phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)",
++ "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "mio"
++version = "0.5.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
++ "miow 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
++ "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
++ "nix 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "slab 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
++ "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "miow"
++version = "0.1.5"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
++ "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "modifier"
++version = "0.1.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "mount"
++version = "0.3.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "iron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "sequence_trie 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "multipart"
++version = "0.8.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "buf_redux 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
++ "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
++ "mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "mime_guess 1.8.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
++ "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "native-tls"
++version = "0.2.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "openssl 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)",
++ "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "openssl-sys 0.9.40 (registry+https://github.com/rust-lang/crates.io-index)",
++ "schannel 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
++ "security-framework 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "security-framework-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
++ "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "net2"
++version = "0.2.33"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "nix"
++version = "0.5.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "nix"
++version = "0.7.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
++ "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
++ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "notify"
++version = "3.0.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "filetime 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
++ "fsevent 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
++ "fsevent-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "inotify 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
++ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "mio 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
++ "walkdir 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "num"
++version = "0.1.42"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "num-bigint 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)",
++ "num-complex 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
++ "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
++ "num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
++ "num-rational 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
++ "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "num-bigint"
++version = "0.1.44"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
++ "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "num-complex"
++version = "0.1.43"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "num-integer"
++version = "0.1.39"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "num-iter"
++version = "0.1.37"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
++ "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "num-rational"
++version = "0.1.42"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "num-bigint 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)",
++ "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
++ "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "num-traits"
++version = "0.1.43"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "num-traits"
++version = "0.2.6"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "num_cpus"
++version = "1.9.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "ole32-sys"
++version = "0.2.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "openssl"
++version = "0.10.16"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
++ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "openssl-sys 0.9.40 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "openssl-probe"
++version = "0.1.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "openssl-sys"
++version = "0.9.40"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
++ "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "params"
++version = "0.6.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "bodyparser 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "iron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "multipart 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
++ "plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "serde_json 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
++ "urlencoded 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "parse-zoneinfo"
++version = "0.1.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "percent-encoding"
++version = "1.0.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "persistent"
++version = "0.3.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "iron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "pest"
++version = "0.3.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "phf"
++version = "0.7.24"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "phf_codegen"
++version = "0.7.24"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)",
++ "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "phf_generator"
++version = "0.7.24"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "phf_shared"
++version = "0.7.24"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
++ "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "pkg-config"
++version = "0.3.14"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "plugin"
++version = "0.2.6"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "quick-error"
++version = "1.2.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "quote"
++version = "0.3.15"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "rand"
++version = "0.3.23"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "rand"
++version = "0.4.6"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "fuchsia-cprng 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "rand"
++version = "0.6.5"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand_jitter 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "rand_chacha"
++version = "0.1.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "rand_core"
++version = "0.3.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "rand_core"
++version = "0.4.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "rand_hc"
++version = "0.1.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "rand_isaac"
++version = "0.1.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "rand_jitter"
++version = "0.1.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "rand_os"
++version = "0.1.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
++ "fuchsia-cprng 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "rand_pcg"
++version = "0.1.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "rand_xorshift"
++version = "0.1.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "rdrand"
++version = "0.4.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "redox_syscall"
++version = "0.1.51"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "regex"
++version = "0.2.11"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
++ "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
++ "regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "regex-syntax"
++version = "0.5.6"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "remove_dir_all"
++version = "0.5.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "rink"
++version = "0.4.4"
++dependencies = [
++ "chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)",
++ "chrono-humanize 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "chrono-tz 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
++ "hyper 0.10.15 (registry+https://github.com/rust-lang/crates.io-index)",
++ "hyper-native-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "json 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "linefeed 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rust-gmp 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)",
++ "serde_derive 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)",
++ "strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "xml-rs 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "rink-irc"
++version = "0.4.0"
++dependencies = [
++ "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
++ "irc 0.11.8 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rink 0.4.4",
++]
++
++[[package]]
++name = "rink-web"
++version = "0.4.0"
++dependencies = [
++ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "handlebars 0.25.3 (registry+https://github.com/rust-lang/crates.io-index)",
++ "handlebars-iron 0.23.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "iron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "limiter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "mount 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "params 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rink 0.4.4",
++ "router 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
++ "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)",
++ "serde_derive 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)",
++ "serde_json 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "staticfile 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "route-recognizer"
++version = "0.1.12"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "router"
++version = "0.5.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "iron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "route-recognizer 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
++ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "rust-gmp"
++version = "0.5.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "rustc-serialize"
++version = "0.3.24"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "rustc_version"
++version = "0.1.7"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "rustc_version"
++version = "0.2.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "safemem"
++version = "0.3.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "same-file"
++version = "0.1.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "schannel"
++version = "0.1.14"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "security-framework"
++version = "0.2.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "security-framework-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "security-framework-sys"
++version = "0.2.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "MacTypes-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "semver"
++version = "0.1.20"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "semver"
++version = "0.9.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "semver-parser"
++version = "0.7.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "sequence_trie"
++version = "0.2.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "serde"
++version = "0.8.23"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "serde"
++version = "1.0.85"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "serde_codegen"
++version = "0.8.23"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
++ "serde_codegen_internals 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
++ "syn 0.10.8 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "serde_codegen_internals"
++version = "0.11.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "syn 0.10.8 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "serde_derive"
++version = "0.8.23"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "serde_codegen 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "serde_json"
++version = "0.8.6"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "dtoa 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "itoa 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
++ "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "shell32-sys"
++version = "0.1.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "siphasher"
++version = "0.2.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "slab"
++version = "0.1.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "smallvec"
++version = "0.6.8"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "staticfile"
++version = "0.4.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "iron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "mount 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
++ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "strsim"
++version = "0.5.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "syn"
++version = "0.10.8"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
++ "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "tempdir"
++version = "0.3.7"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "tempfile"
++version = "3.0.5"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
++ "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
++ "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "thread_local"
++version = "0.3.6"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "time"
++version = "0.1.42"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
++ "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "toml"
++version = "0.2.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
++ "serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "traitobject"
++version = "0.1.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "typeable"
++version = "0.1.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "typemap"
++version = "0.3.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "unsafe-any 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "ucd-util"
++version = "0.1.3"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "unicase"
++version = "1.4.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "unicode-bidi"
++version = "0.3.4"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "unicode-normalization"
++version = "0.1.8"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "unicode-width"
++version = "0.1.5"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "unicode-xid"
++version = "0.0.4"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "unreachable"
++version = "1.0.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "unsafe-any"
++version = "0.4.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "url"
++version = "1.7.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
++ "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
++ "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "urlencoded"
++version = "0.5.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "bodyparser 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "iron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
++ "plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
++ "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "utf8-ranges"
++version = "1.0.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "uuid"
++version = "0.3.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "vcpkg"
++version = "0.2.6"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "version_check"
++version = "0.1.5"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "void"
++version = "1.0.2"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "walkdir"
++version = "0.1.8"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "walkdir"
++version = "1.0.7"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
++ "same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "winapi"
++version = "0.2.8"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "winapi"
++version = "0.3.6"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "winapi-build"
++version = "0.1.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "winapi-i686-pc-windows-gnu"
++version = "0.4.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "winapi-x86_64-pc-windows-gnu"
++version = "0.4.0"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++
++[[package]]
++name = "ws2_32-sys"
++version = "0.2.1"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
++ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[[package]]
++name = "xml-rs"
++version = "0.3.6"
++source = "registry+https://github.com/rust-lang/crates.io-index"
++dependencies = [
++ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
++]
++
++[metadata]
++"checksum MacTypes-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eaf9f0d0b1cc33a4d2aee14fb4b2eac03462ef4db29c8ac4057327d8a71ad86f"
++"checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e"
++"checksum antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5"
++"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799"
++"checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643"
++"checksum bincode 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "55eb0b7fd108527b0c77860f75eca70214e11a8b4c6ef05148c54c05a25d48ad"
++"checksum bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3"
++"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
++"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
++"checksum bodyparser 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6928e817538b74a73d1dd6e9a942a2a35c632a597b6bb14fd009480f859a6bf5"
++"checksum buf_redux 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "861b9d19b9f5cb40647242d10d0cb0a13de0a96d5ff8c8a01ea324fa3956eb7d"
++"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb"
++"checksum bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c129aff112dcc562970abb69e2508b40850dd24c274761bb50fb8a0067ba6c27"
++"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749"
++"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
++"checksum chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)" = "9213f7cd7c27e95c2b57c49f0e69b1ea65b27138da84a170133fd21b07659c00"
++"checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878"
++"checksum chrono-humanize 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92afb1436280b0e4ed573c747ad30a1469cd945c201265b4d01e72cfa598da4f"
++"checksum chrono-tz 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "45438695f3f154032951a341ecca7ed200714bea615096885c9e86ca9fa3d66b"
++"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
++"checksum conduit-mime-types 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "95ca30253581af809925ef68c2641cc140d6183f43e12e0af4992d53768bd7b8"
++"checksum core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "286e0b41c3a20da26536c6000a280585d519fd07b3956b43aed8a79e9edce980"
++"checksum core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "716c271e8613ace48344f723b60b900a93150271e5be206212d052bbc0883efa"
++"checksum dtoa 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0dd841b58510c9618291ffa448da2e4e0f699d984d436122372f446dae62263d"
++"checksum encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec"
++"checksum encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91"
++"checksum encoding-index-korean 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81"
++"checksum encoding-index-simpchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7"
++"checksum encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a"
++"checksum encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18"
++"checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
++"checksum error 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "a6e606f14042bb87cc02ef6a14db6c90ab92ed6f62d87e69377bc759fd7987cc"
++"checksum filetime 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "714653f3e34871534de23771ac7b26e999651a0a228f47beb324dfdf1dd4b10f"
++"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
++"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
++"checksum fsevent 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c4bbbf71584aeed076100b5665ac14e3d85eeb31fdbb45fbd41ef9a682b5ec05"
++"checksum fsevent-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1a772d36c338d07a032d5375a36f15f9a7043bf0cb8ce7cee658e037c6032874"
++"checksum fuchsia-cprng 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81f7f8eb465745ea9b02e2704612a9946a59fa40572086c6fd49d6ddcf30bf31"
++"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
++"checksum handlebars 0.25.3 (registry+https://github.com/rust-lang/crates.io-index)" = "15bdf598fc3c2de40c6b340213028301c0d225eea55a2294e6cc148074e557a1"
++"checksum handlebars-iron 0.23.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f86cf6ff931aa78e61415ad40c48a9af101b9a888eeed6ecf4f48dc52e80b76"
++"checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83"
++"checksum hyper 0.10.15 (registry+https://github.com/rust-lang/crates.io-index)" = "df0caae6b71d266b91b4a83111a61d2b94ed2e2bea024c532b933dcff867e58c"
++"checksum hyper-native-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d375598f442742b0e66208ee12501391f1c7ac0bafb90b4fe53018f81f06068"
++"checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
++"checksum inotify 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8458c07bdbdaf309c80e2c3304d14c3db64e7465d4f07cf589ccb83fd0ff31a"
++"checksum ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "675587430ede6756dd03fdfdf9888f22f83855fd131c8451d842a710b059e571"
++"checksum irc 0.11.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6a45f7136bbfeec4377afc6363b38440ce153d8a61777d56da0c6b1176cf135a"
++"checksum iron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2440ae846e7a8c7f9b401db8f6e31b4ea5e7d3688b91761337da7e054520c75b"
++"checksum itoa 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae3088ea4baeceb0284ee9eea42f591226e6beaecf65373e41b38d95a1b8e7a1"
++"checksum json 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f3fb4510c0dbc38f7f43bdbe8b53defae0cd338b81ef416462a0ef69d600165c"
++"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
++"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
++"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
++"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1"
++"checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047"
++"checksum limiter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cbc5d8bf63416df5331084dd9883b9598582f0d7ad5e42d53e55b05366931676"
++"checksum linefeed 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1301a570e4e7d2d0f324b7a3fa73eac85b05c81b656a0983b16ebc8c504e53b6"
++"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
++"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
++"checksum logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "92ff59f9a797ff30f711fe6b8489ad424953cee17c206de77d3c5957a9182ba7"
++"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
++"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20"
++"checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8"
++"checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0"
++"checksum mime_guess 1.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2d4c0961143b8efdcfa29c3ae63281601b446a4a668165454b6c90f8024954c5"
++"checksum mio 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a637d1ca14eacae06296a008fa7ad955347e34efcb5891cfd8ba05491a37907e"
++"checksum miow 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3e690c5df6b2f60acd45d56378981e827ff8295562fc8d34f573deb267a59cd1"
++"checksum modifier 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41f5c9112cb662acd3b204077e0de5bc66305fa8df65c8019d5adb10e9ab6e58"
++"checksum mount 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "32245731923cd096899502fc4c4317cfd09f121e80e73f7f576cf3777a824256"
++"checksum multipart 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b16d6498fe5b0c2f6d973fd9753da099948834f96584d628e44a75f0d2955b03"
++"checksum native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ff8e08de0070bbf4c31f452ea2a70db092f36f6f2e4d897adf5674477d488fb2"
++"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
++"checksum nix 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bfb3ddedaa14746434a02041940495bf11325c22f6d36125d3bdd56090d50a79"
++"checksum nix 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0d95c5fa8b641c10ad0b8887454ebaafa3c92b5cd5350f8fc693adafd178e7b"
++"checksum notify 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "13fdd4a6894329b193f38f03a88823ce721275fdfdb29820c44a30515033524e"
++"checksum num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e"
++"checksum num-bigint 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)" = "e63899ad0da84ce718c14936262a41cee2c79c981fc0a0e7c7beb47d5a07e8c1"
++"checksum num-complex 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "b288631d7878aaf59442cffd36910ea604ecd7745c36054328595114001c9656"
++"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
++"checksum num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "af3fdbbc3291a5464dc57b03860ec37ca6bf915ed6ee385e7c6c052c422b2124"
++"checksum num-rational 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "ee314c74bd753fc86b4780aa9475da469155f3848473a261d2d18e35245a784e"
++"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
++"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
++"checksum num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5a69d464bdc213aaaff628444e99578ede64e9c854025aa43b9796530afa9238"
++"checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c"
++"checksum openssl 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)" = "ec7bd7ca4cce6dbdc77e7c1230682740d307d1218a87fb0349a571272be749f9"
++"checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
++"checksum openssl-sys 0.9.40 (registry+https://github.com/rust-lang/crates.io-index)" = "1bb974e77de925ef426b6bc82fce15fd45bdcbeb5728bffcfc7cdeeb7ce1c2d6"
++"checksum params 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "421e9f2c30e80365c9672709be664bfc84f73b088720d1cc1f4e99675814bb37"
++"checksum parse-zoneinfo 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f4ee19a3656dadae35a33467f9714f1228dd34766dbe49e10e656b5296867aea"
++"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
++"checksum persistent 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c9c94f2ef72dc272c6bcc8157ccf2bc7da14f4c58c69059ac2fc48492d6916"
++"checksum pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0a6dda33d67c26f0aac90d324ab2eb7239c819fc7b2552fe9faa4fe88441edc8"
++"checksum phf 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18"
++"checksum phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e"
++"checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662"
++"checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0"
++"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c"
++"checksum plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1a6a0dc3910bc8db877ffed8e457763b317cf880df4ae19109b9f77d277cf6e0"
++"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
++"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
++"checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c"
++"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
++"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
++"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
++"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
++"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0"
++"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
++"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
++"checksum rand_jitter 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "080723c6145e37503a2224f801f252e14ac5531cb450f4502698542d188cb3c0"
++"checksum rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b7c690732391ae0abafced5015ffb53656abfaec61b342290e5eb56b286a679d"
++"checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05"
++"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
++"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
++"checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85"
++"checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384"
++"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7"
++"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
++"checksum route-recognizer 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3255338088df8146ba63d60a9b8e3556f1146ce2973bc05a75181a42ce2256"
++"checksum router 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9b1797ff166029cb632237bb5542696e54961b4cf75a324c6f05c9cf0584e4e"
++"checksum rust-gmp 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c3ddf28998d5730b96a9fe188557953de503d77ff403ae175ad1417921e5d906"
++"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
++"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084"
++"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
++"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9"
++"checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7"
++"checksum schannel 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "0e1a231dc10abf6749cfa5d7767f25888d484201accbd919b66ab5413c502d56"
++"checksum security-framework 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfab8dda0e7a327c696d893df9ffa19cadc4bd195797997f5223cf5831beaf05"
++"checksum security-framework-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3d6696852716b589dff9e886ff83778bb635150168e83afa8ac6b8a78cb82abc"
++"checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac"
++"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
++"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
++"checksum sequence_trie 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c915714ca833b1d4d6b8f6a9d72a3ff632fe45b40a8d184ef79c81bec6327eed"
++"checksum serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8"
++"checksum serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "534b8b91a95e0f71bca3ed5824752d558da048d4248c91af873b63bd60519752"
++"checksum serde_codegen 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "a4c5d8a33087d8984f9535daa62a6498a08f6476050b00ab9339dd847e4c25cc"
++"checksum serde_codegen_internals 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "afad7924a009f859f380e4a2e3a509a845c2ac66435fcead74a4d983b21ae806"
++"checksum serde_derive 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "ce44e5f4264b39e9d29c875357b7cc3ebdfb967bb9e22bfb5e44ffa400af5306"
++"checksum serde_json 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "67f7d2e9edc3523a9c8ec8cd6ec481b3a27810aafee3e625d311febd3e656b4c"
++"checksum shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c"
++"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
++"checksum slab 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d807fd58c4181bbabed77cb3b891ba9748241a552bcc5be698faaebefc54f46e"
++"checksum smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "88aea073965ab29f6edb5493faf96ad662fb18aa9eeb186a3b7057951605ed15"
++"checksum staticfile 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "31493480e073d52522a94cdf56269dd8eb05f99549effd1826b0271690608878"
++"checksum strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "67f84c44fbb2f91db7fef94554e6b2ac05909c9c0b0bc23bb98d3a1aebfe7f7c"
++"checksum syn 0.10.8 (registry+https://github.com/rust-lang/crates.io-index)" = "58fd09df59565db3399efbba34ba8a2fec1307511ebd245d0061ff9d42691673"
++"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
++"checksum tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7e91405c14320e5c79b3d148e1c86f40749a36e490642202a31689cb1a3452b2"
++"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
++"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
++"checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4"
++"checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079"
++"checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887"
++"checksum typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "653be63c80a3296da5551e1bfd2cca35227e13cdd08c6668903ae2f4f77aa1f6"
++"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
++"checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33"
++"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
++"checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426"
++"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
++"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
++"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
++"checksum unsafe-any 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f30360d7979f5e9c6e6cea48af192ea8fab4afb3cf72597154b8f08935bc9c7f"
++"checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a"
++"checksum urlencoded 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8c28708636d6f7298a53b1cdb6af40f1ab523209a7cb83cf4d41b3ebc671d319"
++"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737"
++"checksum uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a9ff57156caf7e22f37baf3c9d8f6ce8194842c23419dafcb0716024514d162"
++"checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d"
++"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
++"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
++"checksum walkdir 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c66c0b9792f0a765345452775f3adbd28dde9d33f30d13e5dcc5ae17cf6f3780"
++"checksum walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bb08f9e670fab86099470b97cd2b252d6527f0b3cc1401acdb595ffc9dd288ff"
++"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
++"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
++"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
++"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
++"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
++"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
++"checksum xml-rs 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7ec6c39eaa68382c8e31e35239402c0a9489d4141a8ceb0c716099a0b515b562"
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..0ccb096b8dab
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/rink/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub, rustPlatform, openssl, pkgconfig, gmp, ncurses }:
+
+rustPlatform.buildRustPackage rec {
+  version = "0.4.4";
+  name = "rink-${version}";
+
+  src = fetchFromGitHub {
+    owner = "tiffany352";
+    repo = "rink-rs";
+    rev = "v${version}";
+    sha256 = "0rvck5ahg7s51fdlr2ch698cwnyc6qp84zhfgs3wkszj9r5j470k";
+  };
+  cargoPatches = [ ./cargo-lock.patch ];
+
+  cargoSha256 = "0xmmxm7zwmq7w0pspx17glg4mjgh9l61w0h2k7n97x6p35i198d1";
+
+  buildInputs = [ pkgconfig ];
+  propagatedBuildInputs = [ openssl gmp ncurses ];
+
+  # Some tests fail and/or attempt to use internet servers.
+  doCheck = false;
+
+  meta = with stdenv.lib; {
+    description = "Unit-aware calculator";
+    homepage = http://rink.tiffnix.com;
+    license = with licenses; [ mpl20 gpl3 ];
+    maintainers = [ maintainers.sb0 ];
+  };
+}
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..1f0fc663647a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/root/5.nix
@@ -0,0 +1,80 @@
+{ stdenv, fetchurl, cmake, pcre, pkgconfig, python2
+, libX11, libXpm, libXft, libXext, libGLU_combined, zlib, libxml2, lzma, gsl_1
+, Cocoa, OpenGL, cf-private, noSplash ? false }:
+
+stdenv.mkDerivation rec {
+  name = "root-${version}";
+  version = "5.34.36";
+
+  src = fetchurl {
+    url = "https://root.cern.ch/download/root_v${version}.source.tar.gz";
+    sha256 = "1kbx1jxc0i5xfghpybk8927a0wamxyayij9c74zlqm0595gqx1pw";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ cmake pcre python2 zlib libxml2 lzma gsl_1 ]
+    ++ stdenv.lib.optionals (!stdenv.isDarwin) [ libX11 libXpm libXft libXext libGLU_combined ]
+    ++ stdenv.lib.optionals (stdenv.isDarwin) [ Cocoa OpenGL cf-private ]
+    ;
+
+  patches = [
+    ./sw_vers_root5.patch
+  ];
+
+  preConfigure = ''
+    patchShebangs build/unix/
+    ln -s ${stdenv.lib.getDev stdenv.cc.libc}/include/AvailabilityMacros.h cint/cint/include/
+  '' + stdenv.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"
+  ]
+  ++ stdenv.lib.optional stdenv.isDarwin "-DOPENGL_INCLUDE_DIR=${OpenGL}/Library/Frameworks";
+
+  enableParallelBuilding = true;
+
+  setupHook = ./setup-hook.sh;
+
+  meta = with stdenv.lib; {
+    homepage = https://root.cern.ch/;
+    description = "A data analysis framework";
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ veprbl ];
+    # needs to be adapted to work with modern glibc
+    # it works on darwin by impurely picking up system's libc headers
+    broken = stdenv.isLinux;
+  };
+}
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..8b9573ce4e8b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/root/default.nix
@@ -0,0 +1,77 @@
+{ stdenv, fetchurl, cmake, pcre, pkgconfig, python2
+, libX11, libXpm, libXft, libXext, libGLU_combined, zlib, libxml2, lz4, lzma, gsl, xxHash
+, Cocoa, OpenGL, cf-private, noSplash ? false }:
+
+stdenv.mkDerivation rec {
+  name = "root-${version}";
+  version = "6.12.06";
+
+  src = fetchurl {
+    url = "https://root.cern.ch/download/root_v${version}.source.tar.gz";
+    sha256 = "1557b9sdragsx9i15qh6lq7fn056bgi87d31kxdl4vl0awigvp5f";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ cmake pcre python2 zlib libxml2 lz4 lzma gsl xxHash ]
+    ++ stdenv.lib.optionals (!stdenv.isDarwin) [ libX11 libXpm libXft libXext libGLU_combined ]
+    ++ stdenv.lib.optionals (stdenv.isDarwin) [ Cocoa OpenGL cf-private ]
+    ;
+
+  patches = [
+    ./sw_vers.patch
+  ];
+
+  preConfigure = ''
+    patchShebangs build/unix/
+  '' + stdenv.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"
+    "-Dimt=OFF"
+    "-Dgfal=OFF"
+    "-Dgviz=OFF"
+    "-Dhdfs=OFF"
+    "-Dkrb5=OFF"
+    "-Dldap=OFF"
+    "-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"
+  ]
+  ++ stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.lib.getDev stdenv.cc.libc}/include"
+  ++ stdenv.lib.optional stdenv.isDarwin "-DOPENGL_INCLUDE_DIR=${OpenGL}/Library/Frameworks";
+
+  enableParallelBuilding = true;
+
+  setupHook = ./setup-hook.sh;
+
+  meta = with stdenv.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/setup-hook.sh b/nixpkgs/pkgs/applications/science/misc/root/setup-hook.sh
new file mode 100644
index 000000000000..fc2b697d8a82
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/root/setup-hook.sh
@@ -0,0 +1,9 @@
+thisroot () {
+    # Workaround thisroot.sh dependency on man
+    if [ -z "${MANPATH}" ]; then
+        MANPATH=:
+    fi
+    source @out@/bin/thisroot.sh
+}
+
+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..df0ef79d0a0f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/root/sw_vers.patch
@@ -0,0 +1,90 @@
+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} MATCHES 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,27 +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)
+-  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")
+@@ -135,7 +100,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
+@@ -304,7 +304,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/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..ed6fa3ae886b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/sasview/default.nix
@@ -0,0 +1,75 @@
+{ lib, fetchFromGitHub, gcc, python }:
+
+let
+  xhtml2pdf = import ./xhtml2pdf.nix {
+    inherit lib;
+    fetchPypi = python.pkgs.fetchPypi;
+    buildPythonPackage = python.pkgs.buildPythonPackage;
+    html5lib = python.pkgs.html5lib;
+    httplib2 = python.pkgs.httplib2;
+    nose = python.pkgs.nose;
+    pillow = python.pkgs.pillow;
+    pypdf2 = python.pkgs.pypdf2;
+    reportlab = python.pkgs.reportlab;
+  };
+
+in
+
+python.pkgs.buildPythonApplication rec {
+  pname = "sasview";
+  version = "4.2.0";
+
+  checkInputs = with python.pkgs; [
+    pytest
+    unittest-xml-reporting
+  ];
+
+  checkPhase = ''
+    # fix the following error:
+    # imported module 'sas.sascalc.data_util.uncertainty' has this __file__ attribute:
+    #   /build/source/build/lib.linux-x86_64-2.7/sas/sascalc/data_util/uncertainty.py
+    # which is not the same as the test file we want to collect:
+    #   /build/source/dist/tmpbuild/sasview/sas/sascalc/data_util/uncertainty.py
+    rm -r dist/tmpbuild
+
+    HOME=$(mktemp -d) py.test
+  '';
+
+  propagatedBuildInputs = with python.pkgs; [
+    bumps
+    gcc
+    h5py
+    libxslt
+    lxml
+    matplotlib
+    numpy
+    pyparsing
+    periodictable
+    pillow
+    pylint
+    pyopencl
+    reportlab
+    sasmodels
+    scipy
+    six
+    sphinx
+    wxPython
+    xhtml2pdf
+  ];
+
+  src = fetchFromGitHub {
+    owner = "SasView";
+    repo = "sasview";
+    rev = "v${version}";
+    sha256 = "0k3486h46k6406h0vla8h68fd78wh3dcaq5w6f12jh6g4cjxv9qa";
+  };
+
+  patches = [ ./pyparsing-fix.patch ./local_config.patch ];
+
+  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/local_config.patch b/nixpkgs/pkgs/applications/science/misc/sasview/local_config.patch
new file mode 100644
index 000000000000..5b6c3436494a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/sasview/local_config.patch
@@ -0,0 +1,22 @@
+diff --git a/src/sas/_config.py b/src/sas/_config.py
+index ece08fd4c..926768593 100644
+--- a/src/sas/_config.py
++++ b/src/sas/_config.py
+@@ -67,8 +67,8 @@ def load_local_config(app_dir):
+         logger.info("GuiManager loaded %s", path)
+         return module
+     except Exception as exc:
+-        logger.critical("Error loading %s: %s", path, exc)
+-        sys.exit()
++        import sas.sasview.local_config
++        return sas.sasview.local_config
+ 
+ def make_custom_config_path(user_dir):
+     """
+@@ -116,4 +116,4 @@ def load_custom_config(path):
+ 
+     from sas.sasview import custom_config
+     logger.info("GuiManager custom_config defaults to sas.sasview.custom_config")
+-    return custom_config
+\ No newline at end of file
++    return custom_config
diff --git a/nixpkgs/pkgs/applications/science/misc/sasview/pyparsing-fix.patch b/nixpkgs/pkgs/applications/science/misc/sasview/pyparsing-fix.patch
new file mode 100644
index 000000000000..c3cd164a899a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/sasview/pyparsing-fix.patch
@@ -0,0 +1,13 @@
+diff --git a/setup.py b/setup.py
+index 866ab7e36..78727b276 100755
+--- a/setup.py
++++ b/setup.py
+@@ -401,7 +401,7 @@ package_data['sas.sasview'] = ['images/*',
+ packages.append("sas.sasview")
+ 
+ required = [
+-    'bumps>=0.7.5.9', 'periodictable>=1.5.0', 'pyparsing>=2.0.0',
++    'bumps>=0.7.5.9', 'periodictable>=1.5.0',
+ 
+     # 'lxml>=2.2.2',
+     'lxml', 'h5py',
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..8eff2057928a
--- /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..0b663b2fb63b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/simgrid/default.nix
@@ -0,0 +1,112 @@
+{ stdenv, fetchFromGitHub, cmake, perl, python3, boost, valgrind
+# Optional requirements
+# Lua 5.3 needed and not available now
+#, luaSupport ? false, lua5
+, fortranSupport ? false, gfortran
+, buildDocumentation ? false, transfig, ghostscript, doxygen
+, buildJavaBindings ? false, openjdk
+, modelCheckingSupport ? false, libunwind, libevent, elfutils # Inside elfutils: libelf and libdw
+, debug ? false
+, moreTests ? false
+}:
+
+with stdenv.lib;
+
+let
+  optionOnOff = option: "${if option then "on" else "off"}";
+in
+
+stdenv.mkDerivation rec {
+  name = "simgrid-${version}";
+  version = "3.21";
+
+  src = fetchFromGitHub {
+    owner = "simgrid";
+    repo = "simgrid";
+    rev = "v${replaceChars ["."] ["_"] version}";
+    sha256 = "1v0dwlww2wl56ms8lvg5zwffzbmz3sjzpkqc73f714mrc9g02bxs";
+  };
+
+  nativeBuildInputs = [ cmake perl python3 boost valgrind ]
+      ++ optionals fortranSupport [ gfortran ]
+      ++ optionals buildJavaBindings [ openjdk ]
+      ++ optionals buildDocumentation [ transfig ghostscript doxygen ]
+      ++ optionals modelCheckingSupport [ libunwind libevent elfutils ];
+
+  #buildInputs = optional luaSupport lua5;
+
+  # Make it so that libsimgrid.so will be found when running programs from
+  # the build dir.
+  preConfigure = ''
+    export LD_LIBRARY_PATH="$PWD/build/lib"
+  '';
+
+  # Release mode is not supported in SimGrid
+  cmakeBuildType = "Debug";
+
+  # Disable/Enable functionality
+  # Note: those packages are not packaged in Nixpkgs yet so some options
+  # are disabled:
+  # - papi:   for enable_smpi_papi
+  # - ns3:    for enable_ns3
+  # - lua53:  for enable_lua
+  #
+  # For more information see:
+  # http://simgrid.gforge.inria.fr/simgrid/latest/doc/install.html#install_cmake_list
+  cmakeFlags= ''
+    -Denable_documentation=${optionOnOff buildDocumentation}
+    -Denable_java=${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
+    -Denable_smpi_ISP_testsuite=${optionOnOff moreTests}
+    -Denable_smpi_MPICH3_testsuite=${optionOnOff moreTests}
+    -Denable_compile_warnings=${optionOnOff debug}
+    -Denable_compile_optimizations=${optionOnOff (!debug)}
+    -Denable_lto=${optionOnOff (!debug)}
+  '';
+  # -Denable_lua=${optionOnOff luaSupport}
+  # -Denable_smpi_papi=${optionOnOff moreTests}
+
+  makeFlags = optionalString debug "VERBOSE=1";
+
+  # Some Perl scripts are called to generate test during build which
+  # is before the fixupPhase, so do this manualy here:
+  preBuild = ''
+    patchShebangs ..
+  '';
+
+  doCheck = true;
+
+  checkPhase = ''
+    runHook preCheck
+
+    ctest -j $NIX_BUILD_CORES --output-on-failure -E smpi-replay-multiple
+
+    runHook postCheck
+  '';
+
+  enableParallelBuilding = true;
+
+  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 ];
+    platforms = ["x86_64-linux"];
+  };
+}
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..6f04d436877f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/snakemake/default.nix
@@ -0,0 +1,42 @@
+{
+  stdenv
+, python
+}:
+
+python.buildPythonPackage rec {
+  pname = "snakemake";
+  version = "5.2.2";
+
+  propagatedBuildInputs = with python; [
+    appdirs
+    ConfigArgParse
+    datrie
+    docutils
+    jsonschema
+    pyyaml
+    ratelimiter
+    requests
+    wrapt
+  ];
+
+  src = python.fetchPypi {
+    inherit pname version;
+    sha256 = "adffe7e24b4a613a9e8bf0a2a320b3cea236d86afb9132bb0bbbc08b8e35a3a3";
+  };
+
+  doCheck = false; # Tests depend on Google Cloud credentials at ${HOME}/gcloud-service-key.json
+
+  meta = with stdenv.lib; {
+    homepage = http://snakemake.bitbucket.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 ];
+  };
+}
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..7db2e6a12c20
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/tulip/default.nix
@@ -0,0 +1,38 @@
+{ fetchurl, stdenv, libxml2, freetype, libGLU_combined, glew, qt4
+, cmake, makeWrapper, libjpeg, python }:
+
+let version = "5.1.0"; in
+stdenv.mkDerivation rec {
+  name = "tulip-${version}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/auber/${name}_src.tar.gz";
+    sha256 = "1i70y8b39gkpxfalr9844pa3l4bnnyw5y7ngxdqibil96k2b9q9h";
+  };
+
+  buildInputs = [ libxml2 freetype glew libGLU_combined qt4 libjpeg python ];
+
+  nativeBuildInputs = [ cmake makeWrapper ];
+
+  # 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 = stdenv.lib.licenses.gpl3Plus;
+
+    maintainers = [ ];
+    platforms = stdenv.lib.platforms.gnu ++ stdenv.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..64482ddd74bc
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/misc/vite/default.nix
@@ -0,0 +1,44 @@
+{ fetchsvn, stdenv, cmake, qt4, libGLU_combined }:
+
+# 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 {
+  name = "vite-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
+  '';
+
+  buildInputs = [ cmake qt4 libGLU_combined ];
+
+  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 = stdenv.lib.licenses.cecill20;
+    maintainers = with stdenv.lib.maintainers; [ fuuzetsu ];
+    platforms = stdenv.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..1986f3b75ec1
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/molecular-dynamics/dl-poly-classic/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchurl
+, gfortran, mpi
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.10";
+  name = "DL_POLY_Classic-${version}";
+
+  src = fetchurl {
+    url = "https://ccpforge.cse.rl.ac.uk/gf/download/frsrelease/574/8924/dl_class_1.10.tar.gz";
+    sha256 = "1r76zvln3bwycxlmqday0sqzv5j260y7mdh66as2aqny6jzd5ld7";
+  };
+
+  buildInputs = [ mpi gfortran ];
+
+  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 stdenv.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..a682d59ab23a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/molecular-dynamics/gromacs/default.nix
@@ -0,0 +1,55 @@
+
+{ stdenv, fetchurl, cmake,
+  singlePrec ? true,
+  mpiEnabled ? false,
+  fftw,
+  openmpi
+}:
+
+
+stdenv.mkDerivation {
+  name = "gromacs-2019";
+
+  src = fetchurl {
+    url = "ftp://ftp.gromacs.org/pub/gromacs/gromacs-2019.tar.gz";
+    sha256 = "02qd27pgc5kwkk68m8hwarkbb1b9z5rdrm67yjqyxd5my2jq3cn5";
+  };
+
+  buildInputs = [cmake fftw]
+  ++ (stdenv.lib.optionals mpiEnabled [ openmpi ]);
+
+  cmakeFlags = ''
+    ${if singlePrec then "-DGMX_DOUBLE=OFF" else "-DGMX_DOUBLE=ON -DGMX_DEFAULT_SUFFIX=OFF"}
+    ${if mpiEnabled then "-DGMX_MPI:BOOL=TRUE 
+                          -DGMX_CPU_ACCELERATION:STRING=SSE4.1 
+                          -DGMX_OPENMP:BOOL=TRUE
+                          -DGMX_THREAD_MPI:BOOL=FALSE"
+                     else "-DGMX_MPI:BOOL=FALSE" }
+  '';
+
+  meta = with stdenv.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;
+  };
+}
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..f4491053e4c8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/molecular-dynamics/lammps/default.nix
@@ -0,0 +1,67 @@
+{ stdenv, fetchFromGitHub
+, libpng, gzip, fftw, openblas
+, mpi ? null
+}:
+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";
+    withMPI = (mpi != null);
+in
+stdenv.mkDerivation rec {
+  # LAMMPS has weird versioning converted to ISO 8601 format
+  version = "stable_22Aug2018";
+  name = "lammps-${version}";
+
+  src = fetchFromGitHub {
+    owner = "lammps";
+    repo = "lammps";
+    rev = "${version}";
+    sha256 = "1dlifm9wm1jcw2zwal3fnzzl41ng08c7v48w6hx2mz84zljg1nsj";
+  };
+
+  passthru = {
+    inherit mpi;
+    inherit packages;
+  };
+
+  buildInputs = [ fftw libpng openblas gzip ]
+    ++ (stdenv.lib.optionals withMPI [ mpi ]);
+
+  configurePhase = ''
+    cd src
+    for pack in ${stdenv.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 stdenv.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 = http://lammps.sandia.gov;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.costrouc ];
+  };
+}
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..ad86ff61471c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/physics/quantomatic/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchurl, jre, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "quantomatic-${version}";
+  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 ];
+
+  phases = [ "installPhase" ];
+
+  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 stdenv.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..64b88dcc3d4f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/physics/sacrifice/default.nix
@@ -0,0 +1,47 @@
+{ stdenv, fetchurl, boost, hepmc, lhapdf, pythia, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "sacrifice-${version}";
+  version = "1.0.0";
+
+  src = fetchurl {
+    url = "https://www.hepforge.org/archive/agile/Sacrifice-1.0.0.tar.gz";
+    sha256 = "10bvpq63kmszy1habydwncm0j1dgvam0fkrmvkgbkvf804dcjp6g";
+  };
+
+  buildInputs = [ boost hepmc lhapdf pythia ];
+  nativeBuildInputs = [ makeWrapper ];
+
+  patches = [
+    ./compat.patch
+  ];
+
+  preConfigure = ''
+    substituteInPlace configure --replace HAVE_LCG=yes HAVE_LCG=no
+  ''
+  + stdenv.lib.optionalString stdenv.isDarwin ''
+    substituteInPlace configure --replace LIB_SUFFIX=\"so\" LIB_SUFFIX=\"dylib\"
+  '';
+
+  configureFlags = [
+    "--with-HepMC=${hepmc}"
+    "--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     = stdenv.lib.licenses.gpl2;
+    homepage    = https://agile.hepforge.org/trac/wiki/Sacrifice;
+    platforms   = stdenv.lib.platforms.unix;
+    maintainers = with stdenv.lib.maintainers; [ veprbl ];
+  };
+}
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..7cb3e8881caf
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/physics/sherpa/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchurl, gfortran, hepmc, fastjet, lhapdf, rivet, sqlite }:
+
+stdenv.mkDerivation rec {
+  name = "sherpa-${version}";
+  version = "2.2.6";
+
+  src = fetchurl {
+    url = "https://www.hepforge.org/archive/sherpa/SHERPA-MC-${version}.tar.gz";
+    sha256 = "1cagkkz1pjl0pdf85w1qkwhx0afi3kxm1vnmfavq1zqhss7fc57i";
+  };
+
+  buildInputs = [ gfortran sqlite lhapdf rivet ];
+
+  enableParallelBuilding = true;
+
+  configureFlags = [
+    "--with-sqlite3=${sqlite.dev}"
+    "--enable-hepmc2=${hepmc}"
+    "--enable-fastjet=${fastjet}"
+    "--enable-lhapdf=${lhapdf}"
+    "--enable-rivet=${rivet}"
+  ];
+
+  CXXFLAGS = "-std=c++11"; # needed for rivet on OSX
+
+  meta = {
+    description = "Simulation of High-Energy Reactions of PArticles in lepton-lepton, lepton-photon, photon-photon, lepton-hadron and hadron-hadron collisions";
+    license     = stdenv.lib.licenses.gpl2;
+    homepage    = https://gitlab.com/sherpa-team/sherpa;
+    platforms   = stdenv.lib.platforms.unix;
+    maintainers = with stdenv.lib.maintainers; [ veprbl ];
+  };
+}
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..ae5307f155bd
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/physics/xfitter/default.nix
@@ -0,0 +1,56 @@
+{ stdenv, fetchurl, apfel, apfelgrid, applgrid, blas, gfortran, lhapdf, liblapack, libyaml, lynx, mela, root5, qcdnum, which }:
+
+stdenv.mkDerivation rec {
+  name = "xfitter-${version}";
+  version = "2.0.0";
+
+  src = fetchurl {
+    name = "${name}.tgz";
+    url = "https://www.xfitter.org/xFitter/xFitter/DownloadPage?action=AttachFile&do=get&target=${name}.tgz";
+    sha256 = "0j47s8laq3aqjlgp769yicvgyzqjb738a3rqss51d9fjrihi2515";
+  };
+
+  patches = [
+    ./undefined_behavior.patch
+  ];
+
+  CXXFLAGS = "-Werror=return-type";
+
+  preConfigure =
+  # Fix F77LD to workaround for a following build error:
+  #
+  #   gfortran: error: unrecognized command line option '-stdlib=libc++'
+  #
+    stdenv.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 liblapack mela root5 qcdnum ]
+    # pdf2yaml requires fmemopen and open_memstream which are not readily available on Darwin
+    ++ stdenv.lib.optional (!stdenv.isDarwin) libyaml
+    ;
+  propagatedBuildInputs = [ lynx ];
+
+  enableParallelBuilding = true;
+
+  hardeningDisable = [ "format" ];
+
+  meta = with stdenv.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/programming/fdr/default.nix b/nixpkgs/pkgs/applications/science/programming/fdr/default.nix
new file mode 100644
index 000000000000..3bfb70f5ce8e
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/programming/fdr/default.nix
@@ -0,0 +1,69 @@
+{stdenv, fetchurl, qtbase, qtx11extras, ncurses, xorg, zlib, python27Packages}:
+stdenv.mkDerivation {
+  name = "fdr-4.2.3";
+  src = fetchurl {
+    url = https://www.cs.ox.ac.uk/projects/fdr/downloads/fdr-3789-linux-x86_64.tar.gz;
+    sha256 = "0n2yqichym5xdawlgk3r7yha88k7ycnx6585jfrcm7043sls1i88";
+  };
+
+  libPath = stdenv.lib.makeLibraryPath [
+    stdenv.cc.cc
+    python27Packages.python
+    qtbase
+    qtx11extras
+    ncurses
+    xorg.libX11
+    xorg.libXft
+    zlib
+  ];
+
+  phases = [ "unpackPhase" "installPhase" ];
+  installPhase = ''
+    mkdir -p "$out"
+
+    # shipped Qt is buggy
+    rm lib/libQt*
+    rm -r lib/qt_plugins
+
+    cp -r * "$out"
+    # Hack around lack of libtinfo in NixOS
+    ln -s ${ncurses.out}/lib/libncursesw.so.6 $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 stdenv.lib; {
+    homepage = https://www.cs.ox.ac.uk/projects/fdr/;
+    description = "The CSP refinement checker";
+    license = licenses.unfreeRedistributable;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ nickhu ];
+  };
+}
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..c454ad377686
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/programming/plm/default.nix
@@ -0,0 +1,36 @@
+{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 {
+  major = "2";
+  minor = "5";
+  version = "${major}-${minor}";
+  name = "plm-${version}";
+
+  src = fetchurl {
+    url = "http://webloria.loria.fr/~quinson/Teaching/PLM/plm-${major}_${minor}.jar";
+    sha256 = "0m17cxa3nxi2cbswqvlfzp0mlfi3wrkw8ry2xhkxy6aqzm2mlgcc";
+    name = "${name}.jar";
+  };
+
+  buildInputs = [ makeWrapper jre gcc valgrind ];
+
+  phases = [ "installPhase" ];
+
+  installPhase = ''
+    mkdir -p "$prefix/bin"
+
+    makeWrapper ${jre}/bin/java $out/bin/plm \
+      --add-flags "-jar $src" \
+      --prefix PATH : "$PATH"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Free cross-platform programming exerciser";
+    license = licenses.gpl3;
+    maintainers = [ ];
+    platforms = stdenv.lib.platforms.all;
+    broken = true;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/programming/scyther/cli.nix b/nixpkgs/pkgs/applications/science/programming/scyther/cli.nix
new file mode 100644
index 000000000000..152b71217743
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/programming/scyther/cli.nix
@@ -0,0 +1,32 @@
+{ stdenv, glibc, flex, bison, cmake
+, version, src, meta }:
+stdenv.mkDerivation {
+  name = "scyther-cli-${version}";
+
+  inherit src meta;
+
+  buildInputs = [
+    cmake
+    glibc.static
+    flex
+    bison
+  ];
+
+  patchPhase = ''
+    # Since we're not in a git dir, the normal command this project uses to create this file wouldn't work
+    printf "%s\n" "#define TAGVERSION \"${version}\"" > src/version.h
+  '';
+
+  configurePhase = ''
+    (cd src && cmakeConfigurePhase)
+  '';
+
+  dontUseCmakeBuildDir = true;
+  cmakeFlags = [ "-DCMAKE_C_FLAGS=-std=gnu89" ];
+
+  installPhase = ''
+    mkdir -p "$out/bin"
+    mv src/scyther-linux "$out/bin/scyther-cli"
+    ln -s "$out/bin/scyther-cli" "$out/bin/scyther-linux"
+  '';
+}
diff --git a/nixpkgs/pkgs/applications/science/programming/scyther/default.nix b/nixpkgs/pkgs/applications/science/programming/scyther/default.nix
new file mode 100644
index 000000000000..e0993a580193
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/programming/scyther/default.nix
@@ -0,0 +1,79 @@
+{ stdenv, lib, buildEnv, pkgsi686Linux, fetchFromGitHub, python27Packages, graphviz
+, includeGUI ? true
+, includeProtocols ? true
+}:
+let
+  version = "1.1.3";
+
+  src = fetchFromGitHub {
+    rev = "v${version}";
+    sha256 = "0rb4ha5bnjxnwj4f3hciq7kyj96fhw14hqbwl5kr9cdw8q62mx0h";
+    owner = "cascremers";
+    repo = "scyther";
+  };
+
+  meta = with lib; {
+    description = "Scyther is a tool for the automatic verification of security protocols.";
+    homepage = https://www.cs.ox.ac.uk/people/cas.cremers/scyther/;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ infinisil ];
+    platforms = platforms.linux;
+  };
+
+  cli = pkgsi686Linux.callPackage ./cli.nix {
+    inherit version src meta;
+  };
+
+  gui = stdenv.mkDerivation {
+    name = "scyther-gui-${version}";
+    inherit src meta;
+    buildInputs = [
+      python27Packages.wrapPython
+    ];
+
+    patchPhase = ''
+      file=gui/Scyther/Scyther.py
+
+      # By default the scyther binary is looked for in the directory of the python script ($out/gui), but we want to have it look where our cli package is
+      substituteInPlace $file --replace "return getMyDir()" "return \"${cli}/bin\""
+
+      # Removes the Shebang from the file, as this would be wrapped wrongly
+      sed -i -e "1d" $file
+    '';
+
+    dontBuild = true;
+
+    propagatedBuildInputs = [
+      python27Packages.wxPython
+      graphviz
+    ];
+
+    installPhase = ''
+      mkdir -p "$out"/gui "$out"/bin
+      cp -r gui/* "$out"/gui
+      ln -s "$out"/gui/scyther-gui.py "$out/bin/scyther-gui"
+    '';
+
+    postFixup = ''
+      wrapPythonProgramsIn "$out/gui" "$out $pythonPath"
+    '';
+
+    doInstallCheck = true;
+    installCheckPhase = ''
+      "$out/gui/scyther.py" "$src/gui/Protocols/Demo/ns3.spdl"
+    '';
+  };
+in
+  buildEnv {
+    name = "scyther-${version}";
+    inherit meta;
+    paths = [ cli ] ++ lib.optional includeGUI gui;
+    pathsToLink = [ "/bin" ];
+
+    postBuild = ''
+      rm "$out/bin/scyther-linux"
+    '' + lib.optionalString includeProtocols ''
+      mkdir -p "$out/protocols"
+      cp -rv ${src}/protocols/* "$out/protocols"
+    '';
+  }
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..2d579a803698
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/robotics/apmplanner2/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchFromGitHub, qmake
+, qtbase, qtscript, qtwebkit, qtserialport, qtsvg, qtdeclarative, qtquickcontrols2
+, alsaLib, libsndfile, flite, openssl, udev, SDL2
+}:
+
+stdenv.mkDerivation rec {
+  name = "apmplanner2-${version}";
+  version = "2.0.26";
+  src = fetchFromGitHub {
+    owner = "ArduPilot";
+    repo = "apm_planner";
+    rev = "${version}";
+    sha256 = "0bnyi1r8k8ij5sq2zqv7mfbrxm0xdw97qrx3sk4rinqv2g6h6di4";
+  };
+
+  qtInputs = [
+    qtbase qtscript qtwebkit qtserialport qtsvg qtdeclarative qtquickcontrols2
+  ];
+
+  buildInputs = [ alsaLib libsndfile flite openssl udev SDL2 ] ++ qtInputs;
+  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
+  '';
+  
+  enableParallelBuilding = true;
+
+  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 = http://ardupilot.org/planner2/;
+    license = stdenv.lib.licenses.gpl3;
+    maintainers = [ stdenv.lib.maintainers.wucke13 ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/robotics/gazebo/6.nix b/nixpkgs/pkgs/applications/science/robotics/gazebo/6.nix
new file mode 100644
index 000000000000..0d1aa4a9085f
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/robotics/gazebo/6.nix
@@ -0,0 +1,8 @@
+{ stdenv, fetchurl, callPackage, ignition, gazeboSimulator, ... } @ args:
+
+callPackage ./default.nix (args // rec {
+  version = "6.5.1";
+  src-sha256 = "96260aa23f1a1f24bc116f8e359d31f3bc65011033977cb7fb2c64d574321908";
+  sdformat = gazeboSimulator.sdformat3;
+})
+
diff --git a/nixpkgs/pkgs/applications/science/robotics/gazebo/default.nix b/nixpkgs/pkgs/applications/science/robotics/gazebo/default.nix
new file mode 100644
index 000000000000..98ccd92c4ee5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/robotics/gazebo/default.nix
@@ -0,0 +1,84 @@
+{ stdenv, fetchurl, cmake, pkgconfig, boost, protobuf, freeimage
+  , boost-build, boost_process
+  , xorg_sys_opengl, tbb, ogre, tinyxml-2
+  , libtar, glxinfo,  libusb, libxslt, ignition
+  , pythonPackages, utillinux
+
+  # these deps are hidden; cmake doesn't catch them
+  , gazeboSimulator, sdformat ? gazeboSimulator.sdformat, curl, tinyxml, qt4
+  , xlibsWrapper
+  , withIgnitionTransport ? true
+  , libav, withLibAvSupport ? true
+  , openal, withAudioSupport ? false
+  , withQuickBuild ? false, withHeadless ? false, withLowMemorySupport ? false
+  , doxygen, withDocs ? true
+  , bullet, withBulletEngineSupport ? false
+  , graphviz, withModelEditorSchematicView ? true # graphviz needed for this view
+  , gdal, withDigitalElevationTerrainsSupport ? true
+  , gts, withConstructiveSolidGeometrySupport ? true
+  , hdf5, withHdf5Support ? true
+  , version ? "7.0.0"
+  , src-sha256 ? "127q2g93kvmak2b6vhl13xzg56h09v14s4pki8wv7aqjv0c3whbl"
+  , ...
+}: with stdenv.lib;
+
+stdenv.mkDerivation rec {
+  inherit version;
+  name = "gazebo-${version}";
+
+  src = fetchurl {
+    url = "https://osrf-distributions.s3.amazonaws.com/gazebo/releases/${name}.tar.bz2";
+    sha256 = src-sha256;
+  };
+
+  enableParallelBuilding = true; # gazebo needs this so bad
+  cmakeFlags = [
+  "-DCMAKE_INSTALL_LIBDIR:PATH=lib"
+  "-DCMAKE_INSTALL_INCLUDEDIR=include" ]
+    ++ optional withQuickBuild [ "-DENABLE_TESTS_COMPILATION=False" ]
+    ++ optional withLowMemorySupport [ "-DUSE_LOW_MEMORY_TESTS=True" ]
+    ++ optional withHeadless [ "-DENABLE_SCREEN_TESTS=False" ];
+
+  nativeBuildInputs = [ cmake pkgconfig ];
+
+  propagatedNativeBuildInputs = [ boost boost-build boost_process protobuf ];
+
+  buildInputs = [
+    #cmake boost protobuf
+    freeimage
+    xorg_sys_opengl
+    tbb
+    ogre
+    tinyxml-2
+    libtar
+    glxinfo
+    libusb
+    libxslt
+    ignition.math2
+    sdformat
+    pythonPackages.pyopengl
+
+    # TODO: add these hidden deps to cmake configuration & submit upstream
+    curl
+    tinyxml
+    xlibsWrapper
+    qt4
+  ] ++ optional stdenv.isLinux utillinux # on Linux needs uuid/uuid.h
+    ++ optional withDocs doxygen
+    ++ optional withLibAvSupport libav  #TODO: package rubygem-ronn and put it here
+    ++ optional withAudioSupport openal
+    ++ optional withBulletEngineSupport bullet
+    ++ optional withIgnitionTransport ignition.transport
+    ++ optional withModelEditorSchematicView graphviz
+    ++ optional withDigitalElevationTerrainsSupport gdal
+    ++ optional withConstructiveSolidGeometrySupport gts
+    ++ optional withHdf5Support hdf5;
+
+  meta = with stdenv.lib; {
+    homepage = http://gazebosim.org/;
+    description = "Multi-robot simulator for outdoor environments";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ pxc ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/robotics/qgroundcontrol/0001-fix-gcc-cmath-namespace-issues.patch b/nixpkgs/pkgs/applications/science/robotics/qgroundcontrol/0001-fix-gcc-cmath-namespace-issues.patch
new file mode 100644
index 000000000000..e6c9ca38a989
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/robotics/qgroundcontrol/0001-fix-gcc-cmath-namespace-issues.patch
@@ -0,0 +1,140 @@
+From fffc383c10c7c194e427d78c83802c3b910fa1c2 Mon Sep 17 00:00:00 2001
+From: Patrick Callahan <pxcallahan@gmail.com>
+Date: Thu, 24 Mar 2016 18:17:57 -0700
+Subject: [PATCH] fix gcc cmath namespace issues
+
+---
+ src/Vehicle/Vehicle.cc        | 6 +++---
+ src/comm/QGCFlightGearLink.cc | 4 ++--
+ src/comm/QGCJSBSimLink.cc     | 4 ++--
+ src/uas/UAS.cc                | 8 ++++----
+ src/ui/QGCDataPlot2D.cc       | 4 ++--
+ 5 files changed, 13 insertions(+), 13 deletions(-)
+
+diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc
+index a0d3605..205b1de 100644
+--- a/src/Vehicle/Vehicle.cc
++++ b/src/Vehicle/Vehicle.cc
+@@ -638,17 +638,17 @@ void Vehicle::setLongitude(double longitude){
+ 
+ void Vehicle::_updateAttitude(UASInterface*, double roll, double pitch, double yaw, quint64)
+ {
+-    if (isinf(roll)) {
++    if (std::isinf(roll)) {
+         _rollFact.setRawValue(0);
+     } else {
+         _rollFact.setRawValue(roll * (180.0 / M_PI));
+     }
+-    if (isinf(pitch)) {
++    if (std::isinf(pitch)) {
+         _pitchFact.setRawValue(0);
+     } else {
+         _pitchFact.setRawValue(pitch * (180.0 / M_PI));
+     }
+-    if (isinf(yaw)) {
++    if (std::isinf(yaw)) {
+         _headingFact.setRawValue(0);
+     } else {
+         yaw = yaw * (180.0 / M_PI);
+diff --git a/src/comm/QGCFlightGearLink.cc b/src/comm/QGCFlightGearLink.cc
+index 2a520fb..886aecf 100644
+--- a/src/comm/QGCFlightGearLink.cc
++++ b/src/comm/QGCFlightGearLink.cc
+@@ -230,7 +230,7 @@ void QGCFlightGearLink::updateControls(quint64 time, float rollAilerons, float p
+     Q_UNUSED(systemMode);
+     Q_UNUSED(navMode);
+ 
+-    if(!isnan(rollAilerons) && !isnan(pitchElevator) && !isnan(yawRudder) && !isnan(throttle))
++    if(!std::isnan(rollAilerons) && !std::isnan(pitchElevator) && !std::isnan(yawRudder) && !std::isnan(throttle))
+     {
+         QString state("%1\t%2\t%3\t%4\t%5\n");
+         state = state.arg(rollAilerons).arg(pitchElevator).arg(yawRudder).arg(true).arg(throttle);
+@@ -240,7 +240,7 @@ void QGCFlightGearLink::updateControls(quint64 time, float rollAilerons, float p
+     }
+     else
+     {
+-        qDebug() << "HIL: Got NaN values from the hardware: isnan output: roll: " << isnan(rollAilerons) << ", pitch: " << isnan(pitchElevator) << ", yaw: " << isnan(yawRudder) << ", throttle: " << isnan(throttle);
++        qDebug() << "HIL: Got NaN values from the hardware: std::isnan output: roll: " << std::isnan(rollAilerons) << ", pitch: " << std::isnan(pitchElevator) << ", yaw: " << std::isnan(yawRudder) << ", throttle: " << std::isnan(throttle);
+     }
+ }
+ 
+diff --git a/src/comm/QGCJSBSimLink.cc b/src/comm/QGCJSBSimLink.cc
+index 1210621..89db371 100644
+--- a/src/comm/QGCJSBSimLink.cc
++++ b/src/comm/QGCJSBSimLink.cc
+@@ -242,7 +242,7 @@ void QGCJSBSimLink::updateControls(quint64 time, float rollAilerons, float pitch
+     Q_UNUSED(systemMode);
+     Q_UNUSED(navMode);
+ 
+-    if(!isnan(rollAilerons) && !isnan(pitchElevator) && !isnan(yawRudder) && !isnan(throttle))
++    if(!std::isnan(rollAilerons) && !std::isnan(pitchElevator) && !std::isnan(yawRudder) && !std::isnan(throttle))
+     {
+         QString state("%1\t%2\t%3\t%4\t%5\n");
+         state = state.arg(rollAilerons).arg(pitchElevator).arg(yawRudder).arg(true).arg(throttle);
+@@ -250,7 +250,7 @@ void QGCJSBSimLink::updateControls(quint64 time, float rollAilerons, float pitch
+     }
+     else
+     {
+-        qDebug() << "HIL: Got NaN values from the hardware: isnan output: roll: " << isnan(rollAilerons) << ", pitch: " << isnan(pitchElevator) << ", yaw: " << isnan(yawRudder) << ", throttle: " << isnan(throttle);
++        qDebug() << "HIL: Got NaN values from the hardware: isnan output: roll: " << std::isnan(rollAilerons) << ", pitch: " << std::isnan(pitchElevator) << ", yaw: " << std::isnan(yawRudder) << ", throttle: " << std::isnan(throttle);
+     }
+     //qDebug() << "Updated controls" << state;
+ }
+diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc
+index 4d5c1c2..ac88852 100644
+--- a/src/uas/UAS.cc
++++ b/src/uas/UAS.cc
+@@ -558,7 +558,7 @@ void UAS::receiveMessage(mavlink_message_t message)
+ 

+             setAltitudeAMSL(hud.alt);

+             setGroundSpeed(hud.groundspeed);

+-            if (!isnan(hud.airspeed))

++            if (!std::isnan(hud.airspeed))

+                 setAirSpeed(hud.airspeed);

+             speedZ = -hud.climb;

+             emit altitudeChanged(this, altitudeAMSL, altitudeRelative, -speedZ, time);

+@@ -654,7 +654,7 @@ void UAS::receiveMessage(mavlink_message_t message)
+ 

+                     float vel = pos.vel/100.0f;

+                     // Smaller than threshold and not NaN

+-                    if ((vel < 1000000) && !isnan(vel) && !isinf(vel)) {

++                    if ((vel < 1000000) && !std::isnan(vel) && !std::isinf(vel)) {

+                         setGroundSpeed(vel);

+                         emit speedChanged(this, groundSpeed, airSpeed, time);

+                     } else {

+@@ -1439,8 +1439,8 @@ void UAS::setExternalControlSetpoint(float roll, float pitch, float yaw, float t
+     if (countSinceLastTransmission++ >= 5) {

+         sendCommand = true;

+         countSinceLastTransmission = 0;

+-    } else if ((!isnan(roll) && roll != manualRollAngle) || (!isnan(pitch) && pitch != manualPitchAngle) ||

+-             (!isnan(yaw) && yaw != manualYawAngle) || (!isnan(thrust) && thrust != manualThrust) ||

++    } else if ((!std::isnan(roll) && roll != manualRollAngle) || (!std::isnan(pitch) && pitch != manualPitchAngle) ||

++             (!std::isnan(yaw) && yaw != manualYawAngle) || (!std::isnan(thrust) && thrust != manualThrust) ||

+              buttons != manualButtons) {

+         sendCommand = true;

+ 

+diff --git a/src/ui/QGCDataPlot2D.cc b/src/ui/QGCDataPlot2D.cc
+index 2e530b2..9d5a774 100644
+--- a/src/ui/QGCDataPlot2D.cc
++++ b/src/ui/QGCDataPlot2D.cc
+@@ -535,7 +535,7 @@ void QGCDataPlot2D::loadCsvLog(QString file, QString xAxisName, QString yAxisFil
+                 {
+                     bool okx = true;
+                     x = text.toDouble(&okx);
+-                    if (okx && !isnan(x) && !isinf(x))
++                    if (okx && !std::isnan(x) && !std::isinf(x))
+                     {
+                         headerfound = true;
+                     }
+@@ -561,7 +561,7 @@ void QGCDataPlot2D::loadCsvLog(QString file, QString xAxisName, QString yAxisFil
+                         y = text.toDouble(&oky);
+                         // Only INF is really an issue for the plot
+                         // NaN is fine
+-                        if (oky && !isnan(y) && !isinf(y) && text.length() > 0 && text != " " && text != "\n" && text != "\r" && text != "\t")
++                        if (oky && !std::isnan(y) && !std::isinf(y) && text.length() > 0 && text != " " && text != "\n" && text != "\r" && text != "\t")
+                         {
+                             // Only append definitely valid values
+                             xValues.value(curveName)->append(x);
+-- 
+2.7.4
+
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..eae5d3766d6d
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/robotics/qgroundcontrol/default.nix
@@ -0,0 +1,73 @@
+{ stdenv, fetchgit, git,  SDL2, udev, doxygen
+, qtbase, qtlocation, qtserialport, qtdeclarative, qtconnectivity, qtxmlpatterns
+, qtsvg, qtquick1, qtquickcontrols, qtgraphicaleffects, qmake, qtspeech
+, makeWrapper
+, gst_all_1, pkgconfig
+}:
+
+stdenv.mkDerivation rec {
+  name = "qgroundcontrol-${version}";
+  version = "3.3.0";
+
+  qtInputs = [
+    qtbase qtlocation qtserialport qtdeclarative qtconnectivity qtxmlpatterns qtsvg
+    qtquick1 qtquickcontrols qtgraphicaleffects qtspeech
+  ];
+
+  gstInputs = with gst_all_1; [
+    gstreamer gst-plugins-base
+  ];
+
+  enableParallelBuilding = true;
+  buildInputs = [ SDL2 udev doxygen git ] ++ gstInputs ++ qtInputs;
+  nativeBuildInputs = [ pkgconfig makeWrapper qmake ];
+
+  preConfigure = ''
+    mkdir build
+    cd build
+  '';
+
+  qmakeFlags = [
+    # Default install tries to copy Qt files into package
+    "CONFIG+=QGC_DISABLE_BUILD_SETUP"
+    "../qgroundcontrol.pro"
+  ];
+
+  installPhase = ''
+    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/release/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
+  '';
+
+  postInstall = ''
+    wrapProgram "$out/bin/qgroundcontrol" \
+      --prefix GST_PLUGIN_SYSTEM_PATH : "$GST_PLUGIN_SYSTEM_PATH"
+  '';
+
+  # TODO: package mavlink so we can build from a normal source tarball
+  src = fetchgit {
+    url = "https://github.com/mavlink/qgroundcontrol.git";
+    rev = "refs/tags/v${version}";
+    sha256 = "0abjm0wywp24qlgg9w8g35ijprjg5csq4fgba9caaiwvmpfbhmpw";
+    fetchSubmodules = true;
+  };
+
+  meta = with stdenv.lib; {
+    description = "Provides full ground station support and configuration for the PX4 and APM Flight Stacks";
+    homepage = http://qgroundcontrol.org/;
+    license = licenses.gpl3Plus;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ pxc ];
+  };
+}
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..507481cddab2
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/robotics/yarp/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchFromGitHub, cmake, ace
+}:
+
+stdenv.mkDerivation rec {
+  name = "yarp-${version}";
+  version = "2.3.70.2";
+  src = fetchFromGitHub {
+    owner = "robotology";
+    repo = "yarp";
+    rev = "v${version}";
+    sha256 = "0mphh899niy30xbjjwi9xpsliq8mladfldbbbjfngdrqfhiray1a";
+  };
+
+  buildInputs = [ cmake ace ];
+
+  enableParallelBuilding = true;
+
+  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 = stdenv.lib.licenses.lgpl21;
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.nico202 ];
+  };
+}
+
diff --git a/nixpkgs/pkgs/applications/science/spyder/default.nix b/nixpkgs/pkgs/applications/science/spyder/default.nix
new file mode 100644
index 000000000000..417d5544d6c8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/spyder/default.nix
@@ -0,0 +1,75 @@
+{ stdenv, python3, makeDesktopItem }:
+
+let
+
+  spyder-kernels = with python3.pkgs; buildPythonPackage rec {
+    pname = "spyder-kernels";
+    version = "0.4.2";
+
+    src = fetchPypi {
+      inherit pname version;
+      sha256 = "a13cefb569ef9f63814cb5fcf3d0db66e09d2d7e6cc68c703d5118b2d7ba062b";
+    };
+
+    propagatedBuildInputs = [
+      cloudpickle
+      ipykernel
+      wurlitzer
+    ];
+
+    # No tests
+    doCheck = false;
+
+    meta = {
+      description = "Jupyter kernels for Spyder's console";
+      homepage = https://github.com/spyder-ide/spyder-kernels;
+      license = stdenv.lib.licenses.mit;
+    };
+  };
+
+in python3.pkgs.buildPythonApplication rec {
+  pname = "spyder";
+  version = "3.3.3";
+
+  src = python3.pkgs.fetchPypi {
+    inherit pname version;
+    sha256 = "ef31de03cf6f149077e64ed5736b8797dbd278e3c925e43f0bfc31bb55f6e5ba";
+  };
+
+  propagatedBuildInputs = with python3.pkgs; [
+    jedi pycodestyle psutil pyflakes rope numpy scipy matplotlib pylint keyring
+    numpydoc qtconsole qtawesome nbconvert mccabe pyopengl cloudpickle spyder-kernels
+  ];
+
+  # There is no test for spyder
+  doCheck = false;
+
+  desktopItem = makeDesktopItem {
+    name = "Spyder";
+    exec = "spyder";
+    icon = "spyder";
+    comment = "Scientific Python Development Environment";
+    desktopName = "Spyder";
+    genericName = "Python IDE";
+    categories = "Application;Development;Editor;IDE;";
+  };
+
+  # Create desktop item
+  postInstall = ''
+    mkdir -p $out/share/icons
+    cp spyder/images/spyder.svg $out/share/icons
+    cp -r $desktopItem/share/applications/ $out/share
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Scientific python development environment";
+    longDescription = ''
+      Spyder (previously known as Pydee) is a powerful interactive development
+      environment for the Python language with advanced editing, interactive
+      testing, debugging and introspection features.
+    '';
+    homepage = https://github.com/spyder-ide/spyder/;
+    license = licenses.mit;
+    platforms = platforms.linux;
+  };
+}