1 { config, lib, pkgs, ... }:
6 cfg = config.services.pinnwand;
8 format = pkgs.formats.toml {};
9 configFile = format.generate "pinnwand.toml" cfg.settings;
12 options.services.pinnwand = {
13 enable = mkEnableOption "Pinnwand, a pastebin";
17 description = "The port to listen on.";
24 Your {file}`pinnwand.toml` as a Nix attribute set. Look up
25 possible options in the [documentation](https://pinnwand.readthedocs.io/en/v${pkgs.pinnwand.version}/configuration.html).
27 type = types.submodule {
28 freeformType = format.type;
30 database_uri = mkOption {
32 default = "sqlite:////var/lib/pinnwand/pinnwand.db";
33 example = "sqlite:///:memory";
35 Database URI compatible with [SQLAlchemyhttps://docs.sqlalchemy.org/en/14/core/engines.html#database-urls].
37 Additional packages may need to be introduced into the environment for certain databases.
41 paste_size = mkOption {
42 type = types.ints.positive;
46 Maximum size of a paste in bytes.
49 paste_help = mkOption {
52 <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>
55 Raw HTML help text shown in the header area.
61 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.
64 The footer in raw HTML.
72 config = mkIf cfg.enable {
73 systemd.services.pinnwand = {
74 description = "Pinnwannd HTTP Server";
75 after = [ "network.target" ];
76 wantedBy = [ "multi-user.target" ];
78 unitConfig.Documentation = "https://pinnwand.readthedocs.io/en/latest/";
81 ExecStart = "${pkgs.pinnwand}/bin/pinnwand --configuration-path ${configFile} http --port ${toString cfg.port}";
85 StateDirectory = "pinnwand";
86 StateDirectoryMode = "0700";
88 AmbientCapabilities = [];
89 CapabilityBoundingSet = "";
90 DevicePolicy = "closed";
91 LockPersonality = true;
92 MemoryDenyWriteExecute = true;
93 PrivateDevices = true;
97 ProtectControlGroups = true;
99 ProtectHostname = true;
100 ProtectKernelLogs = true;
101 ProtectKernelModules = true;
102 ProtectKernelTunables = true;
103 ProtectProc = "invisible";
104 RestrictAddressFamilies = [
109 RestrictNamespaces = true;
110 RestrictRealtime = true;
111 SystemCallArchitectures = "native";
121 meta.buildDocsInSandbox = false;