replace rustypaste with hastebin
This commit is contained in:
@@ -1,51 +1,36 @@
|
||||
{ lib, pkgs, config, ... }:
|
||||
{ lib, pkgs, config, inputs, ... }:
|
||||
let
|
||||
cfg = config.modules.services.bin;
|
||||
fqdn = "${cfg.subdomain}.${config.networking.domain}";
|
||||
rustypasteConfig = (pkgs.formats.toml { }).generate "rustypaste-config.toml" {
|
||||
server = {
|
||||
address = "[::1]:${toString cfg.port}";
|
||||
max_content_length = "1GB";
|
||||
upload_path = "/var/lib/rustypaste/uploads";
|
||||
timeout = "5m";
|
||||
};
|
||||
KiB = 1024;
|
||||
MiB = 1024 * KiB;
|
||||
GiB = 1024 * MiB;
|
||||
|
||||
landing_page = {
|
||||
text = ''
|
||||
┬─┐┬ ┬┌─┐┌┬┐┬ ┬┌─┐┌─┐┌─┐┌┬┐┌─┐
|
||||
├┬┘│ │└─┐ │ └┬┘├─┘├─┤└─┐ │ ├┤
|
||||
┴└─└─┘└─┘ ┴ ┴ ┴ ┴ ┴└─┘ ┴ └─┘
|
||||
|
||||
Submit files via HTTP POST here:
|
||||
curl -F 'file=@example.txt' https://${fqdn}
|
||||
This will return the URL of the uploaded file.
|
||||
|
||||
The server administrator might remove any pastes that they do not personally
|
||||
want to host.
|
||||
|
||||
If you are the server administrator and want to change this page, just go
|
||||
into your config file and change it! If you change the expiry time, it is
|
||||
recommended that you do.
|
||||
|
||||
By default, pastes expire every hour. The server admin may or may not have
|
||||
changed this.
|
||||
|
||||
Check out the GitHub repository at https://github.com/orhun/rustypaste
|
||||
Command line tool is available at https://github.com/orhun/rustypaste-cli
|
||||
'';
|
||||
content_type = "text/plain; charset=utf-8";
|
||||
};
|
||||
|
||||
paste = {
|
||||
default_extension = "txt";
|
||||
random_url = { type = "petname"; words = 2; separator = "-"; };
|
||||
delete_expirted_files = { enabled = true; interval = "1h"; };
|
||||
default_expiry = "100y";
|
||||
mime_override = [
|
||||
{ mime = "text/plain"; regex = "^.*\.(log|txt|diff|sh|rs|toml|cr|nix|rb|js|tsx|ts|jsx)$"; }
|
||||
hastebinConfig = (pkgs.formats.yaml { }).generate "hastebin.yml" {
|
||||
port = cfg.port;
|
||||
max_size = 1 * GiB;
|
||||
default_extension = "txt";
|
||||
data_dir = "/var/lib/hastebin";
|
||||
mime_overrides = {
|
||||
"text/plain" = [
|
||||
"log"
|
||||
"txt"
|
||||
"diff"
|
||||
"sh"
|
||||
"rs"
|
||||
"toml"
|
||||
"cr"
|
||||
"nix"
|
||||
"rb"
|
||||
"ts"
|
||||
"tsx"
|
||||
"jsx"
|
||||
];
|
||||
};
|
||||
auth_tokens_file = "/var/secrets/hastebin-tokens";
|
||||
};
|
||||
|
||||
hastebin = inputs.hastebin.packages.${pkgs.system}.default;
|
||||
in
|
||||
{
|
||||
options.modules.services.bin = {
|
||||
@@ -62,22 +47,21 @@ in
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.services.rustypaste = {
|
||||
enable = true;
|
||||
description = "Rustypaste pastebin";
|
||||
description = "Hastebin pastebin";
|
||||
environment = {
|
||||
CONFIG = rustypasteConfig;
|
||||
AUTH_TOKENS_FILE = "/var/secrets/rustypaste-tokens";
|
||||
HASTEBIN_CONFIG = hastebinConfig;
|
||||
};
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.rustypaste}/bin/rustypaste";
|
||||
WorkingDirectory = "/var/lib/rustypaste";
|
||||
StateDirectory = "rustypaste";
|
||||
ExecStart = "${hastebin}/bin/hastebin";
|
||||
WorkingDirectory = "/var/lib/hastebin";
|
||||
StateDirectory = "hastebin";
|
||||
DynamicUser = true;
|
||||
BindReadOnlyPaths = [ "/var/secrets/rustypaste-tokens" ];
|
||||
BindReadOnlyPaths = [ "/var/secrets/hastebin-tokens" ];
|
||||
};
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
confinement = {
|
||||
enable = true;
|
||||
packages = [ rustypasteConfig ];
|
||||
packages = [ hastebinConfig ];
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user