diff --git a/CHANGELOG.md b/CHANGELOG.md
index a50a44e..a1cabd3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,8 @@
* In an effort to reduce the number of arguments to `lib.nixOnDroidConfiguration`
function in flake configurations, `system` is now inferred from `pkgs.system`
and `config` and `extraModules` are now combined into `modules`
+* Add option `environment.motd` to edit the startup message that is printed in
+ every shell
## Release 22.05
diff --git a/modules/environment/login/login-inner.nix b/modules/environment/login/login-inner.nix
index d5f734b..89cf0ab 100644
--- a/modules/environment/login/login-inner.nix
+++ b/modules/environment/login/login-inner.nix
@@ -13,10 +13,11 @@ writeText "login-inner" ''
set -eo pipefail
- if [ "$#" -eq 0 ]; then # if script is called from within nix-on-droid app
- echo "Welcome to Nix-on-Droid!"
- echo "If nothing works, open an issue at https://github.com/t184256/nix-on-droid/issues or try the rescue shell."
- fi
+ ${lib.optionalString (config.environment.motd != null) ''
+ if [ "$#" -eq 0 ]; then # if script is called from within nix-on-droid app
+ echo "${lib.removeSuffix "\n" config.environment.motd}"
+ fi
+ ''}
${lib.optionalString config.build.initialBuild ''
if [ -e /etc/UNINTIALISED ]; then
diff --git a/modules/environment/session-init.nix b/modules/environment/session-init.nix
index b726909..83366d3 100644
--- a/modules/environment/session-init.nix
+++ b/modules/environment/session-init.nix
@@ -1,4 +1,4 @@
-# Copyright (c) 2019-2020, see AUTHORS. Licensed under MIT License, see LICENSE.
+# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
{ config, lib, pkgs, ... }:
@@ -49,41 +49,54 @@ in
options = {
- environment.sessionVariables = mkOption {
- default = { };
- type = types.attrs;
- example = { EDITOR = "emacs"; GS_OPTIONS = "-sPAPERSIZE=a4"; };
- description = ''
- Environment variables to always set at login.
-
- The values may refer to other environment variables using
- POSIX.2 style variable references. For example, a variable
- parameter may be referenced as
- $parameter or ''${parameter}. A
- default value foo may be given as per
- ''${parameter:-foo} and, similarly, an alternate
- value bar can be given as per
- ''${parameter:+bar}.
-
- Note, these variables may be set in any order so no session
- variable may have a runtime dependency on another session
- variable. In particular code like
-
- environment.sessionVariables = {
- FOO = "Hello";
- BAR = "$FOO World!";
- };
-
- may not work as expected. If you need to reference another
- session variable, then do so inside Nix instead. The above
- example then becomes
-
- environment.sessionVariables = {
- FOO = "Hello";
- BAR = "''${config.environment.sessionVariables.FOO} World!";
- };
-
- '';
+ environment = {
+ motd = mkOption {
+ default = ''
+ Welcome to Nix-on-Droid!
+ If nothing works, open an issue at https://github.com/t184256/nix-on-droid/issues or try the rescue shell.
+ '';
+ type = types.nullOr types.lines;
+ description = ''
+ Text to show on every new shell created by nix-on-droid.
+ '';
+ };
+
+ sessionVariables = mkOption {
+ default = { };
+ type = types.attrs;
+ example = { EDITOR = "emacs"; GS_OPTIONS = "-sPAPERSIZE=a4"; };
+ description = ''
+ Environment variables to always set at login.
+
+ The values may refer to other environment variables using
+ POSIX.2 style variable references. For example, a variable
+ parameter may be referenced as
+ $parameter or ''${parameter}. A
+ default value foo may be given as per
+ ''${parameter:-foo} and, similarly, an alternate
+ value bar can be given as per
+ ''${parameter:+bar}.
+
+ Note, these variables may be set in any order so no session
+ variable may have a runtime dependency on another session
+ variable. In particular code like
+
+ environment.sessionVariables = {
+ FOO = "Hello";
+ BAR = "$FOO World!";
+ };
+
+ may not work as expected. If you need to reference another
+ session variable, then do so inside Nix instead. The above
+ example then becomes
+
+ environment.sessionVariables = {
+ FOO = "Hello";
+ BAR = "''${config.environment.sessionVariables.FOO} World!";
+ };
+
+ '';
+ };
};
};