this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

init: ulogger

+425
+117
hosts/profiles/ulogger-server/default.nix
··· 1 + { self, pkgs, config, lib, ... }: 2 + 3 + { 4 + services.postgresql = { 5 + ensureDatabases = [ "ulogger" ]; 6 + ensureUsers = [{ 7 + name = "ulogger"; 8 + ensurePermissions = { 9 + "DATABASE ulogger" = "ALL PRIVILEGES"; 10 + }; 11 + }]; 12 + }; 13 + 14 + services.ulogger = { 15 + enable = true; 16 + hostName = "tracks.mossnet.lan"; 17 + conf = '' 18 + <?php 19 + /* μlogger 20 + * 21 + * Copyright(C) 2017 Bartek Fabiszewski (www.fabiszewski.net) 22 + * 23 + * This is free software; you can redistribute it and/or modify it under 24 + * the terms of the GNU General Public License as published by 25 + * the Free Software Foundation; either version 3 of the License, or 26 + * (at your option) any later version. 27 + * 28 + * This program is distributed in the hope that it will be useful, but 29 + * WITHOUT ANY WARRANTY; without even the implied warranty of 30 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 31 + * General Public License for more details. 32 + * 33 + * You should have received a copy of the GNU General Public License 34 + * along with this program; if not, see <http://www.gnu.org/licenses/>. 35 + */ 36 + 37 + // This is default configuration file. 38 + // Copy it to config.php and customize 39 + 40 + // default map drawing framework 41 + // (gmaps = google maps, openlayers = openlayers/osm) 42 + //$mapapi = "gmaps"; 43 + $mapapi = "openlayers"; 44 + 45 + // openlayers additional map layers 46 + // OpenCycleMap (0 = no, 1 = yes) 47 + $layer_ocm = 1; 48 + // MapQuest-OSM (0 = no, 1 = yes) 49 + $layer_mq = 1; 50 + // osmapa.pl (0 = no, 1 = yes) 51 + $layer_osmapa = 1; 52 + // UMP (0 = no, 1 = yes) 53 + $layer_ump = 1; 54 + 55 + // default coordinates for initial map 56 + $init_latitude = 52.23; 57 + $init_longitude = 21.01; 58 + 59 + // you may set your google maps api key 60 + // this is not obligatory by now 61 + //$gkey = ""; 62 + 63 + // MySQL config 64 + $dbhost = "localhost"; // mysql host, eg. localhost 65 + $dbuser = "ulogger"; // database user 66 + $dbpass = ""; // database pass 67 + $dbname = "ulogger"; // database name 68 + $dbprefix = ""; // optional table names prefix, eg. "ulogger_" 69 + 70 + // other 71 + // require login/password authentication 72 + // (0 = no, 1 = yes) 73 + $require_authentication = 0; 74 + 75 + // all users tracks are visible to authenticated user 76 + // (0 = no, 1 = yes) 77 + $public_tracks = 0; 78 + 79 + // admin user, who 80 + // - can add new users 81 + // - can edit all tracks, users 82 + // - has access to all users locations 83 + // none if empty 84 + $admin_user = "admin"; 85 + 86 + // miniumum required length of user password 87 + $pass_lenmin = 12; 88 + 89 + // required strength of user password 90 + // 0 = no requirements, 91 + // 1 = require mixed case letters (lower and upper), 92 + // 2 = require mixed case and numbers, 93 + // 3 = require mixed case, numbers and non-alphanumeric characters 94 + $pass_strength = 0; 95 + 96 + // Default interval in seconds for live auto reload 97 + $interval = 10; 98 + 99 + // Default language 100 + // (en, pl, de, hu) 101 + $lang = "en"; 102 + //$lang = "pl"; 103 + //$lang = "de"; 104 + //$lang = "hu"; 105 + //$lang = "fr"; 106 + //$lang = "it"; 107 + 108 + // units 109 + // (metric, imperial) 110 + $units = "metric"; 111 + //$units = "imperial"; 112 + 113 + ?> 114 + 115 + ''; 116 + }; 117 + }
+282
modules/nixos/ulogger.nix
··· 1 + { config, options, lib, pkgs, ... }: 2 + 3 + with lib; 4 + let 5 + cfg = config.services.ulogger; 6 + 7 + poolName = "ulogger"; 8 + 9 + configFile = pkgs.writeTextFile { 10 + name = "ulogger-config"; 11 + text = cfg.conf; 12 + destination = "config.php"; 13 + }; 14 + 15 + appDir = pkgs.buildEnv { 16 + name = "ulogger-app-dir"; 17 + ignoreCollisions = true; 18 + checkCollisionContents = false; 19 + paths = [ configFile "${cfg.package}/app" ]; 20 + }; 21 + 22 + in 23 + { 24 + options = { 25 + services.ulogger = { 26 + enable = mkEnableOption "ulogger"; 27 + user = mkOption { 28 + type = types.str; 29 + default = "nginx"; 30 + description = '' 31 + User account under which both the update daemon and the web-application run. 32 + ''; 33 + }; 34 + dataDir = mkOption { 35 + type = types.path; 36 + default = "/var/lib/ulogger"; 37 + description = '' 38 + Data directory. 39 + ''; 40 + }; 41 + 42 + package = mkOption { 43 + type = types.package; 44 + default = pkgs.ulogger-server; 45 + description = '' 46 + ulogger-server package to use. 47 + ''; 48 + }; 49 + 50 + hostName = mkOption { 51 + type = types.str; 52 + description = '' 53 + Name of the nginx virtualhost to use and setup. 54 + ''; 55 + }; 56 + 57 + poolConfig = mkOption { 58 + type = types.lines; 59 + default = '' 60 + pm = dynamic 61 + pm.max_children = 75 62 + pm.start_servers = 1 63 + pm.min_spare_servers = 1 64 + pm.max_spare_servers = 20 65 + pm.max_requests = 500 66 + catch_workers_output = 1 67 + ''; 68 + description = '' 69 + Options for uloggers's PHP pool. See the documentation on <literal>php-fpm.conf</literal> for details on configuration directives. 70 + ''; 71 + }; 72 + 73 + conf = mkOption { 74 + type = types.str; 75 + default = '' 76 + <?php 77 + /* μlogger 78 + * 79 + * Copyright(C) 2017 Bartek Fabiszewski (www.fabiszewski.net) 80 + * 81 + * This is free software; you can redistribute it and/or modify it under 82 + * the terms of the GNU General Public License as published by 83 + * the Free Software Foundation; either version 3 of the License, or 84 + * (at your option) any later version. 85 + * 86 + * This program is distributed in the hope that it will be useful, but 87 + * WITHOUT ANY WARRANTY; without even the implied warranty of 88 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 89 + * General Public License for more details. 90 + * 91 + * You should have received a copy of the GNU General Public License 92 + * along with this program; if not, see <http://www.gnu.org/licenses/>. 93 + */ 94 + 95 + // This is default configuration file. 96 + // Copy it to config.php and customize 97 + 98 + // default map drawing framework 99 + // (gmaps = google maps, openlayers = openlayers/osm) 100 + //$mapapi = "gmaps"; 101 + $mapapi = "openlayers"; 102 + 103 + // openlayers additional map layers 104 + // OpenCycleMap (0 = no, 1 = yes) 105 + $layer_ocm = 1; 106 + // MapQuest-OSM (0 = no, 1 = yes) 107 + $layer_mq = 1; 108 + // osmapa.pl (0 = no, 1 = yes) 109 + $layer_osmapa = 1; 110 + // UMP (0 = no, 1 = yes) 111 + $layer_ump = 1; 112 + 113 + // default coordinates for initial map 114 + $init_latitude = 52.23; 115 + $init_longitude = 21.01; 116 + 117 + // you may set your google maps api key 118 + // this is not obligatory by now 119 + //$gkey = ""; 120 + 121 + // MySQL config 122 + $dbhost = ""; // mysql host, eg. localhost 123 + $dbuser = ""; // database user 124 + $dbpass = ""; // database pass 125 + $dbname = ""; // database name 126 + $dbprefix = ""; // optional table names prefix, eg. "ulogger_" 127 + 128 + // other 129 + // require login/password authentication 130 + // (0 = no, 1 = yes) 131 + $require_authentication = 1; 132 + 133 + // all users tracks are visible to authenticated user 134 + // (0 = no, 1 = yes) 135 + $public_tracks = 0; 136 + 137 + // admin user, who 138 + // - can add new users 139 + // - can edit all tracks, users 140 + // - has access to all users locations 141 + // none if empty 142 + $admin_user = ""; 143 + 144 + // miniumum required length of user password 145 + $pass_lenmin = 12; 146 + 147 + // required strength of user password 148 + // 0 = no requirements, 149 + // 1 = require mixed case letters (lower and upper), 150 + // 2 = require mixed case and numbers, 151 + // 3 = require mixed case, numbers and non-alphanumeric characters 152 + $pass_strength = 2; 153 + 154 + // Default interval in seconds for live auto reload 155 + $interval = 10; 156 + 157 + // Default language 158 + // (en, pl, de, hu) 159 + $lang = "en"; 160 + //$lang = "pl"; 161 + //$lang = "de"; 162 + //$lang = "hu"; 163 + //$lang = "fr"; 164 + //$lang = "it"; 165 + 166 + // units 167 + // (metric, imperial) 168 + $units = "metric"; 169 + //$units = "imperial"; 170 + 171 + ?> 172 + ''; 173 + description = '' 174 + Contents of the ulogger configuration file (config.php) 175 + ''; 176 + }; 177 + }; 178 + }; 179 + 180 + 181 + config = mkIf cfg.enable { 182 + services.phpfpm.pools."${poolName}" = { 183 + user = "${cfg.user}"; 184 + group = "nginx"; 185 + phpPackage = pkgs.php; 186 + settings = { 187 + "listen.owner" = "nginx"; 188 + "listen.group" = "nginx"; 189 + "listen.mode" = "0600"; 190 + "user" = "${cfg.user}"; 191 + "group" = "nginx"; 192 + "pm" = "dynamic"; 193 + "pm.max_children" = "75"; 194 + "pm.min_spare_servers" = "5"; 195 + "pm.max_spare_servers" = "20"; 196 + "pm.max_requests" = "10"; 197 + "catch_workers_output" = "1"; 198 + "php_admin_value[error_log]" = "/var/log/nginx/${poolName}-phpfpm-error.log"; 199 + }; 200 + }; 201 + services.phpfpm.phpOptions = '' 202 + max_execution_time = 120 203 + ''; 204 + 205 + services.nginx.enable = mkDefault true; 206 + 207 + services.nginx.virtualHosts."${cfg.hostName}" = { 208 + enableACME = false; 209 + forceSSL = false; 210 + root = "${cfg.package}"; 211 + 212 + extraConfig = '' 213 + add_header X-Frame-Options SAMEORIGIN; 214 + add_header X-Content-Type-Options nosniff; 215 + add_header X-XSS-Protection "1; mode=block"; 216 + ''; 217 + 218 + locations."/" = { 219 + extraConfig = '' 220 + ''; 221 + }; 222 + 223 + locations."~ ^/app\\.php(/|$)" = { 224 + extraConfig = '' 225 + fastcgi_pass unix:${config.services.phpfpm.pools."${poolName}".socket}; 226 + include ${pkgs.nginx}/conf/fastcgi_params; 227 + include ${pkgs.nginx}/conf/fastcgi.conf; 228 + fastcgi_index ${conf.pkg}/index.php; 229 + ''; 230 + }; 231 + 232 + systemd.services.ulogger-install = { 233 + description = "ulogger install service"; 234 + wantedBy = [ "multi-user.target" ]; 235 + before = [ "phpfpm-ulogger.service" ]; 236 + after = [ "mysql.service" "postgresql.service" ]; 237 + path = with pkgs; [ coreutils php phpPackages.composer ]; 238 + 239 + serviceConfig = { 240 + User = cfg.user; 241 + Type = "oneshot"; 242 + RemainAfterExit = "yes"; 243 + PermissionsStartOnly = true; 244 + }; 245 + 246 + preStart = '' 247 + mkdir -p "${cfg.dataDir}" 248 + mkdir -p "${cfg.dataDir}/uploads" 249 + chown ${cfg.user}:nginx "${cfg.dataDir}" 250 + ''; 251 + 252 + environment = { 253 + ULOGGER_ADMIN_USER = "admin"; 254 + ULOGGER_ADMIN_PASSWORD = "admin"; 255 + }; 256 + 257 + script = '' 258 + echo "Setting up wallabag files in ${cfg.dataDir} ..." 259 + cd "${cfg.dataDir}" 260 + 261 + rm -rf var/cache/* 262 + rm -f app 263 + ln -sf ${appDir} app 264 + ln -sf ${cfg.package}/composer.{json,lock} . 265 + 266 + if [ ! -f installed ]; then 267 + echo "Install file not found, installing ..." 268 + # TODO, taken from https://github.com/bfabiszewski/ulogger-server/blob/master/.docker/init.sh 269 + su postgres -c "psql -U ulogger < ${appDir}/scripts/ulogger.pgsql" 270 + su postgres -c "psql -d ulogger -c \"INSERT INTO users (login, password, admin) VALUES ('$ULOGGER_ADMIN_USER', '$ULOGGER_ADMIN_PASSWORD', TRUE)\"" 271 + touch installed 272 + fi 273 + ''; 274 + }; 275 + }; 276 + 277 + meta = with stdenv.lib; { 278 + maintainers = with maintainers; [ nadrieril ]; 279 + }; 280 + 281 + }; 282 + }
+26
pkgs/ulogger.nix
··· 1 + { lib, stdenv, fetchurl, fetchpatch }: 2 + 3 + let 4 + pname = "ulogger-server"; 5 + version = "1.1"; 6 + in 7 + stdenv.mkDerivation { 8 + inherit pname version; 9 + 10 + # Release tarball includes vendored files 11 + src = fetchurl { 12 + url = "https://github.com/bfabiszewski/ulogger-server/archive/refs/tags/v${version}.tar.gz"; 13 + hash = ""; 14 + }; 15 + 16 + dontBuild = true; 17 + 18 + installPhase = '' 19 + runHook preInstall 20 + rm -R .docker 21 + rm -R .tests 22 + mkdir $out 23 + cp -R * $out/ 24 + runHook postInstall 25 + ''; 26 + }