summaryrefslogtreecommitdiffstats
path: root/pkgs/development/compilers/pakcs/default.nix
blob: 612109d6e2c38670d899cc0a5506b0ef791a0260 (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
{
  lib,
  stdenv,
  fetchurl,
  fetchpatch2,
  makeWrapper,
  haskellPackages,
  haskell,
  which,
  swi-prolog,
  rlwrap,
  tk,
  curl,
  git,
  unzip,
  gnutar,
  coreutils,
  sqlite,
}:

let
  pname = "pakcs";
  version = "3.7.2";

  # Don't switch to "Current release" without a reason, because its
  # source updates without version bump. Prefer last from "Older releases" instead.
  src = fetchurl {
    url = "https://www.informatik.uni-kiel.de/~pakcs/download/pakcs-${version}-src.tar.gz";
    hash = "sha256-ZfQUgFqmPPCeDx/T5G/JdvYDq/7XbvsgxPcEX4y9HZ4=";
  };

  curry-frontend =
    (haskellPackages.override {
      overrides = self: super: {
        curry-frontend = lib.pipe (super.callPackage ./curry-frontend.nix { }) [
          haskell.lib.doJailbreak
          (haskell.lib.compose.overrideCabal (drv: {
            inherit src;
            postUnpack = "sourceRoot+=/frontend";
          }))
          (haskell.lib.compose.appendPatch
            # mtl 2.3 compatibility has been fixed upstream but it's not in
            # the release yet
            (
              fetchpatch2 {
                name = "fix-mtl-2.3.patch";
                url = "https://git.ps.informatik.uni-kiel.de/curry/curry-frontend/-/commit/3b26d2826141fee676da07939c2929a049279b70.diff";
                hash = "sha256-R3XjoUzAwTvDoUEAIIjmrSh2r4RHMqe00RMIs+7jFPY=";
              }
            )
          )
        ];
      };
    }).curry-frontend;

in
stdenv.mkDerivation {
  inherit pname version src;

  buildInputs = [ swi-prolog ];
  nativeBuildInputs = [
    which
    makeWrapper
  ];

  makeFlags = [
    "CURRYFRONTEND=${curry-frontend}/bin/curry-frontend"
    "DISTPKGINSTALL=yes"
    # Not needed, just to make script pass
    "CURRYTOOLSDIR=0"
    "CURRYLIBSDIR=0"
  ];

  preConfigure = ''
    for file in examples/test.sh             \
                currytools/optimize/Makefile \
                testsuite/test.sh            \
                scripts/cleancurry.sh        \
                scripts/compile-all-libs.sh; do
        substituteInPlace $file --replace "/bin/rm" "rm"
    done
  '';

  preBuild = ''
    mkdir -p $out/pakcs
    cp -r * $out/pakcs
    cd $out/pakcs
  '';

  installPhase = ''
    runHook preInstall

    ln -s $out/pakcs/bin $out

    mkdir -p $out/share/emacs/site-lisp
    ln -s $out/pakcs/tools/emacs $out/share/emacs/site-lisp/curry-pakcs

    wrapProgram $out/pakcs/bin/pakcs \
      --prefix PATH ":" "${rlwrap}/bin" \
      --prefix PATH ":" "${tk}/bin"

    # List of dependencies from currytools/cpm/src/CPM/Main.curry
    wrapProgram $out/pakcs/bin/cypm \
      --prefix PATH ":" "${
        lib.makeBinPath [
          curl
          git
          unzip
          gnutar
          coreutils
          sqlite
        ]
      }"

    runHook postInstall
  '';

  meta = {
    homepage = "http://www.informatik.uni-kiel.de/~pakcs/";
    description = "Implementation of the multi-paradigm declarative language Curry";
    license = lib.licenses.bsd3;

    longDescription = ''
      PAKCS is an implementation of the multi-paradigm declarative language
      Curry jointly developed by the Portland State University, the Aachen
      University of Technology, and the University of Kiel. Although this is
      not a highly optimized implementation but based on a high-level
      compilation of Curry programs into Prolog programs, it is not a toy
      implementation but has been used for a variety of applications (e.g.,
      graphical programming environments, an object-oriented front-end for
      Curry, partial evaluators, database applications, HTML programming
      with dynamic web pages, prototyping embedded systems).
    '';

    maintainers = with lib.maintainers; [ t4ccer ];
    platforms = lib.platforms.linux;
  };
}