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 ];
}

View File

@@ -1,10 +1,10 @@
{ lib, buildGoModule, fetchFromGitHub, nixosTests }:
{ lib, buildGoModule, fetchFromGitHub, nixosTests, installShellFiles }:
buildGoModule rec {
pname = "shiori";
version = "1.6.2";
version = "1.7.0";
vendorHash = "sha256-LLiBRsh9HsadeHQh4Yvops1r2GfjtvQKt5ZelQnPGdI=";
vendorHash = "sha256-fakRqgoEcdzw9WZuubaxfGfvVrMvb8gV/IwPikMnfRQ=";
doCheck = false;
@@ -12,17 +12,24 @@ buildGoModule rec {
owner = "go-shiori";
repo = pname;
rev = "v${version}";
sha256 = "sha256-1ZZpQXlAHs5MTowCv3sWS3L7X5FTnU/b4trvHPiz+uE=";
sha256 = "sha256-5+hTtvBnj3Nh5HitReVkLift9LTiMYVuuYx5EirN0SA=";
};
passthru.tests = {
smoke-test = nixosTests.shiori;
};
nativeBuildInputs = [ installShellFiles ];
postInstall = ''
installShellCompletion --cmd shiori \
--bash <($out/bin/shiori completion bash) \
--fish <($out/bin/shiori completion fish) \
--zsh <($out/bin/shiori completion zsh)
'';
# passthru.tests.smoke-test = nixosTests.shiori; # test broken
meta = with lib; {
description = "Simple bookmark manager built with Go";
mainProgram = "shiori";
homepage = "https://github.com/go-shiori/shiori";
license = licenses.mit;
maintainers = with maintainers; [ minijackson ];
maintainers = with maintainers; [ minijackson CaptainJawZ ];
};
}