Privatebin: Replace with nixpkgs package :(.

This commit is contained in:
Dmitry Voronin 2024-12-20 06:15:17 +03:00
parent 06e803da46
commit 46cfbdb861
7 changed files with 42 additions and 184 deletions

View file

@ -11,10 +11,8 @@
configurations = [
"forgejo"
"invidious"
"mattermost"
"nextcloud"
"paperless"
"privatebin"
];
ensureDatabases = [ "root" ] ++ configurations;

View file

@ -1,43 +1,48 @@
{ __findFile, pkgs, ... }@args:
let
package = (pkgs.callPackage <package/privatebin> args);
in
{ ... }:
{
environment.systemPackages = [ package ];
systemd.packages = [ package ];
users.users.paste = {
group = "nginx";
isSystemUser = true;
};
services = {
phpfpm.pools.paste = {
group = "nginx";
user = "paste";
phpPackage = pkgs.php;
settings = {
"catch_workers_output" = true;
"listen.owner" = "nginx";
"php_admin_flag[log_errors]" = true;
"php_admin_value[error_log]" = "stderr";
"pm" = "dynamic";
"pm.max_children" = "32";
"pm.max_requests" = "500";
"pm.max_spare_servers" = "4";
"pm.min_spare_servers" = "2";
"pm.start_servers" = "2";
services.privatebin = {
enable = true;
enableNginx = true;
virtualHost = "paste.voronind.com";
settings = {
main = {
compression = "none";
defaultformatter = "plaintext";
discussion = false;
email = true;
fileupload = false;
languageselection = false;
name = "voronind pastebin";
password = true;
qrcode = true;
sizelimit = 10 * 1000 * 1000;
template = "bootstrap";
};
phpEnv = {
# CONFIG_PATH = "${package}/cfg"; # NOTE: Not working?
expire = {
default = "1week";
};
};
nginx = {
enable = true;
virtualHosts."paste.voronind.com" = {
root = "${package}";
formatter_options = {
markdown = "Markdown";
plaintext = "Plain Text";
syntaxhighlighting = "Source Code";
};
traffic = {
limit = 10;
};
purge = {
limit = 0;
batchsize = 10;
};
# model = {
# class = "Database";
# };
# model_options = {
# "opt[12]" = true;
# dsn = "pgsql:dbname=privatebin";
# pwd = "privatebin";
# tbl = "privatebin_";
# usr = "privatebin";
# };
};
};
}

View file

@ -1,41 +1,11 @@
{ config, ... }:
{
{ ... }: {
"paste.voronind.com" = {
locations = {
"= /".extraConfig = ''
return 403;
'';
"~ \\.php$".extraConfig = ''
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:${config.services.phpfpm.pools.paste.socket};
include ${config.services.nginx.package}/conf/fastcgi.conf;
include ${config.services.nginx.package}/conf/fastcgi_params;
'';
"~ \\.(js|css|ttf|woff2?|png|jpe?g|svg)$".extraConfig = ''
add_header Cache-Control "public, max-age=15778463";
add_header Referrer-Policy no-referrer;
add_header X-Content-Type-Options nosniff;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
add_header X-Robots-Tag none;
add_header X-XSS-Protection "1; mode=block";
access_log off;
'';
"/".extraConfig = ''
rewrite ^ /index.php;
'';
};
extraConfig = ''
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/voronind.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/voronind.com/privkey.pem;
include /etc/letsencrypt/conf/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/conf/ssl-dhparams.pem;
try_files $uri /index.php;
'';
};
}

View file

@ -75,7 +75,6 @@
zip # Zip utility.
# (pkgs.callPackage ./ytdlp {}) # Youtube downloader bin package.
(pkgs.callPackage ./yamusicdownload { }) # Yandex music downloader.
])
++ (with pkgsUnstable; [
fastfetch # Systeminfo summary.

View file

@ -1,55 +0,0 @@
{ pkgs, lib, ... }:
let
cfg = {
main = {
compression = "none";
defaultformatter = "plaintext";
discussion = false;
email = true;
fileupload = false;
languageselection = false;
name = "voronind pastebin";
password = true;
qrcode = true;
sizelimit = 10 * 1000 * 1000;
template = "bootstrap";
};
expire = {
default = "1week";
};
formatter_options = {
markdown = "Markdown";
plaintext = "Plain Text";
syntaxhighlighting = "Source Code";
};
traffic = {
limit = 10;
};
purge = {
limit = 0;
batchsize = 10;
};
model = {
class = "Database";
};
model_options = {
"opt[12]" = true;
dsn = "pgsql:dbname=privatebin";
pwd = "privatebin";
tbl = "privatebin_";
usr = "privatebin";
};
};
in
{
file =
(pkgs.formats.ini {
mkKeyValue =
with lib.generators;
mkKeyValueDefault {
mkValueString = v: if builtins.isString v then "\"${toString v}\"" else toString v;
} " = ";
}).generate
"PrivateBinConfig"
cfg;
}

View file

@ -1,38 +0,0 @@
{
config,
php,
pkgs,
...
}@args:
let
cfg = (import ./Config.nix args).file;
in
php.buildComposerProject (finalAttrs: {
pname = "PrivateBin";
vendorHash = "sha256-JGuO8kXLLXqq76EccdNSoHwYO5OuJT3Au1O2O2szAHI=";
version = "1.7.4";
src = pkgs.fetchFromGitHub {
hash = "sha256-RFP6rhzfBzTmqs4eJXv7LqdniWoeBJpQQ6fLdoGd5Fk=";
owner = "PrivateBin";
repo = "PrivateBin";
rev = finalAttrs.version;
};
installPhase = ''
runHook preInstall
mv $out/share/php/PrivateBin/* $out
rm -r $out/share
cp ${cfg} $out/cfg/conf.php
touch $out/.env
pushd $out
runHook postInstall
'';
postFixup = ''
substituteInPlace $out/index.php --replace-fail \
"define('PATH', ''')" \
"define('PATH', '$out/')"
'';
})

View file

@ -1,21 +0,0 @@
{ pkgs, ... }:
with pkgs.python3Packages;
buildPythonPackage {
format = "pyproject";
meta.mainProgram = "yandex-music-downloader";
pname = "yandex-music-downloader";
version = "1.0.0";
propagatedBuildInputs = [
browser-cookie3
eyed3
requests
setuptools
setuptools-git
];
src = pkgs.fetchFromGitHub {
hash = "sha256-WOFesD7HjskyqHaXZAPy3pgSPaEO+tOyQ+5MV3ZO7XU=";
owner = "llistochek";
repo = "yandex-music-downloader";
rev = "08ea384869cbc31efb1e78b831e2356882219951";
};
}