summary refs log tree commit diff
path: root/pkgs/servers/rt/default.nix
blob: b4400215dd0106fc2725f3a89c66a1824b71753e (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
{ stdenv, buildEnv, fetchurl, perl, perlPackages, makeWrapper }:

# This package isn't extremely useful as it is, but is getting close.
# After running:
#
#   nix-build . -A rt
#
# I created a config file named myconfig.pm with:
#
#   use utf8;
#   Set($rtname, '127.0.0.1');
#   # These dirs need to be pre-created:
#   Set($MasonSessionDir, '/home/grahamc/foo/sessiondir/');
#   Set($MasonDataDir, '/home/grahamc/foo/localstate/');
#   Set($WebPort, 8080);
#
#   Set($DatabaseType, "SQLite");
#   Set( $DatabaseName, '/home/grahamc/projects/foo/my.db' );
#
#   1;
#
# and ran
#
#  RT_SITE_CONFIG=$(pwd)/myconfig.pm ./result/bin/rt-setup-database --action init
#
# Then:
#
#   RT_SITE_CONFIG=$(pwd)/myconfig.pm ./result/bin/rt-server
#
# Make sure to check out result/etc/RT_Config.pm
#
# Good luck.
stdenv.mkDerivation rec {
  pname = "rt";

  version = "4.4.4";

  src = fetchurl {
    url = "https://download.bestpractical.com/pub/rt/release/${pname}-${version}.tar.gz";
    sha256 = "1108jhz1gvalcfnbzgpbk7fkxzxkkc7m74a3bnwyjzldlyj1dhrl";
  };

  patches = [ ./override-generated.patch ];

  buildInputs = [
    makeWrapper
    perl
    (buildEnv {
      name = "rt-perl-deps";
      paths = (with perlPackages; [
        ApacheSession BusinessHours CGIEmulatePSGI CGIPSGI
        CSSMinifierXS CSSSquish ConvertColor CryptEksblowfish
        CryptSSLeay DBDSQLite DBDmysql DBIxSearchBuilder DataGUID
        DataICal DataPagePageset DateExtract DateManip
        DateTimeFormatNatural DevelGlobalDestruction EmailAddress
        EmailAddressList FCGI FCGIProcManager FileShareDir FileWhich
        GD GDGraph GnuPGInterface GraphViz HTMLFormatTextWithLinks
        HTMLFormatTextWithLinksAndTables HTMLMason
        HTMLMasonPSGIHandler HTMLQuoted HTMLRewriteAttributes
        HTMLScrubber IPCRun IPCRun3 JSON JavaScriptMinifierXS LWP
        LWPProtocolHttps LocaleMaketextFuzzy LocaleMaketextLexicon
        LogDispatch MIMETools MIMETypes MailTools ModuleRefresh
        ModuleVersionsReport MozillaCA NetCIDR NetIP PerlIOeol Plack
        RegexpCommon RegexpCommonnetCIDR RegexpIPv6 RoleBasic
        ScopeUpper Starlet SymbolGlobalName TermReadKey
        TextPasswordPronounceable TextQuoted TextTemplate
        TextWikiFormat TextWrapper TimeParseDate TreeSimple
        UNIVERSALrequire XMLRSS
      ]);
    })
  ];

  preConfigure = ''
    configureFlags="$configureFlags --with-web-user=$UID"
    configureFlags="$configureFlags --with-web-group=$(id -g)"
    configureFlags="$configureFlags --with-rt-group=$(id -g)"
    configureFlags="$configureFlags --with-bin-owner=$UID"
    configureFlags="$configureFlags --with-libs-owner=$UID"
    configureFlags="$configureFlags --with-libs-group=$(id -g)"
  '';
  configureFlags = [
    "--enable-graphviz"
    "--enable-gd"
    "--enable-gpg"
    "--with-db-type=SQLite"
  ];

  buildPhase = ''
    make testdeps | grep -i missing | sort
  '';

  preFixup = ''
    for i in $(find $out/bin -type f; find $out/sbin -type f); do
      wrapProgram $i \
          --prefix PERL5LIB ':' $PERL5LIB
    done
  '';

  meta = {
    platforms = stdenv.lib.platforms.unix;
  };
}