↵select↑↓navigateescclose
Search frappe-nix

Reference

services.frappe-nix options

Every option of the frappe-nix NixOS module, at the top level and per site, with types and defaults.

Updated
Tags
  • options
  • reference
  • nixos
On this page

These are the options of nixosModules.default, the NixOS module that deploys a built bench. The types and defaults were checked against the module by evaluating it. For how the pieces work together, see Run Frappe as a NixOS service and Operate a deployed site.

Top-level options

These sit directly under services.frappe-nix. The module was services.frappe, an alias of the whole tree through 1.x. Since frappe-nix 2.0.0 it fails an assertion that names services.frappe-nix.

OptionTypeDefaultNotes
enableboolfalseEnable the Frappe production deployment (systemd).
packagepackagerequiredThe default bench package: builtBench, or packages.default of a bench repository. Sites inherit it unless they set their own.
userstr"frappe"The service user. The module creates it only when the name is frappe.
groupstr"frappe"The service group. The module creates it only when the name is frappe.
extraEnvattrs of str{ }Extra environment variables for all Frappe services.
environmentFileslist of path[ ]Files of KEY=value lines for every unit that runs Frappe code, and for bench from a root shell, as systemd EnvironmentFile=s: secrets an app reads from its environment, kept out of the store. Read by systemd as root.
hardening.enablebooltrueSandbox every frappe-* unit with python-devops-nix's lib.nixos.hardening. The default since 2.0.0 (off through 1.x). See The sandbox.
extraPathlist of package[ ]Extra packages on the units' PATH. systemd's path sets PATH to exactly the listed packages, so a package that is only in environment.systemPackages is invisible to these services. The module already includes git, gzip, tar, bash and the MariaDB client tools that Frappe's backup code needs.
workerslist of str[ "default" "short" "long" ]Background worker queues per site. Under the unified runtime they are passed to the runner as --queue instead of becoming one unit each.
web.workersint4Number of gunicorn workers, shared across sites. Ignored when runtime.enable is on, with a warning when it is not at its default.
database.createLocallyboolfalseEnable a local MariaDB. Aggregate: it is on if this or any site requests it.
database.slowQueryMsnull or unsigned intnullLog statements that take at least this many milliseconds to MariaDB's slow query log (a file in its data directory, not rotated). 0 logs all of them. Only with a local database.
database.packagepackagepkgs.mariadbThe MariaDB package. Its client library is on LD_LIBRARY_PATH.
redis.createLocallyboolfalseRun a local Redis instance, named frappe, unit redis-frappe.
redis.portport13000The port of that Redis. The sites' Redis URLs default to a fixed string and do not follow it.
runtime.enablebooltrueOne frappe-runtime unit per site (web, realtime, jobs and scheduler) instead of separate web, socketio, worker and scheduler units. Needs frappe-runtime in the bench's Python environment.
runtime.jobThreadsint4Concurrent background jobs inside the runtime process.
runtime.webThreadsint0Concurrent web requests. 0 keeps frappe_runtime.asgi's own default (FRAPPE_WEB_THREADS, itself defaulting to 8). Size the database pool against it.
runtime.restartAfterRequestsint5000Web requests before a graceful restart. 0 means never.
runtime.restartAfterJobsint500Background jobs before a graceful restart. 0 means never.
runtime.restartIdleSecondsint300Idle seconds before a graceful restart. 0 means never.
runtime.requestDrainSecondsint60How long a graceful stop waits for in-flight web requests.
runtime.jobDrainSecondsint600How long a graceful stop waits for a job in progress. TimeoutStopSec is derived from this and requestDrainSeconds, so systemd outlasts the drain instead of killing the process partway through.
runtime.extraArgslist of str[ ]Extra arguments appended to the frappe-runtime command line.
logging.leveldebug, info, warning or error"warning"Threshold for Frappe's application loggers and bench's own log (FRAPPE_NIX_LOG_LEVEL). See Logging.
logging.accessLogbooltruenginx's access log to the journal as JSON, one object per request. false turns access logging off for every virtual host on the machine.
chromium.enableboolfalseChromium for print-builder formats, the chrome PDF generator and Print Designer, linked where Frappe looks for it, plus Liberation and Noto in fonts.packages. See Render PDFs.
chromium.packagepackagechrome-headless-shellThe browser that is linked, by its main program. Keep it a chrome-headless-shell: full Chromium (pkgs.chromium) needs a writable home directory and leaves a profile behind for every PDF.
wkhtmltopdf.enableboolfalsewkhtmltopdf (pdfkiln, which renders with Chromium), which renders the Standard print and classic HTML formats, on the units' PATH with the which pdfkit finds it through, plus the same fonts. See Render PDFs.
wkhtmltopdf.packagepackagepdfkiln (python-devops-nix)The wkhtmltopdf the sites render with: pdfkiln, which renders with Chromium. Frappe's PDF headers and footers need a build "with patched qt", which pdfkiln reports.
migrate.enablebooltrueRun bench migrate automatically per site when a new build is deployed.
migrate.snapshotbooltrueTake a mysqldump snapshot before migrating, as a safety net.
migrate.rollbackOnFailurebooltrueRestore the snapshot if the migration fails. No effect when snapshot is off.
migrate.maintenanceModebooltrueToggle maintenance mode around the migration. It is left on if the migration fails.
migrate.snapshotRetentionpositive int3Snapshots to keep per site under <siteDir>/snapshots.
migrate.offline.enableboolfalseAlter large tables online before bench migrate, inside the same snapshot and maintenance mode. See Migrate large tables online.
migrate.offline.rowThresholdunsigned int100000Rows at which a table is altered online rather than by bench migrate itself. 0 sends every table with a pending change through it.

Per-site options

These sit under services.frappe-nix.sites.<NAME>, where <NAME> is the site name.

OptionTypeDefaultNotes
enableboolfalseEnable this site.
packagepackage or nullnullPer-site bench package override. Defaults to services.frappe-nix.package.
siteDirstr"/var/lib/frappe/<NAME>"The state directory for this site.
web.portport8000The listen port of the runtime or gunicorn. Ignored when web.socketPath is set.
web.socketPathstr""A unix socket instead of a TCP port. nginx reaches it through a generated upstream. The directory must not be /run itself: see Run Frappe as a NixOS service.
socketio.portport9000The Node realtime server port. Only with runtime.enable = false, and ignored when socketio.socketPath is set.
socketio.socketPathstr""A unix socket for the realtime server (socketio_uds). Needs Frappe 15.46 or newer. Only with runtime.enable = false; with the runtime it is ignored, with a warning.
database.createLocallyboolfalseCreate a local MariaDB database and user for this site.
database.hoststr"127.0.0.1"The database host, used when socket is empty.
database.portport3306The database port, used when socket is empty.
database.socketstr"/run/mysqld/mysqld.sock"The database unix socket. Empty disables socket authentication and makes Frappe use host and port.
database.namestrthe site nameThe database name, defaulting to the site name with dots and hyphens replaced by underscores.
database.userstrthe site nameThe database user, defaulting the same way.
database.passwordFilepath or nullnullA file containing the database password. Merged into site_config.json at activation.
redis.cacheUrlstr"redis://127.0.0.1:13000"The Redis cache URL.
redis.queueUrlstr"redis://127.0.0.1:13000"The Redis queue URL.
redis.socketioUrlstr"redis://127.0.0.1:13000"The Redis URL for realtime.
encryptionKeyFilepath or nullnullA file containing the Frappe encryption key. Merged into site_config.json at activation.
settingsJSON attrscomputed keysThe site's site_config.json, under Frappe's spelling: any JSON value, no secrets. It already holds the keys computed from the options above, so it shows the file as written, before the secrets are merged in. See Site settings. Was extraConfig, an alias through 1.x and refused since frappe-nix 2.0.0.
settings.host_namestr or nullnullThe site's public URL, scheme included, for links built without a request (scheduled jobs, workers). Left out of the file when null.
settingsFileslist of path[ ]JSON files deep-merged into site_config.json at activation. Was extraConfigFiles, an alias through 1.x and refused since frappe-nix 2.0.0. This is the place for secrets such as object-storage credentials.
renamedAppsattrs of str{ }Apps renamed in place, OLD = NEW. The migrate unit runs frappe-rename-app --site after maintenance mode goes on and before migrating, inside the snapshot. See Renaming an app.
replacedAppsattrs of str{ }Apps replaced by a new app, OLD = NEW. Where OLD is installed, the migrate unit installs NEW and uninstalls OLD before migrating, inside the snapshot. See Renaming an app.
nginx.enableboolfalseCreate an nginx virtual host for this site.
nginx.socketPathstr""Also serve the virtual host on a unix socket, for a co-located reverse proxy or tunnel connector that terminates TLS elsewhere. The client address then comes from CF-Connecting-IP. Requires nginx.enable.

Site settings

sites.<NAME>.settings is a freeform block in the shape of the nixpkgs settings options (RFC 42). The module puts its own keys in it at mkDefault priority: db_host, db_port, db_user, db_socket, redis_cache, redis_queue, redis_socketio, socketio_port and, under the split units, socketio_uds. A key you set replaces one of those without lib.mkForce, and attribute sets from several modules merge key by key. Two keys are the module's own: db_name is database.name and db_type is mariadb, because the migrate snapshot and its rollback, database.createLocally and the grants all use database.name, and this module runs MariaDB only. Set database.name instead. A different db_name or db_type is a conflicting definition, and one forced past that with lib.mkForce fails an assertion that says what would break (through 1.x either was a warning). A value JSON cannot hold, such as a function, is a type error.

Because the computed keys are in it, evaluating the option shows the base site_config.json:

$ nix eval --json '.#nixosConfigurations.<HOST>.config.services.frappe-nix.sites."<NAME>".settings'

The units' environment (FRAPPE_DB_HOST and the rest) and the migrate snapshot follow the typed options, not settings, so change a database or Redis address through database.* and redis.*.