From 988feead01eb2766dbd65c5b7996f8e3d9034eb7 Mon Sep 17 00:00:00 2001 From: Bruno Inec Date: Wed, 14 Dec 2022 16:14:29 +0100 Subject: [PATCH 1/6] nixos/goeland: init --- .../from_md/release-notes/rl-2305.section.xml | 8 +++ .../manual/release-notes/rl-2305.section.md | 2 + nixos/modules/module-list.nix | 1 + nixos/modules/services/mail/goeland.nix | 58 +++++++++++++++++++ .../feedreaders/goeland/default.nix | 9 +-- 5 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 nixos/modules/services/mail/goeland.nix diff --git a/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml index 5e2a65061fc6..821a9312dae2 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2305.section.xml @@ -83,6 +83,14 @@ networking.stevenblack. + + + goeland, + an alternative to rss2email written in golang with many + filters. Available as + services.goeland. + + atuin, diff --git a/nixos/doc/manual/release-notes/rl-2305.section.md b/nixos/doc/manual/release-notes/rl-2305.section.md index 8c67815ada56..da7596a3089c 100644 --- a/nixos/doc/manual/release-notes/rl-2305.section.md +++ b/nixos/doc/manual/release-notes/rl-2305.section.md @@ -30,6 +30,8 @@ In addition to numerous new and upgraded packages, this release has the followin - [stevenblack-blocklist](https://github.com/StevenBlack/hosts), A unified hosts file with base extensions for blocking unwanted websites. Available as [networking.stevenblack](options.html#opt-networking.stevenblack.enable). +- [goeland](https://github.com/slurdge/goeland), an alternative to rss2email written in golang with many filters. Available as [services.goeland](#opt-services.goeland.enable). + - [atuin](https://github.com/ellie/atuin), a sync server for shell history. Available as [services.atuin](#opt-services.atuin.enable). - [mmsd](https://gitlab.com/kop316/mmsd), a lower level daemon that transmits and recieves MMSes. Available as [services.mmsd](#opt-services.mmsd.enable). diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index dce6e878540d..45a7acdedc41 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -530,6 +530,7 @@ ./services/mail/dovecot.nix ./services/mail/dspam.nix ./services/mail/exim.nix + ./services/mail/goeland.nix ./services/mail/listmonk.nix ./services/mail/maddy.nix ./services/mail/mail.nix diff --git a/nixos/modules/services/mail/goeland.nix b/nixos/modules/services/mail/goeland.nix new file mode 100644 index 000000000000..aeeee97ea41c --- /dev/null +++ b/nixos/modules/services/mail/goeland.nix @@ -0,0 +1,58 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.goeland; + tomlFormat = pkgs.formats.toml { }; +in +{ + options.services.goeland = { + enable = mkEnableOption (mdDoc "goeland"); + + settings = mkOption { + description = mdDoc '' + Configuration of goeland. + See the [example config file](https://github.com/slurdge/goeland/blob/master/cmd/asset/config.default.toml) for the available options. + ''; + default = { }; + type = types.submodule { + freeformType = tomlFormat.type; + }; + }; + schedule = mkOption { + type = types.str; + default = "12h"; + example = "Mon, 00:00:00"; + description = mdDoc "How often to run goeland, in systemd time format"; + }; + databaseDirectory = mkOption { + type = types.path; + default = "/var/lib/goeland"; + description = mdDoc "Directory where the goeland database will reside if using the `unseen` filter"; + }; + }; + + config = mkIf cfg.enable { + systemd.tmpfiles.rules = [ "d ${cfg.databaseDirectory} 0750 goeland goeland -" ]; + + services.goeland.settings.database = "${cfg.databaseDirectory}/goeland.db"; + + systemd.services.goeland = { + serviceConfig = let confFile = tomlFormat.generate "config.toml" cfg.settings; in { + ExecStart = "${pkgs.goeland}/bin/goeland run -c ${confFile}"; + User = "goeland"; + }; + startAt = cfg.schedule; + }; + + users.users.goeland = { + description = "goeland user"; + group = "goeland"; + isSystemUser = true; + }; + users.groups.goeland = { }; + }; + + meta.maintainers = with maintainers; [ sweenu ]; +} diff --git a/pkgs/applications/networking/feedreaders/goeland/default.nix b/pkgs/applications/networking/feedreaders/goeland/default.nix index 946e145a5707..270cb7cdb622 100644 --- a/pkgs/applications/networking/feedreaders/goeland/default.nix +++ b/pkgs/applications/networking/feedreaders/goeland/default.nix @@ -23,14 +23,15 @@ buildGoModule rec { ]; meta = with lib; { - description = "An alternative to RSS2Email written in golang with many filters."; + description = "An alternative to rss2email written in golang with many filters"; longDescription = '' - Goeland excels at creating beautiful emails from RSS, - tailored for daily or weekly digest. It include a number of + Goeland excels at creating beautiful emails from RSS feeds, + tailored for daily or weekly digest. It includes a number of filters that can transform the RSS content along the way. - It can also consume other sources, such as a Imgur tag. + It can also consume other sources, such as Imgur tags. ''; homepage = "https://github.com/slurdge/goeland"; + changelog = "https://github.com/slurdge/goeland/blob/v${version}/CHANGELOG.md"; license = with licenses; [ mit ]; maintainers = [ maintainers.sweenu ]; }; From 8f10857af43c0f43fa1c64aa19add3e509ad7734 Mon Sep 17 00:00:00 2001 From: Bruno Inec Date: Fri, 6 Jan 2023 15:37:44 +0100 Subject: [PATCH 2/6] let systemd handle /var/lib/goeland creation --- nixos/modules/services/mail/goeland.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/mail/goeland.nix b/nixos/modules/services/mail/goeland.nix index aeeee97ea41c..e4a32de1dc3c 100644 --- a/nixos/modules/services/mail/goeland.nix +++ b/nixos/modules/services/mail/goeland.nix @@ -34,14 +34,15 @@ in }; config = mkIf cfg.enable { - systemd.tmpfiles.rules = [ "d ${cfg.databaseDirectory} 0750 goeland goeland -" ]; - services.goeland.settings.database = "${cfg.databaseDirectory}/goeland.db"; systemd.services.goeland = { serviceConfig = let confFile = tomlFormat.generate "config.toml" cfg.settings; in { ExecStart = "${pkgs.goeland}/bin/goeland run -c ${confFile}"; User = "goeland"; + Group = "goeland"; + StateDirectory = "goeland"; + StateDirectoryMode = "0750"; }; startAt = cfg.schedule; }; From 15414ff8e1ec38f367ed47f7c33d46faded39d69 Mon Sep 17 00:00:00 2001 From: Bruno Inec Date: Wed, 18 Jan 2023 15:18:36 +0100 Subject: [PATCH 3/6] databaseDirectory -> StateDir and changed description --- nixos/modules/services/mail/goeland.nix | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/nixos/modules/services/mail/goeland.nix b/nixos/modules/services/mail/goeland.nix index e4a32de1dc3c..de2f7b457d7a 100644 --- a/nixos/modules/services/mail/goeland.nix +++ b/nixos/modules/services/mail/goeland.nix @@ -16,25 +16,28 @@ in See the [example config file](https://github.com/slurdge/goeland/blob/master/cmd/asset/config.default.toml) for the available options. ''; default = { }; - type = types.submodule { - freeformType = tomlFormat.type; - }; + type = tomlFormat.type; }; schedule = mkOption { type = types.str; default = "12h"; example = "Mon, 00:00:00"; - description = mdDoc "How often to run goeland, in systemd time format"; + description = mdDoc "How often to run goeland, in systemd time format."; }; - databaseDirectory = mkOption { + stateDir = mkOption { type = types.path; default = "/var/lib/goeland"; - description = mdDoc "Directory where the goeland database will reside if using the `unseen` filter"; + description = mdDoc '' + The data directory for goeland where the database will reside if using the unseen filter. + If left as the default value this directory will automatically be created before the goeland + server starts, otherwise you are responsible for ensuring the directory exists with + appropriate ownership and permissions. + ''; }; }; config = mkIf cfg.enable { - services.goeland.settings.database = "${cfg.databaseDirectory}/goeland.db"; + services.goeland.settings.database = "${cfg.stateDir}/goeland.db"; systemd.services.goeland = { serviceConfig = let confFile = tomlFormat.generate "config.toml" cfg.settings; in { From 5edf9bd76ffb0ac02bbd4d70c3c330d4267b5d78 Mon Sep 17 00:00:00 2001 From: Bruno Inec Date: Wed, 18 Jan 2023 15:22:08 +0100 Subject: [PATCH 4/6] Apply suggestion Co-authored-by: Aaron Andersen --- nixos/modules/services/mail/goeland.nix | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/nixos/modules/services/mail/goeland.nix b/nixos/modules/services/mail/goeland.nix index de2f7b457d7a..c407ffafcf18 100644 --- a/nixos/modules/services/mail/goeland.nix +++ b/nixos/modules/services/mail/goeland.nix @@ -40,13 +40,17 @@ in services.goeland.settings.database = "${cfg.stateDir}/goeland.db"; systemd.services.goeland = { - serviceConfig = let confFile = tomlFormat.generate "config.toml" cfg.settings; in { - ExecStart = "${pkgs.goeland}/bin/goeland run -c ${confFile}"; - User = "goeland"; - Group = "goeland"; - StateDirectory = "goeland"; - StateDirectoryMode = "0750"; - }; + serviceConfig = let confFile = tomlFormat.generate "config.toml" cfg.settings; in mkMerge [ + { + ExecStart = "${pkgs.goeland}/bin/goeland run -c ${confFile}"; + User = "goeland"; + Group = "goeland"; + } + (mkIf (cfg.stateDir == "/var/lib/goeland") { + StateDirectory = "goeland"; + StateDirectoryMode = "0750"; + }) + ]; startAt = cfg.schedule; }; From edb6b1096601ec5553608e7ea6874a65ae9e5381 Mon Sep 17 00:00:00 2001 From: Bruno Inec Date: Fri, 20 Jan 2023 00:38:52 +0100 Subject: [PATCH 5/6] add warning if not using password_file --- nixos/modules/services/mail/goeland.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nixos/modules/services/mail/goeland.nix b/nixos/modules/services/mail/goeland.nix index c407ffafcf18..949ecfe91a4e 100644 --- a/nixos/modules/services/mail/goeland.nix +++ b/nixos/modules/services/mail/goeland.nix @@ -60,6 +60,17 @@ in isSystemUser = true; }; users.groups.goeland = { }; + + warnings = + if hasAttr "password" cfg.settings.email + then [ + '' + It is not recommended to set the "services.goeland.settings.email.password" + option as it will be in cleartext in the Nix store. + Please use "services.goeland.settings.email.password_file" instead. + '' + ] + else [ ]; }; meta.maintainers = with maintainers; [ sweenu ]; From dbbb062d479e938e662ba27f0edcebbad6518fe7 Mon Sep 17 00:00:00 2001 From: Bruno Inec Date: Fri, 20 Jan 2023 14:39:35 +0100 Subject: [PATCH 6/6] Apply suggestion Co-authored-by: Aaron Andersen --- nixos/modules/services/mail/goeland.nix | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/nixos/modules/services/mail/goeland.nix b/nixos/modules/services/mail/goeland.nix index 949ecfe91a4e..13092a65ed90 100644 --- a/nixos/modules/services/mail/goeland.nix +++ b/nixos/modules/services/mail/goeland.nix @@ -61,16 +61,13 @@ in }; users.groups.goeland = { }; - warnings = - if hasAttr "password" cfg.settings.email - then [ - '' - It is not recommended to set the "services.goeland.settings.email.password" - option as it will be in cleartext in the Nix store. - Please use "services.goeland.settings.email.password_file" instead. - '' - ] - else [ ]; + warnings = optionals (hasAttr "password" cfg.settings.email) [ + '' + It is not recommended to set the "services.goeland.settings.email.password" + option as it will be in cleartext in the Nix store. + Please use "services.goeland.settings.email.password_file" instead. + '' + ]; }; meta.maintainers = with maintainers; [ sweenu ];