summary refs log tree commit diff
path: root/pkgs/applications/science/math/gap/default.nix
blob: 74fff2390a39c5ab6661cf13d8792c57c10a8310 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
x@{builderDefsPackage
  , pari ? null
  , ...}:
builderDefsPackage
(a :
let
  helperArgNames = ["stdenv" "fetchurl" "builderDefsPackage"] ++
    [];

  buildInputs = map (n: builtins.getAttr n x)
    (builtins.attrNames (builtins.removeAttrs x helperArgNames));
  sourceInfo = rec {
    baseName="gap";
    version="4r4p12";
    name="${baseName}-${version}";
    url="ftp://ftp.gap-system.org/pub/gap/gap4/tar.gz/${baseName}${version}.tar.gz";
    hash="0flap5lbkvpms3zznq1zwxyxyj0ax3fk7m24f3bvhvr37vyxnf40";
    pkgVer="2012_01_12-10_47_UTC";
    pkgURL="ftp://ftp.gap-system.org/pub/gap/gap4/tar.bz2/packages-${pkgVer}.tar.bz2";
    pkgHash="0z9ncy1m5gvv4llkclxd1vpcgpb0b81a2pfmnhzvw8x708frhmnb";
  };
in
rec {
  src = a.fetchurl {
    url = sourceInfo.url;
    sha256 = sourceInfo.hash;
  };

  pkgSrc = a.fetchurl {
    url=sourceInfo.pkgURL;
    sha256=sourceInfo.pkgHash;
  };

  inherit (sourceInfo) name version;
  inherit buildInputs;

  /* doConfigure should be removed if not needed */
  phaseNames = ["doConfigure" "doMake" "doDeploy"];

  doDeploy = a.fullDepEntry ''
    ensureDir "$out/bin" "$out/share/gap/"

    cp -r . "$out/share/gap/build-dir"

    tar xf "${pkgSrc}" -C "$out/share/gap/build-dir/pkg"

    ${if a.pari != null then
      ''sed -e '2iexport PATH=$PATH:${pari}/bin' -i "$out/share/gap/build-dir/bin/gap.sh" ''
    else ""}
    sed -e "/GAP_DIR=/aGAP_DIR='$out/share/gap/build-dir/'" -i "$out/share/gap/build-dir/bin/gap.sh"

    ln -s "$out/share/gap/build-dir/bin/gap.sh" "$out/bin"
  '' ["doMake" "minInit" "defEnsureDir"];

  meta = {
    description = "Computational discrete algebra system";
    maintainers = with a.lib.maintainers;
    [
      raskin
    ];
    platforms = with a.lib.platforms;
      linux;
    license = with a.lib.licenses;
      gpl2;
    homepage = "http://gap-system.org/";
  };
}) x