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.
93 lines
2.4 KiB
Nix
93 lines
2.4 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.lighttpd.cgit;
|
|
pathPrefix = if stringLength cfg.subdir == 0 then "" else "/" + cfg.subdir;
|
|
configFile = pkgs.writeText "cgitrc"
|
|
''
|
|
# default paths to static assets
|
|
css=${pathPrefix}/cgit.css
|
|
logo=${pathPrefix}/cgit.png
|
|
favicon=${pathPrefix}/favicon.ico
|
|
|
|
# user configuration
|
|
${cfg.configText}
|
|
'';
|
|
in
|
|
{
|
|
|
|
options.services.lighttpd.cgit = {
|
|
|
|
enable = mkOption {
|
|
default = false;
|
|
type = types.bool;
|
|
description = lib.mdDoc ''
|
|
If true, enable cgit (fast web interface for git repositories) as a
|
|
sub-service in lighttpd.
|
|
'';
|
|
};
|
|
|
|
subdir = mkOption {
|
|
default = "cgit";
|
|
example = "";
|
|
type = types.str;
|
|
description = lib.mdDoc ''
|
|
The subdirectory in which to serve cgit. The web application will be
|
|
accessible at http://yourserver/''${subdir}
|
|
'';
|
|
};
|
|
|
|
configText = mkOption {
|
|
default = "";
|
|
example = literalExpression ''
|
|
'''
|
|
source-filter=''${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py
|
|
about-filter=''${pkgs.cgit}/lib/cgit/filters/about-formatting.sh
|
|
cache-size=1000
|
|
scan-path=/srv/git
|
|
'''
|
|
'';
|
|
type = types.lines;
|
|
description = lib.mdDoc ''
|
|
Verbatim contents of the cgit runtime configuration file. Documentation
|
|
(with cgitrc example file) is available in "man cgitrc". Or online:
|
|
http://git.zx2c4.com/cgit/tree/cgitrc.5.txt
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
# make the cgitrc manpage available
|
|
environment.systemPackages = [ pkgs.cgit ];
|
|
|
|
# declare module dependencies
|
|
services.lighttpd.enableModules = [ "mod_cgi" "mod_alias" "mod_setenv" ];
|
|
|
|
services.lighttpd.extraConfig = ''
|
|
$HTTP["url"] =~ "^/${cfg.subdir}" {
|
|
cgi.assign = (
|
|
"cgit.cgi" => "${pkgs.cgit}/cgit/cgit.cgi"
|
|
)
|
|
alias.url = (
|
|
"${pathPrefix}/cgit.css" => "${pkgs.cgit}/cgit/cgit.css",
|
|
"${pathPrefix}/cgit.png" => "${pkgs.cgit}/cgit/cgit.png",
|
|
"${pathPrefix}" => "${pkgs.cgit}/cgit/cgit.cgi"
|
|
)
|
|
setenv.add-environment = (
|
|
"CGIT_CONFIG" => "${configFile}"
|
|
)
|
|
}
|
|
'';
|
|
|
|
systemd.services.lighttpd.preStart = ''
|
|
mkdir -p /var/cache/cgit
|
|
chown lighttpd:lighttpd /var/cache/cgit
|
|
'';
|
|
|
|
};
|
|
|
|
}
|