2019-09-22 16:54:16 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.shiori;
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.shiori = {
|
|
|
|
enable = mkEnableOption "Shiori simple bookmarks manager";
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.shiori;
|
|
|
|
defaultText = "pkgs.shiori";
|
|
|
|
description = "The Shiori package to use.";
|
|
|
|
};
|
|
|
|
|
|
|
|
address = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
The IP address on which Shiori will listen.
|
|
|
|
If empty, listens on all interfaces.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 8080;
|
|
|
|
description = "The port of the Shiori web application";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.shiori = with cfg; {
|
|
|
|
description = "Shiori simple bookmarks manager";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
2020-10-02 19:31:38 +01:00
|
|
|
environment.SHIORI_DIR = "/var/lib/shiori";
|
|
|
|
|
2019-09-22 16:54:16 +01:00
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${package}/bin/shiori serve --address '${address}' --port '${toString port}'";
|
2020-10-02 19:31:38 +01:00
|
|
|
|
2019-09-22 16:54:16 +01:00
|
|
|
DynamicUser = true;
|
|
|
|
StateDirectory = "shiori";
|
2020-10-02 19:31:38 +01:00
|
|
|
# As the RootDirectory
|
|
|
|
RuntimeDirectory = "shiori";
|
|
|
|
|
|
|
|
# Security options
|
|
|
|
|
|
|
|
BindReadOnlyPaths = [
|
|
|
|
"/nix/store"
|
|
|
|
|
|
|
|
# For SSL certificates, and the resolv.conf
|
|
|
|
"/etc"
|
|
|
|
];
|
|
|
|
|
|
|
|
CapabilityBoundingSet = "";
|
|
|
|
|
|
|
|
DeviceAllow = "";
|
|
|
|
|
|
|
|
LockPersonality = true;
|
|
|
|
|
|
|
|
MemoryDenyWriteExecute = true;
|
|
|
|
|
|
|
|
PrivateDevices = true;
|
|
|
|
PrivateUsers = true;
|
|
|
|
|
|
|
|
ProtectClock = true;
|
|
|
|
ProtectControlGroups = true;
|
|
|
|
ProtectHome = true;
|
|
|
|
ProtectHostname = true;
|
|
|
|
ProtectKernelLogs = true;
|
|
|
|
ProtectKernelModules = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
|
|
|
|
RestrictNamespaces = true;
|
|
|
|
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
|
|
|
|
RestrictRealtime = true;
|
|
|
|
RestrictSUIDSGID = true;
|
|
|
|
|
|
|
|
RootDirectory = "/run/shiori";
|
|
|
|
|
|
|
|
SystemCallArchitectures = "native";
|
|
|
|
SystemCallErrorNumber = "EPERM";
|
|
|
|
SystemCallFilter = [
|
|
|
|
"@system-service"
|
|
|
|
|
2021-04-03 11:44:24 +01:00
|
|
|
"~@chown" "~@cpu-emulation" "~@debug" "~@keyring" "~@memlock"
|
|
|
|
"~@module" "~@obsolete" "~@privileged" "~@raw-io"
|
2020-10-02 19:31:38 +01:00
|
|
|
"~@resources" "~@setuid"
|
|
|
|
];
|
2019-09-22 16:54:16 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
meta.maintainers = with maintainers; [ minijackson ];
|
|
|
|
}
|