home/modules: move newsboat automation to module
This commit is contained in:
parent
3269834e3f
commit
e298262966
@ -148,6 +148,7 @@
|
||||
neovim-auto-clean-swapfiles = ./home/modules/programs/neovim/auto-clean-swapfiles.nix;
|
||||
nix-index-auto-update-database = ./home/modules/programs/nix-index/auto-update-database.nix;
|
||||
direnv-auto-prune = ./home/modules/programs/direnv/auto-prune.nix;
|
||||
newsboat = ./home/modules/programs/newsboat;
|
||||
};
|
||||
|
||||
homeConfigurations = {
|
||||
|
@ -53,6 +53,7 @@ in {
|
||||
./modules/programs/neovim/auto-clean-swapfiles.nix
|
||||
./modules/programs/nix-index/auto-update-database.nix
|
||||
./modules/programs/direnv/auto-prune.nix
|
||||
./modules/programs/newsboat
|
||||
] ++ (optionals graphics [
|
||||
./config/gtk.nix
|
||||
|
||||
|
6
home/modules/programs/newsboat/default.nix
Normal file
6
home/modules/programs/newsboat/default.nix
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
imports = [
|
||||
./vacuum.nix
|
||||
./fetch-articles.nix
|
||||
];
|
||||
}
|
53
home/modules/programs/newsboat/fetch-articles.nix
Normal file
53
home/modules/programs/newsboat/fetch-articles.nix
Normal file
@ -0,0 +1,53 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
cfg = config.programs.newsboat;
|
||||
package = pkgs.newsboat;
|
||||
in
|
||||
{
|
||||
options.programs.newsboat.fetch-articles = {
|
||||
enable = lib.mkEnableOption "automatic article fetcher for newsboat";
|
||||
|
||||
onCalendar = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "daily";
|
||||
example = "weekly";
|
||||
# TODO: link to systemd manpage for format.
|
||||
description = "How often to fetch new articles.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.fetch-articles.enable {
|
||||
# TODO: wait for internet
|
||||
systemd.user.services.newsboat-fetch-articles = {
|
||||
Unit = {
|
||||
Description = "Automatically fetch new articles for newsboat";
|
||||
Documentation = [ "man:newsboat(1)" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
CPUSchedulingPolicy = "idle";
|
||||
IOSchedulingClass = "idle";
|
||||
ExecStart = "${lib.getExe pkgs.flock} %t/newsboat.lock ${lib.getExe package} --execute=reload";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.timers.newsboat-fetch-articles = {
|
||||
Unit = {
|
||||
Description = "Automatically fetch new articles for newsboat";
|
||||
Documentation = [ "man:newsboat(1)" ];
|
||||
After = [ "network.target" ];
|
||||
};
|
||||
|
||||
Timer = {
|
||||
Unit = "newsboat-fetch-articles.service";
|
||||
OnCalendar = cfg.fetch-articles.onCalendar;
|
||||
Persistent = true;
|
||||
};
|
||||
|
||||
Install = {
|
||||
WantedBy = [ "timers.target" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
51
home/modules/programs/newsboat/vacuum.nix
Normal file
51
home/modules/programs/newsboat/vacuum.nix
Normal file
@ -0,0 +1,51 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
cfg = config.programs.newsboat;
|
||||
package = pkgs.newsboat;
|
||||
in
|
||||
{
|
||||
options.programs.newsboat.vacuum = {
|
||||
enable = lib.mkEnableOption "automatic cleaning of the newsboat cache";
|
||||
|
||||
onCalendar = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "weekly";
|
||||
example = "monthly";
|
||||
# TODO: link to systemd manpage for format.
|
||||
description = "How often to run the cleaning.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.vacuum.enable {
|
||||
systemd.user.services.newsboat-vacuum = {
|
||||
Unit = {
|
||||
Description = "Automatically clean newsboat cache";
|
||||
Documentation = [ "man:newsboat(1)" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
CPUSchedulingPolicy = "idle";
|
||||
IOSchedulingClass = "idle";
|
||||
ExecStart = "${lib.getExe pkgs.flock} %t/newsboat.lock ${lib.getExe package} --vacuum";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.timers.newsboat-vacuum = {
|
||||
Unit = {
|
||||
Description = "Automatically clean newsboat cache";
|
||||
Documentation = [ "man:newsboat(1)" ];
|
||||
};
|
||||
|
||||
Timer = {
|
||||
Unit = "newsboat-vacuum.service";
|
||||
OnCalendar = cfg.vacuum.onCalendar;
|
||||
Persistent = true;
|
||||
};
|
||||
|
||||
Install = {
|
||||
WantedBy = [ "timers.target" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
@ -12,6 +12,10 @@ in {
|
||||
|
||||
programs.newsboat = {
|
||||
enable = true;
|
||||
|
||||
fetch-articles.enable = true;
|
||||
vacuum.enable = true;
|
||||
|
||||
autoReload = true;
|
||||
maxItems = 50;
|
||||
browser = ''"${defaultBrowser}"'';
|
||||
@ -71,76 +75,10 @@ in {
|
||||
];
|
||||
};
|
||||
|
||||
systemd.user.slices.app-newsboat = {
|
||||
Unit = {
|
||||
Description = "Newsboat automation";
|
||||
Documentation = [ "man:newsboat(1)" ];
|
||||
};
|
||||
};
|
||||
|
||||
# TODO: wait for internet
|
||||
systemd.user.services.newsboat-fetch-articles = {
|
||||
Unit = {
|
||||
Description = "Automatically fetch new articles for newsboat";
|
||||
Documentation = [ "man:newsboat(1)" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
Slice = "app-newsboat.slice";
|
||||
CPUSchedulingPolicy = "idle";
|
||||
IOSchedulingClass = "idle";
|
||||
ExecStart = "${lib.getExe pkgs.flock} %t/newsboat.lock ${lib.getExe package} --execute=reload";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.timers.newsboat-fetch-articles = {
|
||||
Unit = {
|
||||
Description = "Automatically fetch new articles for newsboat";
|
||||
Documentation = [ "man:newsboat(1)" ];
|
||||
After = [ "network.target" ];
|
||||
};
|
||||
|
||||
Timer = {
|
||||
Unit = "newsboat-fetch-articles.service";
|
||||
OnCalendar = lib.mkDefault "daily";
|
||||
Persistent = true;
|
||||
};
|
||||
|
||||
Install = {
|
||||
WantedBy = [ "timers.target" ];
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.services.newsboat-vacuum = {
|
||||
Unit = {
|
||||
Description = "Automatically clean newsboat cache";
|
||||
Documentation = [ "man:newsboat(1)" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
Slice = "app-newsboat.slice";
|
||||
CPUSchedulingPolicy = "idle";
|
||||
IOSchedulingClass = "idle";
|
||||
ExecStart = "${lib.getExe pkgs.flock} %t/newsboat.lock ${lib.getExe package} --vacuum";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.timers.newsboat-vacuum = {
|
||||
Unit = {
|
||||
Description = "Automatically clean newsboat cache";
|
||||
Documentation = [ "man:newsboat(1)" ];
|
||||
};
|
||||
|
||||
Timer = {
|
||||
Unit = "newsboat-vacuum.service";
|
||||
OnCalendar = lib.mkDefault "weekly";
|
||||
Persistent = true;
|
||||
};
|
||||
|
||||
Install = {
|
||||
WantedBy = [ "timers.target" ];
|
||||
};
|
||||
};
|
||||
# systemd.user.slices.app-newsboat = {
|
||||
# Unit = {
|
||||
# Description = "Newsboat automation";
|
||||
# Documentation = [ "man:newsboat(1)" ];
|
||||
# };
|
||||
# };
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user