nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv, fetchurl, fetchpatch, perlPackages, gettext, makeWrapper, ImageMagick, which, highlight
2, gitSupport ? false, git
3, docutilsSupport ? false, python, docutils
4, monotoneSupport ? false, monotone
5, bazaarSupport ? false, breezy
6, cvsSupport ? false, cvs, cvsps
7, subversionSupport ? false, subversion
8, mercurialSupport ? false, mercurial
9, extraUtils ? []
10}:
11
12stdenv.mkDerivation rec {
13 pname = "ikiwiki";
14 version = "3.20200202.3";
15
16 src = fetchurl {
17 url = "mirror://debian/pool/main/i/ikiwiki/ikiwiki_${version}.orig.tar.xz";
18 sha256 = "0skrc8r4wh4mjfgw1c94awr5sacfb9nfsbm4frikanc9xsy16ksr";
19 };
20
21 nativeBuildInputs = [ makeWrapper ];
22 buildInputs = [ which highlight ]
23 ++ (with perlPackages; [ perl TextMarkdown URI HTMLParser HTMLScrubber HTMLTemplate
24 TimeDate gettext DBFile CGISession CGIFormBuilder LocaleGettext
25 RpcXML XMLSimple ImageMagick YAML YAMLLibYAML HTMLTree AuthenPassphrase
26 NetOpenIDConsumer LWPxParanoidAgent CryptSSLeay ])
27 ++ lib.optionals docutilsSupport [
28 (python.withPackages (pp: with pp; [ pygments ]))
29 docutils
30 ]
31 ++ lib.optionals gitSupport [git]
32 ++ lib.optionals monotoneSupport [monotone]
33 ++ lib.optionals bazaarSupport [breezy]
34 ++ lib.optionals cvsSupport [cvs cvsps perlPackages.Filechdir]
35 ++ lib.optionals subversionSupport [subversion]
36 ++ lib.optionals mercurialSupport [mercurial];
37
38 patches = [
39 # A few markdown tests fail, but this is expected when using Text::Markdown
40 # instead of Text::Markdown::Discount.
41 ./remove-markdown-tests.patch
42
43 (fetchpatch {
44 name = "Catch-up-to-highlight-4.0-API-change";
45 url = "http://source.ikiwiki.branchable.com/?p=source.git;a=patch;h=9ea3f9dfe7c0341f4e002b48728b8139293e19d0";
46 sha256 = "16s4wvsfclx0a5cm2awr69dvw2vsi8lpm0d7kyl5w0kjlmzfc7h9";
47 })
48 ];
49
50 postPatch = ''
51 sed -i s@/usr/bin/perl@${perlPackages.perl}/bin/perl@ pm_filter mdwn2man
52 sed -i s@/etc/ikiwiki@$out/etc@ Makefile.PL
53 sed -i /ENV{PATH}/d ikiwiki.in
54 # State the gcc dependency, and make the cgi use our wrapper
55 sed -i -e 's@$0@"'$out/bin/ikiwiki'"@' \
56 -e "s@'cc'@'${stdenv.cc}/bin/gcc'@" IkiWiki/Wrapper.pm
57 # Without patched plugin shebangs, some tests like t/rst.t fail
58 # (with docutilsSupport enabled)
59 patchShebangs plugins/*
60
61 # Creating shared git repo fails when running tests in Nix sandbox.
62 # The error is: "fatal: Could not make /tmp/ikiwiki-test-git.2043/repo/branches/ writable by group".
63 # Hopefully, not many people use `ikiwiki-makerepo` to create locally shared repositories these days.
64 substituteInPlace ikiwiki-makerepo --replace "git --bare init --shared" "git --bare init"
65 '';
66
67 configurePhase = "perl Makefile.PL PREFIX=$out";
68
69 postInstall = ''
70 for a in "$out/bin/"*; do
71 wrapProgram $a --suffix PERL5LIB : $PERL5LIB --prefix PATH : ${perlPackages.perl}/bin:$out/bin \
72 ${lib.optionalString gitSupport "--prefix PATH : ${git}/bin "} \
73 ${lib.optionalString monotoneSupport "--prefix PATH : ${monotone}/bin "} \
74 ${lib.optionalString bazaarSupport "--prefix PATH : ${breezy}/bin "} \
75 ${lib.optionalString cvsSupport "--prefix PATH : ${cvs}/bin "} \
76 ${lib.optionalString cvsSupport "--prefix PATH : ${cvsps}/bin "} \
77 ${lib.optionalString subversionSupport "--prefix PATH : ${subversion.out}/bin "} \
78 ${lib.optionalString mercurialSupport "--prefix PATH : ${mercurial}/bin "} \
79 ${lib.optionalString docutilsSupport ''--prefix PYTHONPATH : "$(toPythonPath ${docutils})" ''} \
80 ${lib.concatMapStrings (x: "--prefix PATH : ${x}/bin ") extraUtils}
81 done
82 '';
83
84 preCheck = ''
85 # Git needs some help figuring this out during test suite run.
86 export EMAIL="nobody@example.org"
87 '';
88
89 checkTarget = "test";
90 doCheck = true;
91
92 meta = with lib; {
93 description = "Wiki compiler, storing pages and history in a RCS";
94 homepage = "http://ikiwiki.info/";
95 license = licenses.gpl2Plus;
96 platforms = platforms.linux;
97 maintainers = [ maintainers.wentasah ];
98 };
99}