1 { config, lib, pkgs, ... }:
6 cfg = config.services.changedetection-io;
9 options.services.changedetection-io = {
10 enable = mkEnableOption "changedetection-io";
13 default = "changedetection-io";
16 User account under which changedetection-io runs.
21 default = "changedetection-io";
24 Group account under which changedetection-io runs.
28 listenAddress = mkOption {
30 default = "localhost";
31 description = "Address the server will listen on.";
37 description = "Port the server will listen on.";
40 datastorePath = mkOption {
42 default = "/var/lib/changedetection-io";
44 The directory used to store all data for changedetection-io.
49 type = types.nullOr types.str;
51 example = "https://changedetection-io.example";
53 The base url used in notifications and `{base_url}` token.
57 behindProxy = mkOption {
61 Enable this option when changedetection-io runs behind a reverse proxy, so that it trusts X-* headers.
62 It is recommend to run changedetection-io behind a TLS reverse proxy.
66 environmentFile = mkOption {
67 type = types.nullOr types.path;
69 example = "/run/secrets/changedetection-io.env";
71 Securely pass environment variabels to changedetection-io.
73 This can be used to set for example a frontend password reproducible via `SALTED_PASS`
74 which convinetly also deactivates nags about the hosted version.
75 `SALTED_PASS` should be 64 characters long while the first 32 are the salt and the second the frontend password.
76 It can easily be retrieved from the settings file when first set via the frontend with the following command:
77 ``jq -r .settings.application.password /var/lib/changedetection-io/url-watches.json``
81 webDriverSupport = mkOption {
85 Enable support for fetching web pages using WebDriver and Chromium.
86 This starts a headless chromium controlled by puppeteer in an oci container.
89 Playwright can currently leak memory.
90 See https://github.com/dgtlmoon/changedetection.io/wiki/Playwright-content-fetcher#playwright-memory-leak
95 playwrightSupport = mkOption {
99 Enable support for fetching web pages using playwright and Chromium.
100 This starts a headless Chromium controlled by puppeteer in an oci container.
103 Playwright can currently leak memory.
104 See https://github.com/dgtlmoon/changedetection.io/wiki/Playwright-content-fetcher#playwright-memory-leak
109 chromePort = mkOption {
113 A free port on which webDriverSupport or playwrightSupport listen on localhost.
118 config = mkIf cfg.enable {
121 assertion = !((cfg.webDriverSupport == true) && (cfg.playwrightSupport == true));
122 message = "'services.changedetection-io.webDriverSupport' and 'services.changedetection-io.playwrightSupport' cannot be used together.";
127 defaultStateDir = cfg.datastorePath == "/var/lib/changedetection-io";
129 services.changedetection-io = {
130 wantedBy = [ "multi-user.target" ];
131 after = [ "network.target" ];
135 StateDirectory = mkIf defaultStateDir "changedetection-io";
136 StateDirectoryMode = mkIf defaultStateDir "0750";
137 WorkingDirectory = cfg.datastorePath;
138 Environment = [ "HIDE_REFERER=true" ]
139 ++ lib.optional (cfg.baseURL != null) "BASE_URL=${cfg.baseURL}"
140 ++ lib.optional cfg.behindProxy "USE_X_SETTINGS=1"
141 ++ lib.optional cfg.webDriverSupport "WEBDRIVER_URL=http://127.0.0.1:${toString cfg.chromePort}/wd/hub"
142 ++ lib.optional cfg.playwrightSupport "PLAYWRIGHT_DRIVER_URL=ws://127.0.0.1:${toString cfg.chromePort}/?stealth=1&--disable-web-security=true";
143 EnvironmentFile = mkIf (cfg.environmentFile != null) cfg.environmentFile;
145 ${pkgs.changedetection-io}/bin/changedetection.py \
146 -h ${cfg.listenAddress} -p ${toString cfg.port} -d ${cfg.datastorePath}
149 ProtectSystem = true;
150 Restart = "on-failure";
153 tmpfiles.rules = mkIf (!defaultStateDir) [
154 "d ${cfg.datastorePath} 0750 ${cfg.user} ${cfg.group} - -"
159 users = optionalAttrs (cfg.user == "changedetection-io") {
160 "changedetection-io" = {
162 group = "changedetection-io";
166 groups = optionalAttrs (cfg.group == "changedetection-io") {
167 "changedetection-io" = { };
172 oci-containers.containers = lib.mkMerge [
173 (mkIf cfg.webDriverSupport {
174 changedetection-io-webdriver = {
175 image = "selenium/standalone-chrome";
177 VNC_NO_PASSWORD = "1";
178 SCREEN_WIDTH = "1920";
179 SCREEN_HEIGHT = "1080";
183 "127.0.0.1:${toString cfg.chromePort}:4444"
188 extraOptions = [ "--network=bridge" ];
192 (mkIf cfg.playwrightSupport {
193 changedetection-io-playwright = {
194 image = "browserless/chrome";
196 SCREEN_WIDTH = "1920";
197 SCREEN_HEIGHT = "1024";
199 ENABLE_DEBUGGER = "false";
200 PREBOOT_CHROME = "true";
201 CONNECTION_TIMEOUT = "300000";
202 MAX_CONCURRENT_SESSIONS = "10";
203 CHROME_REFRESH_TIME = "600000";
204 DEFAULT_BLOCK_ADS = "true";
205 DEFAULT_STEALTH = "true";
208 "127.0.0.1:${toString cfg.chromePort}:3000"
210 extraOptions = [ "--network=bridge" ];
214 podman.defaultNetwork.settings.dns_enabled = true;