diff options
Diffstat (limited to 'nixpkgs/pkgs/by-name/la/lanraragi')
5 files changed, 363 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/by-name/la/lanraragi/expose-password-hashing.patch b/nixpkgs/pkgs/by-name/la/lanraragi/expose-password-hashing.patch new file mode 100644 index 000000000000..1f6941f55ff4 --- /dev/null +++ b/nixpkgs/pkgs/by-name/la/lanraragi/expose-password-hashing.patch @@ -0,0 +1,36 @@ +diff --git a/lib/LANraragi/Controller/Config.pm b/lib/LANraragi/Controller/Config.pm +index 2cd2c999..0bd8ab6e 100644 +--- a/lib/LANraragi/Controller/Config.pm ++++ b/lib/LANraragi/Controller/Config.pm +@@ -50,6 +50,15 @@ sub index { + ); + } + ++sub make_password_hash { ++ my $ppr = Authen::Passphrase::BlowfishCrypt->new( ++ cost => 8, ++ salt_random => 1, ++ passphrase => shift, ++ ); ++ return $ppr->as_rfc2307; ++} ++ + # Save the given parameters to the Redis config + sub save_config { + +@@ -95,14 +104,7 @@ sub save_config { + my $password = $self->req->param('newpassword'); + + if ( $password ne "" ) { +- my $ppr = Authen::Passphrase::BlowfishCrypt->new( +- cost => 8, +- salt_random => 1, +- passphrase => $password, +- ); +- +- my $pass_hashed = $ppr->as_rfc2307; +- $confhash{password} = $pass_hashed; ++ $confhash{password} = make_password_hash($password); + } + } + diff --git a/nixpkgs/pkgs/by-name/la/lanraragi/fix-minion-redis-password.patch b/nixpkgs/pkgs/by-name/la/lanraragi/fix-minion-redis-password.patch new file mode 100644 index 000000000000..eb6b88f68f7f --- /dev/null +++ b/nixpkgs/pkgs/by-name/la/lanraragi/fix-minion-redis-password.patch @@ -0,0 +1,34 @@ +diff --git a/lib/LANraragi.pm b/lib/LANraragi.pm +index e6b833c4..d677030b 100644 +--- a/lib/LANraragi.pm ++++ b/lib/LANraragi.pm +@@ -144,8 +144,13 @@ sub startup { + shutdown_from_pid( get_temp . "/minion.pid" ); + + my $miniondb = $self->LRR_CONF->get_redisad . "/" . $self->LRR_CONF->get_miniondb; ++ my $redispassword = $self->LRR_CONF->get_redispassword; ++ ++ # If the password is non-empty, add the required delimiters ++ if ($redispassword) { $redispassword = "x:" . $redispassword . "@"; } ++ + say "Minion will use the Redis database at $miniondb"; +- $self->plugin( 'Minion' => { Redis => "redis://$miniondb" } ); ++ $self->plugin( 'Minion' => { Redis => "redis://$redispassword$miniondb" } ); + $self->LRR_LOGGER->info("Successfully connected to Minion database."); + $self->minion->missing_after(5); # Clean up older workers after 5 seconds of unavailability + +diff --git a/lib/LANraragi/Model/Config.pm b/lib/LANraragi/Model/Config.pm +index f52056d4..63e1f5d3 100644 +--- a/lib/LANraragi/Model/Config.pm ++++ b/lib/LANraragi/Model/Config.pm +@@ -42,8 +42,8 @@ sub get_minion { + my $miniondb = get_redisad . "/" . get_miniondb; + my $password = get_redispassword; + +- # If the password is non-empty, add the required @ +- if ($password) { $password = $password . "@"; } ++ # If the password is non-empty, add the required delimiters ++ if ($password) { $password = "x:" . $password . "@"; } + + return Minion->new( Redis => "redis://$password$miniondb" ); + } diff --git a/nixpkgs/pkgs/by-name/la/lanraragi/fix-paths.patch b/nixpkgs/pkgs/by-name/la/lanraragi/fix-paths.patch new file mode 100644 index 000000000000..f545bd4759f7 --- /dev/null +++ b/nixpkgs/pkgs/by-name/la/lanraragi/fix-paths.patch @@ -0,0 +1,100 @@ +diff --git a/lib/LANraragi.pm b/lib/LANraragi.pm +index e6b833c4..4b90e4c5 100644 +--- a/lib/LANraragi.pm ++++ b/lib/LANraragi.pm +@@ -21,6 +21,8 @@ use LANraragi::Utils::Minion; + use LANraragi::Model::Search; + use LANraragi::Model::Config; + ++use FindBin; ++ + # This method will run once at server start + sub startup { + my $self = shift; +@@ -30,7 +32,7 @@ sub startup { + say "キタ━━━━━━(゚∀゚)━━━━━━!!!!!"; + + # Load package.json to get version/vername/description +- my $packagejson = decode_json( Mojo::File->new('package.json')->slurp ); ++ my $packagejson = decode_json( Mojo::File->new("$FindBin::Bin/../package.json")->slurp ); + + my $version = $packagejson->{version}; + my $vername = $packagejson->{version_name}; +diff --git a/lib/LANraragi/Model/Archive.pm b/lib/LANraragi/Model/Archive.pm +index 73e824dd..8bcea29c 100644 +--- a/lib/LANraragi/Model/Archive.pm ++++ b/lib/LANraragi/Model/Archive.pm +@@ -13,6 +13,7 @@ use Time::HiRes qw(usleep); + use File::Basename; + use File::Copy "cp"; + use File::Path qw(make_path); ++use FindBin; + + use LANraragi::Utils::Generic qw(remove_spaces remove_newlines render_api_response); + use LANraragi::Utils::TempFolder qw(get_temp); +@@ -126,7 +127,7 @@ sub serve_thumbnail { + } else { + + # If the thumbnail doesn't exist, serve the default thumbnail. +- $self->render_file( filepath => "./public/img/noThumb.png" ); ++ $self->render_file( filepath => "$FindBin::Bin/../public/img/noThumb.png" ); + } + return; + +diff --git a/lib/LANraragi/Utils/Generic.pm b/lib/LANraragi/Utils/Generic.pm +index 14736893..4352f023 100644 +--- a/lib/LANraragi/Utils/Generic.pm ++++ b/lib/LANraragi/Utils/Generic.pm +@@ -17,6 +17,8 @@ use Sys::CpuAffinity; + use LANraragi::Utils::TempFolder qw(get_temp); + use LANraragi::Utils::Logging qw(get_logger); + ++use FindBin; ++ + # Generic Utility Functions. + use Exporter 'import'; + our @EXPORT_OK = +@@ -161,7 +163,7 @@ sub start_shinobu { + my $mojo = shift; + + my $proc = Proc::Simple->new(); +- $proc->start( $^X, "./lib/Shinobu.pm" ); ++ $proc->start( $^X, "$FindBin::Bin/../lib/Shinobu.pm" ); + $proc->kill_on_destroy(0); + + $mojo->LRR_LOGGER->debug( "Shinobu Worker new PID is " . $proc->pid ); +@@ -201,7 +203,7 @@ sub get_css_list { + + #Get all the available CSS sheets. + my @css; +- opendir( my $dir, "./public/themes" ) or die $!; ++ opendir( my $dir, "$FindBin::Bin/../public/themes" ) or die $!; + while ( my $file = readdir($dir) ) { + if ( $file =~ /.+\.css/ ) { push( @css, $file ); } + } +diff --git a/lib/LANraragi/Utils/Logging.pm b/lib/LANraragi/Utils/Logging.pm +index ee29c507..6bdfc1bd 100644 +--- a/lib/LANraragi/Utils/Logging.pm ++++ b/lib/LANraragi/Utils/Logging.pm +@@ -18,7 +18,7 @@ our @EXPORT_OK = qw(get_logger get_plugin_logger get_logdir get_lines_from_file) + # Get the Log folder. + sub get_logdir { + +- my $log_folder = "$FindBin::Bin/../log"; ++ my $log_folder = "./log"; + + # Folder location can be overriden by LRR_LOG_DIRECTORY + if ( $ENV{LRR_LOG_DIRECTORY} ) { +diff --git a/lib/LANraragi/Utils/TempFolder.pm b/lib/LANraragi/Utils/TempFolder.pm +index 792b1c1b..f0eb341b 100644 +--- a/lib/LANraragi/Utils/TempFolder.pm ++++ b/lib/LANraragi/Utils/TempFolder.pm +@@ -20,7 +20,7 @@ our @EXPORT_OK = qw(get_temp get_tempsize clean_temp_full clean_temp_partial); + #Get the current tempfolder. + #This can be called from any process safely as it uses FindBin. + sub get_temp { +- my $temp_folder = "$FindBin::Bin/../public/temp"; ++ my $temp_folder = "./public/temp"; + + # Folder location can be overriden by LRR_TEMP_DIRECTORY + if ( $ENV{LRR_TEMP_DIRECTORY} ) { diff --git a/nixpkgs/pkgs/by-name/la/lanraragi/install.patch b/nixpkgs/pkgs/by-name/la/lanraragi/install.patch new file mode 100644 index 000000000000..9d260f5a494f --- /dev/null +++ b/nixpkgs/pkgs/by-name/la/lanraragi/install.patch @@ -0,0 +1,63 @@ +diff --git a/tools/cpanfile b/tools/cpanfile +index 359c61fe..ca3b7ec7 100755 +--- a/tools/cpanfile ++++ b/tools/cpanfile +@@ -20,7 +20,7 @@ requires 'Sort::Naturally', 1.03; + requires 'Authen::Passphrase', 0.008; + requires 'File::ReadBackwards', 1.05; + requires 'URI::Escape', 1.74; +-requires 'URI', 5.09; ++requires 'URI', 5.05; + + # Used by Installer + requires 'IPC::Cmd', 1.02; +diff --git a/tools/install.pl b/tools/install.pl +index 0cbb847d..1bd61fa0 100755 +--- a/tools/install.pl ++++ b/tools/install.pl +@@ -91,32 +91,6 @@ if ( $ENV{HOMEBREW_FORMULA_PREFIX} ) { + $cpanopt = " -l " . $ENV{HOMEBREW_FORMULA_PREFIX} . "/libexec"; + } + +-#Load IPC::Cmd +-install_package( "IPC::Cmd", $cpanopt ); +-install_package( "Config::AutoConf", $cpanopt ); +-IPC::Cmd->import('can_run'); +-require Config::AutoConf; +- +-say("\r\nWill now check if all LRR software dependencies are met. \r\n"); +- +-#Check for Redis +-say("Checking for Redis..."); +-can_run('redis-server') +- or die 'NOT FOUND! Please install a Redis server before proceeding.'; +-say("OK!"); +- +-#Check for GhostScript +-say("Checking for GhostScript..."); +-can_run('gs') +- or warn 'NOT FOUND! PDF support will not work properly. Please install the "gs" tool.'; +-say("OK!"); +- +-#Check for libarchive +-say("Checking for libarchive..."); +-Config::AutoConf->new()->check_header("archive.h") +- or die 'NOT FOUND! Please install libarchive and ensure its headers are present.'; +-say("OK!"); +- + #Check for PerlMagick + say("Checking for ImageMagick/PerlMagick..."); + my $imgk; +@@ -154,12 +128,6 @@ if ( $back || $full ) { + #Clientside Dependencies with Provisioning + if ( $front || $full ) { + +- say("\r\nObtaining remote Web dependencies...\r\n"); +- +- if ( system("npm install") != 0 ) { +- die "Something went wrong while obtaining node modules - Bailing out."; +- } +- + say("\r\nProvisioning...\r\n"); + + #Load File::Copy diff --git a/nixpkgs/pkgs/by-name/la/lanraragi/package.nix b/nixpkgs/pkgs/by-name/la/lanraragi/package.nix new file mode 100644 index 000000000000..74ec38eeae23 --- /dev/null +++ b/nixpkgs/pkgs/by-name/la/lanraragi/package.nix @@ -0,0 +1,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; + }; +} |