2022-09-12 21:48:43 -06:00
|
|
|
{ config, lib, pkgs, prettyJSON, ... }:
|
|
|
|
with pkgs;
|
|
|
|
let
|
|
|
|
cfg = config.services.gotosocial;
|
|
|
|
gotosocial = callPackage ../pkgs/gotosocial.nix { };
|
2022-10-12 20:34:56 -06:00
|
|
|
settingsFormat = pkgs.formats.json { };
|
|
|
|
settingsType = settingsFormat.type;
|
2022-09-12 21:48:43 -06:00
|
|
|
prettyJSON = conf:
|
|
|
|
pkgs.runCommandLocal "gotosocial-config.json" { } ''
|
|
|
|
echo '${
|
|
|
|
builtins.toJSON conf
|
|
|
|
}' | ${pkgs.buildPackages.jq}/bin/jq 'del(._module)' > $out
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
options = with lib; {
|
|
|
|
services.gotosocial = {
|
|
|
|
enable = mkEnableOption "Enable gotosocial";
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = with types; oneOf [ str int ];
|
|
|
|
default = "gotosocial";
|
|
|
|
description = ''
|
|
|
|
The user the service will use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = with types; oneOf [ str int ];
|
|
|
|
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 {
|
|
|
|
users.groups.gotosocial = { };
|
|
|
|
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";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2022-09-12 23:28:56 -06:00
|
|
|
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 ${
|
|
|
|
prettyJSON cfg.configuration
|
|
|
|
} server start";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|