From e4ddb51e2fbd561ffc436f871eecff5636c7edd6 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 12 May 2017 19:34:19 +0200 Subject: l 3 news: init --- lass/3modules/default.nix | 1 + lass/3modules/news.nix | 76 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 lass/3modules/news.nix (limited to 'lass/3modules') diff --git a/lass/3modules/default.nix b/lass/3modules/default.nix index 959c9d1b4..73692446a 100644 --- a/lass/3modules/default.nix +++ b/lass/3modules/default.nix @@ -5,6 +5,7 @@ _: ./folderPerms.nix ./hosts.nix ./mysql-backup.nix + ./news.nix ./umts.nix ./usershadow.nix ./xresources.nix diff --git a/lass/3modules/news.nix b/lass/3modules/news.nix new file mode 100644 index 000000000..ecf43ab0a --- /dev/null +++ b/lass/3modules/news.nix @@ -0,0 +1,76 @@ +{ config, lib, pkgs, ... }: + +with import ; + +let + cfg = config.lass.news; + + out = { + options.lass.news = api; + config = lib.mkIf cfg.enable imp; + }; + + api = { + enable = mkEnableOption "umts"; + feeds = mkOption { + type = types.listOf (types.submodule { options = { + nick = mkOption { + type = types.str; + }; + feedurl = mkOption { + type = types.str; + }; + interval = mkOption { + type = types.int; + default = 1000; + }; + channels = mkOption { + type = types.listOf types.str; + }; + };}); + }; + user = mkOption { + type = types.user; + default = { + name = "news"; + home = "/var/lib/news"; + }; + }; + ircServer = mkOption { + type = types.str; + default = "echelon.r"; + description = "to which server the bot should connect"; + }; + }; + + imp = { + + users.users.${cfg.user.name} = { + inherit (cfg.user) home name uid; + createHome = true; + }; + + systemd.services = listToAttrs (map (feed: + nameValuePair "news-${feed.nick}" { + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + serviceConfig = { + SyslogIdentifier = "news-${feed.nick}"; + User = cfg.user.name; + PrivateTmp = true; + Restart = "always"; + ExecStart = pkgs.writeDash "news-${feed.nick}" '' + ${pkgs.haskellPackages.news}/bin/news '${feed.feedurl}' '${toString feed.interval}' \ + | ${pkgs.goify}/bin/goify \ + | while :; do + ${pkgs.haskellPackages.kirk}/bin/ircout --nick '${feed.nick}' --host '${cfg.ircServer}' \ + \${concatStringsSep " \\" feed.channels} + done + ''; + }; + } + ) cfg.feeds); + + }; + +in out -- cgit v1.2.3 From e6164ce3b3bab2efd14d0c03ada2f0f855f3f8cd Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 15 May 2017 23:40:52 +0200 Subject: l 3 news: use correct name in enable --- lass/3modules/news.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lass/3modules') diff --git a/lass/3modules/news.nix b/lass/3modules/news.nix index ecf43ab0a..06b80df8d 100644 --- a/lass/3modules/news.nix +++ b/lass/3modules/news.nix @@ -11,7 +11,7 @@ let }; api = { - enable = mkEnableOption "umts"; + enable = mkEnableOption "news"; feeds = mkOption { type = types.listOf (types.submodule { options = { nick = mkOption { -- cgit v1.2.3