about summary refs log tree commit diff
path: root/pkgs/applications/misc/auto-multiple-choice/default.nix
blob: bdd1e6fbb85400fa84fc2d4faf8e9f57f0fd544e (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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
{ lib
, stdenv
, fetchurl
, perlPackages
, makeWrapper
, wrapGAppsHook
, cairo
, dblatex
, gnumake
, gobject-introspection
, graphicsmagick
, gsettings-desktop-schemas
, gtk3
, hicolor-icon-theme
, libnotify
, librsvg
, libxslt
, netpbm
, opencv
, pango
, perl
, pkg-config
, poppler
, auto-multiple-choice
}:
stdenv.mkDerivation (finalAttrs: rec {
  pname = "auto-multiple-choice";
  version = "1.6.0";
  src = fetchurl {
    url = "https://download.auto-multiple-choice.net/${pname}_${version}_dist.tar.gz";
    # before 1.6.0, the URL pattern used "precomp" instead of "dist".    ^^^^
    sha256 = "sha256-I9Xw1BN8ZSQhi5F1R3axHBKE6tnaCNk8k5tts6LoMjY=";
  };

  # There's only the Makefile
  dontConfigure = true;

  makeFlags = [
    "PERLPATH=${perl}/bin/perl"
    # We *need* to pass DESTDIR, as the Makefile ignores PREFIX.
    "DESTDIR=$(out)"
    # Relative paths.
    "BINDIR=/bin"
    "PERLDIR=/share/perl5"
    "MODSDIR=/lib" # At runtime, AMC will test for that dir before
    # defaulting to the "portable" strategy we use, so this test
    # *must* fail.  *But* this variable cannot be set to anything but
    # "/lib" , because that name is hardcoded in the main executable
    # and this variable controls both both the path AMC will check at
    # runtime, AND the path where the actual modules will be stored at
    # build-time.  This has been reported upstream as
    # https://project.auto-multiple-choice.net/issues/872
    "TEXDIR=/tex/latex/" # what texlive.combine expects
    "TEXDOCDIR=/share/doc/texmf/" # TODO where to put this?
    "MAN1DIR=/share/man/man1"
    "DESKTOPDIR=/share/applications"
    "METAINFODIR=/share/metainfo"
    "ICONSDIR=/share/auto-multiple-choice/icons"
    "APPICONDIR=/share/icons/hicolor"
    "LOCALEDIR=/share/locale"
    "MODELSDIR=/share/auto-multiple-choice/models"
    "DOCDIR=/share/doc/auto-multiple-choice"
    "SHARED_MIMEINFO_DIR=/share/mime/packages"
    "LANG_GTKSOURCEVIEW_DIR=/share/gtksourceview-4/language-specs"
    # Pretend to be redhat so `install` doesn't try to chown/chgrp.
    "SYSTEM_TYPE=rpm"
    "GCC=${stdenv.cc.targetPrefix}cc"
    "GCC_PP=${stdenv.cc.targetPrefix}c++"
  ];

  preFixup = ''
    makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
  '';

  postFixup = ''
    wrapProgram $out/bin/auto-multiple-choice \
    ''${makeWrapperArgs[@]} \
    --prefix PERL5LIB : "${with perlPackages; makeFullPerlPath [
      ArchiveZip
      DBDSQLite
      Cairo
      CairoGObject
      DBI
      Glib
      GlibObjectIntrospection
      Gtk3
      LocaleGettext
      OpenOfficeOODoc
      PerlMagick
      TextCSV
      XMLParser
      XMLSimple
      XMLWriter
    ]}:"$out/share/perl5 \
    --prefix XDG_DATA_DIRS : "$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH" \
    --set TEXINPUTS ":.:$out/tex/latex"
  '';

  nativeBuildInputs = [
    pkg-config
    makeWrapper
    wrapGAppsHook
    gobject-introspection
  ];

  buildInputs = [
    cairo
    cairo.dev
    dblatex
    gnumake
    graphicsmagick
    gsettings-desktop-schemas
    gtk3
    hicolor-icon-theme
    libnotify
    librsvg
    libxslt
    netpbm
    opencv
    pango
    poppler
  ] ++ (with perlPackages; [
    perl
    ArchiveZip
    Cairo
    CairoGObject
    DBDSQLite
    DBI
    Glib
    GlibObjectIntrospection
    Gtk3
    LocaleGettext
    PerlMagick
    TextCSV
    XMLParser
    XMLSimple
    XMLWriter
  ]);

  passthru = {
    tlType = "run";
    pkgs = [ finalAttrs.finalPackage ];
  };

  meta = with lib; {
    description = "Create and manage multiple choice questionnaires with automated marking.";
    mainProgram = "auto-multiple-choice";
    longDescription = ''
      Create, manage and mark multiple-choice questionnaires.
      auto-multiple-choice features automated or manual formatting with
      LaTeX, shuffling of questions and answers and automated marking using
      Optical Mark Recognition.

      Questionnaires can be created using either a very simple text syntax,
      AMC-TXT, or LaTeX. In the latter case, your TeXLive installation must
      be combined with this package.  This can be done in configuration.nix
      as follows:

      <screen>
      environment.systemPackages = with pkgs; [
        auto-multiple-choice
        (texlive.combine {
          inherit (pkgs.texlive) scheme-full;
          inherit auto-multiple-choice;
        })
      ];
      </screen>

      For usage instructions, see documentation at the project's homepage.
    '';
    homepage = "https://www.auto-multiple-choice.net/";
    changelog = "https://gitlab.com/jojo_boulix/auto-multiple-choice/-/blob/master/ChangeLog";
    license = licenses.gpl2Plus;
    maintainers = [ maintainers.thblt ];
    platforms = platforms.all;
  };
})