mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/services.postfixadmin: remove with lib;
This commit is contained in:
parent
8491fdcc31
commit
dae6c6c58a
1 changed files with 27 additions and 30 deletions
|
@ -1,7 +1,4 @@
|
|||
{ lib, config, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.postfixadmin;
|
||||
fpm = config.services.phpfpm.pools.postfixadmin;
|
||||
|
@ -10,8 +7,8 @@ let
|
|||
in
|
||||
{
|
||||
options.services.postfixadmin = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to enable postfixadmin.
|
||||
|
@ -22,14 +19,14 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
hostName = mkOption {
|
||||
type = types.str;
|
||||
hostName = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
example = "postfixadmin.example.com";
|
||||
description = "Hostname to use for the nginx vhost";
|
||||
};
|
||||
|
||||
adminEmail = mkOption {
|
||||
type = types.str;
|
||||
adminEmail = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
example = "postmaster@example.com";
|
||||
description = ''
|
||||
Defines the Site Admin's email address.
|
||||
|
@ -38,8 +35,8 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
setupPasswordFile = mkOption {
|
||||
type = types.path;
|
||||
setupPasswordFile = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = ''
|
||||
Password file for the admin.
|
||||
Generate with `php -r "echo password_hash('some password here', PASSWORD_DEFAULT);"`
|
||||
|
@ -47,16 +44,16 @@ in
|
|||
};
|
||||
|
||||
database = {
|
||||
username = mkOption {
|
||||
type = types.str;
|
||||
username = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "postfixadmin";
|
||||
description = ''
|
||||
Username for the postgresql connection.
|
||||
If `database.host` is set to `localhost`, a unix user and group of the same name will be created as well.
|
||||
'';
|
||||
};
|
||||
host = mkOption {
|
||||
type = types.str;
|
||||
host = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "localhost";
|
||||
description = ''
|
||||
Host of the postgresql server. If this is not set to
|
||||
|
@ -65,25 +62,25 @@ in
|
|||
permissions.
|
||||
'';
|
||||
};
|
||||
passwordFile = mkOption {
|
||||
type = types.path;
|
||||
passwordFile = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = "Password file for the postgresql connection. Must be readable by user `nginx`.";
|
||||
};
|
||||
dbname = mkOption {
|
||||
type = types.str;
|
||||
dbname = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "postfixadmin";
|
||||
description = "Name of the postgresql database";
|
||||
};
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
extraConfig = lib.mkOption {
|
||||
type = lib.types.lines;
|
||||
default = "";
|
||||
description = "Extra configuration for the postfixadmin instance, see postfixadmin's config.inc.php for available options.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.etc."postfixadmin/config.local.php".text = ''
|
||||
<?php
|
||||
|
||||
|
@ -91,7 +88,7 @@ in
|
|||
|
||||
$CONF['database_type'] = 'pgsql';
|
||||
$CONF['database_host'] = ${if localDB then "null" else "'${cfg.database.host}'"};
|
||||
${optionalString localDB "$CONF['database_user'] = '${cfg.database.username}';"}
|
||||
${lib.optionalString localDB "$CONF['database_user'] = '${cfg.database.username}';"}
|
||||
$CONF['database_password'] = ${if localDB then "'dummy'" else "file_get_contents('${cfg.database.passwordFile}')"};
|
||||
$CONF['database_name'] = '${cfg.database.dbname}';
|
||||
$CONF['configured'] = true;
|
||||
|
@ -109,8 +106,8 @@ in
|
|||
enable = true;
|
||||
virtualHosts = {
|
||||
${cfg.hostName} = {
|
||||
forceSSL = mkDefault true;
|
||||
enableACME = mkDefault true;
|
||||
forceSSL = lib.mkDefault true;
|
||||
enableACME = lib.mkDefault true;
|
||||
locations."/" = {
|
||||
root = "${pkgs.postfixadmin}/public";
|
||||
index = "index.php";
|
||||
|
@ -127,7 +124,7 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
services.postgresql = mkIf localDB {
|
||||
services.postgresql = lib.mkIf localDB {
|
||||
enable = true;
|
||||
ensureUsers = [ {
|
||||
name = cfg.database.username;
|
||||
|
@ -136,7 +133,7 @@ in
|
|||
# The postgresql module doesn't currently support concepts like
|
||||
# objects owners and extensions; for now we tack on what's needed
|
||||
# here.
|
||||
systemd.services.postfixadmin-postgres = let pgsql = config.services.postgresql; in mkIf localDB {
|
||||
systemd.services.postfixadmin-postgres = let pgsql = config.services.postgresql; in lib.mkIf localDB {
|
||||
after = [ "postgresql.service" ];
|
||||
bindsTo = [ "postgresql.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
@ -172,12 +169,12 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
users.users.${user} = mkIf localDB {
|
||||
users.users.${user} = lib.mkIf localDB {
|
||||
group = user;
|
||||
isSystemUser = true;
|
||||
createHome = false;
|
||||
};
|
||||
users.groups.${user} = mkIf localDB {};
|
||||
users.groups.${user} = lib.mkIf localDB {};
|
||||
|
||||
services.phpfpm.pools.postfixadmin = {
|
||||
user = user;
|
||||
|
@ -186,7 +183,7 @@ in
|
|||
error_log = 'stderr'
|
||||
log_errors = on
|
||||
'';
|
||||
settings = mapAttrs (name: mkDefault) {
|
||||
settings = lib.mapAttrs (name: lib.mkDefault) {
|
||||
"listen.owner" = "nginx";
|
||||
"listen.group" = "nginx";
|
||||
"listen.mode" = "0660";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue