6afb255d97
these changes were generated with nixq 0.0.2, by running nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix two mentions of the mdDoc function remain in nixos/, both of which are inside of comments. Since lib.mdDoc is already defined as just id, this commit is a no-op as far as Nix (and the built manual) is concerned.
55 lines
1.3 KiB
Nix
55 lines
1.3 KiB
Nix
{ 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 "Merecat HTTP server";
|
|
|
|
settings = mkOption {
|
|
inherit (format) type;
|
|
default = { };
|
|
description = ''
|
|
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" ];
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
}
|