From dc099cf5674e829db25e84afd27012eb7bf0fbec Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Fri, 20 Dec 2024 06:15:17 +0300 Subject: [PATCH] Privatebin: Replace with nixpkgs package :(. --- host/x86_64-linux/home/Postgres.nix | 2 - host/x86_64-linux/home/Privatebin.nix | 77 +++++++++++---------- host/x86_64-linux/home/nginx/Privatebin.nix | 32 +-------- package/default.nix | 1 - package/privatebin/Config.nix | 55 --------------- package/privatebin/default.nix | 38 ---------- package/yamusicdownload/default.nix | 21 ------ 7 files changed, 42 insertions(+), 184 deletions(-) delete mode 100644 package/privatebin/Config.nix delete mode 100644 package/privatebin/default.nix delete mode 100644 package/yamusicdownload/default.nix diff --git a/host/x86_64-linux/home/Postgres.nix b/host/x86_64-linux/home/Postgres.nix index 13afe3d1..62030f2d 100644 --- a/host/x86_64-linux/home/Postgres.nix +++ b/host/x86_64-linux/home/Postgres.nix @@ -11,10 +11,8 @@ configurations = [ "forgejo" "invidious" - "mattermost" "nextcloud" "paperless" - "privatebin" ]; ensureDatabases = [ "root" ] ++ configurations; diff --git a/host/x86_64-linux/home/Privatebin.nix b/host/x86_64-linux/home/Privatebin.nix index 45bcf4b4..7ca7a2fb 100644 --- a/host/x86_64-linux/home/Privatebin.nix +++ b/host/x86_64-linux/home/Privatebin.nix @@ -1,43 +1,48 @@ -{ __findFile, pkgs, ... }@args: -let - package = (pkgs.callPackage 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"; + # }; }; }; } diff --git a/host/x86_64-linux/home/nginx/Privatebin.nix b/host/x86_64-linux/home/nginx/Privatebin.nix index 6478f40f..b5888473 100644 --- a/host/x86_64-linux/home/nginx/Privatebin.nix +++ b/host/x86_64-linux/home/nginx/Privatebin.nix @@ -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; ''; }; } diff --git a/package/default.nix b/package/default.nix index 6a05a5f2..39e20895 100644 --- a/package/default.nix +++ b/package/default.nix @@ -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. diff --git a/package/privatebin/Config.nix b/package/privatebin/Config.nix deleted file mode 100644 index 7272246c..00000000 --- a/package/privatebin/Config.nix +++ /dev/null @@ -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; -} diff --git a/package/privatebin/default.nix b/package/privatebin/default.nix deleted file mode 100644 index 6abe23d9..00000000 --- a/package/privatebin/default.nix +++ /dev/null @@ -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/')" - ''; -}) diff --git a/package/yamusicdownload/default.nix b/package/yamusicdownload/default.nix deleted file mode 100644 index 9f36bc41..00000000 --- a/package/yamusicdownload/default.nix +++ /dev/null @@ -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"; - }; -}