mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 16:57:55 +00:00
services: refactor
This commit is contained in:
parent
66092ff8c5
commit
d20b192c41
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.archivebox;
|
cfg = config.services.archivebox;
|
||||||
|
jobUnitName = name: "archivebox-job-${name}";
|
||||||
jobType = { name, options, ... }: {
|
jobType = { name, options, ... }: {
|
||||||
options = {
|
options = {
|
||||||
links = lib.mkOption {
|
links = lib.mkOption {
|
||||||
@ -104,7 +105,7 @@ in {
|
|||||||
|
|
||||||
systemd.user.services = lib.mkMerge [
|
systemd.user.services = lib.mkMerge [
|
||||||
(lib.mapAttrs' (name: value:
|
(lib.mapAttrs' (name: value:
|
||||||
lib.nameValuePair "archivebox-add-${name}" {
|
lib.nameValuePair (jobUnitName name) {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description =
|
Description =
|
||||||
"Archivebox archive group '${name}' for ${cfg.archivePath}";
|
"Archivebox archive group '${name}' for ${cfg.archivePath}";
|
||||||
@ -152,7 +153,7 @@ in {
|
|||||||
];
|
];
|
||||||
|
|
||||||
systemd.user.timers = lib.mapAttrs' (name: value:
|
systemd.user.timers = lib.mapAttrs' (name: value:
|
||||||
lib.nameValuePair "archivebox-add-${name}" {
|
lib.nameValuePair (jobUnitName name) {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "Archivebox additions for ${cfg.archivePath}";
|
Description = "Archivebox additions for ${cfg.archivePath}";
|
||||||
After = "network.target";
|
After = "network.target";
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
let
|
let
|
||||||
cfg = config.services.gallery-dl;
|
cfg = config.services.gallery-dl;
|
||||||
|
|
||||||
|
jobUnitName = name: "gallery-dl-service-job-${name}";
|
||||||
|
|
||||||
settingsFormat = pkgs.formats.json { };
|
settingsFormat = pkgs.formats.json { };
|
||||||
settingsFormatFile =
|
settingsFormatFile =
|
||||||
settingsFormat.generate "gallery-dl-service-config-${config.home.username}"
|
settingsFormat.generate "gallery-dl-service-config-${config.home.username}"
|
||||||
@ -162,7 +164,7 @@ in {
|
|||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
systemd.user.services = lib.mapAttrs' (name: value:
|
systemd.user.services = lib.mapAttrs' (name: value:
|
||||||
lib.nameValuePair "gallery-dl-archive-service-${name}" {
|
lib.nameValuePair (jobUnitName name) {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "gallery-dl archive job for group '${name}'";
|
Description = "gallery-dl archive job for group '${name}'";
|
||||||
After = [ "default.target" ];
|
After = [ "default.target" ];
|
||||||
@ -189,7 +191,7 @@ in {
|
|||||||
}) cfg.jobs;
|
}) cfg.jobs;
|
||||||
|
|
||||||
systemd.user.timers = lib.mapAttrs' (name: value:
|
systemd.user.timers = lib.mapAttrs' (name: value:
|
||||||
lib.nameValuePair "gallery-dl-archive-service-${name}" {
|
lib.nameValuePair (jobUnitName name) {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "gallery-dl archive job for group '${name}'";
|
Description = "gallery-dl archive job for group '${name}'";
|
||||||
Documentation = "man:gallery-dl(1)";
|
Documentation = "man:gallery-dl(1)";
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
let
|
let
|
||||||
cfg = config.services.yt-dlp;
|
cfg = config.services.yt-dlp;
|
||||||
|
|
||||||
|
jobUnitName = name: "yt-dlp-archive-service-${name}";
|
||||||
|
|
||||||
serviceLevelArgs = lib.escapeShellArgs cfg.extraArgs;
|
serviceLevelArgs = lib.escapeShellArgs cfg.extraArgs;
|
||||||
|
|
||||||
jobType = { name, config, options, ... }: {
|
jobType = { name, config, options, ... }: {
|
||||||
@ -134,7 +136,7 @@ in {
|
|||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
systemd.user.services = lib.mapAttrs' (name: value:
|
systemd.user.services = lib.mapAttrs' (name: value:
|
||||||
lib.nameValuePair "yt-dlp-archive-service-${name}" {
|
lib.nameValuePair (jobUnitName name) {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "yt-dlp archive job for group '${name}'";
|
Description = "yt-dlp archive job for group '${name}'";
|
||||||
After = [ "default.target" ];
|
After = [ "default.target" ];
|
||||||
@ -163,7 +165,7 @@ in {
|
|||||||
}) cfg.jobs;
|
}) cfg.jobs;
|
||||||
|
|
||||||
systemd.user.timers = lib.mapAttrs' (name: value:
|
systemd.user.timers = lib.mapAttrs' (name: value:
|
||||||
lib.nameValuePair "yt-dlp-archive-service-${name}" {
|
lib.nameValuePair (jobUnitName name) {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "yt-dlp archive job for group '${name}'";
|
Description = "yt-dlp archive job for group '${name}'";
|
||||||
Documentation = "man:yt-dlp(1)";
|
Documentation = "man:yt-dlp(1)";
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.archivebox;
|
cfg = config.services.archivebox;
|
||||||
|
jobUnitName = name: "archivebox-job-${name}";
|
||||||
jobType = { name, options, ... }: {
|
jobType = { name, options, ... }: {
|
||||||
options = {
|
options = {
|
||||||
urls = lib.mkOption {
|
urls = lib.mkOption {
|
||||||
@ -101,7 +102,7 @@ in {
|
|||||||
in lib.mkIf cfg.enable {
|
in lib.mkIf cfg.enable {
|
||||||
systemd.services = lib.mkMerge [
|
systemd.services = lib.mkMerge [
|
||||||
(lib.mapAttrs' (name: value:
|
(lib.mapAttrs' (name: value:
|
||||||
lib.nameValuePair "archivebox-add-${name}" {
|
lib.nameValuePair (jobUnitName name) {
|
||||||
description =
|
description =
|
||||||
"Archivebox archive group '${name}' for ${cfg.archivePath}";
|
"Archivebox archive group '${name}' for ${cfg.archivePath}";
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
@ -165,7 +166,7 @@ in {
|
|||||||
];
|
];
|
||||||
|
|
||||||
systemd.timers = lib.mapAttrs' (name: value:
|
systemd.timers = lib.mapAttrs' (name: value:
|
||||||
lib.nameValuePair "archivebox-add-${name}" {
|
lib.nameValuePair (jobUnitName name) {
|
||||||
description =
|
description =
|
||||||
"Archivebox archive group '${name}' for ${cfg.archivePath}";
|
"Archivebox archive group '${name}' for ${cfg.archivePath}";
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
let
|
let
|
||||||
cfg = config.services.gallery-dl;
|
cfg = config.services.gallery-dl;
|
||||||
|
|
||||||
|
jobUnitName = name: "gallery-dl-archive-job-${name}";
|
||||||
|
|
||||||
settingsFormat = pkgs.formats.json { };
|
settingsFormat = pkgs.formats.json { };
|
||||||
settingsFormatFile =
|
settingsFormatFile =
|
||||||
settingsFormat.generate "gallery-dl-service-config" cfg.settings;
|
settingsFormat.generate "gallery-dl-service-config" cfg.settings;
|
||||||
@ -156,7 +158,7 @@ in {
|
|||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
systemd.services = lib.mapAttrs' (name: value:
|
systemd.services = lib.mapAttrs' (name: value:
|
||||||
lib.nameValuePair "gallery-dl-archive-service-${name}" {
|
lib.nameValuePair (jobUnitName name) {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
description = "gallery-dl archive job for group '${name}'";
|
description = "gallery-dl archive job for group '${name}'";
|
||||||
documentation = [ "man:gallery-dl(1)" ];
|
documentation = [ "man:gallery-dl(1)" ];
|
||||||
@ -208,7 +210,7 @@ in {
|
|||||||
}) cfg.jobs;
|
}) cfg.jobs;
|
||||||
|
|
||||||
systemd.timers = lib.mapAttrs' (name: value:
|
systemd.timers = lib.mapAttrs' (name: value:
|
||||||
lib.nameValuePair "gallery-dl-archive-service-${name}" {
|
lib.nameValuePair (jobUnitName name) {
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
Persistent = value.persistent;
|
Persistent = value.persistent;
|
||||||
RandomizedDelaySec = "2min";
|
RandomizedDelaySec = "2min";
|
||||||
|
@ -5,6 +5,8 @@ let
|
|||||||
|
|
||||||
serviceLevelArgs = lib.escapeShellArgs cfg.extraArgs;
|
serviceLevelArgs = lib.escapeShellArgs cfg.extraArgs;
|
||||||
|
|
||||||
|
jobUnitName = name: "yt-dlp-archive-service-${name}";
|
||||||
|
|
||||||
jobType = { name, config, options, ... }: {
|
jobType = { name, config, options, ... }: {
|
||||||
options = {
|
options = {
|
||||||
urls = lib.mkOption {
|
urls = lib.mkOption {
|
||||||
@ -89,6 +91,7 @@ in {
|
|||||||
default = [ "--download-archive videos" ];
|
default = [ "--download-archive videos" ];
|
||||||
example = lib.literalExpression ''
|
example = lib.literalExpression ''
|
||||||
[
|
[
|
||||||
|
"--verbose"
|
||||||
"--download-archive" "''${cfg.archivePath}/download-list"
|
"--download-archive" "''${cfg.archivePath}/download-list"
|
||||||
"--concurrent-fragments" "2"
|
"--concurrent-fragments" "2"
|
||||||
"--retries" "20"
|
"--retries" "20"
|
||||||
@ -130,7 +133,7 @@ in {
|
|||||||
systemd.services = lib.mapAttrs' (name: value: let
|
systemd.services = lib.mapAttrs' (name: value: let
|
||||||
jobLevelArgs = lib.escapeShellArgs value.extraArgs;
|
jobLevelArgs = lib.escapeShellArgs value.extraArgs;
|
||||||
in
|
in
|
||||||
lib.nameValuePair "yt-dlp-archive-service-${name}" {
|
lib.nameValuePair (jobUnitName name) {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
description = "yt-dlp archive job for group '${name}'";
|
description = "yt-dlp archive job for group '${name}'";
|
||||||
documentation = [ "man:yt-dlp(1)" ];
|
documentation = [ "man:yt-dlp(1)" ];
|
||||||
@ -163,7 +166,7 @@ in {
|
|||||||
}) cfg.jobs;
|
}) cfg.jobs;
|
||||||
|
|
||||||
systemd.timers = lib.mapAttrs' (name: value:
|
systemd.timers = lib.mapAttrs' (name: value:
|
||||||
lib.nameValuePair "yt-dlp-archive-service-${name}" {
|
lib.nameValuePair (jobUnitName name) {
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
Persistent = value.persistent;
|
Persistent = value.persistent;
|
||||||
RandomizedDelaySec = "2min";
|
RandomizedDelaySec = "2min";
|
||||||
|
Loading…
Reference in New Issue
Block a user