diff --git a/docs/setup-example.nix b/docs/setup-example.nix new file mode 100644 index 0000000..d73d49f --- /dev/null +++ b/docs/setup-example.nix @@ -0,0 +1,36 @@ +{ + imports = [ + (builtins.fetchTarball { + # Pick a release version you are interested in and set its hash, e.g. + url = "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/nixos-25.11/nixos-mailserver-nixos-25.11.tar.gz"; + # To get the sha256 of the nixos-mailserver tarball, we can use the nix-prefetch-url command: + # release="nixos-25.11"; nix-prefetch-url "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/${release}/nixos-mailserver-${release}.tar.gz" --unpack + sha256 = "0000000000000000000000000000000000000000000000000000"; + }) + ]; + + mailserver = { + enable = true; + stateVersion = 3; + fqdn = "mail.example.com"; + domains = [ "example.com" ]; + + # A list of all login accounts. To create the password hashes, use + # nix-shell -p mkpasswd --run 'mkpasswd -sm bcrypt' + loginAccounts = { + "user1@example.com" = { + hashedPasswordFile = "/a/file/containing/a/hashed/password"; + aliases = [ "postmaster@example.com" ]; + }; + "user2@example.com" = { + # ... + }; + }; + + # Use Let's Encrypt certificates. Note that this needs to set up a stripped + # down nginx and opens port 80. + certificateScheme = "acme-nginx"; + }; + security.acme.acceptTerms = true; + security.acme.defaults.email = "security@example.com"; +} diff --git a/docs/setup-guide.rst b/docs/setup-guide.rst index 70ff349..e6ef029 100644 --- a/docs/setup-guide.rst +++ b/docs/setup-guide.rst @@ -57,42 +57,8 @@ though there are more possible options (see the `NixOS Mailserver options documentation `_), these should be the most common ones. -.. code:: nix - - { config, pkgs, ... }: { - imports = [ - (builtins.fetchTarball { - # Pick a release version you are interested in and set its hash, e.g. - url = "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/nixos-25.11/nixos-mailserver-nixos-25.11.tar.gz"; - # To get the sha256 of the nixos-mailserver tarball, we can use the nix-prefetch-url command: - # release="nixos-25.11"; nix-prefetch-url "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/${release}/nixos-mailserver-${release}.tar.gz" --unpack - sha256 = "0000000000000000000000000000000000000000000000000000"; - }) - ]; - - mailserver = { - enable = true; - stateVersion = 3; - fqdn = "mail.example.com"; - domains = [ "example.com" ]; - - # A list of all login accounts. To create the password hashes, use - # nix-shell -p mkpasswd --run 'mkpasswd -sm bcrypt' - loginAccounts = { - "user1@example.com" = { - hashedPasswordFile = "/a/file/containing/a/hashed/password"; - aliases = ["postmaster@example.com"]; - }; - "user2@example.com" = { ... }; - }; - - # Use Let's Encrypt certificates. Note that this needs to set up a stripped - # down nginx and opens port 80. - certificateScheme = "acme-nginx"; - }; - security.acme.acceptTerms = true; - security.acme.defaults.email = "security@example.com"; - } +.. literalinclude:: ./setup-example.nix + :language: nix After a ``nixos-rebuild switch`` your server should be running all mail components. diff --git a/flake.nix b/flake.nix index 26e1670..2ed9577 100644 --- a/flake.nix +++ b/flake.nix @@ -112,6 +112,7 @@ "logo\\.png" "conf\\.py" "Makefile" + ".*\\.nix" ".*\\.rst" ]; buildInputs = [