|
14 | 14 | pacServerAddr = "127.0.0.1:8000"; |
15 | 15 | _ghafPacFileFetcher = |
16 | 16 | let |
17 | | - pacFileDownloadUrl = cfg.pacUrl; |
18 | | - proxyServerUrl = "http://${cfg.proxyAddress}:${toString cfg.proxyPort}"; |
| 17 | + pacFileDownloadUrl = cfg.pacFileFetcher.pacUrl; |
| 18 | + proxyServerUrl = "http://${cfg.pacFileFetcher.proxyAddress}:${toString cfg.pacFileFetcher.proxyPort}"; |
19 | 19 | logTag = "ghaf-pac-fetcher"; |
20 | 20 | in |
21 | 21 | pkgs.writeShellApplication { |
|
72 | 72 | { |
73 | 73 | options.ghaf.reference.services.pac = { |
74 | 74 | enable = lib.mkEnableOption "Proxy Auto-Configuration (PAC)"; |
75 | | - |
76 | | - proxyAddress = lib.mkOption { |
77 | | - type = lib.types.str; |
78 | | - description = "Proxy address"; |
79 | | - }; |
80 | | - |
81 | | - proxyPort = lib.mkOption { |
82 | | - type = lib.types.int; |
83 | | - description = "Proxy port"; |
84 | | - }; |
85 | | - |
86 | | - pacUrl = lib.mkOption { |
87 | | - type = lib.types.str; |
88 | | - description = "URL of the Proxy Auto-Configuration (PAC) file"; |
89 | | - default = "https://raw.githubusercontent.com/tiiuae/ghaf-rt-config/refs/heads/main/network/proxy/ghaf.pac"; |
90 | | - }; |
91 | | - |
92 | 75 | proxyPacUrl = lib.mkOption { |
93 | 76 | type = lib.types.str; |
94 | 77 | description = "Local PAC URL that can be passed to the browser"; |
95 | 78 | default = "http://${pacServerAddr}/${pacFileName}"; |
96 | 79 | readOnly = true; |
97 | 80 | }; |
| 81 | + |
| 82 | + pacFileFetcher = { |
| 83 | + enable = lib.mkEnableOption "PAC file fetcher"; |
| 84 | + |
| 85 | + proxyAddress = lib.mkOption { |
| 86 | + type = lib.types.str; |
| 87 | + description = "Proxy address"; |
| 88 | + }; |
| 89 | + |
| 90 | + proxyPort = lib.mkOption { |
| 91 | + type = lib.types.int; |
| 92 | + description = "Proxy port"; |
| 93 | + }; |
| 94 | + |
| 95 | + pacUrl = lib.mkOption { |
| 96 | + type = lib.types.str; |
| 97 | + description = "URL of the Proxy Auto-Configuration (PAC) file"; |
| 98 | + default = "https://raw.githubusercontent.com/tiiuae/ghaf-rt-config/refs/heads/main/network/proxy/ghaf.pac"; |
| 99 | + }; |
| 100 | + }; |
98 | 101 | }; |
99 | 102 |
|
100 | 103 | config = lib.mkIf cfg.enable { |
|
109 | 112 | }; |
110 | 113 |
|
111 | 114 | systemd = { |
112 | | - tmpfiles.rules = [ |
113 | | - "f /etc/proxy/${pacFileName} 0664 ${proxyUserName} ${proxyGroupName} - -" |
114 | | - ]; |
| 115 | + tmpfiles = lib.mkIf cfg.pacFileFetcher.enable { |
| 116 | + rules = [ |
| 117 | + "f /etc/proxy/${pacFileName} 0664 ${proxyUserName} ${proxyGroupName} - -" |
| 118 | + ]; |
| 119 | + }; |
115 | 120 |
|
116 | 121 | services = { |
117 | 122 | pacServer = { |
|
131 | 136 | }; |
132 | 137 | }; |
133 | 138 |
|
134 | | - ghafPacFileFetcher = { |
| 139 | + ghafPacFileFetcher = lib.mkIf cfg.pacFileFetcher.enable { |
135 | 140 | description = "Fetch ghaf pac file periodically with retries if internet is available"; |
136 | 141 | serviceConfig = { |
137 | 142 | ExecStart = "${_ghafPacFileFetcher}/bin/ghafPacFileFetcher"; |
|
0 commit comments