diff --git a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
index f6cf4b50c3be..4a5480c6ecce 100644
--- a/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
+++ b/nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
@@ -365,6 +365,13 @@
services.expressvpn.
+
+
+ merecat,
+ a small and easy HTTP server based on thttpd. Available as
+ services.merecat
+
+
go-autoconfig,
diff --git a/nixos/doc/manual/release-notes/rl-2211.section.md b/nixos/doc/manual/release-notes/rl-2211.section.md
index 8f2430fb34b4..dac9f6b9424e 100644
--- a/nixos/doc/manual/release-notes/rl-2211.section.md
+++ b/nixos/doc/manual/release-notes/rl-2211.section.md
@@ -123,6 +123,8 @@ In addition to numerous new and upgraded packages, this release has the followin
- [expressvpn](https://www.expressvpn.com), the CLI client for ExpressVPN. Available as [services.expressvpn](#opt-services.expressvpn.enable).
+- [merecat](https://troglobit.com/projects/merecat/), a small and easy HTTP server based on thttpd. Available as [services.merecat](#opt-services.merecat.enable)
+
- [go-autoconfig](https://github.com/L11R/go-autoconfig), IMAP/SMTP autodiscover server. Available as [services.go-autoconfig](#opt-services.go-autoconfig.enable).
- [tmate-ssh-server](https://github.com/tmate-io/tmate-ssh-server), server side part of [tmate](https://tmate.io/). Available as [services.tmate-ssh-server](#opt-services.tmate-ssh-server.enable).
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index ad0679d6165e..19b57c56ab22 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -1155,6 +1155,7 @@
./services/web-servers/lighttpd/collectd.nix
./services/web-servers/lighttpd/default.nix
./services/web-servers/lighttpd/gitweb.nix
+ ./services/web-servers/merecat.nix
./services/web-servers/mighttpd2.nix
./services/web-servers/minio.nix
./services/web-servers/molly-brown.nix
diff --git a/nixos/modules/services/web-servers/merecat.nix b/nixos/modules/services/web-servers/merecat.nix
new file mode 100644
index 000000000000..aad93605b717
--- /dev/null
+++ b/nixos/modules/services/web-servers/merecat.nix
@@ -0,0 +1,55 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ cfg = config.services.merecat;
+ format = pkgs.formats.keyValue {
+ mkKeyValue = generators.mkKeyValueDefault {
+ mkValueString = v:
+ # In merecat.conf, booleans are "true" and "false"
+ if builtins.isBool v
+ then if v then "true" else "false"
+ else generators.mkValueStringDefault {} v;
+ } "=";
+ };
+ configFile = format.generate "merecat.conf" cfg.settings;
+
+in {
+
+ options.services.merecat = {
+
+ enable = mkEnableOption (lib.mdDoc "Merecat HTTP server");
+
+ settings = mkOption {
+ inherit (format) type;
+ default = { };
+ description = lib.mdDoc ''
+ Merecat configuration. Refer to merecat(8) for details on supported values.
+ '';
+ example = {
+ hostname = "localhost";
+ port = 8080;
+ virtual-host = true;
+ directory = "/srv/www";
+ };
+ };
+
+ };
+
+ config = mkIf cfg.enable {
+
+ systemd.services.merecat = {
+ description = "Merecat HTTP server";
+ after = [ "network.target" ];
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ DynamicUser = true;
+ ExecStart = "${pkgs.merecat}/bin/merecat -n -f ${configFile}";
+ AmbientCapabilities = lib.mkIf ((cfg.settings.port or 80) < 1024) [ "CAP_NET_BIND_SERVICE" ];
+ };
+ };
+
+ };
+
+}
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index b1694768104f..59b8c81fb0b5 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -368,6 +368,7 @@ in {
mediawiki = handleTest ./mediawiki.nix {};
meilisearch = handleTest ./meilisearch.nix {};
memcached = handleTest ./memcached.nix {};
+ merecat = handleTest ./merecat.nix {};
metabase = handleTest ./metabase.nix {};
minecraft = handleTest ./minecraft.nix {};
minecraft-server = handleTest ./minecraft-server.nix {};
diff --git a/nixos/tests/merecat.nix b/nixos/tests/merecat.nix
new file mode 100644
index 000000000000..9d8f66165ee9
--- /dev/null
+++ b/nixos/tests/merecat.nix
@@ -0,0 +1,28 @@
+import ./make-test-python.nix ({ pkgs, ... }: {
+ name = "merecat";
+ meta = with pkgs.lib.maintainers; {
+ maintainers = [ fgaz ];
+ };
+
+ nodes.machine = { config, pkgs, ... }: {
+ services.merecat = {
+ enable = true;
+ settings = {
+ hostname = "localhost";
+ virtual-host = true;
+ directory = toString (pkgs.runCommand "merecat-webdir" {} ''
+ mkdir -p $out/foo.localhost $out/bar.localhost
+ echo 'Hello foo
' > $out/foo.localhost/index.html
+ echo 'Hello bar
' > $out/bar.localhost/index.html
+ '');
+ };
+ };
+ };
+
+ testScript = ''
+ machine.wait_for_unit("merecat")
+ machine.wait_for_open_port(80)
+ machine.succeed("curl --fail foo.localhost | grep 'Hello foo'")
+ machine.succeed("curl --fail bar.localhost | grep 'Hello bar'")
+ '';
+})
diff --git a/pkgs/servers/http/merecat/default.nix b/pkgs/servers/http/merecat/default.nix
index a71df96f6de2..b655381a0819 100644
--- a/pkgs/servers/http/merecat/default.nix
+++ b/pkgs/servers/http/merecat/default.nix
@@ -7,6 +7,7 @@
, libxcrypt
, testers
, merecat
+, nixosTests
}:
stdenv.mkDerivation rec {
@@ -36,6 +37,7 @@ stdenv.mkDerivation rec {
package = merecat;
command = "merecat -V";
};
+ inherit (nixosTests) merecat;
};
meta = with lib; {