at 23.11-pre 1.8 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.ethercalc; 7in { 8 options = { 9 services.ethercalc = { 10 enable = mkOption { 11 default = false; 12 type = types.bool; 13 description = lib.mdDoc '' 14 ethercalc, an online collaborative spreadsheet server. 15 16 Persistent state will be maintained under 17 {file}`/var/lib/ethercalc`. Upstream supports using a 18 redis server for storage and recommends the redis backend for 19 intensive use; however, the Nix module doesn't currently support 20 redis. 21 22 Note that while ethercalc is a good and robust project with an active 23 issue tracker, there haven't been new commits since the end of 2020. 24 ''; 25 }; 26 27 package = mkOption { 28 default = pkgs.ethercalc; 29 defaultText = literalExpression "pkgs.ethercalc"; 30 type = types.package; 31 description = lib.mdDoc "Ethercalc package to use."; 32 }; 33 34 host = mkOption { 35 type = types.str; 36 default = "0.0.0.0"; 37 description = lib.mdDoc "Address to listen on (use 0.0.0.0 to allow access from any address)."; 38 }; 39 40 port = mkOption { 41 type = types.port; 42 default = 8000; 43 description = lib.mdDoc "Port to bind to."; 44 }; 45 }; 46 }; 47 48 config = mkIf cfg.enable { 49 systemd.services.ethercalc = { 50 description = "Ethercalc service"; 51 wantedBy = [ "multi-user.target" ]; 52 after = [ "network.target" ]; 53 serviceConfig = { 54 DynamicUser = true; 55 ExecStart = "${cfg.package}/bin/ethercalc --host ${cfg.host} --port ${toString cfg.port}"; 56 Restart = "always"; 57 StateDirectory = "ethercalc"; 58 WorkingDirectory = "/var/lib/ethercalc"; 59 }; 60 }; 61 }; 62}