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`
|
* In an effort to reduce the number of arguments to `lib.nixOnDroidConfiguration`
|
||||||
function in flake configurations, `system` is now inferred from `pkgs.system`
|
function in flake configurations, `system` is now inferred from `pkgs.system`
|
||||||
and `config` and `extraModules` are now combined into `modules`
|
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
|
## Release 22.05
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,11 @@ writeText "login-inner" ''
|
||||||
|
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
if [ "$#" -eq 0 ]; then # if script is called from within nix-on-droid app
|
${lib.optionalString (config.environment.motd != null) ''
|
||||||
echo "Welcome to Nix-on-Droid!"
|
if [ "$#" -eq 0 ]; then # if script is called from within nix-on-droid app
|
||||||
echo "If nothing works, open an issue at https://github.com/t184256/nix-on-droid/issues or try the rescue shell."
|
echo "${lib.removeSuffix "\n" config.environment.motd}"
|
||||||
fi
|
fi
|
||||||
|
''}
|
||||||
|
|
||||||
${lib.optionalString config.build.initialBuild ''
|
${lib.optionalString config.build.initialBuild ''
|
||||||
if [ -e /etc/UNINTIALISED ]; then
|
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, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
|
@ -49,41 +49,54 @@ in
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
environment.sessionVariables = mkOption {
|
environment = {
|
||||||
default = { };
|
motd = mkOption {
|
||||||
type = types.attrs;
|
default = ''
|
||||||
example = { EDITOR = "emacs"; GS_OPTIONS = "-sPAPERSIZE=a4"; };
|
Welcome to Nix-on-Droid!
|
||||||
description = ''
|
If nothing works, open an issue at https://github.com/t184256/nix-on-droid/issues or try the rescue shell.
|
||||||
Environment variables to always set at login.
|
'';
|
||||||
</para><para>
|
type = types.nullOr types.lines;
|
||||||
The values may refer to other environment variables using
|
description = ''
|
||||||
POSIX.2 style variable references. For example, a variable
|
Text to show on every new shell created by nix-on-droid.
|
||||||
<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
|
sessionVariables = mkOption {
|
||||||
value <literal>bar</literal> can be given as per
|
default = { };
|
||||||
<code>''${parameter:+bar}</code>.
|
type = types.attrs;
|
||||||
</para><para>
|
example = { EDITOR = "emacs"; GS_OPTIONS = "-sPAPERSIZE=a4"; };
|
||||||
Note, these variables may be set in any order so no session
|
description = ''
|
||||||
variable may have a runtime dependency on another session
|
Environment variables to always set at login.
|
||||||
variable. In particular code like
|
</para><para>
|
||||||
<programlisting language="nix">
|
The values may refer to other environment variables using
|
||||||
environment.sessionVariables = {
|
POSIX.2 style variable references. For example, a variable
|
||||||
FOO = "Hello";
|
<varname>parameter</varname> may be referenced as
|
||||||
BAR = "$FOO World!";
|
<code>$parameter</code> or <code>''${parameter}</code>. A
|
||||||
};
|
default value <literal>foo</literal> may be given as per
|
||||||
</programlisting>
|
<code>''${parameter:-foo}</code> and, similarly, an alternate
|
||||||
may not work as expected. If you need to reference another
|
value <literal>bar</literal> can be given as per
|
||||||
session variable, then do so inside Nix instead. The above
|
<code>''${parameter:+bar}</code>.
|
||||||
example then becomes
|
</para><para>
|
||||||
<programlisting language="nix">
|
Note, these variables may be set in any order so no session
|
||||||
environment.sessionVariables = {
|
variable may have a runtime dependency on another session
|
||||||
FOO = "Hello";
|
variable. In particular code like
|
||||||
BAR = "''${config.environment.sessionVariables.FOO} World!";
|
<programlisting language="nix">
|
||||||
};
|
environment.sessionVariables = {
|
||||||
</programlisting>
|
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