at 25.11-pre 2.1 kB view raw
1{ 2 pkgs, 3 lib, 4 config, 5 ... 6}: 7 8let 9 cfg = config.services.gotify; 10in 11{ 12 imports = [ 13 (lib.mkRenamedOptionModule 14 [ 15 "services" 16 "gotify" 17 "port" 18 ] 19 [ 20 "services" 21 "gotify" 22 "environment" 23 "GOTIFY_SERVER_PORT" 24 ] 25 ) 26 ]; 27 28 options.services.gotify = { 29 enable = lib.mkEnableOption "Gotify webserver"; 30 31 package = lib.mkPackageOption pkgs "gotify-server" { }; 32 33 environment = lib.mkOption { 34 type = lib.types.attrsOf ( 35 lib.types.oneOf [ 36 lib.types.str 37 lib.types.int 38 ] 39 ); 40 default = { }; 41 example = { 42 GOTIFY_SERVER_PORT = 8080; 43 GOTIFY_DATABASE_DIALECT = "sqlite3"; 44 }; 45 description = '' 46 Config environment variables for the gotify-server. 47 See <https://gotify.net/docs/config> for more details. 48 ''; 49 }; 50 51 environmentFiles = lib.mkOption { 52 type = lib.types.listOf lib.types.path; 53 default = [ ]; 54 description = '' 55 Files containing additional config environment variables for gotify-server. 56 Secrets should be set in environmentFiles instead of environment. 57 ''; 58 }; 59 60 stateDirectoryName = lib.mkOption { 61 type = lib.types.str; 62 default = "gotify-server"; 63 description = '' 64 The name of the directory below {file}`/var/lib` where 65 gotify stores its runtime data. 66 ''; 67 }; 68 }; 69 70 config = lib.mkIf cfg.enable { 71 systemd.services.gotify-server = { 72 wantedBy = [ "multi-user.target" ]; 73 after = [ "network.target" ]; 74 description = "Simple server for sending and receiving messages"; 75 76 environment = lib.mapAttrs (_: toString) cfg.environment; 77 78 serviceConfig = { 79 WorkingDirectory = "/var/lib/${cfg.stateDirectoryName}"; 80 StateDirectory = cfg.stateDirectoryName; 81 EnvironmentFile = cfg.environmentFiles; 82 Restart = "always"; 83 DynamicUser = true; 84 ExecStart = lib.getExe cfg.package; 85 }; 86 }; 87 }; 88 89 meta.maintainers = with lib.maintainers; [ DCsunset ]; 90}