From 5e43dafc96acd0041f4bf9fb364a54e2753b0550 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Tue, 10 Mar 2026 04:20:29 +0100 Subject: [PATCH] docs: update Flakes example and add a small example how to deploy with nixos-rebuild. --- docs/flakes.nix | 35 +++++++++++++++++++++++++++++++++++ docs/flakes.rst | 38 +++++++++++++------------------------- 2 files changed, 48 insertions(+), 25 deletions(-) create mode 100644 docs/flakes.nix diff --git a/docs/flakes.nix b/docs/flakes.nix new file mode 100644 index 0000000..a74bdfa --- /dev/null +++ b/docs/flakes.nix @@ -0,0 +1,35 @@ +{ + description = "NixOS configuration"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11-small"; + + simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-25.11"; + simple-nixos-mailserver.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = + { + nixpkgs, + simple-nixos-mailserver, + ... + }: + { + nixosConfigurations = { + hostname = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; # or aarch64-linux + modules = [ + simple-nixos-mailserver.nixosModule + { + mailserver = { + enable = true; + + # Check the setup guide if you have no idea how to continue + # from here! + }; + } + ]; + }; + }; + }; +} diff --git a/docs/flakes.rst b/docs/flakes.rst index f56ec96..8a21bee 100644 --- a/docs/flakes.rst +++ b/docs/flakes.rst @@ -1,30 +1,18 @@ -Nix Flakes -========== +Flakes +====== -If you're using `flakes `__, you can use -the following minimal ``flake.nix`` as an example: +To use NixOS mailserver `Nix flakes`_, the following minimal ``flake.nix`` can +serve as an example to get started: -.. code:: nix +.. _Nix flakes: https://wiki.nixos.org/wiki/Flakes - { - description = "NixOS configuration"; +.. literalinclude:: ./flakes.nix + :language: nix - inputs.simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-20.09"; - outputs = { self, nixpkgs, simple-nixos-mailserver }: { - nixosConfigurations = { - hostname = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - simple-nixos-mailserver.nixosModule - { - mailserver = { - enable = true; - # ... - }; - } - ]; - }; - }; - }; - } +Lock the inputs and deploy the system closure: + +.. code-block:: console + + nix flake lock + nixos-rebuild --target-host root@mail.example.com --flake .#hostname switch