1 { config, lib, pkgs, ... }:
3 let cfg = config.services.shiori;
7 enable = lib.mkEnableOption "Shiori simple bookmarks manager";
9 package = lib.mkPackageOption pkgs "shiori" { };
11 address = lib.mkOption {
15 The IP address on which Shiori will listen.
16 If empty, listens on all interfaces.
21 type = lib.types.port;
23 description = "The port of the Shiori web application";
26 webRoot = lib.mkOption {
30 description = "The root of the Shiori web application";
33 environmentFile = lib.mkOption {
34 type = lib.types.nullOr lib.types.path;
36 example = "/path/to/environmentFile";
38 Path to file containing environment variables.
39 Useful for passing down secrets.
40 <https://github.com/go-shiori/shiori/blob/master/docs/Configuration.md#overall-configuration>
44 databaseUrl = lib.mkOption {
45 type = lib.types.nullOr lib.types.str;
47 example = "postgres:///shiori?host=/run/postgresql";
48 description = "The connection URL to connect to MySQL or PostgreSQL";
53 config = lib.mkIf cfg.enable {
54 systemd.services.shiori = {
55 description = "Shiori simple bookmarks manager";
56 wantedBy = [ "multi-user.target" ];
57 after = [ "postgresql.service" "mysql.service" ];
59 SHIORI_DIR = "/var/lib/shiori";
60 } // lib.optionalAttrs (cfg.databaseUrl != null) {
61 SHIORI_DATABASE_URL = cfg.databaseUrl;
66 "${cfg.package}/bin/shiori server --address '${cfg.address}' --port '${
68 }' --webroot '${cfg.webRoot}'";
71 StateDirectory = "shiori";
72 # As the RootDirectory
73 RuntimeDirectory = "shiori";
77 lib.optional (cfg.environmentFile != null) cfg.environmentFile;
81 # For SSL certificates, and the resolv.conf
83 ] ++ lib.optional (config.services.postgresql.enable &&
84 cfg.databaseUrl != null &&
85 lib.strings.hasPrefix "postgres://" cfg.databaseUrl)
87 ++ lib.optional (config.services.mysql.enable &&
88 cfg.databaseUrl != null &&
89 lib.strings.hasPrefix "mysql://" cfg.databaseUrl)
92 CapabilityBoundingSet = "";
93 AmbientCapabilities = "CAP_NET_BIND_SERVICE";
97 LockPersonality = true;
99 MemoryDenyWriteExecute = true;
101 PrivateDevices = true;
105 ProtectControlGroups = true;
107 ProtectHostname = true;
108 ProtectKernelLogs = true;
109 ProtectKernelModules = true;
110 ProtectKernelTunables = true;
112 RestrictNamespaces = true;
113 RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ];
114 RestrictRealtime = true;
115 RestrictSUIDSGID = true;
117 RootDirectory = "/run/shiori";
119 SystemCallArchitectures = "native";
120 SystemCallErrorNumber = "EPERM";
135 meta.maintainers = with lib.maintainers; [ minijackson CaptainJawZ ];