File tree 2 files changed +16
-12
lines changed
2 files changed +16
-12
lines changed Original file line number Diff line number Diff line change 46
46
} ;
47
47
48
48
systemd . services . mox-setup = {
49
- description = "Setup Mox Mail Server" ;
49
+ description = "Setup Mox Mail Server Configuration Files " ;
50
50
wantedBy = [ "multi-user.target" ] ;
51
+ requires = [ "network-online.target" ] ;
52
+ after = [ "network-online.target" ] ;
51
53
before = [ "mox.service" ] ;
52
54
serviceConfig = {
53
55
Type = "oneshot" ;
54
56
RemainAfterExit = true ;
57
+ User = "mox" ;
58
+ Group = "mox" ;
55
59
} ;
56
60
script = ''
57
- mkdir -p /var/lib/mox
58
- cd /var/lib/mox
59
- ${ pkgs . mox } /bin/mox quickstart -hostname ${ config . services . mox . hostname } ${ config . services . mox . user }
60
- chown -R mox:mox /var/lib/mox
61
+ mkdir -p /var/lib/mox
62
+ cd /var/lib/mox
63
+ ${ pkgs . mox } /bin/mox quickstart -hostname ${ config . services . mox . hostname } ${ config . services . mox . user }
61
64
'' ;
62
65
} ;
63
66
64
67
systemd . services . mox = {
65
68
wantedBy = [ "multi-user.target" ] ;
66
- after = [ "network.target" " mox-setup.service" ] ;
67
- requires = [ "mox-setup.service" ] ; # This ensures mox-setup must succeed
69
+ after = [ "mox-setup.service" ] ;
70
+ requires = [ "mox-setup.service" ] ;
68
71
serviceConfig = {
69
72
WorkingDirectory = "/var/lib/mox" ;
70
73
ExecStart = "${ pkgs . mox } /bin/mox -config /var/lib/mox/config/mox.conf serve" ;
Original file line number Diff line number Diff line change 9
9
nodes = {
10
10
machine =
11
11
{ ... } :
12
- {
12
+ rec {
13
13
imports = [
14
14
sources . modules . ngipkgs
15
15
# Sources module path depends on your folder structure
16
16
./module.nix
17
17
] ;
18
18
19
+ # Allow necessary ports through the firewall
20
+ networking . firewall . allowedTCPPorts = [ 25 80 143 443 587 993 ] ;
21
+ networking . firewall . allowedUDPPorts = [ 53 ] ;
22
+
19
23
# Configure the mox service
20
24
services . mox = {
21
25
enable = true ;
22
26
hostname = "mail.example.com" ;
23
27
24
28
} ;
25
-
26
- # Allow necessary ports through the firewall
27
- networking . firewall . allowedTCPPorts = [ 25 143 587 993 ] ;
28
29
} ;
29
30
} ;
30
31
37
38
machine.wait_for_unit("multi-user.target")
38
39
39
40
# Verify the mox-setup service has run successfully
40
- # machine.wait_for_unit("mox-setup.service")
41
+ machine.wait_for_unit("mox-setup.service")
41
42
42
43
# Verify the mox service is running
43
44
machine.wait_for_unit("mox.service")
You can’t perform that action at this time.
0 commit comments