replace rustypaste with hastebin
This commit is contained in:
21
flake.lock
generated
21
flake.lock
generated
@@ -258,6 +258,26 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"hastebin": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1739148691,
|
||||||
|
"narHash": "sha256-8+CoG/VgpZXta7pd6rCEy9HXO3U22j+J0k+1jL6sHjE=",
|
||||||
|
"owner": "~repomaa",
|
||||||
|
"repo": "hastebin",
|
||||||
|
"rev": "4f49d71c09d365ad7bca18390547c9fcf4eb0887",
|
||||||
|
"type": "sourcehut"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "~repomaa",
|
||||||
|
"repo": "hastebin",
|
||||||
|
"type": "sourcehut"
|
||||||
|
}
|
||||||
|
},
|
||||||
"home-manager": {
|
"home-manager": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
@@ -599,6 +619,7 @@
|
|||||||
"flake-parts": "flake-parts",
|
"flake-parts": "flake-parts",
|
||||||
"gen-nvim": "gen-nvim",
|
"gen-nvim": "gen-nvim",
|
||||||
"gtrackmap": "gtrackmap",
|
"gtrackmap": "gtrackmap",
|
||||||
|
"hastebin": "hastebin",
|
||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
"ketchup": "ketchup",
|
"ketchup": "ketchup",
|
||||||
"ksoloti-pr": "ksoloti-pr",
|
"ksoloti-pr": "ksoloti-pr",
|
||||||
|
|||||||
@@ -47,6 +47,10 @@
|
|||||||
url = "sourcehut:~repomaa/workout-sync";
|
url = "sourcehut:~repomaa/workout-sync";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
hastebin = {
|
||||||
|
url = "sourcehut:~repomaa/hastebin";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
ksoloti-pr.url = "github:repomaa/nixpkgs/pkg/ksoloti";
|
ksoloti-pr.url = "github:repomaa/nixpkgs/pkg/ksoloti";
|
||||||
};
|
};
|
||||||
outputs = { flake-parts, nixpkgs, ... }@inputs:
|
outputs = { flake-parts, nixpkgs, ... }@inputs:
|
||||||
|
|||||||
@@ -1,51 +1,36 @@
|
|||||||
{ lib, pkgs, config, ... }:
|
{ lib, pkgs, config, inputs, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.modules.services.bin;
|
cfg = config.modules.services.bin;
|
||||||
fqdn = "${cfg.subdomain}.${config.networking.domain}";
|
fqdn = "${cfg.subdomain}.${config.networking.domain}";
|
||||||
rustypasteConfig = (pkgs.formats.toml { }).generate "rustypaste-config.toml" {
|
KiB = 1024;
|
||||||
server = {
|
MiB = 1024 * KiB;
|
||||||
address = "[::1]:${toString cfg.port}";
|
GiB = 1024 * MiB;
|
||||||
max_content_length = "1GB";
|
|
||||||
upload_path = "/var/lib/rustypaste/uploads";
|
|
||||||
timeout = "5m";
|
|
||||||
};
|
|
||||||
|
|
||||||
landing_page = {
|
hastebinConfig = (pkgs.formats.yaml { }).generate "hastebin.yml" {
|
||||||
text = ''
|
port = cfg.port;
|
||||||
┬─┐┬ ┬┌─┐┌┬┐┬ ┬┌─┐┌─┐┌─┐┌┬┐┌─┐
|
max_size = 1 * GiB;
|
||||||
├┬┘│ │└─┐ │ └┬┘├─┘├─┤└─┐ │ ├┤
|
default_extension = "txt";
|
||||||
┴└─└─┘└─┘ ┴ ┴ ┴ ┴ ┴└─┘ ┴ └─┘
|
data_dir = "/var/lib/hastebin";
|
||||||
|
mime_overrides = {
|
||||||
Submit files via HTTP POST here:
|
"text/plain" = [
|
||||||
curl -F 'file=@example.txt' https://${fqdn}
|
"log"
|
||||||
This will return the URL of the uploaded file.
|
"txt"
|
||||||
|
"diff"
|
||||||
The server administrator might remove any pastes that they do not personally
|
"sh"
|
||||||
want to host.
|
"rs"
|
||||||
|
"toml"
|
||||||
If you are the server administrator and want to change this page, just go
|
"cr"
|
||||||
into your config file and change it! If you change the expiry time, it is
|
"nix"
|
||||||
recommended that you do.
|
"rb"
|
||||||
|
"ts"
|
||||||
By default, pastes expire every hour. The server admin may or may not have
|
"tsx"
|
||||||
changed this.
|
"jsx"
|
||||||
|
|
||||||
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)$"; }
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
auth_tokens_file = "/var/secrets/hastebin-tokens";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
hastebin = inputs.hastebin.packages.${pkgs.system}.default;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.modules.services.bin = {
|
options.modules.services.bin = {
|
||||||
@@ -62,22 +47,21 @@ in
|
|||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
systemd.services.rustypaste = {
|
systemd.services.rustypaste = {
|
||||||
enable = true;
|
enable = true;
|
||||||
description = "Rustypaste pastebin";
|
description = "Hastebin pastebin";
|
||||||
environment = {
|
environment = {
|
||||||
CONFIG = rustypasteConfig;
|
HASTEBIN_CONFIG = hastebinConfig;
|
||||||
AUTH_TOKENS_FILE = "/var/secrets/rustypaste-tokens";
|
|
||||||
};
|
};
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${pkgs.rustypaste}/bin/rustypaste";
|
ExecStart = "${hastebin}/bin/hastebin";
|
||||||
WorkingDirectory = "/var/lib/rustypaste";
|
WorkingDirectory = "/var/lib/hastebin";
|
||||||
StateDirectory = "rustypaste";
|
StateDirectory = "hastebin";
|
||||||
DynamicUser = true;
|
DynamicUser = true;
|
||||||
BindReadOnlyPaths = [ "/var/secrets/rustypaste-tokens" ];
|
BindReadOnlyPaths = [ "/var/secrets/hastebin-tokens" ];
|
||||||
};
|
};
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
confinement = {
|
confinement = {
|
||||||
enable = true;
|
enable = true;
|
||||||
packages = [ rustypasteConfig ];
|
packages = [ hastebinConfig ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user