working ulogger!

This commit is contained in:
Anish Lakhwara 2023-04-23 21:02:59 +10:00
parent 042c8dcec9
commit a68dd78843
9 changed files with 90 additions and 140 deletions

View file

@ -32,11 +32,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1680877018, "lastModified": 1682226636,
"narHash": "sha256-jhd0G+LWF79L2m8dME55pBBoDY1FBenZ75WgKRA/Quk=", "narHash": "sha256-fmETHfUtQ5zOVr/4MT5wE7eNALCSQCnEUYZYmV3UEwg=",
"ref": "main", "ref": "main",
"rev": "15db0ea5c19c70bce8504290724661586dc94006", "rev": "095d14ff2469c8f3de7cbf45d229c0f46a733aae",
"revCount": 71, "revCount": 77,
"type": "git", "type": "git",
"url": "ssh://gitea@git.sealight.xyz/aynish/basant" "url": "ssh://gitea@git.sealight.xyz/aynish/basant"
}, },
@ -403,11 +403,11 @@
"vimwiki-cli": "vimwiki-cli" "vimwiki-cli": "vimwiki-cli"
}, },
"locked": { "locked": {
"lastModified": 1681311621, "lastModified": 1682222403,
"narHash": "sha256-EQo+NdexCl+7I8vTsXpPvLHKJNU7dd4nRE2PqEoGJCA=", "narHash": "sha256-mLheDjdJ9TkmrR62FlPQtrYxKc/PJt4lhNBi5s9A97U=",
"ref": "main", "ref": "main",
"rev": "dfb078dbd8eb679e8f133afb4b6fec0f9e229b6c", "rev": "01fae2ec19d01256c17b58dcdc8ff43d717ec9da",
"revCount": 607, "revCount": 640,
"type": "git", "type": "git",
"url": "ssh://gitea@git.sealight.xyz/aynish/kitaab" "url": "ssh://gitea@git.sealight.xyz/aynish/kitaab"
}, },

View file

@ -83,6 +83,9 @@
unstable = unstable.legacyPackages.${prev.system}; unstable = unstable.legacyPackages.${prev.system};
deploy = deploy-rs.packages.${prev.system}.deploy-rs; deploy = deploy-rs.packages.${prev.system}.deploy-rs;
}; };
llamaOverlay = final: prev: {
llama = llamacpp.packages.${prev.system}.default;
};
nixpkgsFor = forAllSystems (system: import nixpkgs { nixpkgsFor = forAllSystems (system: import nixpkgs {
inherit system; inherit system;
@ -222,6 +225,7 @@
self.nixosModules.wireguard self.nixosModules.wireguard
self.nixosModules.wallabag self.nixosModules.wallabag
self.nixosModules.gonic self.nixosModules.gonic
self.nixosModules.ulogger-server
# grasp.nixosModule # grasp.nixosModule
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
{ {

View file

@ -22,6 +22,7 @@
# ../profiles/archivebox # ../profiles/archivebox
../profiles/woodpecker-agent ../profiles/woodpecker-agent
../profiles/jellyfin ../profiles/jellyfin
../profiles/ulogger-server
]; ];
# Something broke when manually updating grasp... # Something broke when manually updating grasp...

View file

@ -26,6 +26,7 @@
"paper.mossnet.lan" "paper.mossnet.lan"
"cal.mossnet.lan" "cal.mossnet.lan"
"archive.mossnet.lan" "archive.mossnet.lan"
"tracks.mossnet.lan"
]; ];
"192.168.1.226" = [ "192.168.1.226" = [
"df-web.lan" "df-web.lan"

View file

@ -2,6 +2,7 @@
{ {
services.postgresql = { services.postgresql = {
enable = true;
ensureDatabases = [ "ulogger" ]; ensureDatabases = [ "ulogger" ];
ensureUsers = [{ ensureUsers = [{
name = "ulogger"; name = "ulogger";
@ -14,6 +15,7 @@
services.ulogger = { services.ulogger = {
enable = true; enable = true;
hostName = "tracks.mossnet.lan"; hostName = "tracks.mossnet.lan";
user = "ulogger";
conf = '' conf = ''
<?php <?php
/* μlogger /* μlogger
@ -37,81 +39,25 @@
// This is default configuration file. // This is default configuration file.
// Copy it to config.php and customize // Copy it to config.php and customize
// default map drawing framework // Database config
// (gmaps = google maps, openlayers = openlayers/osm)
//$mapapi = "gmaps";
$mapapi = "openlayers";
// openlayers additional map layers // PDO data source name, eg.:
// OpenCycleMap (0 = no, 1 = yes) // mysql:host=localhost;port=3307;dbname=ulogger;charset=utf8
$layer_ocm = 1; // mysql:unix_socket=/path/to/mysql.sock;dbname=ulogger;charset=utf8
// MapQuest-OSM (0 = no, 1 = yes) // pgsql:host=localhost;port=5432;dbname=ulogger
$layer_mq = 1; // sqlite:/path/to/ulogger.db
// osmapa.pl (0 = no, 1 = yes) $dbdsn = "pgsql:host=/run/postgresql/;port=5432;dbname=ulogger";
$layer_osmapa = 1;
// UMP (0 = no, 1 = yes)
$layer_ump = 1;
// default coordinates for initial map // Database user name
$init_latitude = 52.23; $dbuser = "ulogger";
$init_longitude = 21.01;
// you may set your google maps api key // Database user password
// this is not obligatory by now $dbpass = "";
//$gkey = "";
// MySQL config // Optional table names prefix, eg. "ulogger_"
$dbhost = "localhost"; // mysql host, eg. localhost $dbprefix = "";
$dbuser = "ulogger"; // database user
$dbpass = ""; // database pass
$dbname = "ulogger"; // database name
$dbprefix = ""; // optional table names prefix, eg. "ulogger_"
// other
// require login/password authentication
// (0 = no, 1 = yes)
$require_authentication = 0;
// all users tracks are visible to authenticated user
// (0 = no, 1 = yes)
$public_tracks = 0;
// admin user, who
// - can add new users
// - can edit all tracks, users
// - has access to all users locations
// none if empty
$admin_user = "admin";
// miniumum required length of user password
$pass_lenmin = 12;
// required strength of user password
// 0 = no requirements,
// 1 = require mixed case letters (lower and upper),
// 2 = require mixed case and numbers,
// 3 = require mixed case, numbers and non-alphanumeric characters
$pass_strength = 0;
// Default interval in seconds for live auto reload
$interval = 10;
// Default language
// (en, pl, de, hu)
$lang = "en";
//$lang = "pl";
//$lang = "de";
//$lang = "hu";
//$lang = "fr";
//$lang = "it";
// units
// (metric, imperial)
$units = "metric";
//$units = "imperial";
?> ?>
''; '';
}; };
} }

View file

@ -8,4 +8,5 @@
hesienbridge = import ./heisenbridge.nix; hesienbridge = import ./heisenbridge.nix;
wireguard = import ./wireguard.nix; wireguard = import ./wireguard.nix;
backup = import ./backup.nix; backup = import ./backup.nix;
ulogger-server = import ./ulogger.nix;
} }

View file

@ -9,14 +9,7 @@ let
configFile = pkgs.writeTextFile { configFile = pkgs.writeTextFile {
name = "ulogger-config"; name = "ulogger-config";
text = cfg.conf; text = cfg.conf;
destination = "config.php"; destination = "/config.php";
};
appDir = pkgs.buildEnv {
name = "ulogger-app-dir";
ignoreCollisions = true;
checkCollisionContents = false;
paths = [ configFile "${cfg.package}/app" ];
}; };
in in
@ -207,34 +200,41 @@ in
services.nginx.virtualHosts."${cfg.hostName}" = { services.nginx.virtualHosts."${cfg.hostName}" = {
enableACME = false; enableACME = false;
forceSSL = false; forceSSL = false;
root = "${cfg.package}"; root = "${cfg.dataDir}";
extraConfig = '' extraConfig = ''
index index.php;
add_header X-Frame-Options SAMEORIGIN; add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff; add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block"; add_header X-XSS-Protection "1; mode=block";
''; '';
locations."/" = { locations."~ .php$" = {
extraConfig = ''
'';
};
locations."~ ^/app\\.php(/|$)" = {
extraConfig = '' extraConfig = ''
fastcgi_pass unix:${config.services.phpfpm.pools."${poolName}".socket}; fastcgi_pass unix:${config.services.phpfpm.pools."${poolName}".socket};
include ${pkgs.nginx}/conf/fastcgi_params; include ${pkgs.nginx}/conf/fastcgi_params;
include ${pkgs.nginx}/conf/fastcgi.conf; include ${pkgs.nginx}/conf/fastcgi.conf;
fastcgi_index ${conf.pkg}/index.php; fastcgi_param DOCUMENT_ROOT ${cfg.dataDir};
fastcgi_param SCRIPT_FILENAME ${cfg.dataDir}/$fastcgi_script_name;
fastcgi_index index.php;
''; '';
}; };
};
users.users = {
${cfg.user} = {
group = "nginx";
description = "ulogger server user";
isSystemUser = true;
};
};
systemd.services.ulogger-install = { systemd.services.ulogger-install = {
description = "ulogger install service"; description = "ulogger install service";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
before = [ "phpfpm-ulogger.service" ]; before = [ "phpfpm-ulogger.service" ];
after = [ "mysql.service" "postgresql.service" ]; after = [ "mysql.service" "postgresql.service" ];
path = with pkgs; [ coreutils php phpPackages.composer ]; path = with pkgs; [ coreutils php phpPackages.composer postgresql ];
serviceConfig = { serviceConfig = {
User = cfg.user; User = cfg.user;
@ -246,28 +246,25 @@ in
preStart = '' preStart = ''
mkdir -p "${cfg.dataDir}" mkdir -p "${cfg.dataDir}"
mkdir -p "${cfg.dataDir}/uploads" mkdir -p "${cfg.dataDir}/uploads"
chown ${cfg.user}:nginx "${cfg.dataDir}" chown -R ${cfg.user}:nginx "${cfg.dataDir}"
''; '';
environment = { environment = {
ULOGGER_ADMIN_USER = "admin"; ULOGGER_ADMIN_USER = "admin";
ULOGGER_ADMIN_PASSWORD = "admin"; ULOGGER_ADMIN_PASSWORD = "\$2y\$10\$7OvZrKgonVZM9lkzrTbiou.CVhO3HjPk5y0W9L68fVwPs/osBRIMq"; # hashed "admin"
}; };
script = '' script = ''
echo "Setting up wallabag files in ${cfg.dataDir} ..." echo "Setting up ulogger-server files in ${cfg.dataDir} ..."
cd "${cfg.dataDir}" cd "${cfg.dataDir}"
rm -rf var/cache/* cp -R ${cfg.package}/* ./
rm -f app cp ${configFile}/config.php ./
ln -sf ${appDir} app
ln -sf ${cfg.package}/composer.{json,lock} .
if [ ! -f installed ]; then if [ ! -f installed ]; then
echo "Install file not found, installing ..." echo "Install file not found, installing ..."
# TODO, taken from https://github.com/bfabiszewski/ulogger-server/blob/master/.docker/init.sh psql -U ulogger < ${cfg.package}/scripts/ulogger.pgsql
su postgres -c "psql -U ulogger < ${appDir}/scripts/ulogger.pgsql" psql -d ulogger -c "INSERT INTO users (login, password, admin) VALUES ('$ULOGGER_ADMIN_USER', '$ULOGGER_ADMIN_PASSWORD', TRUE)"
su postgres -c "psql -d ulogger -c \"INSERT INTO users (login, password, admin) VALUES ('$ULOGGER_ADMIN_USER', '$ULOGGER_ADMIN_PASSWORD', TRUE)\""
touch installed touch installed
fi fi
''; '';
@ -277,6 +274,4 @@ in
meta = with stdenv.lib; { meta = with stdenv.lib; {
maintainers = with maintainers; [ nadrieril ]; maintainers = with maintainers; [ nadrieril ];
}; };
};
} }

View file

@ -7,4 +7,5 @@
fennel-ls = pkgs.callPackage ./fennel-ls.nix { }; fennel-ls = pkgs.callPackage ./fennel-ls.nix { };
kobopatch = pkgs.callPackage ./kobopatch.nix { }; kobopatch = pkgs.callPackage ./kobopatch.nix { };
my-mautrix-discord = pkgs.callPackage ./mautrix-discord.nix { }; # Handled by matrix-appservices input my-mautrix-discord = pkgs.callPackage ./mautrix-discord.nix { }; # Handled by matrix-appservices input
ulogger-server = pkgs.callPackage ./ulogger.nix { };
} }

View file

@ -10,7 +10,7 @@ stdenv.mkDerivation {
# Release tarball includes vendored files # Release tarball includes vendored files
src = fetchurl { src = fetchurl {
url = "https://github.com/bfabiszewski/ulogger-server/archive/refs/tags/v${version}.tar.gz"; url = "https://github.com/bfabiszewski/ulogger-server/archive/refs/tags/v${version}.tar.gz";
hash = ""; hash = "sha256-+ZyNA5+lhD6DKXIWNdlLA7ArtV1F61H3UmMyRVRdws0=";
}; };
dontBuild = true; dontBuild = true;
@ -19,6 +19,7 @@ stdenv.mkDerivation {
runHook preInstall runHook preInstall
rm -R .docker rm -R .docker
rm -R .tests rm -R .tests
rm -R uploads/
mkdir $out mkdir $out
cp -R * $out/ cp -R * $out/
runHook postInstall runHook postInstall