From 263a49d48f9a018c0ae75dbc3f530eec78a3dc1d Mon Sep 17 00:00:00 2001 From: stubbfel Date: Sat, 13 Nov 2021 18:00:10 +0100 Subject: [PATCH] add reurn value section and add server aliases argument --- README.md | 58 ++++++++++++++++++++++++++++++-------- examples/mailcow_nixos.nix | 3 +- mailcow.nix | 2 ++ 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 759e37f..aa882ea 100644 --- a/README.md +++ b/README.md @@ -4,23 +4,55 @@ ```nix { - pkgs ? import {}, - stateDir ? "/opt/mailcow-dockerized", # install target folder - ptr ? "mail.example.org", # PTR Resource Record https://www.cloudns.net/wiki/article/40/ - timeZone ? "Europe/Berlin", # time zone - httpPort ? "80", # http port for mailcow website - httpBind ? "0.0.0.0", # http bind, e.g if you use a reverse proxy then you want that mailcow website us only listen to like 127.0.0.1 - httpsPort ? "443", # https port for mailcow website - httpsBind ? "0.0.0.0", # https bind, e.g if you use a reverse proxy then you want that mailcow website us only listen to like 127.0.0.1 - skipMailCowAcme ? false, # skip the acme container of mailcow e.g. you use a own one - nginxEnableACME ? true, # enable acme for nginx setting - nginxForceSSL ? true, # force ssl usage for nginx setting - nginxIsDefault ? true, # set mailcow virtual host as default host + pkgs, # parameter for nixpkgs set + stateDir, # install target folder + ptr, # PTR Resource Record https://www.cloudns.net/wiki/article/40/, will be also use as server name for the nginx setting + timeZone, # time zone + httpPort, # http port for mailcow website + httpBind, # http bind, e.g if you use a reverse proxy then you want that mailcow website us only listen to like 127.0.0.1 + httpsPort, # https port for mailcow website + httpsBind, # https bind, e.g if you use a reverse proxy then you want that mailcow website us only listen to like 127.0.0.1 + skipMailCowAcme, # skip the acme container of mailcow e.g. you use a own one + nginxEnableACME, # enable acme for nginx setting + nginxForceSSL, # force ssl usage for nginx setting + nginxIsDefault, # set mailcow virtual host as default host + nginxServerAliases, # list of additional domains which would handle by the mail cow virtual host gitUrl ? "https://github.com/mailcow/mailcow-dockerized.git", # mailcow clone url gitRef ? "master" # git ref for init setup } ``` +## Return value + +```nix +{ + runMailCow = { # shell script which run the mail cow + command, # the run script + paths # build path for the run script + }, + configureMailCow = { # shell script which configure the mail cow + command, # the configure script + paths # build path for the configure script + }, + updateMailCow = { # shell script which update the mail cow + command, # the update script + paths # build path for the update script + }, + systemd = { + services = { + mailcow, # systemd mail cow service + mailcow-update # systemd mail cow update service + }, + timers.mailcow-update # systemd timer which invoke the mail cow update service weekly + }, + nginx.virtualHosts.mailCow, # ngnix virtual host setting for the mail cow service + acme = { + certName, # name of the acme cert + postRun # copy the acme script to the mail cow cert path + } +} +``` + ## Example ### shell @@ -30,6 +62,7 @@ nix-shell mailcow_nix-shell.nix --run configureMailCow nix-shell mailcow_nix-shell.nix --run runMailCow nix-shell mailcow_nix-shell.nix --run updateMailCow ``` +for details see `examples/mailcow_nix-build.nix` ### build @@ -39,6 +72,7 @@ result/bin/configureMailCow result/bin/runMailCow result/bin/updateMailCow ``` +for details see `examples/mailcow_nix-build.nix` ### nixos diff --git a/examples/mailcow_nixos.nix b/examples/mailcow_nixos.nix index 207b9bf..dbcf1a0 100644 --- a/examples/mailcow_nixos.nix +++ b/examples/mailcow_nixos.nix @@ -2,12 +2,13 @@ let mc = pkgs.callPackage ../mailcow.nix { - ptr = "mail.devel-nixos.org"; + ptr = "server.of.devel-nixos.org"; httpPort = "7780"; httpBind = "127.0.0.1"; httpsPort = "7443"; httpsBind = "127.0.0.1"; skipMailCowAcme = true; + nginxServerAliases = [ "mail.devel-nixos.org" ]; }; in { diff --git a/mailcow.nix b/mailcow.nix index 3897cfc..20e79ae 100644 --- a/mailcow.nix +++ b/mailcow.nix @@ -12,6 +12,7 @@ nginxEnableACME ? true, nginxForceSSL ? true, nginxIsDefault ? true, + nginxServerAliases ? [] gitUrl ? "https://github.com/mailcow/mailcow-dockerized.git", gitRef ? "master" }: @@ -120,6 +121,7 @@ in default = nginxIsDefault; locations."/".proxyPass = "http://localhost:${httpPort}"; serverName = "${ptr}"; + serverAliases = nginxServerAliases; }; }; };