Merge pull request 'shaarli-api' (#4) from shaarli-api into devos

Reviewed-on: aynish/nix-garden#4
This commit is contained in:
Anish Lakhwara 2022-06-18 08:27:54 +00:00
commit e8151a418c
3 changed files with 32 additions and 31 deletions

View file

@ -1,5 +1,5 @@
{ pkgs, config, ... }: { pkgs, config, ... }:
let let
dataDir = "/var/www/shaarli-config"; dataDir = "/var/www/shaarli-config";
name = "shaarli"; name = "shaarli";
in in
@ -12,14 +12,15 @@ in
enableACME = false; enableACME = false;
root = "${dataDir}"; root = "${dataDir}";
extraConfig = '' extraConfig = ''
index index.php; index index.php;
'';
locations = {
"/".extraConfig = ''
try_files $uri $uri/ index.php$is_args$args;
''; '';
locations = {
"/".extraConfig = ''
index index.php;
try_files _ /index.php$is_args$args;
'';
"~ (index)\\.php$".extraConfig = '' "~ (index)\\.php$".extraConfig = ''
try_files $uri =404; try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_split_path_info ^(.+\.php)(/.+)$;
@ -74,39 +75,39 @@ in
user = "nginx"; user = "nginx";
group = "nginx"; group = "nginx";
#listen = "/run/phpfpm/php.sock"; #listen = "/run/phpfpm/php.sock";
settings = { settings = {
"listen.owner" = "nginx"; "listen.owner" = "nginx";
"listen.group" = "nginx"; "listen.group" = "nginx";
"user" = "nginx"; "user" = "nginx";
"pm" = "dynamic"; "pm" = "dynamic";
"pm.max_children" = "4"; "pm.max_children" = "4";
"pm.min_spare_servers" = "1"; "pm.min_spare_servers" = "1";
"pm.max_spare_servers" = "4"; "pm.max_spare_servers" = "4";
"pm.max_requests" = "32"; "pm.max_requests" = "32";
"catch_workers_output" = "1"; "catch_workers_output" = "1";
"php_admin_value[error_log]" = "/var/log/nginx/${name}-phpfpm-error.log"; "php_admin_value[error_log]" = "/var/log/nginx/${name}-phpfpm-error.log";
}; };
}; };
}; };
}; };
users.extraUsers."${name}" = { group = "${name}"; }; users.extraUsers."${name}" = { group = "${name}"; };
users.extraGroups."${name}" = { }; users.extraGroups."${name}" = { };
users.users.shaarli.isSystemUser = true; users.users.shaarli.isSystemUser = true;
systemd.services.shaarli-install = { systemd.services.shaarli-install = {
serviceConfig.Type = "oneshot"; serviceConfig.Type = "oneshot";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
script = '' script = ''
if [ ! -d "${dataDir}" ]; then if [ ! -d "${dataDir}" ]; then
#cp -R ${pkgs.shaarli}/data.orig/.htaccess ${dataDir}/cache/ #cp -R ${pkgs.shaarli}/data.orig/.htaccess ${dataDir}/cache/
#cp -R ${pkgs.shaarli}/data.orig/.htaccess ${dataDir}/data/ #cp -R ${pkgs.shaarli}/data.orig/.htaccess ${dataDir}/data/
#cp -R ${pkgs.shaarli}/data.orig/.htaccess ${dataDir}/pagecache/ #cp -R ${pkgs.shaarli}/data.orig/.htaccess ${dataDir}/pagecache/
#cp -R ${pkgs.shaarli}/data.orig/.htaccess ${dataDir}/tmp/ #cp -R ${pkgs.shaarli}/data.orig/.htaccess ${dataDir}/tmp/
mkdir -p ${dataDir}/{cache,data,pagecache,tmp} mkdir -p ${dataDir}/{cache,data,pagecache,tmp}
ln -s ${pkgs.shaarli}/* ${dataDir} ln -s ${pkgs.shaarli}/* ${dataDir}
fi fi
chown -Rc nginx:nginx ${dataDir} chown -Rc nginx:nginx ${dataDir}
find ${dataDir} -type d ! -perm 0700 -exec chmod 0700 {} \; -exec chmod g-s {} \; find ${dataDir} -type d ! -perm 0700 -exec chmod 0700 {} \; -exec chmod g-s {} \;
find ${dataDir} -type f ! -perm 0600 -exec chmod 0600 {} \; find ${dataDir} -type f ! -perm 0600 -exec chmod 0600 {} \;
''; '';
}; };
# TODO: Write the configuration file here? # TODO: Write the configuration file here?