1 { config, lib, pkgs, ... }:
4 cfg = config.services.wastebin;
6 mkEnableOption mkPackageOption mkIf mkOption
7 types mapAttrs isBool getExe boolToString optionalAttrs;
11 options.services.wastebin = {
13 enable = mkEnableOption "Wastebin, a pastebin service";
15 package = mkPackageOption pkgs "wastebin" { };
19 default = "/var/lib/wastebin";
20 description = "State directory of the daemon.";
23 secretFile = mkOption {
24 type = types.nullOr types.path;
26 example = "/run/secrets/wastebin.env";
28 Path to file containing sensitive environment variables.
29 Some variables that can be considered secrets are:
31 - WASTEBIN_PASSWORD_SALT:
32 salt used to hash user passwords used for encrypting pastes.
34 - WASTEBIN_SIGNING_KEY:
35 sets the key to sign cookies. If not set, a random key will be
36 generated which means cookies will become invalid after restarts and
37 paste creators will not be able to delete their pastes anymore.
44 Additional configuration for wastebin, see
45 <https://github.com/matze/wastebin#usage> for supported values.
46 For secrets use secretFile option instead.
49 type = types.submodule {
51 freeformType = with types; attrsOf (oneOf [ bool int str ]);
55 WASTEBIN_ADDRESS_PORT = mkOption {
57 default = "0.0.0.0:8088";
58 description = "Address and port to bind to";
61 WASTEBIN_BASE_URL = mkOption {
62 default = "http://localhost";
63 example = "https://myhost.tld";
66 Base URL for the QR code display. If not set, the user agent's Host
67 header field is used as an approximation.
71 WASTEBIN_CACHE_SIZE = mkOption {
74 description = "Number of rendered syntax highlight items to cache. Can be disabled by setting to 0.";
77 WASTEBIN_DATABASE_PATH = mkOption {
78 default = "/var/lib/wastebin/sqlite3.db"; # TODO make this default to stateDir/sqlite3.db
80 description = "Path to the sqlite3 database file. If not set, an in-memory database is used.";
83 WASTEBIN_HTTP_TIMEOUT = mkOption {
86 description = "Maximum number of seconds a request can be processed until wastebin responds with 408";
89 WASTEBIN_MAX_BODY_SIZE = mkOption {
92 description = "Number of bytes to accept for POST requests";
95 WASTEBIN_TITLE = mkOption {
98 description = "Overrides the HTML page title";
101 RUST_LOG = mkOption {
106 Influences logging. Besides the typical trace, debug, info etc.
107 keys, you can also set the tower_http key to some log level to get
108 additional information request and response logs.
117 WASTEBIN_TITLE = "My awesome pastebin";
122 config = mkIf cfg.enable
124 systemd.services.wastebin = {
125 after = [ "network.target" ];
126 wantedBy = [ "multi-user.target" ];
127 environment = mapAttrs (_: v: if isBool v then boolToString v else toString v) cfg.settings;
129 DevicePolicy = "closed";
131 ExecStart = "${getExe cfg.package}";
132 LockPersonality = true;
133 MemoryDenyWriteExecute = true;
134 PrivateDevices = true;
137 ProtectControlGroups = true;
138 ProtectHostname = true;
139 ProtectKernelLogs = true;
140 ProtectKernelModules = true;
141 ProtectKernelTunables = true;
142 ProtectProc = "invisible";
143 RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
144 RestrictNamespaces = true;
145 RestrictRealtime = true;
146 SystemCallArchitectures = [ "native" ];
147 SystemCallFilter = [ "@system-service" ];
148 StateDirectory = baseNameOf cfg.stateDir;
149 ReadWritePaths = cfg.stateDir;
150 } // optionalAttrs (cfg.secretFile != null) {
151 EnvironmentFile = cfg.secretFile;
156 meta.maintainers = with lib.maintainers; [ pinpox ];