2023-09-12 08:44:05 -06:00
|
|
|
{ config
|
|
|
|
, lib
|
|
|
|
, pkgs
|
|
|
|
, ...
|
2023-07-11 09:12:50 -06:00
|
|
|
}:
|
|
|
|
with pkgs; let
|
2022-09-12 21:48:43 -06:00
|
|
|
cfg = config.services.gotosocial;
|
2023-09-12 08:44:05 -06:00
|
|
|
gotosocial = callPackage ../pkgs/gotosocial.nix { };
|
|
|
|
settingsFormat = pkgs.formats.json { };
|
2022-10-12 20:34:56 -06:00
|
|
|
settingsType = settingsFormat.type;
|
2022-09-12 21:48:43 -06:00
|
|
|
prettyJSON = conf:
|
2023-09-12 08:44:05 -06:00
|
|
|
pkgs.runCommandLocal "gotosocial-config.json" { } ''
|
2022-09-12 21:48:43 -06:00
|
|
|
echo '${
|
|
|
|
builtins.toJSON conf
|
|
|
|
}' | ${pkgs.buildPackages.jq}/bin/jq 'del(._module)' > $out
|
|
|
|
'';
|
2023-09-12 08:44:05 -06:00
|
|
|
in
|
|
|
|
{
|
2022-09-12 21:48:43 -06:00
|
|
|
options = with lib; {
|
|
|
|
services.gotosocial = {
|
|
|
|
enable = mkEnableOption "Enable gotosocial";
|
|
|
|
|
|
|
|
user = mkOption {
|
2023-09-12 08:44:05 -06:00
|
|
|
type = with types; oneOf [ str int ];
|
2022-09-12 21:48:43 -06:00
|
|
|
default = "gotosocial";
|
|
|
|
description = ''
|
|
|
|
The user the service will use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
2023-09-12 08:44:05 -06:00
|
|
|
type = with types; oneOf [ str int ];
|
2022-09-12 21:48:43 -06:00
|
|
|
default = "gotosocial";
|
|
|
|
description = ''
|
|
|
|
The user the service will use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
configuration = mkOption {
|
2022-10-13 11:45:25 -06:00
|
|
|
type = settingsType;
|
2022-09-12 21:48:43 -06:00
|
|
|
description = ''
|
|
|
|
Specify the configuration for GoToSocial in Nix.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = gotosocial;
|
|
|
|
defaultText = literalExpression "pkgs.gotosocial";
|
|
|
|
description = "The package to use for gotosocial";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
2023-09-12 08:44:05 -06:00
|
|
|
users.groups.gotosocial = { };
|
2022-09-12 21:48:43 -06:00
|
|
|
users.users.gotosocial = {
|
|
|
|
description = "Gotosocial service user";
|
|
|
|
isSystemUser = true;
|
|
|
|
home = "/var/lib/gotosocial";
|
|
|
|
createHome = true;
|
|
|
|
group = "gotosocial";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.gotosocial = {
|
|
|
|
enable = true;
|
|
|
|
description = "GoToSocial server";
|
2023-09-12 08:44:05 -06:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "postgresql.service" ];
|
2022-09-12 21:48:43 -06:00
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
|
|
|
|
RuntimeDirectory = "/var/lib/gotosocial";
|
|
|
|
|
|
|
|
ExecStart = "${cfg.package}/bin/gotosocial --config-path ${
|
2023-07-11 09:12:50 -06:00
|
|
|
prettyJSON cfg.configuration
|
|
|
|
} server start";
|
2022-09-12 21:48:43 -06:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|