mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 11:36:07 +01:00
environment.motd: add option
This commit is contained in:
parent
a99c1e0416
commit
ffac515cfb
3 changed files with 56 additions and 40 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
</para><para>
|
||||
The values may refer to other environment variables using
|
||||
POSIX.2 style variable references. For example, a variable
|
||||
<varname>parameter</varname> may be referenced as
|
||||
<code>$parameter</code> or <code>''${parameter}</code>. A
|
||||
default value <literal>foo</literal> may be given as per
|
||||
<code>''${parameter:-foo}</code> and, similarly, an alternate
|
||||
value <literal>bar</literal> can be given as per
|
||||
<code>''${parameter:+bar}</code>.
|
||||
</para><para>
|
||||
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
|
||||
<programlisting language="nix">
|
||||
environment.sessionVariables = {
|
||||
FOO = "Hello";
|
||||
BAR = "$FOO World!";
|
||||
};
|
||||
</programlisting>
|
||||
may not work as expected. If you need to reference another
|
||||
session variable, then do so inside Nix instead. The above
|
||||
example then becomes
|
||||
<programlisting language="nix">
|
||||
environment.sessionVariables = {
|
||||
FOO = "Hello";
|
||||
BAR = "''${config.environment.sessionVariables.FOO} World!";
|
||||
};
|
||||
</programlisting>
|
||||
'';
|
||||
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.
|
||||
</para><para>
|
||||
The values may refer to other environment variables using
|
||||
POSIX.2 style variable references. For example, a variable
|
||||
<varname>parameter</varname> may be referenced as
|
||||
<code>$parameter</code> or <code>''${parameter}</code>. A
|
||||
default value <literal>foo</literal> may be given as per
|
||||
<code>''${parameter:-foo}</code> and, similarly, an alternate
|
||||
value <literal>bar</literal> can be given as per
|
||||
<code>''${parameter:+bar}</code>.
|
||||
</para><para>
|
||||
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
|
||||
<programlisting language="nix">
|
||||
environment.sessionVariables = {
|
||||
FOO = "Hello";
|
||||
BAR = "$FOO World!";
|
||||
};
|
||||
</programlisting>
|
||||
may not work as expected. If you need to reference another
|
||||
session variable, then do so inside Nix instead. The above
|
||||
example then becomes
|
||||
<programlisting language="nix">
|
||||
environment.sessionVariables = {
|
||||
FOO = "Hello";
|
||||
BAR = "''${config.environment.sessionVariables.FOO} World!";
|
||||
};
|
||||
</programlisting>
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue