nixpkgs/pkgs/by-name/la/lanraragi/package.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

128 lines
3.1 KiB
Nix

{ lib
, stdenv
, buildNpmPackage
, fetchFromGitHub
, makeBinaryWrapper
, perl
, ghostscript
, nixosTests
}:
buildNpmPackage rec {
pname = "lanraragi";
version = "0.9.21";
src = fetchFromGitHub {
owner = "Difegue";
repo = "LANraragi";
rev = "v.${version}";
hash = "sha256-2YdQeBW1MQiUs5nliloISaxG0yhFJ6ulkU/Urx8PN3Y=";
};
patches = [
./install.patch
./fix-paths.patch
./expose-password-hashing.patch # Used by the NixOS module
];
npmDepsHash = "sha256-RAjZGuK0C6R22fVFq82GPQoD1HpRs3MYMluUAV5ZEc8=";
nativeBuildInputs = [ perl makeBinaryWrapper ];
buildInputs = with perl.pkgs; [
perl
ImageMagick
locallib
Redis
Encode
ArchiveLibarchiveExtract
ArchiveLibarchivePeek
ListMoreUtils
NetDNSNative
SortNaturally
AuthenPassphrase
FileReadBackwards
URI
LogfileRotate
Mojolicious
MojoliciousPluginTemplateToolkit
MojoliciousPluginRenderFile
MojoliciousPluginStatus
IOSocketSocks
IOSocketSSL
CpanelJSONXS
Minion
MinionBackendRedis
ProcSimple
ParallelLoops
SysCpuAffinity
FileChangeNotify
ModulePluggable
TimeLocal
YAMLPP
StringSimilarity
] ++ lib.optionals stdenv.hostPlatform.isLinux [ LinuxInotify2 ];
buildPhase = ''
runHook preBuild
# Check if every perl dependency was installed
# explicitly call cpanm with perl because the shebang is broken on darwin
perl ${perl.pkgs.Appcpanminus}/bin/cpanm --installdeps ./tools --notest
perl ./tools/install.pl install-full
rm -r node_modules public/js/vendor/*.map public/css/vendor/*.map
runHook postBuild
'';
doCheck = true;
nativeCheckInputs = with perl.pkgs; [
TestMockObject
TestTrap
TestDeep
];
checkPhase = ''
runHook preCheck
rm tests/plugins.t # Uses network
prove -r -l -v tests
runHook postCheck
'';
installPhase = ''
runHook preInstall
mkdir -p $out/share/lanraragi
chmod +x script/launcher.pl
cp -r lib public script templates package.json lrr.conf $out/share/lanraragi
makeWrapper $out/share/lanraragi/script/launcher.pl $out/bin/lanraragi \
--prefix PERL5LIB : $PERL5LIB \
--prefix PATH : ${lib.makeBinPath [ ghostscript ]} \
--run "cp -n --no-preserve=all $out/share/lanraragi/lrr.conf ./lrr.conf 2>/dev/null || true" \
--add-flags "-f $out/share/lanraragi/script/lanraragi"
makeWrapper ${lib.getExe perl} $out/bin/helpers/lrr-make-password-hash \
--prefix PERL5LIB : $out/share/lanraragi/lib:$PERL5LIB \
--add-flags "-e 'use LANraragi::Controller::Config; print LANraragi::Controller::Config::make_password_hash(@ARGV[0])' 2>/dev/null"
runHook postInstall
'';
passthru.tests.module = 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;
};
}