mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-09-11 07:15:54 +03:00
lanraragi: 0.8.90 -> 0.9.0
This commit is contained in:
parent
ce89133d42
commit
eac5dfd20f
@ -72,11 +72,10 @@ in
|
|||||||
"HOME" = "/var/lib/lanraragi";
|
"HOME" = "/var/lib/lanraragi";
|
||||||
};
|
};
|
||||||
preStart = ''
|
preStart = ''
|
||||||
REDIS_PASS=${lib.optionalString (cfg.redis.passwordFile != null) "$(head -n1 ${cfg.redis.passwordFile})"}
|
|
||||||
cat > lrr.conf <<EOF
|
cat > lrr.conf <<EOF
|
||||||
{
|
{
|
||||||
redis_address => "127.0.0.1:${toString cfg.redis.port}",
|
redis_address => "127.0.0.1:${toString cfg.redis.port}",
|
||||||
redis_password => "$REDIS_PASS",
|
redis_password => "${lib.optionalString (cfg.redis.passwordFile != null) ''$(head -n1 ${cfg.redis.passwordFile})''}",
|
||||||
redis_database => "0",
|
redis_database => "0",
|
||||||
redis_database_minion => "1",
|
redis_database_minion => "1",
|
||||||
redis_database_config => "2",
|
redis_database_config => "2",
|
||||||
@ -84,15 +83,9 @@ in
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
'' + lib.optionalString (cfg.passwordFile != null) ''
|
'' + lib.optionalString (cfg.passwordFile != null) ''
|
||||||
PASS_HASH=$(
|
${lib.getExe pkgs.redis} -h 127.0.0.1 -p ${toString cfg.redis.port} ${lib.optionalString (cfg.redis.passwordFile != null) ''-a "$(head -n1 ${cfg.redis.passwordFile})"''}<<EOF
|
||||||
PASS=$(head -n1 ${cfg.passwordFile}) ${cfg.package.perlEnv}/bin/perl -I${cfg.package}/share/lanraragi/lib -e \
|
|
||||||
'use LANraragi::Controller::Config; print LANraragi::Controller::Config::make_password_hash($ENV{PASS})' \
|
|
||||||
2>/dev/null
|
|
||||||
)
|
|
||||||
|
|
||||||
${lib.getExe pkgs.redis} -h 127.0.0.1 -p ${toString cfg.redis.port} -a "$REDIS_PASS" <<EOF
|
|
||||||
SELECT 2
|
SELECT 2
|
||||||
HSET LRR_CONFIG password $PASS_HASH
|
HSET LRR_CONFIG password $(${cfg.package}/bin/helpers/lrr-make-password-hash $(head -n1 ${cfg.passwordFile}))
|
||||||
EOF
|
EOF
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
@ -10,19 +10,17 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
|
|||||||
services.lanraragi = {
|
services.lanraragi = {
|
||||||
enable = true;
|
enable = true;
|
||||||
passwordFile = pkgs.writeText "lrr-test-pass" ''
|
passwordFile = pkgs.writeText "lrr-test-pass" ''
|
||||||
ultra-secure-password
|
Ultra-secure-p@ssword-"with-spec1al\chars
|
||||||
'';
|
'';
|
||||||
port = 4000;
|
port = 4000;
|
||||||
redis = {
|
redis = {
|
||||||
port = 4001;
|
port = 4001;
|
||||||
passwordFile = pkgs.writeText "redis-lrr-test-pass" ''
|
passwordFile = pkgs.writeText "redis-lrr-test-pass" ''
|
||||||
still-a-very-secure-password
|
123-redis-PASS
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
@ -34,7 +32,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
|
|||||||
|
|
||||||
machine2.wait_for_unit("lanraragi.service")
|
machine2.wait_for_unit("lanraragi.service")
|
||||||
machine2.wait_until_succeeds("curl -f localhost:4000")
|
machine2.wait_until_succeeds("curl -f localhost:4000")
|
||||||
machine2.succeed("[ $(curl -o /dev/null -X post 'http://localhost:4000/login' --data-raw 'password=ultra-secure-password' -w '%{http_code}') -eq 302 ]")
|
machine2.succeed("[ $(curl -o /dev/null -X post 'http://localhost:4000/login' --data-raw 'password=Ultra-secure-p@ssword-\"with-spec1al\\chars' -w '%{http_code}') -eq 302 ]")
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
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" );
|
|
||||||
}
|
|
@ -1,21 +1,16 @@
|
|||||||
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
|
diff --git a/tools/install.pl b/tools/install.pl
|
||||||
index 0cbb847d..1bd61fa0 100755
|
index dbeb7c11..06e4c675 100755
|
||||||
--- a/tools/install.pl
|
--- a/tools/install.pl
|
||||||
+++ b/tools/install.pl
|
+++ b/tools/install.pl
|
||||||
@@ -91,32 +91,6 @@ if ( $ENV{HOMEBREW_FORMULA_PREFIX} ) {
|
@@ -9,6 +9,7 @@ use Config;
|
||||||
|
|
||||||
|
use feature qw(say);
|
||||||
|
use File::Path qw(make_path);
|
||||||
|
+use File::Copy qw(copy);
|
||||||
|
|
||||||
|
#Vendor dependencies
|
||||||
|
my @vendor_css = (
|
||||||
|
@@ -91,32 +92,6 @@ if ( $ENV{HOMEBREW_FORMULA_PREFIX} ) {
|
||||||
$cpanopt = " -l " . $ENV{HOMEBREW_FORMULA_PREFIX} . "/libexec";
|
$cpanopt = " -l " . $ENV{HOMEBREW_FORMULA_PREFIX} . "/libexec";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,16 +43,60 @@ index 0cbb847d..1bd61fa0 100755
|
|||||||
#Check for PerlMagick
|
#Check for PerlMagick
|
||||||
say("Checking for ImageMagick/PerlMagick...");
|
say("Checking for ImageMagick/PerlMagick...");
|
||||||
my $imgk;
|
my $imgk;
|
||||||
@@ -154,12 +128,6 @@ if ( $back || $full ) {
|
@@ -136,36 +111,11 @@ if ($@) {
|
||||||
|
say("OK!");
|
||||||
|
}
|
||||||
|
|
||||||
|
-#Build & Install CPAN Dependencies
|
||||||
|
-if ( $back || $full ) {
|
||||||
|
- say("\r\nInstalling Perl modules... This might take a while.\r\n");
|
||||||
|
-
|
||||||
|
- if ( $Config{"osname"} ne "darwin" ) {
|
||||||
|
- say("Installing Linux::Inotify2 for non-macOS systems... (This will do nothing if the package is there already)");
|
||||||
|
-
|
||||||
|
- install_package( "Linux::Inotify2", $cpanopt );
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if ( system( "cpanm --installdeps ./tools/. --notest" . $cpanopt ) != 0 ) {
|
||||||
|
- die "Something went wrong while installing Perl modules - Bailing out.";
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
-
|
||||||
#Clientside Dependencies with Provisioning
|
#Clientside Dependencies with Provisioning
|
||||||
if ( $front || $full ) {
|
if ( $front || $full ) {
|
||||||
|
|
||||||
- say("\r\nObtaining remote Web dependencies...\r\n");
|
- say("\r\nObtaining remote Web dependencies...\r\n");
|
||||||
-
|
-
|
||||||
- if ( system("npm install") != 0 ) {
|
- if ( system("npm ci") != 0 ) {
|
||||||
- die "Something went wrong while obtaining node modules - Bailing out.";
|
- die "Something went wrong while obtaining node modules - Bailing out.";
|
||||||
- }
|
- }
|
||||||
-
|
-
|
||||||
say("\r\nProvisioning...\r\n");
|
say("\r\nProvisioning...\r\n");
|
||||||
|
|
||||||
#Load File::Copy
|
- #Load File::Copy
|
||||||
|
- install_package( "File::Copy", $cpanopt );
|
||||||
|
- File::Copy->import("copy");
|
||||||
|
-
|
||||||
|
make_path getcwd . "/public/css/vendor";
|
||||||
|
make_path getcwd . "/public/css/webfonts";
|
||||||
|
make_path getcwd . "/public/js/vendor";
|
||||||
|
@@ -212,19 +162,3 @@ sub cp_node_module {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
-sub install_package {
|
||||||
|
-
|
||||||
|
- my $package = $_[0];
|
||||||
|
- my $cpanopt = $_[1];
|
||||||
|
-
|
||||||
|
- ## no critic
|
||||||
|
- eval "require $package"; #Run-time evals are needed here to check if the package has been properly installed.
|
||||||
|
- ## use critic
|
||||||
|
-
|
||||||
|
- if ($@) {
|
||||||
|
- say("$package not installed! Trying to install now using cpanm$cpanopt");
|
||||||
|
- system("cpanm $package $cpanopt");
|
||||||
|
- } else {
|
||||||
|
- say("$package package installed, proceeding...");
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
13
pkgs/by-name/la/lanraragi/loosen-dep-reqs.patch
Normal file
13
pkgs/by-name/la/lanraragi/loosen-dep-reqs.patch
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
diff --git a/tools/cpanfile b/tools/cpanfile
|
||||||
|
index 7385aea7..22f9b069 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;
|
@ -9,16 +9,47 @@
|
|||||||
, nixosTests
|
, nixosTests
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
buildNpmPackage rec {
|
||||||
perlEnv = perl.withPackages (_: cpanDeps);
|
pname = "lanraragi";
|
||||||
|
version = "0.9.0";
|
||||||
|
|
||||||
cpanDeps = with perl.pkgs; [
|
src = fetchFromGitHub {
|
||||||
|
owner = "Difegue";
|
||||||
|
repo = "LANraragi";
|
||||||
|
rev = "v.${version}";
|
||||||
|
hash = "sha256-euZotpXTUSmxlA5rbTUhHpHH0Ojd3AZjGasxYZ+L7NY=";
|
||||||
|
};
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
(fetchpatch {
|
||||||
|
name = "fix-redis-auth.patch";
|
||||||
|
url = "https://github.com/Difegue/LANraragi/commit/1711b39759ad02ab2a8863ce1f35f6479c9a2917.patch";
|
||||||
|
hash = "sha256-WfKeieysIlS64qgVEc75JFKjxXuvZN85M6US/gwjTzw=";
|
||||||
|
})
|
||||||
|
(fetchpatch {
|
||||||
|
name = "fix-ghostscript-device.patch";
|
||||||
|
url = "https://github.com/Difegue/LANraragi/commit/087d63b11c89fda8cb3a30cdb2e86ecd6be66bb7.patch";
|
||||||
|
hash = "sha256-Cu9d/dDlO0yuFCTKOyg5A0gIuiA+FcWD9PjexB/BK0U=";
|
||||||
|
})
|
||||||
|
./install.patch
|
||||||
|
./loosen-dep-reqs.patch # Can be removed once perl.pkgs.URI is updated
|
||||||
|
./fix-paths.patch
|
||||||
|
./expose-password-hashing.patch # Used by the NixOS module
|
||||||
|
];
|
||||||
|
|
||||||
|
npmDepsHash = "sha256-/F/lhQIVGbbFxFuQXXwHUVlV2jhHt0hFf94v0FrTKt8=";
|
||||||
|
|
||||||
|
nativeBuildInputs = [ perl makeBinaryWrapper ];
|
||||||
|
|
||||||
|
buildInputs = with perl.pkgs; [
|
||||||
|
perl
|
||||||
ImageMagick
|
ImageMagick
|
||||||
locallib
|
locallib
|
||||||
Redis
|
Redis
|
||||||
Encode
|
Encode
|
||||||
ArchiveLibarchiveExtract
|
ArchiveLibarchiveExtract
|
||||||
ArchiveLibarchivePeek
|
ArchiveLibarchivePeek
|
||||||
|
ListMoreUtils
|
||||||
NetDNSNative
|
NetDNSNative
|
||||||
SortNaturally
|
SortNaturally
|
||||||
AuthenPassphrase
|
AuthenPassphrase
|
||||||
@ -39,50 +70,17 @@ let
|
|||||||
FileChangeNotify
|
FileChangeNotify
|
||||||
ModulePluggable
|
ModulePluggable
|
||||||
TimeLocal
|
TimeLocal
|
||||||
|
YAMLSyck
|
||||||
|
StringSimilarity
|
||||||
] ++ lib.optional stdenv.isLinux LinuxInotify2;
|
] ++ 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 = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
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
|
perl ./tools/install.pl install-full
|
||||||
rm -r node_modules public/js/vendor/*.map public/css/vendor/*.map
|
rm -r node_modules public/js/vendor/*.map public/css/vendor/*.map
|
||||||
|
|
||||||
@ -91,6 +89,12 @@ buildNpmPackage rec {
|
|||||||
|
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
|
|
||||||
|
nativeCheckInputs = with perl.pkgs; [
|
||||||
|
TestMockObject
|
||||||
|
TestTrap
|
||||||
|
TestDeep
|
||||||
|
];
|
||||||
|
|
||||||
checkPhase = ''
|
checkPhase = ''
|
||||||
runHook preCheck
|
runHook preCheck
|
||||||
|
|
||||||
@ -104,19 +108,23 @@ buildNpmPackage rec {
|
|||||||
runHook preInstall
|
runHook preInstall
|
||||||
|
|
||||||
mkdir -p $out/share/lanraragi
|
mkdir -p $out/share/lanraragi
|
||||||
cp -r lib public script templates package.json $out/share/lanraragi
|
chmod +x script/launcher.pl
|
||||||
|
cp -r lib public script templates package.json lrr.conf $out/share/lanraragi
|
||||||
|
|
||||||
makeWrapper ${perlEnv}/bin/perl $out/bin/lanraragi \
|
makeWrapper $out/share/lanraragi/script/launcher.pl $out/bin/lanraragi \
|
||||||
|
--prefix PERL5LIB : $PERL5LIB \
|
||||||
--prefix PATH : ${lib.makeBinPath [ ghostscript ]} \
|
--prefix PATH : ${lib.makeBinPath [ ghostscript ]} \
|
||||||
--add-flags "$out/share/lanraragi/script/launcher.pl -f $out/share/lanraragi/script/lanraragi"
|
--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
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = {
|
passthru.tests.module = nixosTests.lanraragi;
|
||||||
inherit perlEnv;
|
|
||||||
tests = { inherit (nixosTests) lanraragi; };
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
changelog = "https://github.com/Difegue/LANraragi/releases/tag/${src.rev}";
|
changelog = "https://github.com/Difegue/LANraragi/releases/tag/${src.rev}";
|
||||||
@ -128,3 +136,4 @@ buildNpmPackage rec {
|
|||||||
platforms = lib.platforms.unix;
|
platforms = lib.platforms.unix;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user