/ flake.nix.example
flake.nix.example
 1  {
 2    description = "Example SMTP & IMAP server using postal";
 3  
 4    inputs = {
 5      nixpkgs.url = "github:NixOS/nixpkgs";
 6      postal.url = "github:koenw/postal";
 7    };
 8  
 9    outputs = { self, nixpkgs, postal }@inputs: {
10      nixosConfigurations."mymailserver" = nixpkgs.lib.nixosSystem {
11        system = "x86_64";
12        modules = [
13          postal.nixosModules.postal
14          ({config, pkgs, lib, ...}:
15          {
16            networking = {
17              hostname = "mymailserver";
18              domain = "example.com";
19              # We're using dhcp so the example "just works" for most. In
20              # production you'd configure a static IP ofc.
21              useDHCP = true;
22            };
23  
24            # Uncomment to use let's encryt to provision SMTP, IMAP and HTTPS
25            # certificates.
26            # security.acme.acceptTerms = true;
27            # security.acme.defaults.email = <your email address>;
28  
29            users.groups.bla = {};
30            users.users.bla = {
31              isNormalUser = true;
32              extraGroups = [ "wheel" ];
33              group = "bla";
34            #   openssh.authorizedKeys.keys = [
35            #     "ssh-ed25519 AAAAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX bla@purple"
36            #   ];
37                initialHashedPassword = "blablabla";
38            # };
39  
40  
41            # Now the fun stuff :)
42            postal = {
43              enable = true;
44              # Domains you want to receive mail for, or send as
45              domains = [ "example.net" "example.org" ];
46              mailboxes = [
47                {
48                  user = "alice", addresses = [
49                    "alice@example.org"
50                    "alice88@example.net"
51                  ];
52                  user = "bob", addresses = [ "bob@example.org" ];
53                }
54              ];
55            };
56          })
57        ];
58      };
59    };
60  }