Home : Make services switch-independent.

This commit is contained in:
Dmitry Voronin 2024-05-10 20:34:15 +03:00
parent 0fd72bc32c
commit 6236a8e65b
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
6 changed files with 17 additions and 13 deletions

View file

@ -74,7 +74,7 @@
echo "Backup : Complete ''${bupsize}." echo "Backup : Complete ''${bupsize}."
''; '';
in { in {
systemd.services.backup = { systemd.services.backup = util.mkStaticSystemdService {
enable = true; enable = true;
description = "Home system backup."; description = "Home system backup.";
serviceConfig = { serviceConfig = {

View file

@ -4,7 +4,7 @@
docker exec -u 33 cloud php -f /var/www/html/cron.php || notify 'Nextcloud : Failed to run cron.' docker exec -u 33 cloud php -f /var/www/html/cron.php || notify 'Nextcloud : Failed to run cron.'
''; '';
in { in {
systemd.services.nextcloud = { systemd.services.nextcloud = util.mkStaticSystemdService {
enable = true; enable = true;
description = "Nextcloud worker."; description = "Nextcloud worker.";
serviceConfig = { serviceConfig = {

View file

@ -1,11 +1,11 @@
{ pkgs, ... }: let { pkgs, util, ... }: let
script = '' script = ''
in="/storage/hot/docker/cloud/data/data/cakee/files/media/photo/" in="/storage/hot/docker/cloud/data/data/cakee/files/media/photo/"
out="/storage/cold_1/backup/tmp/photo/" out="/storage/cold_1/backup/tmp/photo/"
docker run --rm -v "''${in}":/in -v "''${out}":/out voronind.com/photoprocess:latest docker run --rm -v "''${in}":/in -v "''${out}":/out voronind.com/photoprocess:latest
''; '';
in { in {
systemd.services.photos_process = { systemd.services.photos_process = util.mkStaticSystemdService {
enable = true; enable = true;
description = "Process uploaded photos."; description = "Process uploaded photos.";
serviceConfig = { serviceConfig = {

View file

@ -1,10 +1,10 @@
{ pkgs, ... }: let { pkgs, util, ... }: let
script = '' script = ''
music="/storage/hot/media/music/" music="/storage/hot/media/music/"
docker run --rm -v "''${music}":/music voronind.com/yamusic:latest docker run --rm -v "''${music}":/music voronind.com/yamusic:latest
''; '';
in { in {
systemd.services.yandex_music = { systemd.services.yandex_music = util.mkStaticSystemdService {
enable = true; enable = true;
description = "Sync music from Yandex.Music."; description = "Sync music from Yandex.Music.";
serviceConfig = { serviceConfig = {

View file

@ -1,11 +1,8 @@
{ const, pkgs, lib, secret, ... }: { { const, pkgs, lib, secret, util, ... }: {
systemd.services.autoupdate = { systemd.services.autoupdate = util.mkStaticSystemdService {
enable = true; enable = true;
description = "Signed system auto-update."; description = "Signed system auto-update.";
restartIfChanged = false;
serviceConfig.Type = "oneshot"; serviceConfig.Type = "oneshot";
stopIfChanged = false;
unitConfig.X-StopOnRemoval = false;
path = with pkgs; [ path = with pkgs; [
bash bash
git git

View file

@ -14,4 +14,11 @@
catText = files: args: builtins.foldl' (acc: mod: catText = files: args: builtins.foldl' (acc: mod:
acc + trimTabs ((import mod args).text) acc + trimTabs ((import mod args).text)
) "" files; ) "" files;
# Systemd service that does not restart with system switch.
mkStaticSystemdService = params: params // {
restartIfChanged = false;
stopIfChanged = false;
unitConfig.X-StopOnRemoval = false;
};
} }