-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Package Mox as a service #677
base: main
Are you sure you want to change the base?
Conversation
Update: I've run the test interactively for debugging and got access to the VM. The VM might not have a running nameserver, and I'd like to know if there's a way I can get one running as part of the machine configs before running the test(s). @eljamm, any pointers for further debugging? |
Turns out that it was just a matter of modifying the service order since the dns configuration is not over by the time the fix-mox-service-order.patch
---
projects/Mox/module.nix | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/projects/Mox/module.nix b/projects/Mox/module.nix
index 43bb8d7..91d38d7 100644
--- a/projects/Mox/module.nix
+++ b/projects/Mox/module.nix
@@ -48,23 +48,26 @@
systemd.services.mox-setup = {
description = "Setup Mox Mail Server";
wantedBy = [ "multi-user.target" ];
+ requires = [ "network-online.target" ];
+ after = [ "network-online.target" ];
before = [ "mox.service" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
+ User = "mox";
+ Group = "mox";
};
script = ''
mkdir -p /var/lib/mox
cd /var/lib/mox
${pkgs.mox}/bin/mox quickstart -hostname ${config.services.mox.hostname} ${config.services.mox.user}
- chown -R mox:mox /var/lib/mox
'';
};
systemd.services.mox = {
wantedBy = [ "multi-user.target" ];
- after = [ "network.target" "mox-setup.service" ];
- requires = [ "mox-setup.service" ]; # This ensures mox-setup must succeed
+ after = [ "mox-setup.service" ];
+ requires = [ "mox-setup.service" ];
serviceConfig = {
WorkingDirectory = "/var/lib/mox";
ExecStart = "${pkgs.mox}/bin/mox -config /var/lib/mox/config/mox.conf serve";
--
2.47.2 |
lol. Been on it since I left the office hour I added |
That sounds like it could be useful for a separate example config that uses DNSSEC, for those interested in that |
530c09e
to
077a483
Compare
Yess. I've stashed changes using |
- Expose Mox as a service
I think the test fails in CI because it's not running with
which will fail. |
After many days of debugging, I got it working @eljamm I've refreshed my knowledge on DNSs quite much in this process. It was as good as it was heartbreaking 😅 Kindly give it a review. Thanks for the time you've dedicated to my issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done @themadbit! This is shaping up really nicely.
{ | ||
options = { | ||
services.mox = { | ||
enable = lib.mkEnableOption "Enable Mox Mail Server"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes it easier for users to change/override the mox package if they need to
enable = lib.mkEnableOption "Enable Mox Mail Server"; | |
enable = lib.mkEnableOption "Enable Mox Mail Server"; | |
package = lib.mkPackageOption pkgs "mox" { }; |
pkgs, | ||
... | ||
}: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let | |
cfg = config.services.mox; | |
in |
environment.systemPackages = with pkgs; [ | ||
mox | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
environment.systemPackages = with pkgs; [ | |
mox | |
]; | |
environment.systemPackages = [ | |
cfg.package | |
]; |
}; | ||
}; | ||
|
||
config = lib.mkIf config.services.mox.enable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config = lib.mkIf config.services.mox.enable { | |
config = lib.mkIf cfg.enable { |
mkdir -p /var/lib/mox | ||
cd /var/lib/mox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just use serviceConfig.stateDirectory which is relative to /var/lib
mkdir -p /var/lib/mox | |
cd /var/lib/mox |
users.groups.mox = { | ||
name = "mox"; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
users.groups.mox = { | |
name = "mox"; | |
}; | |
users.groups.mox = { }; |
nodes = { | ||
machine = | ||
{ ... }: | ||
rec { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rec
is not necessary, here
rec { | |
{ |
Mox is a modern, secure, and open-source email server that implements all modern email protocols. | ||
It makes it easy for people and organizations to run their own email server in minutes using mox quickstart. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say this is short and descriptive enough
Mox is a modern, secure, and open-source email server that implements all modern email protocols. | |
It makes it easy for people and organizations to run their own email server in minutes using mox quickstart. | |
Modern, secure, and open-source email server that implements all modern email protocols. |
It makes it easy for people and organizations to run their own email server in minutes using mox quickstart. | ||
''; | ||
subgrants = [ | ||
"Mox" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Mox" | |
"Mox" | |
"Mox-API" | |
"Mox-Automation" |
25 | ||
80 | ||
143 | ||
443 | ||
587 | ||
993 | ||
5335 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all of these necessary? Can we add comments on why they're needed?
i.e:
However, it fails to start/survive reboot with:
So, I'll leave this as a draft PR as I investigate further. Putting it out here in case you've had a similar headache and know the painkiller 😅