diff options
author | Rok Garbas <rok@garbas.si> | 2013-07-24 00:20:37 +0200 |
---|---|---|
committer | Rok Garbas <rok@garbas.si> | 2013-07-24 00:20:37 +0200 |
commit | 73284567cc8d9b6e79c9595351d1840f3781c8df (patch) | |
tree | 0df96c9c52298c5e0254b9cb6267ccb8f98f3cce /modules/programs/venus.nix | |
parent | f9fbbb5d2fca16c477754b0b0470f7a7956cf112 (diff) | |
download | nixpkgs-73284567cc8d9b6e79c9595351d1840f3781c8df.tar nixpkgs-73284567cc8d9b6e79c9595351d1840f3781c8df.tar.gz nixpkgs-73284567cc8d9b6e79c9595351d1840f3781c8df.tar.bz2 nixpkgs-73284567cc8d9b6e79c9595351d1840f3781c8df.tar.lz nixpkgs-73284567cc8d9b6e79c9595351d1840f3781c8df.tar.xz nixpkgs-73284567cc8d9b6e79c9595351d1840f3781c8df.tar.zst nixpkgs-73284567cc8d9b6e79c9595351d1840f3781c8df.zip |
venus service: using systemd timer instead of cronjob
Diffstat (limited to 'modules/programs/venus.nix')
-rw-r--r-- | modules/programs/venus.nix | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/modules/programs/venus.nix b/modules/programs/venus.nix index a3263319304..a211fd40ddf 100644 --- a/modules/programs/venus.nix +++ b/modules/programs/venus.nix @@ -24,10 +24,6 @@ let '') cfg.feeds))} ''; - cronJob = '' - ${cfg.cronInterval} ${cfg.cronUser} ${pkgs.venus}/bin/venus-planet ${configFile} - ''; - in { @@ -43,19 +39,30 @@ in ''; }; - cronInterval = mkOption { - default = "*/10 * * * *"; + dates = mkOption { + default = "*:0,15,30,45"; + type = types.string; + description = '' + Specification (in the format described by + <citerefentry><refentrytitle>systemd.time</refentrytitle> + <manvolnum>5</manvolnum></citerefentry>) of the time at + which the Venus will collect feeds. + ''; + }; + + user = mkOption { + default = "root"; type = types.string; description = '' - Interval in cron format. Default is every 10 minutes. + User for running venus script. ''; }; - cronUser = mkOption { + group = mkOption { default = "root"; type = types.string; description = '' - User for running the cron job. + Group for running venus script. ''; }; @@ -142,16 +149,29 @@ in }; config = mkIf cfg.enable { + system.activationScripts.venus = '' mkdir -p ${cfg.outputDirectory} - chown ${cfg.cronUser} ${cfg.outputDirectory} -R - rm -rf ${cfg.cacheDirectory}/themes - mkdir -p ${cfg.cacheDirectory}/themes + chown ${cfg.user}:${cfg.group} ${cfg.outputDirectory} -R + rm -rf ${cfg.cacheDirectory}/theme + mkdir -p ${cfg.cacheDirectory}/theme cp -R ${cfg.outputTheme}/* ${cfg.cacheDirectory}/theme - chown ${cfg.cronUser} ${cfg.cacheDirectory} -R + chown ${cfg.user}:${cfg.group} ${cfg.cacheDirectory} -R ''; - services.cron.systemCronJobs = [ cronJob ]; + + systemd.services.venus = + { description = "Planet Venus, an awesome ‘river of news’ feed reader"; + path = [ pkgs.venus ]; + script = "exec venus-planet ${configFile}"; + serviceConfig.User = "${cfg.user}"; + serviceConfig.Group = "${cfg.group}"; + }; + + systemd.timers.venus = + { wantedBy = [ "timers.target" ]; + timerConfig.OnCalendar = cfg.dates; + }; }; } |