mirror of
https://codeberg.org/privacy1st/nix-git
synced 2024-11-22 22:09:34 +01:00
55 lines
1.4 KiB
Nix
55 lines
1.4 KiB
Nix
{ config, pkgs, ... }:
|
|
{
|
|
imports = [
|
|
./syncthing.nix
|
|
];
|
|
|
|
# Update and start Jinja-Compose project
|
|
# during boot and after every 30 minutes.
|
|
# To view the log, run
|
|
# journalctl -b -u Jinja-Compose -f
|
|
#
|
|
systemd.timers."Jinja-Compose" = {
|
|
wantedBy = [ "timers.target" ];
|
|
partOf = [ "Jinja-Compose.service" ];
|
|
timerConfig = {
|
|
OnBootSec = "0m";
|
|
OnUnitInactiveSec = "30m";
|
|
|
|
AccuracySec = "1m";
|
|
RandomizedDelaySec = "1m";
|
|
};
|
|
};
|
|
# TODO: Add shutdown script (./docker-compose down).
|
|
systemd.services."Jinja-Compose" = {
|
|
description = "Update and start Jinja-Compose project";
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
PrivateTmp = true;
|
|
User = "root";
|
|
};
|
|
path = with pkgs; [
|
|
# The `docker-compose` helper script is written in `bash` (!)
|
|
bash
|
|
docker
|
|
];
|
|
script = ''
|
|
set -eu -o pipefail
|
|
|
|
# We use
|
|
# 2> >(sed 's/^/<3> /' >&2)
|
|
# to prefix each line of stderr with
|
|
# "<3> "
|
|
# Source: https://superuser.com/a/882025/919675
|
|
#
|
|
# With this prefix, the stderr output is treated as error messages by systemd.
|
|
# See https://www.freedesktop.org/software/systemd/man/latest/sd-daemon.html
|
|
# They can be viewed with
|
|
# journalctl -b -u Jinja-Compose.service
|
|
|
|
/jc-config/docker-compose pull 2> >(sed 's/^/<3> /' >&2)
|
|
/jc-config/docker-compose up -d --wait 2> >(sed 's/^/<3> /' >&2)
|
|
'';
|
|
};
|
|
}
|