nixos/pleroma: add pleroma NixOS module
This commit is contained in:
parent
5f2966bacb
commit
047a8ddf55
|
@ -0,0 +1,84 @@
|
|||
{ config, lib, pkgs, stdenv }:
|
||||
let
|
||||
cfg = config.services.pleroma;
|
||||
in {
|
||||
options = {
|
||||
services.pleroma = with lib; {
|
||||
enable = mkEnableOption "pleroma";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = import ../default.nix { inherit pkgs stdenv; };
|
||||
description = "Pleroma package to use.";
|
||||
};
|
||||
|
||||
runMigrationOnStartup = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Run the database migrations on the Pleroma service startup.";
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
type = types.str;
|
||||
default = "/var/lib/pleroma";
|
||||
description = "Directory storing Pleroma's data.";
|
||||
};
|
||||
|
||||
confDir = mkOption {
|
||||
type = types.str;
|
||||
default = "/etc/pleroma";
|
||||
description = "Directory storing Pleroma's configuration.";
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
default = "pleroma";
|
||||
description = "User account under which pleroma runs.";
|
||||
};
|
||||
|
||||
group = mkOption {
|
||||
type = types.str;
|
||||
default = "pleroma";
|
||||
description = "Group account under which pleroma runs.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.users.pleroma = {
|
||||
description = "Pleroma user";
|
||||
createHome = true;
|
||||
home = cfg.dataDir;
|
||||
};
|
||||
|
||||
postgresql.enable = true;
|
||||
|
||||
systemd.services.pleroma = {
|
||||
description = "Pleroma social network";
|
||||
after = [ "network-online.target" "postgresql.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
environment = {
|
||||
MIX_ENV = "prod";
|
||||
};
|
||||
serviceConfig = {
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
Type = "forking";
|
||||
WorkingDirectory = cfg.dataDir;
|
||||
ExecStart = "${cfg.package}/bin/pleroma start";
|
||||
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
||||
|
||||
# Systemd sandboxing directives.
|
||||
# Taken from the upstream contrib systemd service at
|
||||
# pleroma/installation/pleroma.service
|
||||
PrivateTmp = true;
|
||||
ProtectHome = true;
|
||||
ProtectSystem = "full";
|
||||
PrivateDevices = false;
|
||||
NoNewPrivileges = true;
|
||||
CapabilityBoundingSet = "~CAP_SYS_ADMIN";
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue