mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-29 09:04:17 +00:00
2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
91 lines
1.9 KiB
Nix
91 lines
1.9 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
inherit (pkgs) prayer;
|
|
|
|
cfg = config.services.prayer;
|
|
|
|
stateDir = "/var/lib/prayer";
|
|
|
|
prayerUser = "prayer";
|
|
prayerGroup = "prayer";
|
|
|
|
prayerExtraCfg = pkgs.writeText "extraprayer.cf" ''
|
|
prefix = "${prayer}"
|
|
var_prefix = "${stateDir}"
|
|
prayer_user = "${prayerUser}"
|
|
prayer_group = "${prayerGroup}"
|
|
sendmail_path = "/run/wrappers/bin/sendmail"
|
|
|
|
use_http_port ${cfg.port}
|
|
|
|
${cfg.extraConfig}
|
|
'';
|
|
|
|
prayerCfg = pkgs.runCommand "prayer.cf" { preferLocalBuild = true; } ''
|
|
# We have to remove the http_port 80, or it will start a server there
|
|
cat ${prayer}/etc/prayer.cf | grep -v http_port > $out
|
|
cat ${prayerExtraCfg} >> $out
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.prayer = {
|
|
|
|
enable = mkEnableOption "the prayer webmail http server";
|
|
|
|
port = mkOption {
|
|
default = 2080;
|
|
type = types.port;
|
|
description = lib.mdDoc ''
|
|
Port the prayer http server is listening to.
|
|
'';
|
|
};
|
|
|
|
extraConfig = mkOption {
|
|
type = types.lines;
|
|
default = "" ;
|
|
description = lib.mdDoc ''
|
|
Extra configuration. Contents will be added verbatim to the configuration file.
|
|
'';
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf config.services.prayer.enable {
|
|
environment.systemPackages = [ prayer ];
|
|
|
|
users.users.${prayerUser} =
|
|
{ uid = config.ids.uids.prayer;
|
|
description = "Prayer daemon user";
|
|
home = stateDir;
|
|
};
|
|
|
|
users.groups.${prayerGroup} =
|
|
{ gid = config.ids.gids.prayer; };
|
|
|
|
systemd.services.prayer = {
|
|
wantedBy = [ "multi-user.target" ];
|
|
serviceConfig.Type = "forking";
|
|
preStart = ''
|
|
mkdir -m 0755 -p ${stateDir}
|
|
chown ${prayerUser}:${prayerGroup} ${stateDir}
|
|
'';
|
|
script = "${prayer}/sbin/prayer --config-file=${prayerCfg}";
|
|
};
|
|
};
|
|
}
|