Merge pull request #190325 from fgaz/merecat/init

merecat: init at 2.31
This commit is contained in:
Stanisław Pitucha 2022-10-31 21:23:03 +11:00 committed by GitHub
commit 08fbb5de2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 148 additions and 0 deletions

View file

@ -374,6 +374,13 @@
<link linkend="opt-services.expressvpn.enable">services.expressvpn</link>.
</para>
</listitem>
<listitem>
<para>
<link xlink:href="https://troglobit.com/projects/merecat/">merecat</link>,
a small and easy HTTP server based on thttpd. Available as
<link linkend="opt-services.merecat.enable">services.merecat</link>
</para>
</listitem>
<listitem>
<para>
<link xlink:href="https://github.com/L11R/go-autoconfig">go-autoconfig</link>,

View file

@ -126,6 +126,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).

View file

@ -1156,6 +1156,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

View file

@ -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" ];
};
};
};
}

View file

@ -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 {};

28
nixos/tests/merecat.nix Normal file
View file

@ -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 '<h1>Hello foo</h1>' > $out/foo.localhost/index.html
echo '<h1>Hello bar</h1>' > $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'")
'';
})

View file

@ -0,0 +1,52 @@
{ lib
, stdenv
, fetchFromGitHub
, autoreconfHook
, pkg-config
, libconfuse
, libxcrypt
, testers
, merecat
, nixosTests
}:
stdenv.mkDerivation rec {
pname = "merecat";
version = "2.31";
# Or, already reconf'd: ftp://ftp.troglobit.com/merecat/merecat-${version}.tar.xz
src = fetchFromGitHub {
owner = "troglobit";
repo = "merecat";
rev = "v${version}";
hash = "sha256-oIzOXUnCFqd3HPyKp58r+enRRpaE7f9hqNITtxCCB7I=";
};
nativeBuildInputs = [
autoreconfHook
pkg-config
];
buildInputs = [
libconfuse
libxcrypt
];
passthru.tests = {
testVersion = testers.testVersion {
package = merecat;
command = "merecat -V";
};
inherit (nixosTests) merecat;
};
meta = with lib; {
description = "Small and made-easy HTTP/HTTPS server based on Jef Poskanzer's thttpd";
homepage = "https://troglobit.com/projects/merecat/";
license = licenses.bsd2;
maintainers = with maintainers; [ fgaz ];
platforms = platforms.all;
# Strange header and/or linker errors
broken = stdenv.isDarwin;
};
}

View file

@ -23708,6 +23708,8 @@ with pkgs;
memcached = callPackage ../servers/memcached {};
merecat = callPackage ../servers/http/merecat { };
meteor = callPackage ../servers/meteor { };
micronaut = callPackage ../development/tools/micronaut {};