forked from mirrors/nixpkgs
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.
127 lines
3.5 KiB
Nix
127 lines
3.5 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.cntlm;
|
|
|
|
configFile = if cfg.configText != "" then
|
|
pkgs.writeText "cntlm.conf" ''
|
|
${cfg.configText}
|
|
''
|
|
else
|
|
pkgs.writeText "lighttpd.conf" ''
|
|
# Cntlm Authentication Proxy Configuration
|
|
Username ${cfg.username}
|
|
Domain ${cfg.domain}
|
|
Password ${cfg.password}
|
|
${optionalString (cfg.netbios_hostname != "") "Workstation ${cfg.netbios_hostname}"}
|
|
${concatMapStrings (entry: "Proxy ${entry}\n") cfg.proxy}
|
|
${optionalString (cfg.noproxy != []) "NoProxy ${concatStringsSep ", " cfg.noproxy}"}
|
|
|
|
${concatMapStrings (port: ''
|
|
Listen ${toString port}
|
|
'') cfg.port}
|
|
|
|
${cfg.extraConfig}
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.services.cntlm = {
|
|
|
|
enable = mkEnableOption "cntlm, which starts a local proxy";
|
|
|
|
username = mkOption {
|
|
type = types.str;
|
|
description = lib.mdDoc ''
|
|
Proxy account name, without the possibility to include domain name ('at' sign is interpreted literally).
|
|
'';
|
|
};
|
|
|
|
domain = mkOption {
|
|
type = types.str;
|
|
description = lib.mdDoc "Proxy account domain/workgroup name.";
|
|
};
|
|
|
|
password = mkOption {
|
|
default = "/etc/cntlm.password";
|
|
type = types.str;
|
|
description = lib.mdDoc "Proxy account password. Note: use chmod 0600 on /etc/cntlm.password for security.";
|
|
};
|
|
|
|
netbios_hostname = mkOption {
|
|
type = types.str;
|
|
default = "";
|
|
description = lib.mdDoc ''
|
|
The hostname of your machine.
|
|
'';
|
|
};
|
|
|
|
proxy = mkOption {
|
|
type = types.listOf types.str;
|
|
description = lib.mdDoc ''
|
|
A list of NTLM/NTLMv2 authenticating HTTP proxies.
|
|
|
|
Parent proxy, which requires authentication. The same as proxy on the command-line, can be used more than once to specify unlimited
|
|
number of proxies. Should one proxy fail, cntlm automatically moves on to the next one. The connect request fails only if the whole
|
|
list of proxies is scanned and (for each request) and found to be invalid. Command-line takes precedence over the configuration file.
|
|
'';
|
|
example = [ "proxy.example.com:81" ];
|
|
};
|
|
|
|
noproxy = mkOption {
|
|
description = lib.mdDoc ''
|
|
A list of domains where the proxy is skipped.
|
|
'';
|
|
default = [];
|
|
type = types.listOf types.str;
|
|
example = [ "*.example.com" "example.com" ];
|
|
};
|
|
|
|
port = mkOption {
|
|
default = [3128];
|
|
type = types.listOf types.port;
|
|
description = lib.mdDoc "Specifies on which ports the cntlm daemon listens.";
|
|
};
|
|
|
|
extraConfig = mkOption {
|
|
type = types.lines;
|
|
default = "";
|
|
description = lib.mdDoc "Additional config appended to the end of the generated {file}`cntlm.conf`.";
|
|
};
|
|
|
|
configText = mkOption {
|
|
type = types.lines;
|
|
default = "";
|
|
description = lib.mdDoc "Verbatim contents of {file}`cntlm.conf`.";
|
|
};
|
|
|
|
};
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
|
systemd.services.cntlm = {
|
|
description = "CNTLM is an NTLM / NTLM Session Response / NTLMv2 authenticating HTTP proxy";
|
|
after = [ "network.target" ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
serviceConfig = {
|
|
User = "cntlm";
|
|
ExecStart = ''
|
|
${pkgs.cntlm}/bin/cntlm -U cntlm -c ${configFile} -v -f
|
|
'';
|
|
};
|
|
};
|
|
|
|
users.users.cntlm = {
|
|
name = "cntlm";
|
|
description = "cntlm system-wide daemon";
|
|
isSystemUser = true;
|
|
};
|
|
};
|
|
}
|