2020-12-15 16:01:40 +01:00
|
|
|
{
|
|
|
|
description = "A complete and Simple Nixos Mailserver";
|
|
|
|
|
|
|
|
inputs = {
|
2022-11-30 22:30:45 +01:00
|
|
|
flake-compat = {
|
|
|
|
url = "github:edolstra/flake-compat";
|
|
|
|
flake = false;
|
|
|
|
};
|
2020-12-15 16:01:40 +01:00
|
|
|
utils.url = "github:numtide/flake-utils";
|
|
|
|
nixpkgs.url = "flake:nixpkgs/nixos-unstable";
|
2021-07-10 16:05:25 +02:00
|
|
|
blobs = {
|
|
|
|
url = "gitlab:simple-nixos-mailserver/blobs";
|
|
|
|
flake = false;
|
|
|
|
};
|
2020-12-15 16:01:40 +01:00
|
|
|
};
|
|
|
|
|
2024-03-14 21:14:35 +01:00
|
|
|
outputs = { self, utils, blobs, nixpkgs, ... }: let
|
2022-11-30 22:30:45 +01:00
|
|
|
lib = nixpkgs.lib;
|
2021-07-10 16:05:25 +02:00
|
|
|
system = "x86_64-linux";
|
2020-12-15 16:01:40 +01:00
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
2021-07-10 16:05:25 +02:00
|
|
|
releases = [
|
|
|
|
{
|
|
|
|
name = "unstable";
|
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
testNames = [
|
|
|
|
"internal"
|
|
|
|
"external"
|
|
|
|
"clamav"
|
|
|
|
"multiple"
|
2022-08-12 18:54:49 +02:00
|
|
|
"ldap"
|
2021-07-10 16:05:25 +02:00
|
|
|
];
|
|
|
|
genTest = testName: release: {
|
2023-05-24 22:02:55 +02:00
|
|
|
"name"= "${testName}-${builtins.replaceStrings ["."] ["_"] release.name}";
|
2021-07-10 16:05:25 +02:00
|
|
|
"value"= import (./tests/. + "/${testName}.nix") {
|
|
|
|
pkgs = release.pkgs;
|
|
|
|
inherit blobs;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
# Generate an attribute set such as
|
|
|
|
# {
|
|
|
|
# external-unstable = <derivation>;
|
|
|
|
# external-21_05 = <derivation>;
|
|
|
|
# ...
|
|
|
|
# }
|
2022-11-30 22:30:45 +01:00
|
|
|
allTests = lib.listToAttrs (
|
|
|
|
lib.flatten (map (t: map (r: genTest t r) releases) testNames));
|
2021-07-10 16:05:25 +02:00
|
|
|
|
2021-07-14 10:06:58 +02:00
|
|
|
mailserverModule = import ./.;
|
|
|
|
|
2022-11-30 22:30:45 +01:00
|
|
|
# Generate a MarkDown file describing the options of the NixOS mailserver module
|
|
|
|
optionsDoc = let
|
|
|
|
eval = lib.evalModules {
|
2021-07-14 10:06:58 +02:00
|
|
|
modules = [
|
|
|
|
mailserverModule
|
|
|
|
{
|
2022-11-30 22:30:45 +01:00
|
|
|
_module.check = false;
|
2021-10-03 14:31:43 +02:00
|
|
|
mailserver = {
|
|
|
|
fqdn = "mx.example.com";
|
|
|
|
domains = [
|
|
|
|
"example.com"
|
|
|
|
];
|
|
|
|
dmarcReporting = {
|
|
|
|
organizationName = "Example Corp";
|
|
|
|
domain = "example.com";
|
|
|
|
};
|
|
|
|
};
|
2021-07-14 10:06:58 +02:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2022-11-30 22:30:45 +01:00
|
|
|
options = builtins.toFile "options.json" (builtins.toJSON
|
|
|
|
(lib.filter (opt: opt.visible && !opt.internal && lib.head opt.loc == "mailserver")
|
|
|
|
(lib.optionAttrSetToDocList eval.options)));
|
|
|
|
in pkgs.runCommand "options.md" { buildInputs = [pkgs.python3Minimal]; } ''
|
|
|
|
echo "Generating options.md from ${options}"
|
|
|
|
python ${./scripts/generate-options.py} ${options} > $out
|
2021-07-14 10:06:58 +02:00
|
|
|
'';
|
|
|
|
|
2021-07-23 21:25:14 +02:00
|
|
|
documentation = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "documentation";
|
2022-11-30 22:30:45 +01:00
|
|
|
src = lib.sourceByRegex ./docs ["logo\\.png" "conf\\.py" "Makefile" ".*\\.rst"];
|
2021-07-23 21:25:14 +02:00
|
|
|
buildInputs = [(
|
2022-11-30 22:30:45 +01:00
|
|
|
pkgs.python3.withPackages (p: with p; [
|
|
|
|
sphinx
|
|
|
|
sphinx_rtd_theme
|
|
|
|
myst-parser
|
2023-12-19 23:07:52 +01:00
|
|
|
linkify-it-py
|
2021-07-23 21:25:14 +02:00
|
|
|
])
|
|
|
|
)];
|
|
|
|
buildPhase = ''
|
2022-11-30 22:30:45 +01:00
|
|
|
cp ${optionsDoc} options.md
|
2021-07-23 21:25:14 +02:00
|
|
|
# Workaround for https://github.com/sphinx-doc/sphinx/issues/3451
|
2022-11-30 22:30:45 +01:00
|
|
|
unset SOURCE_DATE_EPOCH
|
2021-07-23 21:25:14 +02:00
|
|
|
make html
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
2022-11-30 22:30:45 +01:00
|
|
|
cp -Tr _build/html $out
|
2021-07-23 21:25:14 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-11-30 22:30:45 +01:00
|
|
|
in {
|
|
|
|
nixosModules = rec {
|
|
|
|
mailserver = mailserverModule;
|
|
|
|
default = mailserver;
|
|
|
|
};
|
|
|
|
nixosModule = self.nixosModules.default; # compatibility
|
2021-07-14 10:06:58 +02:00
|
|
|
hydraJobs.${system} = allTests // {
|
2021-07-23 21:25:14 +02:00
|
|
|
inherit documentation;
|
2021-07-14 10:06:58 +02:00
|
|
|
};
|
2021-07-10 16:05:25 +02:00
|
|
|
checks.${system} = allTests;
|
2022-12-01 14:22:27 +01:00
|
|
|
packages.${system} = {
|
|
|
|
inherit optionsDoc documentation;
|
|
|
|
};
|
2022-11-30 22:30:45 +01:00
|
|
|
devShells.${system}.default = pkgs.mkShell {
|
|
|
|
inputsFrom = [ documentation ];
|
|
|
|
packages = with pkgs; [
|
2020-12-15 16:01:40 +01:00
|
|
|
clamav
|
|
|
|
];
|
|
|
|
};
|
2022-11-30 22:30:45 +01:00
|
|
|
devShell.${system} = self.devShells.${system}.default; # compatibility
|
2021-07-10 16:05:25 +02:00
|
|
|
};
|
2020-12-15 16:01:40 +01:00
|
|
|
}
|