lol

Merge pull request #201780 from helsinki-systems/init/nextcloud-notify-push

nextcloud-notify-push: init at 0.5.0

authored by

Sandro and committed by
GitHub
83b8193b 1cdbf440

+173 -1
+1
nixos/modules/module-list.nix
··· 1168 1168 ./services/web-apps/moodle.nix 1169 1169 ./services/web-apps/netbox.nix 1170 1170 ./services/web-apps/nextcloud.nix 1171 + ./services/web-apps/nextcloud-notify_push.nix 1171 1172 ./services/web-apps/nexus.nix 1172 1173 ./services/web-apps/nifi.nix 1173 1174 ./services/web-apps/node-red.nix
+96
nixos/modules/services/web-apps/nextcloud-notify_push.nix
··· 1 + { config, options, lib, pkgs, ... }: 2 + 3 + let 4 + cfg = config.services.nextcloud.notify_push; 5 + in 6 + { 7 + options.services.nextcloud.notify_push = { 8 + enable = lib.mkEnableOption (lib.mdDoc "Notify push"); 9 + 10 + package = lib.mkOption { 11 + type = lib.types.package; 12 + default = pkgs.nextcloud-notify_push; 13 + defaultText = lib.literalMD "pkgs.nextcloud-notify_push"; 14 + description = lib.mdDoc "Which package to use for notify_push"; 15 + }; 16 + 17 + socketPath = lib.mkOption { 18 + type = lib.types.str; 19 + default = "/run/nextcloud-notify_push/sock"; 20 + description = lib.mdDoc "Socket path to use for notify_push"; 21 + }; 22 + 23 + logLevel = lib.mkOption { 24 + type = lib.types.enum [ "error" "warn" "info" "debug" "trace" ]; 25 + default = "error"; 26 + description = lib.mdDoc "Log level"; 27 + }; 28 + } // ( 29 + lib.genAttrs [ 30 + "dbtype" 31 + "dbname" 32 + "dbuser" 33 + "dbpassFile" 34 + "dbhost" 35 + "dbport" 36 + "dbtableprefix" 37 + ] ( 38 + opt: options.services.nextcloud.config.${opt} // { 39 + default = config.services.nextcloud.config.${opt}; 40 + defaultText = "config.services.nextcloud.config.${opt}"; 41 + } 42 + ) 43 + ); 44 + 45 + config = lib.mkIf cfg.enable { 46 + systemd.services.nextcloud-notify_push = let 47 + nextcloudUrl = "http${lib.optionalString config.services.nextcloud.https "s"}://${config.services.nextcloud.hostName}"; 48 + in { 49 + description = "Push daemon for Nextcloud clients"; 50 + documentation = [ "https://github.com/nextcloud/notify_push" ]; 51 + after = [ "phpfpm-nextcloud.service" ]; 52 + wantedBy = [ "multi-user.target" ]; 53 + environment = { 54 + NEXTCLOUD_URL = nextcloudUrl; 55 + SOCKET_PATH = cfg.socketPath; 56 + DATABASE_PREFIX = cfg.dbtableprefix; 57 + LOG = cfg.logLevel; 58 + }; 59 + postStart = '' 60 + ${config.services.nextcloud.occ}/bin/nextcloud-occ notify_push:setup ${nextcloudUrl}/push 61 + ''; 62 + script = let 63 + dbType = if cfg.dbtype == "pgsql" then "postgresql" else cfg.dbtype; 64 + dbUser = lib.optionalString (cfg.dbuser != null) cfg.dbuser; 65 + dbPass = lib.optionalString (cfg.dbpassFile != null) ":$DATABASE_PASSWORD"; 66 + isSocket = lib.hasPrefix "/" (toString cfg.dbhost); 67 + dbHost = lib.optionalString (cfg.dbhost != null) (if 68 + isSocket then 69 + if dbType == "postgresql" then "?host=${cfg.dbhost}" else 70 + if dbType == "mysql" then "?socket=${cfg.dbhost}" else throw "unsupported dbtype" 71 + else 72 + "@${cfg.dbhost}"); 73 + dbName = lib.optionalString (cfg.dbname != null) "/${cfg.dbname}"; 74 + dbUrl = "${dbType}://${dbUser}${dbPass}${lib.optionalString (!isSocket) dbHost}${dbName}${lib.optionalString isSocket dbHost}"; 75 + in lib.optionalString (dbPass != "") '' 76 + export DATABASE_PASSWORD="$(<"${cfg.dbpassFile}")" 77 + '' + '' 78 + export DATABASE_URL="${dbUrl}" 79 + ${cfg.package}/bin/notify_push --glob-config '${config.services.nextcloud.datadir}/config/config.php' 80 + ''; 81 + serviceConfig = { 82 + User = "nextcloud"; 83 + Group = "nextcloud"; 84 + RuntimeDirectory = [ "nextcloud-notify_push" ]; 85 + Restart = "on-failure"; 86 + RestartSec = "5s"; 87 + }; 88 + }; 89 + 90 + services.nginx.virtualHosts.${config.services.nextcloud.hostName}.locations."^~ /push/" = { 91 + proxyPass = "http://unix:${cfg.socketPath}"; 92 + proxyWebsockets = true; 93 + recommendedProxySettings = true; 94 + }; 95 + }; 96 + }
+12 -1
nixos/tests/nextcloud/with-postgresql-and-redis.nix
··· 13 13 # The only thing the client needs to do is download a file. 14 14 client = { ... }: {}; 15 15 16 - nextcloud = { config, pkgs, ... }: { 16 + nextcloud = { config, pkgs, lib, ... }: { 17 17 networking.firewall.allowedTCPPorts = [ 80 ]; 18 18 19 19 services.nextcloud = { ··· 34 34 adminpassFile = toString (pkgs.writeText "admin-pass-file" '' 35 35 ${adminpass} 36 36 ''); 37 + trustedProxies = [ "::1" ]; 38 + }; 39 + notify_push = { 40 + enable = true; 41 + logLevel = "debug"; 42 + }; 43 + extraAppsEnable = true; 44 + extraApps = { 45 + inherit (pkgs."nextcloud${lib.versions.major config.services.nextcloud.package.version}Packages".apps) notify_push; 37 46 }; 38 47 }; 39 48 ··· 94 103 "${withRcloneEnv} ${copySharedFile}" 95 104 ) 96 105 client.wait_for_unit("multi-user.target") 106 + client.execute("${pkgs.nextcloud-notify_push.passthru.test_client}/bin/test_client http://nextcloud ${adminuser} ${adminpass} >&2 &") 97 107 client.succeed( 98 108 "${withRcloneEnv} ${diffSharedFile}" 99 109 ) 110 + nextcloud.wait_until_succeeds("journalctl -u nextcloud-notify_push | grep -q \"Sending ping to ${adminuser}\"") 100 111 ''; 101 112 })) args
+41
pkgs/servers/nextcloud/notify_push.nix
··· 1 + { lib, fetchFromGitHub, fetchpatch, rustPlatform }: 2 + 3 + rustPlatform.buildRustPackage rec { 4 + pname = "notify_push"; 5 + version = "0.5.0"; 6 + 7 + src = fetchFromGitHub { 8 + owner = "nextcloud"; 9 + repo = pname; 10 + rev = "v${version}"; 11 + hash = "sha256-LkC2mD3klMQRF3z5QuVPcRHzz33VJP+UcN6LxsQXq7Q="; 12 + }; 13 + 14 + cargoHash = "sha256-GZikXM3AvhC2gtwE2wYbGV+aRV+QKothWQG17Vzi2Lc="; 15 + 16 + passthru = { 17 + test_client = rustPlatform.buildRustPackage { 18 + pname = "${pname}-test_client"; 19 + inherit src version; 20 + 21 + cargoPatches = [ 22 + # fix test client not being able to connect 23 + (fetchpatch { 24 + url = "https://github.com/nextcloud/notify_push/commit/03aa38d917bfcba4d07f72b6aedac6a5057cad81.patch"; 25 + hash = "sha256-dcN62tA05HH1RTvG0puonJjKMQn1EouA8iuz82vh2aU="; 26 + }) 27 + ]; 28 + 29 + buildAndTestSubdir = "test_client"; 30 + 31 + cargoHash = "sha256-RALqjI6DlWmfgKvyaH4RiSyqWsIqUyY9f709hOi2ldc="; 32 + }; 33 + }; 34 + 35 + meta = with lib; { 36 + description = "Update notifications for nextcloud clients"; 37 + homepage = "https://github.com/nextcloud/notify_push"; 38 + license = licenses.agpl3Plus; 39 + maintainers = with maintainers; [ ajs124 ]; 40 + }; 41 + }
+10
pkgs/servers/nextcloud/packages/24.json
··· 129 129 "agpl" 130 130 ] 131 131 }, 132 + "notify_push": { 133 + "sha256": "1raxkzdcd9mixg30ifv22lzf10j47n79n05yqbf6mjagrgj0rr7f", 134 + "url": "https://github.com/nextcloud/notify_push/releases/download/v0.5.0/notify_push.tar.gz", 135 + "version": "0.5.0", 136 + "description": "Push update support for desktop app.\n\nOnce the app is installed, the push binary needs to be setup. You can either use the setup wizard with `occ notify_push:setup` or see the [README](http://github.com/nextcloud/notify_push) for detailed setup instructions", 137 + "homepage": "", 138 + "licenses": [ 139 + "agpl" 140 + ] 141 + }, 132 142 "onlyoffice": { 133 143 "sha256": "6117b7b8c5c7133975e4ebf482814cdcd3f94a1b3c76ea1b5eed47bdd1fbfcbb", 134 144 "url": "https://github.com/ONLYOFFICE/onlyoffice-nextcloud/releases/download/v7.5.8/onlyoffice.tar.gz",
+10
pkgs/servers/nextcloud/packages/25.json
··· 109 109 "agpl" 110 110 ] 111 111 }, 112 + "notify_push": { 113 + "sha256": "1raxkzdcd9mixg30ifv22lzf10j47n79n05yqbf6mjagrgj0rr7f", 114 + "url": "https://github.com/nextcloud/notify_push/releases/download/v0.5.0/notify_push.tar.gz", 115 + "version": "0.5.0", 116 + "description": "Push update support for desktop app.\n\nOnce the app is installed, the push binary needs to be setup. You can either use the setup wizard with `occ notify_push:setup` or see the [README](http://github.com/nextcloud/notify_push) for detailed setup instructions", 117 + "homepage": "", 118 + "licenses": [ 119 + "agpl" 120 + ] 121 + }, 112 122 "onlyoffice": { 113 123 "sha256": "0gy4n86q7b5qmy609ncibp94v1b3z9msc0129572qz2zyxfqxq3i", 114 124 "url": "https://github.com/ONLYOFFICE/onlyoffice-nextcloud/releases/download/v7.6.8/onlyoffice.tar.gz",
+1
pkgs/servers/nextcloud/packages/nextcloud-apps.json
··· 12 12 , "mail" 13 13 , "news" 14 14 , "notes" 15 + , "notify_push" 15 16 , "onlyoffice" 16 17 , "polls" 17 18 , "registration"
+2
pkgs/top-level/all-packages.nix
··· 10144 10144 10145 10145 nextcloud-news-updater = callPackage ../servers/nextcloud/news-updater.nix { }; 10146 10146 10147 + nextcloud-notify_push = callPackage ../servers/nextcloud/notify_push.nix { }; 10148 + 10147 10149 ndstool = callPackage ../tools/archivers/ndstool { }; 10148 10150 10149 10151 nfs-ganesha = callPackage ../servers/nfs-ganesha { };