From f84c5387581418457179e7bdeac7c3f1fb7417aa Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Wed, 24 Jan 2024 21:49:14 +0300 Subject: [PATCH] Systemd : Migrate to Nix. --- .config/linux/nix/home/Backup.nix | 22 +++++++++++++++++++ .config/linux/nix/home/Nextcloud.nix | 22 +++++++++++++++++++ .config/linux/nix/home/PhotosProcess.nix | 22 +++++++++++++++++++ .config/linux/nix/home/YandexMusic.nix | 22 +++++++++++++++++++ .config/linux/systemd/home/Backup.service | 10 --------- .config/linux/systemd/home/Backup.timer | 9 -------- .config/linux/systemd/home/Nextcloud.service | 10 --------- .config/linux/systemd/home/Nextcloud.timer | 9 -------- .../linux/systemd/home/PhotosProcess.service | 10 --------- .../linux/systemd/home/PhotosProcess.timer | 9 -------- .../linux/systemd/home/YandexMusic.service | 10 --------- .config/linux/systemd/home/YandexMusic.timer | 9 -------- .../linux/systemd/power/Powerlimit.service | 12 ---------- .../linux/systemd/power/PowersaveAmd.service | 12 ---------- .../systemd/power/PowersaveIntel.service | 12 ---------- 15 files changed, 88 insertions(+), 112 deletions(-) create mode 100644 .config/linux/nix/home/Backup.nix create mode 100644 .config/linux/nix/home/Nextcloud.nix create mode 100644 .config/linux/nix/home/PhotosProcess.nix create mode 100644 .config/linux/nix/home/YandexMusic.nix delete mode 100644 .config/linux/systemd/home/Backup.service delete mode 100644 .config/linux/systemd/home/Backup.timer delete mode 100644 .config/linux/systemd/home/Nextcloud.service delete mode 100644 .config/linux/systemd/home/Nextcloud.timer delete mode 100644 .config/linux/systemd/home/PhotosProcess.service delete mode 100644 .config/linux/systemd/home/PhotosProcess.timer delete mode 100644 .config/linux/systemd/home/YandexMusic.service delete mode 100644 .config/linux/systemd/home/YandexMusic.timer delete mode 100644 .config/linux/systemd/power/Powerlimit.service delete mode 100644 .config/linux/systemd/power/PowersaveAmd.service delete mode 100644 .config/linux/systemd/power/PowersaveIntel.service diff --git a/.config/linux/nix/home/Backup.nix b/.config/linux/nix/home/Backup.nix new file mode 100644 index 0000000..9089896 --- /dev/null +++ b/.config/linux/nix/home/Backup.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: + +{ + systemd.services.backup = { + enable = true; + description = "Home system backup."; + serviceConfig = { + Type = "oneshot"; + ExecStart = "/root/app/bin/home/backup"; + }; + wantedBy = [ "multi-user.target" ]; + }; + + systemd.timers.backup = { + timerConfig = { + OnCalendar = "*-*-* 06:00:00"; + Persistent = true; + Unit = "backup.service"; + }; + wantedBy = [ "timers.target" ]; + }; +} diff --git a/.config/linux/nix/home/Nextcloud.nix b/.config/linux/nix/home/Nextcloud.nix new file mode 100644 index 0000000..9204244 --- /dev/null +++ b/.config/linux/nix/home/Nextcloud.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: + +{ + systemd.services.nextcloud = { + enable = true; + description = "Nextcloud worker."; + serviceConfig = { + Type = "oneshot"; + ExecStart = "/root/app/bin/home/nextcloud"; + }; + wantedBy = [ "multi-user.target" ]; + }; + + systemd.timers.nextcloud = { + timerConfig = { + OnCalendar = "hourly"; + Persistent = false; + Unit = "nextcloud.service"; + }; + wantedBy = [ "timers.target" ]; + }; +} diff --git a/.config/linux/nix/home/PhotosProcess.nix b/.config/linux/nix/home/PhotosProcess.nix new file mode 100644 index 0000000..4f9c4a0 --- /dev/null +++ b/.config/linux/nix/home/PhotosProcess.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: + +{ + systemd.services.photos_process = { + enable = true; + description = "Process uploaded photos."; + serviceConfig = { + Type = "oneshot"; + ExecStart = "/root/app/bin/home/photos_process"; + }; + wantedBy = [ "multi-user.target" ]; + }; + + systemd.timers.photos_process = { + timerConfig = { + OnCalendar = "daily"; + Persistent = true; + Unit = "photos_process.service"; + }; + wantedBy = [ "timers.target" ]; + }; +} diff --git a/.config/linux/nix/home/YandexMusic.nix b/.config/linux/nix/home/YandexMusic.nix new file mode 100644 index 0000000..09e5e50 --- /dev/null +++ b/.config/linux/nix/home/YandexMusic.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: + +{ + systemd.services.yandex_music = { + enable = true; + description = "Sync music from Yandex.Music."; + serviceConfig = { + Type = "oneshot"; + ExecStart = "/root/app/bin/home/yandex_music"; + }; + wantedBy = [ "multi-user.target" ]; + }; + + systemd.timers.yandex_music = { + timerConfig = { + OnCalendar = "daily"; + Persistent = true; + Unit = "yandex_music.service"; + }; + wantedBy = [ "timers.target" ]; + }; +} diff --git a/.config/linux/systemd/home/Backup.service b/.config/linux/systemd/home/Backup.service deleted file mode 100644 index 8157701..0000000 --- a/.config/linux/systemd/home/Backup.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=backup system - -[Service] -Type=oneshot -ExecStart=/var/roothome/app/bin/home/backup -#Restart=on-failure - -[Install] -WantedBy=multi-user.target diff --git a/.config/linux/systemd/home/Backup.timer b/.config/linux/systemd/home/Backup.timer deleted file mode 100644 index 9ccd0c1..0000000 --- a/.config/linux/systemd/home/Backup.timer +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=backup system - -[Timer] -OnCalendar=*-*-* 06:00:00 -Persistent=true - -[Install] -WantedBy=timers.target diff --git a/.config/linux/systemd/home/Nextcloud.service b/.config/linux/systemd/home/Nextcloud.service deleted file mode 100644 index 6e810b5..0000000 --- a/.config/linux/systemd/home/Nextcloud.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=nextcloud maintenance - -[Service] -Type=oneshot -ExecStart=/var/roothome/app/bin/home/nextcloud -#Restart=on-failure - -[Install] -WantedBy=multi-user.target diff --git a/.config/linux/systemd/home/Nextcloud.timer b/.config/linux/systemd/home/Nextcloud.timer deleted file mode 100644 index bad7977..0000000 --- a/.config/linux/systemd/home/Nextcloud.timer +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=nextcloud maintenance - -[Timer] -OnCalendar=hourly -Persistent=false - -[Install] -WantedBy=timers.target diff --git a/.config/linux/systemd/home/PhotosProcess.service b/.config/linux/systemd/home/PhotosProcess.service deleted file mode 100644 index 11b5436..0000000 --- a/.config/linux/systemd/home/PhotosProcess.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=photos processing - -[Service] -Type=oneshot -ExecStart=/var/roothome/app/bin/home/photos_process -#Restart=on-failure - -[Install] -WantedBy=multi-user.target diff --git a/.config/linux/systemd/home/PhotosProcess.timer b/.config/linux/systemd/home/PhotosProcess.timer deleted file mode 100644 index 8137033..0000000 --- a/.config/linux/systemd/home/PhotosProcess.timer +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=process photos - -[Timer] -OnCalendar=daily -Persistent=true - -[Install] -WantedBy=timers.target diff --git a/.config/linux/systemd/home/YandexMusic.service b/.config/linux/systemd/home/YandexMusic.service deleted file mode 100644 index 47e193f..0000000 --- a/.config/linux/systemd/home/YandexMusic.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=download music - -[Service] -Type=oneshot -ExecStart=/var/roothome/app/bin/home/yandex_music -#Restart=on-failure - -[Install] -WantedBy=multi-user.target diff --git a/.config/linux/systemd/home/YandexMusic.timer b/.config/linux/systemd/home/YandexMusic.timer deleted file mode 100644 index f381bcb..0000000 --- a/.config/linux/systemd/home/YandexMusic.timer +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=download music - -[Timer] -OnCalendar=daily -Persistent=true - -[Install] -WantedBy=timers.target diff --git a/.config/linux/systemd/power/Powerlimit.service b/.config/linux/systemd/power/Powerlimit.service deleted file mode 100644 index c322f99..0000000 --- a/.config/linux/systemd/power/Powerlimit.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=limit battery charge to 40-80 percent - -[Service] -Type=simple -RemainAfterExit=yes -ExecStart=/usr/bin/bash -c '/usr/bin/echo 40 > /sys/class/power_supply/BAT0/charge_control_start_threshold; /usr/bin/echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold;' -ExecStop=/usr/bin/bash -c '/usr/bin/echo 95 > /sys/class/power_supply/BAT0/charge_control_end_threshold; /usr/bin/echo 90 > /sys/class/power_supply/BAT0/charge_control_start_threshold;' -#Restart=on-failure - -[Install] -WantedBy=multi-user.target diff --git a/.config/linux/systemd/power/PowersaveAmd.service b/.config/linux/systemd/power/PowersaveAmd.service deleted file mode 100644 index f682ffb..0000000 --- a/.config/linux/systemd/power/PowersaveAmd.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=disable amd boost - -[Service] -Type=simple -RemainAfterExit=yes -ExecStart=/usr/bin/bash -c '/usr/bin/echo 0 > /sys/devices/system/cpu/cpufreq/boost' -ExecStop=/usr/bin/bash -c '/usr/bin/echo 1 > /sys/devices/system/cpu/cpufreq/boost' -#Restart=on-failure - -[Install] -WantedBy=multi-user.target diff --git a/.config/linux/systemd/power/PowersaveIntel.service b/.config/linux/systemd/power/PowersaveIntel.service deleted file mode 100644 index 343e9c9..0000000 --- a/.config/linux/systemd/power/PowersaveIntel.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=disable intel boost - -[Service] -Type=simple -RemainAfterExit=yes -ExecStart=/usr/bin/bash -c '/usr/bin/echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo' -ExecStop=/usr/bin/bash -c '/usr/bin/echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo' -#Restart=on-failure - -[Install] -WantedBy=multi-user.target