mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
nixos/merecat: init
This commit is contained in:
parent
ada312b3c4
commit
b43605fb03
@ -365,6 +365,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>,
|
||||
|
@ -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).
|
||||
|
@ -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
|
||||
|
55
nixos/modules/services/web-servers/merecat.nix
Normal file
55
nixos/modules/services/web-servers/merecat.nix
Normal 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" ];
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -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
28
nixos/tests/merecat.nix
Normal 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'")
|
||||
'';
|
||||
})
|
@ -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; {
|
||||
|
Loading…
Reference in New Issue
Block a user