1
0
Fork 0

make documentRoot and argument for ttrss and simplify definition

This commit is contained in:
ibizaman 2022-05-15 00:44:06 -07:00
parent addd852c9b
commit e0c1af94da

View file

@ -2,87 +2,85 @@
, pkgs
, lib
}:
{ documentRoot
, user ? "http"
, group ? "http"
}:
{ TtrssPostgresDB
}:
let
asTtrssConfig = attrs: builtins.concatStringsSep "\n" (["<php"] ++ lib.attrsets.mapAttrsToList wrapPutenv attrs);
wrapPutenv = key: value: "putenv('TTRSS_${lib.toUpper key}=${value}')";
asTtrssConfig = attrs: builtins.concatStringsSep "\n" (
["<?php" ""]
++ lib.attrsets.mapAttrsToList wrapPutenv attrs
++ [""] # Needs a newline at the end
);
wrapPutenv = key: value: "putenv('TTRSS_${lib.toUpper key}=${value}');";
config = self_url_path: {
db_type = "pgsql";
db_host = TtrssPostgresDB.target.properties.hostname;
db_user = TtrssPostgresDB.postgresUsername;
db_name = TtrssPostgresDB.postgresDatabase;
db_pass = TtrssPostgresDB.postgresPassword;
db_port = builtins.toString TtrssPostgresDB.postgresPort;
self_url_path = self_url_path;
single_user_mode = "true";
simple_update_mode = "false";
php_executable = pkgs.php;
lock_directory = "/run/ttrss/lock";
cache_dir = "/run/ttrss/cache";
icons_dir = "feed-icons";
icons_url = "feed-icons";
auth_auto_create = "true";
auth_auto_login = "true";
force_article_purge = "0";
sphinx_server = "localhost:9312";
sphinx_index = "ttrss, delta";
enable_registration = "false";
reg_notify_address = "user@your.domain.dom";
reg_max_users = "10";
session_cookie_lifetime = "86400";
smtp_from_name = "Tiny Tiny RSS";
smtp_from_address = "noreply@tiserbox.com";
digest_subject = "[tt-rss] New headlines for last 24 hours";
check_for_updates = "true";
plugins = "auth_internal, note";
log_destination = "syslog";
};
outputDirs = [
config.cache_dir
config.lock_directory
];
in
stdenv.mkDerivation rec {
name = "ttrss";
src = pkgs.tt-rss;
buildCommand =
let
configFile = pkgs.writeText "config.php" (asTtrssConfig {
db_type = "pgsql";
db_host = TtrssPostgresDB.target.properties.hostname;
db_user = TtrssPostgresDB.postgresUsername;
db_name = TtrssPostgresDB.postgresDatabase;
db_pass = TtrssPostgresDB.postgresPassword;
db_port = builtins.toString TtrssPostgresDB.postgresPort;
self_url_path = "https://tt-rss.tiserbox.com/";
single_user_mode = "true";
simple_update_mode = "false";
php_executable = pkgs.php;
lock_directory = "/usr/share/webapps/tt-rss/lock";
cache_dir = "/var/cache/tt-rss";
icons_dir = "feed-icons";
icons_url = "feed-icons";
auth_auto_create = "true";
auth_auto_login = "true";
force_article_purge = "0";
sphinx_server = "localhost:9312";
sphinx_index = "ttrss, delta";
enable_registration = "false";
reg_notify_address = "user@your.domain.dom";
reg_max_users = "10";
session_cookie_lifetime = "86400";
smtp_from_name = "Tiny Tiny RSS";
smtp_from_address = "noreply@tiserbox.com";
digest_subject = "[tt-rss] New headlines for last 24 hours";
check_for_updates = "true";
plugins = "auth_internal, note";
log_destination = "syslog";
});
configFile = pkgs.writeText "config.php" (asTtrssConfig (config "https://${name}.tiserbox.com/"));
in
''
mkdir -p $out/webapps/${name}
cp -ra $src/* $out/webapps/${name}
mkdir -p $out/${name}
cp -ra $src/* $out/${name}
cp ${configFile} $out/${name}/config.php
mkdir -p $out/etc/ttrss
cp ${configFile} $out/etc/ttrss/config.php
echo "/usr/share/webapps" > $out/.dysnomia-targetdir
# echo "http:http" > $out/.dysnomia-filesetowner
echo "${documentRoot}" > $out/.dysnomia-targetdir
echo "${user}:${group}" > $out/.dysnomia-filesetowner
cat > $out/.dysnomia-fileset <<FILESET
mkdir /etc/ttrss
symlink $out/etc/ttrss/config.php
target /etc/ttrss
mkdir /usr/share/webapps
symlink $out/webapps/ttrss
target /usr/share/webapps
symlink $out/${name}
target ${documentRoot}
FILESET
# mkdir -p $out/webapps/${name}
# cp -ra $src/* $out/webapps/${name}
# mkdir -p $out/etc/tt-rss/
# cp ${configFile} $out/etc/tt-rss/config.php
# mkdir -p $out/usr/share/webapps/tt-rss/
# cp -ra $src/* $out/usr/share/webapps/tt-rss/
'';
}