nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildNpmPackage,
5 fetchFromGitHub,
6 makeBinaryWrapper,
7 perl,
8 ghostscript,
9 nixosTests,
10}:
11
12buildNpmPackage rec {
13 pname = "lanraragi";
14 version = "0.9.21";
15
16 src = fetchFromGitHub {
17 owner = "Difegue";
18 repo = "LANraragi";
19 rev = "v.${version}";
20 hash = "sha256-2YdQeBW1MQiUs5nliloISaxG0yhFJ6ulkU/Urx8PN3Y=";
21 };
22
23 patches = [
24 ./install.patch
25 ./fix-paths.patch
26 ./expose-password-hashing.patch # Used by the NixOS module
27 ];
28
29 npmDepsHash = "sha256-RAjZGuK0C6R22fVFq82GPQoD1HpRs3MYMluUAV5ZEc8=";
30
31 nativeBuildInputs = [
32 perl
33 makeBinaryWrapper
34 ];
35
36 buildInputs =
37 with perl.pkgs;
38 [
39 perl
40 ImageMagick
41 locallib
42 Redis
43 Encode
44 ArchiveLibarchiveExtract
45 ArchiveLibarchivePeek
46 ListMoreUtils
47 NetDNSNative
48 SortNaturally
49 AuthenPassphrase
50 FileReadBackwards
51 URI
52 LogfileRotate
53 Mojolicious
54 MojoliciousPluginTemplateToolkit
55 MojoliciousPluginRenderFile
56 MojoliciousPluginStatus
57 IOSocketSocks
58 IOSocketSSL
59 CpanelJSONXS
60 Minion
61 MinionBackendRedis
62 ProcSimple
63 ParallelLoops
64 SysCpuAffinity
65 FileChangeNotify
66 ModulePluggable
67 TimeLocal
68 YAMLPP
69 StringSimilarity
70 ]
71 ++ lib.optionals stdenv.hostPlatform.isLinux [ LinuxInotify2 ];
72
73 buildPhase = ''
74 runHook preBuild
75
76 # Check if every perl dependency was installed
77 # explicitly call cpanm with perl because the shebang is broken on darwin
78 perl ${perl.pkgs.Appcpanminus}/bin/cpanm --installdeps ./tools --notest
79
80 perl ./tools/install.pl install-full
81 rm -r node_modules public/js/vendor/*.map public/css/vendor/*.map
82
83 runHook postBuild
84 '';
85
86 doCheck = true;
87
88 nativeCheckInputs = with perl.pkgs; [
89 TestMockObject
90 TestTrap
91 TestDeep
92 ];
93
94 checkPhase = ''
95 runHook preCheck
96
97 rm tests/plugins.t # Uses network
98 prove -r -l -v tests
99
100 runHook postCheck
101 '';
102
103 installPhase = ''
104 runHook preInstall
105
106 mkdir -p $out/share/lanraragi
107 chmod +x script/launcher.pl
108 cp -r lib public script templates package.json lrr.conf $out/share/lanraragi
109
110 makeWrapper $out/share/lanraragi/script/launcher.pl $out/bin/lanraragi \
111 --prefix PERL5LIB : $PERL5LIB \
112 --prefix PATH : ${lib.makeBinPath [ ghostscript ]} \
113 --run "cp -n --no-preserve=all $out/share/lanraragi/lrr.conf ./lrr.conf 2>/dev/null || true" \
114 --add-flags "-f $out/share/lanraragi/script/lanraragi"
115
116 makeWrapper ${lib.getExe perl} $out/bin/helpers/lrr-make-password-hash \
117 --prefix PERL5LIB : $out/share/lanraragi/lib:$PERL5LIB \
118 --add-flags "-e 'use LANraragi::Controller::Config; print LANraragi::Controller::Config::make_password_hash(@ARGV[0])' 2>/dev/null"
119
120 runHook postInstall
121 '';
122
123 passthru.tests.module = nixosTests.lanraragi;
124
125 meta = {
126 changelog = "https://github.com/Difegue/LANraragi/releases/tag/${src.rev}";
127 description = "Web application for archival and reading of manga/doujinshi";
128 homepage = "https://github.com/Difegue/LANraragi";
129 license = lib.licenses.mit;
130 mainProgram = "lanraragi";
131 maintainers = with lib.maintainers; [ tomasajt ];
132 platforms = lib.platforms.unix;
133 };
134}