1 { config, lib, pkgs, ... }:
3 cfg = config.services.pinnwand;
5 format = pkgs.formats.toml {};
6 configFile = format.generate "pinnwand.toml" cfg.settings;
9 options.services.pinnwand = {
10 enable = lib.mkEnableOption "Pinnwand, a pastebin";
13 type = lib.types.port;
14 description = "The port to listen on.";
18 settings = lib.mkOption {
21 Your {file}`pinnwand.toml` as a Nix attribute set. Look up
22 possible options in the [documentation](https://pinnwand.readthedocs.io/en/v${pkgs.pinnwand.version}/configuration.html).
24 type = lib.types.submodule {
25 freeformType = format.type;
27 database_uri = lib.mkOption {
29 default = "sqlite:////var/lib/pinnwand/pinnwand.db";
30 example = "sqlite:///:memory";
32 Database URI compatible with [SQLAlchemyhttps://docs.sqlalchemy.org/en/14/core/engines.html#database-urls].
34 Additional packages may need to be introduced into the environment for certain databases.
38 paste_size = lib.mkOption {
39 type = lib.types.ints.positive;
43 Maximum size of a paste in bytes.
46 paste_help = lib.mkOption {
49 <p>Welcome to pinnwand, this site is a pastebin. It allows you to share code with others. If you write code in the text area below and press the paste button you will be given a link you can share with others so they can view your code as well.</p><p>People with the link can view your pasted code, only you can remove your paste and it expires automatically. Note that anyone could guess the URI to your paste so don't rely on it being private.</p>
52 Raw HTML help text shown in the header area.
55 footer = lib.mkOption {
58 View <a href="//github.com/supakeen/pinnwand" target="_BLANK">source code</a>, the <a href="/removal">removal</a> or <a href="/expiry">expiry</a> stories, or read the <a href="/about">about</a> page.
61 The footer in raw HTML.
69 config = lib.mkIf cfg.enable {
70 systemd.services.pinnwand = {
71 description = "Pinnwannd HTTP Server";
72 after = [ "network.target" ];
73 wantedBy = [ "multi-user.target" ];
75 unitConfig.Documentation = "https://pinnwand.readthedocs.io/en/latest/";
78 ExecStart = "${pkgs.pinnwand}/bin/pinnwand --configuration-path ${configFile} http --port ${toString cfg.port}";
82 StateDirectory = "pinnwand";
83 StateDirectoryMode = "0700";
85 AmbientCapabilities = [];
86 CapabilityBoundingSet = "";
87 DevicePolicy = "closed";
88 LockPersonality = true;
89 MemoryDenyWriteExecute = true;
90 PrivateDevices = true;
94 ProtectControlGroups = true;
96 ProtectHostname = true;
97 ProtectKernelLogs = true;
98 ProtectKernelModules = true;
99 ProtectKernelTunables = true;
100 ProtectProc = "invisible";
101 RestrictAddressFamilies = [
106 RestrictNamespaces = true;
107 RestrictRealtime = true;
108 SystemCallArchitectures = "native";
118 meta.buildDocsInSandbox = false;