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" ];
133 mkdir -p ${cfg.datastorePath}
138 StateDirectory = mkIf defaultStateDir "changedetection-io";
139 StateDirectoryMode = mkIf defaultStateDir "0750";
140 WorkingDirectory = cfg.datastorePath;
141 Environment = [ "HIDE_REFERER=true" ]
142 ++ lib.optional (cfg.baseURL != null) "BASE_URL=${cfg.baseURL}"
143 ++ lib.optional cfg.behindProxy "USE_X_SETTINGS=1"
144 ++ lib.optional cfg.webDriverSupport "WEBDRIVER_URL=http://127.0.0.1:${toString cfg.chromePort}/wd/hub"
145 ++ lib.optional cfg.playwrightSupport "PLAYWRIGHT_DRIVER_URL=ws://127.0.0.1:${toString cfg.chromePort}/?stealth=1&--disable-web-security=true";
146 EnvironmentFile = mkIf (cfg.environmentFile != null) cfg.environmentFile;
148 ${pkgs.changedetection-io}/bin/changedetection.py \
149 -h ${cfg.listenAddress} -p ${toString cfg.port} -d ${cfg.datastorePath}
152 ProtectSystem = true;
153 Restart = "on-failure";
156 tmpfiles.rules = mkIf defaultStateDir [
157 "d ${cfg.datastorePath} 0750 ${cfg.user} ${cfg.group} - -"
162 users = optionalAttrs (cfg.user == "changedetection-io") {
163 "changedetection-io" = {
165 group = "changedetection-io";
169 groups = optionalAttrs (cfg.group == "changedetection-io") {
170 "changedetection-io" = { };
175 oci-containers.containers = lib.mkMerge [
176 (mkIf cfg.webDriverSupport {
177 changedetection-io-webdriver = {
178 image = "selenium/standalone-chrome";
180 VNC_NO_PASSWORD = "1";
181 SCREEN_WIDTH = "1920";
182 SCREEN_HEIGHT = "1080";
186 "127.0.0.1:${toString cfg.chromePort}:4444"
191 extraOptions = [ "--network=bridge" ];
195 (mkIf cfg.playwrightSupport {
196 changedetection-io-playwright = {
197 image = "browserless/chrome";
199 SCREEN_WIDTH = "1920";
200 SCREEN_HEIGHT = "1024";
202 ENABLE_DEBUGGER = "false";
203 PREBOOT_CHROME = "true";
204 CONNECTION_TIMEOUT = "300000";
205 MAX_CONCURRENT_SESSIONS = "10";
206 CHROME_REFRESH_TIME = "600000";
207 DEFAULT_BLOCK_ADS = "true";
208 DEFAULT_STEALTH = "true";
211 "127.0.0.1:${toString cfg.chromePort}:3000"
213 extraOptions = [ "--network=bridge" ];
217 podman.defaultNetwork.settings.dns_enabled = true;