feat: add mastodon module
This commit is contained in:
parent
c0a33e111a
commit
b66ac7683b
5 changed files with 146 additions and 3 deletions
37
modules/mastodon/default.nix
Normal file
37
modules/mastodon/default.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.aether.mastodon;
|
||||
mastodon = config.services.mastodon;
|
||||
|
||||
useSubdomain = !(builtins.isNull cfg.subdomain);
|
||||
domain = lib.optionalString useSubdomain "${cfg.subdomain}."
|
||||
+ config.aether.domain;
|
||||
in {
|
||||
imports = [ ./options.nix ];
|
||||
|
||||
services.mastodon = {
|
||||
enable = true;
|
||||
user = cfg.user;
|
||||
group = mastodon.user;
|
||||
localDomain = domain;
|
||||
configureNginx = true;
|
||||
smtp.fromAddress = cfg.email;
|
||||
};
|
||||
|
||||
security.acme.acceptTerms = true;
|
||||
security.acme.defaults.email = config.aether.acmeEmail;
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
||||
|
||||
users.users = lib.mkIf (cfg.createUser && mastodon.user != "mastodon") {
|
||||
${mastodon.user} = {
|
||||
home = mastodon.package;
|
||||
useDefaultShell = true;
|
||||
group = mastodon.group;
|
||||
isSystemUser = true;
|
||||
};
|
||||
};
|
||||
users.groups = lib.mkIf (cfg.createUser && mastodon.group != "mastodon") {
|
||||
${mastodon.group} = {};
|
||||
};
|
||||
}
|
||||
42
modules/mastodon/options.nix
Normal file
42
modules/mastodon/options.nix
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
{ config, lib, ... }:
|
||||
{
|
||||
imports = [ ../options.nix ];
|
||||
|
||||
options.aether = {
|
||||
mastodon = {
|
||||
subdomain = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = "mastodon";
|
||||
description = ''
|
||||
The subdomain to host Mastodon under.
|
||||
|
||||
If null, then Mastodon is hosted at the domain itself.
|
||||
'';
|
||||
};
|
||||
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "mastodon";
|
||||
description = ''
|
||||
The user to run Mastodon with.
|
||||
'';
|
||||
};
|
||||
|
||||
createUser = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to create the Mastodon user automatically.
|
||||
'';
|
||||
};
|
||||
|
||||
email = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = config.aether.acmeEmail;
|
||||
description = ''
|
||||
The email address used by Mastodon to send emails from.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue