shiori upgrade to 1.7.0

This commit is contained in:
2024-06-29 15:40:27 -06:00
parent 520646bdd4
commit b88a195eda
5 changed files with 57 additions and 45 deletions

View File

@@ -1,16 +1,15 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.services.shiori;
in {
options = {
services.shiori = {
enable = mkEnableOption "Shiori simple bookmarks manager";
enable = lib.mkEnableOption "Shiori simple bookmarks manager";
package = mkPackageOption pkgs "shiori" { };
package = lib.mkPackageOption pkgs "shiori" { };
address = mkOption {
type = types.str;
address = lib.mkOption {
type = lib.types.str;
default = "";
description = ''
The IP address on which Shiori will listen.
@@ -18,53 +17,55 @@ in {
'';
};
port = mkOption {
type = types.port;
port = lib.mkOption {
type = lib.types.port;
default = 8080;
description = "The port of the Shiori web application";
};
webRoot = mkOption {
type = types.str;
webRoot = lib.mkOption {
type = lib.types.str;
default = "/";
example = "/shiori";
description = "The root of the Shiori web application";
};
httpSecretKey = mkOption {
type = types.str;
example = "SuperSecretPassword";
description =
"When empty all sessions will be invalidated on server restart";
environmentFile = lib.mkOption {
type = lib.types.null or 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 = mkOption {
type = types.str;
default = "";
databaseUrl = lib.mkOption {
type = lib.types.null or lib.types.str;
default = null;
example = "postgresql:///shiori?host=/run/postgresql";
description = "The connection URL to connect to MySQL or PostgreSQL";
};
};
};
config = mkIf cfg.enable {
systemd.services.shiori = with cfg; {
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 != "") {
} // lib.optionalAttrs (cfg.databaseUrl != null) {
SHIORI_DATABASE_URL = cfg.databaseUrl;
} // lib.optionalAttrs (cfg.httpSecretKey != "") {
SHIORI_HTTP_SECRET_KEY = cfg.httpSecretKey;
};
serviceConfig = {
ExecStart =
"${package}/bin/shiori server --address '${address}' --port '${
toString port
}' --webroot '${webRoot}'";
"${cfg.package}/bin/shiori server --address '${cfg.address}' --port '${
toString cfg.port
}' --webroot '${cfg.webRoot}'";
DynamicUser = true;
StateDirectory = "shiori";
@@ -72,16 +73,17 @@ in {
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 (lib.strings.hasInfix "postgres" cfg.databaseUrl)
"/run/postgresql"
++ lib.optional (lib.strings.hasInfix "mysql" cfg.databaseUrl)
"/var/run/mysqld";
] ++ lib.optional (lib.strings.hasInfix "postgres" cfg.databaseUrl
&& config.services.postgresql.enable) "/run/postgresql"
++ lib.optional (lib.strings.hasInfix "mysql" cfg.databaseUrl
&& config.services.mysql.enable) "/var/run/mysqld";
CapabilityBoundingSet = "";
AmbientCapabilities = "CAP_NET_BIND_SERVICE";
@@ -126,5 +128,5 @@ in {
};
};
meta.maintainers = with maintainers; [ minijackson CaptainJawZ ];
meta.maintainers = with lib.maintainers; [ minijackson CaptainJawZ ];
}