about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/la/lanraragi/package.nix
blob: 74ec38eeae230fd39e325035405cadf3d2d8d444 (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
{ lib
, stdenv
, buildNpmPackage
, fetchFromGitHub
, fetchpatch
, makeBinaryWrapper
, perl
, ghostscript
, nixosTests
}:

let
  perlEnv = perl.withPackages (_: cpanDeps);

  cpanDeps = with perl.pkgs; [
    ImageMagick
    locallib
    Redis
    Encode
    ArchiveLibarchiveExtract
    ArchiveLibarchivePeek
    NetDNSNative
    SortNaturally
    AuthenPassphrase
    FileReadBackwards
    URI
    LogfileRotate
    Mojolicious
    MojoliciousPluginTemplateToolkit
    MojoliciousPluginRenderFile
    MojoliciousPluginStatus
    IOSocketSSL
    CpanelJSONXS
    Minion
    MinionBackendRedis
    ProcSimple
    ParallelLoops
    SysCpuAffinity
    FileChangeNotify
    ModulePluggable
    TimeLocal
  ] ++ lib.optional stdenv.isLinux LinuxInotify2;
in
buildNpmPackage rec {
  pname = "lanraragi";
  version = "0.8.90";

  src = fetchFromGitHub {
    owner = "Difegue";
    repo = "LANraragi";
    rev = "v.${version}";
    hash = "sha256-ljnREUGCKvUJvcQ+aJ6XqiMTkVmfjt/0oC47w3PCj/k=";
  };

  patches = [
    (fetchpatch {
      name = "add-package-lock-json.patch"; # Can be removed when updating to 0.9.0
      url = "https://github.com/Difegue/LANraragi/commit/c5cd8641795bf7e40deef4ae955ea848dde44050.patch";
      hash = "sha256-XKxRzeugkIe6N4XRN6+O1wEZpxo6OzU0OaG0ywKFv38=";
    })
    ./install.patch
    ./fix-paths.patch
    ./expose-password-hashing.patch
    ./fix-minion-redis-password.patch # Should be upstreamed
  ];

  npmFlags = [ "--legacy-peer-deps" ];

  npmDepsHash = "sha256-UQsChPU5b4+r5Kv6P/3rJCGUzssiUNSKo3w4axNyJew=";

  nativeBuildInputs = [
    perl
    makeBinaryWrapper
    perl.pkgs.Appcpanminus
  ] ++ cpanDeps;

  nativeCheckInputs = with perl.pkgs; [
    TestMockObject
    TestTrap
    TestDeep
  ];

  buildPhase = ''
    runHook preBuild

    perl ./tools/install.pl install-full
    rm -r node_modules public/js/vendor/*.map public/css/vendor/*.map

    runHook postBuild
  '';

  doCheck = true;

  checkPhase = ''
    runHook preCheck

    rm tests/plugins.t # Uses network
    prove -r -l -v tests

    runHook postCheck
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/share/lanraragi
    cp -r lib public script templates package.json $out/share/lanraragi

    makeWrapper ${perlEnv}/bin/perl $out/bin/lanraragi \
      --prefix PATH : ${lib.makeBinPath [ ghostscript ]} \
      --add-flags "$out/share/lanraragi/script/launcher.pl -f $out/share/lanraragi/script/lanraragi"

    runHook postInstall
  '';

  passthru = {
    inherit perlEnv;
    tests = { inherit (nixosTests) lanraragi; };
  };

  meta = {
    changelog = "https://github.com/Difegue/LANraragi/releases/tag/${src.rev}";
    description = "Web application for archival and reading of manga/doujinshi";
    homepage = "https://github.com/Difegue/LANraragi";
    license = lib.licenses.mit;
    mainProgram = "lanraragi";
    maintainers = with lib.maintainers; [ tomasajt ];
    platforms = lib.platforms.unix;
  };
}