mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 12:15:34 +03:00

After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
154 lines
3.9 KiB
Nix
154 lines
3.9 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
|
|
let
|
|
cfg = config.services.shiori;
|
|
in
|
|
{
|
|
options = {
|
|
services.shiori = {
|
|
enable = lib.mkEnableOption "Shiori simple bookmarks manager";
|
|
|
|
package = lib.mkPackageOption pkgs "shiori" { };
|
|
|
|
address = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "";
|
|
description = ''
|
|
The IP address on which Shiori will listen.
|
|
If empty, listens on all interfaces.
|
|
'';
|
|
};
|
|
|
|
port = lib.mkOption {
|
|
type = lib.types.port;
|
|
default = 8080;
|
|
description = "The port of the Shiori web application";
|
|
};
|
|
|
|
webRoot = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "/";
|
|
example = "/shiori";
|
|
description = "The root of the Shiori web application";
|
|
};
|
|
|
|
environmentFile = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.path;
|
|
default = null;
|
|
example = "/path/to/environmentFile";
|
|
description = ''
|
|
Path to file containing environment variables.
|
|
Useful for passing down secrets.
|
|
<https://github.com/go-shiori/shiori/blob/master/docs/Configuration.md#overall-configuration>
|
|
'';
|
|
};
|
|
|
|
databaseUrl = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.str;
|
|
default = null;
|
|
example = "postgres:///shiori?host=/run/postgresql";
|
|
description = "The connection URL to connect to MySQL or PostgreSQL";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
systemd.services.shiori = {
|
|
description = "Shiori simple bookmarks manager";
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [
|
|
"postgresql.service"
|
|
"mysql.service"
|
|
];
|
|
environment =
|
|
{
|
|
SHIORI_DIR = "/var/lib/shiori";
|
|
}
|
|
// lib.optionalAttrs (cfg.databaseUrl != null) {
|
|
SHIORI_DATABASE_URL = cfg.databaseUrl;
|
|
};
|
|
|
|
serviceConfig = {
|
|
ExecStart = "${cfg.package}/bin/shiori server --address '${cfg.address}' --port '${toString cfg.port}' --webroot '${cfg.webRoot}'";
|
|
|
|
DynamicUser = true;
|
|
StateDirectory = "shiori";
|
|
# As the RootDirectory
|
|
RuntimeDirectory = "shiori";
|
|
|
|
# Security options
|
|
EnvironmentFile = lib.optional (cfg.environmentFile != null) cfg.environmentFile;
|
|
BindReadOnlyPaths =
|
|
[
|
|
"/nix/store"
|
|
|
|
# For SSL certificates, and the resolv.conf
|
|
"/etc"
|
|
]
|
|
++ lib.optional (
|
|
config.services.postgresql.enable
|
|
&& cfg.databaseUrl != null
|
|
&& lib.strings.hasPrefix "postgres://" cfg.databaseUrl
|
|
) "/run/postgresql"
|
|
++ lib.optional (
|
|
config.services.mysql.enable
|
|
&& cfg.databaseUrl != null
|
|
&& lib.strings.hasPrefix "mysql://" cfg.databaseUrl
|
|
) "/var/run/mysqld";
|
|
|
|
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"
|
|
"AF_UNIX"
|
|
];
|
|
RestrictRealtime = true;
|
|
RestrictSUIDSGID = true;
|
|
|
|
RootDirectory = "/run/shiori";
|
|
|
|
SystemCallArchitectures = "native";
|
|
SystemCallErrorNumber = "EPERM";
|
|
SystemCallFilter = [
|
|
"@system-service"
|
|
"~@cpu-emulation"
|
|
"~@debug"
|
|
"~@keyring"
|
|
"~@memlock"
|
|
"~@obsolete"
|
|
"~@privileged"
|
|
"~@setuid"
|
|
];
|
|
};
|
|
};
|
|
};
|
|
|
|
meta.maintainers = with lib.maintainers; [
|
|
minijackson
|
|
CaptainJawZ
|
|
];
|
|
}
|