9 cfg = config.services.cntlm;
12 if cfg.configText != "" then
13 pkgs.writeText "cntlm.conf" ''
17 pkgs.writeText "lighttpd.conf" ''
18 # Cntlm Authentication Proxy Configuration
19 Username ${cfg.username}
21 Password ${cfg.password}
22 ${lib.optionalString (cfg.netbios_hostname != "") "Workstation ${cfg.netbios_hostname}"}
23 ${lib.concatMapStrings (entry: "Proxy ${entry}\n") cfg.proxy}
24 ${lib.optionalString (cfg.noproxy != [ ]) "NoProxy ${lib.concatStringsSep ", " cfg.noproxy}"}
26 ${lib.concatMapStrings (port: ''
27 Listen ${toString port}
37 options.services.cntlm = {
39 enable = lib.mkEnableOption "cntlm, which starts a local proxy";
41 username = lib.mkOption {
44 Proxy account name, without the possibility to include domain name ('at' sign is interpreted literally).
48 domain = lib.mkOption {
50 description = "Proxy account domain/workgroup name.";
53 password = lib.mkOption {
54 default = "/etc/cntlm.password";
56 description = "Proxy account password. Note: use chmod 0600 on /etc/cntlm.password for security.";
59 netbios_hostname = lib.mkOption {
63 The hostname of your machine.
67 proxy = lib.mkOption {
68 type = lib.types.listOf lib.types.str;
70 A list of NTLM/NTLMv2 authenticating HTTP proxies.
72 Parent proxy, which requires authentication. The same as proxy on the command-line, can be used more than once to specify unlimited
73 number of proxies. Should one proxy fail, cntlm automatically moves on to the next one. The connect request fails only if the whole
74 list of proxies is scanned and (for each request) and found to be invalid. Command-line takes precedence over the configuration file.
76 example = [ "proxy.example.com:81" ];
79 noproxy = lib.mkOption {
81 A list of domains where the proxy is skipped.
84 type = lib.types.listOf lib.types.str;
93 type = lib.types.listOf lib.types.port;
94 description = "Specifies on which ports the cntlm daemon listens.";
97 extraConfig = lib.mkOption {
98 type = lib.types.lines;
100 description = "Additional config appended to the end of the generated {file}`cntlm.conf`.";
103 configText = lib.mkOption {
104 type = lib.types.lines;
106 description = "Verbatim contents of {file}`cntlm.conf`.";
111 ###### implementation
113 config = lib.mkIf cfg.enable {
114 systemd.services.cntlm = {
115 description = "CNTLM is an NTLM / NTLM Session Response / NTLMv2 authenticating HTTP proxy";
116 after = [ "network.target" ];
117 wantedBy = [ "multi-user.target" ];
121 ${pkgs.cntlm}/bin/cntlm -U cntlm -c ${configFile} -v -f
126 users.users.cntlm = {
128 description = "cntlm system-wide daemon";