nixos/hatsu: init module

This commit is contained in:
藍+85CD 2024-10-01 00:33:38 +08:00
parent ef1ecffdbe
commit 2f15b523d9
No known key found for this signature in database
GPG Key ID: BCB0111111111111
4 changed files with 123 additions and 0 deletions

View File

@ -84,6 +84,8 @@
alos create normal users and change passwords. Available as
[services.userborn](#opt-services.userborn.enable)
- [Hatsu](https://github.com/importantimport/hatsu), a self-hosted bridge that interacts with Fediverse on behalf of your static site. Available as [services.hatsu](options.html#opt-services.hatsu).
- [Flood](https://flood.js.org/), a beautiful WebUI for various torrent clients. Available as [services.flood](options.html#opt-services.flood).
- [Firefly-iii Data Importer](https://github.com/firefly-iii/data-importer), a data importer for Firefly-III. Available as [services.firefly-iii-data-importer](options.html#opt-services.firefly-iii-data-importer)

View File

@ -1424,6 +1424,7 @@
./services/web-apps/goatcounter.nix
./services/web-apps/guacamole-client.nix
./services/web-apps/guacamole-server.nix
./services/web-apps/hatsu.nix
./services/web-apps/healthchecks.nix
./services/web-apps/hedgedoc.nix
./services/web-apps/hledger-web.nix

View File

@ -0,0 +1,23 @@
# Hatsu {#module-services-hatsu}
[Hatsu](https://github.com/importantimport/hatsu) is an fully-automated ActivityPub bridge for static sites.
## Quickstart {#module-services-hatsu-quickstart}
the minimum configuration to start hatsu server would look like this:
```nix
{
services.hatsu = {
enable = true;
settings = {
HATSU_DOMAIN = "hatsu.local";
HATSU_PRIMARY_ACCOUNT = "example.com";
};
};
}
```
this will start the hatsu server on port 3939 and save the database in `/var/lib/hatsu/hatsu.sqlite3`.
Please refer to the [Hatsu Documentation](https://hatsu.cli.rs) for additional configuration options.

View File

@ -0,0 +1,97 @@
{
lib,
pkgs,
config,
...
}:
let
cfg = config.services.hatsu;
in
{
meta.doc = ./hatsu.md;
meta.maintainers = with lib.maintainers; [ kwaa ];
options.services.hatsu = {
enable = lib.mkEnableOption "Self-hosted and fully-automated ActivityPub bridge for static sites";
package = lib.mkPackageOption pkgs "hatsu" { };
settings = lib.mkOption {
type = lib.types.submodule {
freeformType =
with lib.types;
attrsOf (
nullOr (oneOf [
bool
int
port
str
])
);
options = {
HATSU_DATABASE_URL = lib.mkOption {
type = lib.types.str;
default = "sqlite:///var/lib/hatsu/hatsu.sqlite?mode=rwc";
example = "postgres://username:password@host/database";
description = "Database URL.";
};
HATSU_DOMAIN = lib.mkOption {
type = lib.types.str;
description = "The domain name of your instance (eg 'hatsu.local').";
};
HATSU_LISTEN_HOST = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = "Host where hatsu should listen for incoming requests.";
};
HATSU_LISTEN_PORT = lib.mkOption {
type = lib.types.port;
apply = toString;
default = 3939;
description = "Port where hatsu should listen for incoming requests.";
};
HATSU_PRIMARY_ACCOUNT = lib.mkOption {
type = lib.types.str;
description = "The primary account of your instance (eg 'example.com').";
};
};
};
default = { };
description = ''
Configuration for Hatsu, see
<link xlink:href="https://hatsu.cli.rs/admins/environments.html"/>
for supported values.
'';
};
};
config = lib.mkIf cfg.enable {
systemd.services.hatsu = {
environment = cfg.settings;
description = "Hatsu server";
documentation = [ "https://hatsu.cli.rs/" ];
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
DynamicUser = true;
ExecStart = "${lib.getExe cfg.package}";
Restart = "on-failure";
StateDirectory = "hatsu";
Type = "simple";
WorkingDirectory = "%S/hatsu";
};
};
};
}