1 { config, lib, pkgs, ... }:
6 cfg = config.services.merecat;
7 format = pkgs.formats.keyValue {
8 mkKeyValue = generators.mkKeyValueDefault {
10 # In merecat.conf, booleans are "true" and "false"
12 then if v then "true" else "false"
13 else generators.mkValueStringDefault {} v;
16 configFile = format.generate "merecat.conf" cfg.settings;
20 options.services.merecat = {
22 enable = mkEnableOption (lib.mdDoc "Merecat HTTP server");
25 inherit (format) type;
27 description = lib.mdDoc ''
28 Merecat configuration. Refer to merecat(8) for details on supported values.
31 hostname = "localhost";
34 directory = "/srv/www";
40 config = mkIf cfg.enable {
42 systemd.services.merecat = {
43 description = "Merecat HTTP server";
44 after = [ "network.target" ];
45 wantedBy = [ "multi-user.target" ];
48 ExecStart = "${pkgs.merecat}/bin/merecat -n -f ${configFile}";
49 AmbientCapabilities = lib.mkIf ((cfg.settings.port or 80) < 1024) [ "CAP_NET_BIND_SERVICE" ];