2013-07-23 22:41:52 +02:00
|
|
|
|
{config, pkgs, ...}:
|
|
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
let
|
|
|
|
|
cfg = config.services.venus;
|
|
|
|
|
|
|
|
|
|
configFile = pkgs.writeText "venus.ini"
|
|
|
|
|
''
|
|
|
|
|
[Planet]
|
|
|
|
|
name = ${cfg.name}
|
|
|
|
|
link = ${cfg.link}
|
|
|
|
|
owner_name = ${cfg.ownerName}
|
|
|
|
|
owner_email = ${cfg.ownerEmail}
|
|
|
|
|
output_theme = ${cfg.cacheDirectory}/theme
|
|
|
|
|
output_dir = ${cfg.outputDirectory}
|
|
|
|
|
cache_directory = ${cfg.cacheDirectory}
|
|
|
|
|
items_per_page = ${toString cfg.itemsPerPage}
|
|
|
|
|
${(concatStringsSep "\n\n"
|
|
|
|
|
(map ({ name, feedUrl, homepageUrl }:
|
|
|
|
|
''
|
|
|
|
|
[${feedUrl}]
|
|
|
|
|
name = ${name}
|
|
|
|
|
link = ${homepageUrl}
|
|
|
|
|
'') cfg.feeds))}
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
in
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
services.venus = {
|
|
|
|
|
enable = mkOption {
|
|
|
|
|
default = false;
|
|
|
|
|
type = types.bool;
|
|
|
|
|
description = ''
|
2013-07-23 23:04:38 +02:00
|
|
|
|
Planet Venus is an awesome ‘river of news’ feed reader. It downloads
|
|
|
|
|
news feeds published by web sites and aggregates their content
|
|
|
|
|
together into a single combined feed, latest news first.
|
2013-07-23 22:41:52 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2013-07-24 00:20:37 +02:00
|
|
|
|
dates = mkOption {
|
2013-11-02 20:41:54 +01:00
|
|
|
|
default = "*:0/15";
|
2013-07-24 00:20:37 +02:00
|
|
|
|
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";
|
2013-07-23 22:41:52 +02:00
|
|
|
|
type = types.string;
|
|
|
|
|
description = ''
|
2013-07-24 00:20:37 +02:00
|
|
|
|
User for running venus script.
|
2013-07-23 22:41:52 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2013-07-24 00:20:37 +02:00
|
|
|
|
group = mkOption {
|
2013-07-23 22:41:52 +02:00
|
|
|
|
default = "root";
|
|
|
|
|
type = types.string;
|
|
|
|
|
description = ''
|
2013-07-24 00:20:37 +02:00
|
|
|
|
Group for running venus script.
|
2013-07-23 22:41:52 +02:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
name = mkOption {
|
|
|
|
|
default = "NixOS Planet";
|
|
|
|
|
type = types.string;
|
|
|
|
|
description = ''
|
|
|
|
|
Your planet's name.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
link = mkOption {
|
|
|
|
|
default = "http://planet.nixos.org";
|
|
|
|
|
type = types.string;
|
|
|
|
|
description = ''
|
|
|
|
|
Link to the main page.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ownerName = mkOption {
|
|
|
|
|
default = "Rok Garbas";
|
|
|
|
|
type = types.string;
|
|
|
|
|
description = ''
|
|
|
|
|
Your name.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ownerEmail = mkOption {
|
|
|
|
|
default = "some@example.com";
|
|
|
|
|
type = types.string;
|
|
|
|
|
description = ''
|
|
|
|
|
Your e-mail address.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
outputTheme = mkOption {
|
|
|
|
|
default = "${pkgs.venus}/themes/classic_fancy";
|
|
|
|
|
type = types.path;
|
|
|
|
|
description = ''
|
|
|
|
|
Directory containing a config.ini file which is merged with this one.
|
|
|
|
|
This is typically used to specify templating and bill of material
|
|
|
|
|
information.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
outputDirectory = mkOption {
|
|
|
|
|
type = types.path;
|
|
|
|
|
description = ''
|
|
|
|
|
Directory to place output files.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
cacheDirectory = mkOption {
|
|
|
|
|
default = "/var/cache/venus";
|
|
|
|
|
type = types.path;
|
|
|
|
|
description = ''
|
|
|
|
|
Where cached feeds are stored.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
itemsPerPage = mkOption {
|
|
|
|
|
default = 15;
|
|
|
|
|
type = types.int;
|
|
|
|
|
description = ''
|
|
|
|
|
How many items to put on each page.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
feeds = mkOption {
|
|
|
|
|
default = [];
|
|
|
|
|
example = [
|
|
|
|
|
{
|
|
|
|
|
name = "Rok Garbas";
|
|
|
|
|
feedUrl= "http://url/to/rss/feed.xml";
|
|
|
|
|
homepageUrl = "http://garbas.si";
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
description = ''
|
|
|
|
|
List of feeds.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2013-07-24 00:20:37 +02:00
|
|
|
|
|
2013-07-23 22:41:52 +02:00
|
|
|
|
system.activationScripts.venus =
|
|
|
|
|
''
|
|
|
|
|
mkdir -p ${cfg.outputDirectory}
|
2013-07-24 00:20:37 +02:00
|
|
|
|
chown ${cfg.user}:${cfg.group} ${cfg.outputDirectory} -R
|
|
|
|
|
rm -rf ${cfg.cacheDirectory}/theme
|
|
|
|
|
mkdir -p ${cfg.cacheDirectory}/theme
|
2013-07-23 22:41:52 +02:00
|
|
|
|
cp -R ${cfg.outputTheme}/* ${cfg.cacheDirectory}/theme
|
2013-07-24 00:20:37 +02:00
|
|
|
|
chown ${cfg.user}:${cfg.group} ${cfg.cacheDirectory} -R
|
2013-07-23 22:41:52 +02:00
|
|
|
|
'';
|
2013-07-24 00:20:37 +02:00
|
|
|
|
|
|
|
|
|
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}";
|
2013-07-25 22:56:58 +02:00
|
|
|
|
environment.OPENSSL_X509_CERT_FILE = "/etc/ssl/certs/ca-bundle.crt";
|
2013-11-02 20:41:54 +01:00
|
|
|
|
startAt = cfg.dates;
|
2013-07-24 00:20:37 +02:00
|
|
|
|
};
|
2013-07-23 22:41:52 +02:00
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}
|