diff --git a/home-manager/home-manager b/home-manager/home-manager index 8e0bd40c..e793e146 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -110,6 +110,10 @@ function doListPackages() { fi } +function doShowNews() { + echo "Not implemented yet" +} + function doHelp() { echo "Usage: $0 [OPTION] COMMAND" echo @@ -182,6 +186,9 @@ case "$cmd" in packages) doListPackages ;; + news) + doShowNews + ;; help|--help) doHelp ;; diff --git a/modules/default.nix b/modules/default.nix index a6dc6848..7add9dc3 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -11,6 +11,7 @@ let ./home-environment.nix ./manual.nix ./misc/gtk.nix + ./misc/news.nix ./misc/pam.nix ./programs/bash.nix ./programs/beets.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix new file mode 100644 index 00000000..617004c8 --- /dev/null +++ b/modules/misc/news.nix @@ -0,0 +1,137 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.news; + + entryModule = types.submodule ({ config, ... }: { + options = { + id = mkOption { + internal = true; + type = types.str; + description = '' + A unique entry identifier. By default it is a base16 + formatted hash of the entry message. + ''; + }; + + time = mkOption { + internal = true; + type = types.str; + example = "2017-07-10T21:55:04+00:00"; + description = '' + News entry time stamp in ISO-8601 format. Must be in UTC + (ending in '+00:00'). + ''; + }; + + condition = mkOption { + internal = true; + default = true; + description = "Whether the news entry should be active."; + }; + + message = mkOption { + internal = true; + type = types.str; + description = "The news entry content."; + }; + }; + + config = { + id = mkDefault (builtins.hashString "sha256" config.message); + }; + }); + +in + +{ + options = { + news = { + display = mkOption { + type = types.enum [ "notify" "show" ]; + default = "notify"; + description = '' + How unread and relevant news should be presented when + running home-manager build and + home-manager switch. + + + + The options are + + + + notify + + + The number of unread and relevant news entries will be + printed to standard output. The home-manager + news command can later be used to view the + entries. + + + + + show + + + A pager showing all news entries is opened, unread and + relevant news are marked as such. + + + + + ''; + }; + + entries = mkOption { + internal = true; + type = types.listOf entryModule; + default = []; + description = "News entries."; + }; + }; + }; + + config = { + news.entries = [ + { + time = "2017-09-01T10:56:28+00:00"; + message = '' + Hello! This is a news entry and it represents an + experimental new feature of Home Manager. The idea is to + inform you when something of importance happens in Home + Manager or its modules. + + We will try to not disturb you about the same news more than + once so the next time you run + + home-manager switch + + or + + home-manager build + + it should not notify you about this text again. + + News items may be conditional and will then only show if the + condition holds, for example if they are relevant to your + configuration. + + If you want to see all news then please use the + + home-manager news + + command. + + Since this is an experimental feature any positive or + negative feedback would be greatly appreciated. For example, + by commenting in https://git.io/v5BJL. + ''; + } + ]; + }; +}