nushell: add login.nu configuration option
Nushell has the option to source from the login.nu file in the case that nushell is used as a login shell. This commit adds the login file alongside the existing config and env files as another configuration option.
This commit is contained in:
parent
24805d3ca7
commit
e15010ee6e
|
@ -96,6 +96,23 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
loginFile = mkOption {
|
||||
type = types.nullOr (linesOrSource "login.nu");
|
||||
default = null;
|
||||
example = ''
|
||||
# Prints "Hello, World" upon logging into tty1
|
||||
if (tty) == "/dev/tty1" {
|
||||
echo "Hello, World"
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
The login file to be used for nushell upon logging in.
|
||||
</para>
|
||||
<para>
|
||||
See <link xlink:href="https://www.nushell.sh/book/configuration.html#configuring-nu-as-a-login-shell" /> for more information.
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
|
@ -112,6 +129,14 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
extraLogin = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Additional configuration to add to the nushell login file.
|
||||
'';
|
||||
};
|
||||
|
||||
shellAliases = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
default = { };
|
||||
|
@ -161,6 +186,12 @@ in {
|
|||
envVarsStr
|
||||
];
|
||||
})
|
||||
(mkIf (cfg.loginFile != null || cfg.extraLogin != "") {
|
||||
"${configDir}/login.nu".text = mkMerge [
|
||||
(mkIf (cfg.loginFile != null) cfg.loginFile.text)
|
||||
cfg.extraLogin
|
||||
];
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -16,6 +16,13 @@
|
|||
let-env FOO = 'BAR'
|
||||
'';
|
||||
|
||||
loginFile.text = ''
|
||||
# Prints "Hello, World" upon logging into tty1
|
||||
if (tty) == "/dev/tty1" {
|
||||
echo "Hello, World"
|
||||
}
|
||||
'';
|
||||
|
||||
shellAliases = {
|
||||
"lsname" = "(ls | get name)";
|
||||
"ll" = "ls -a";
|
||||
|
@ -38,5 +45,8 @@
|
|||
assertFileContent \
|
||||
"${configDir}/env.nu" \
|
||||
${./env-expected.nu}
|
||||
assertFileContent \
|
||||
"${configDir}/login.nu" \
|
||||
${./login-expected.nu}
|
||||
'';
|
||||
}
|
||||
|
|
5
tests/modules/programs/nushell/login-expected.nu
Normal file
5
tests/modules/programs/nushell/login-expected.nu
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Prints "Hello, World" upon logging into tty1
|
||||
if (tty) == "/dev/tty1" {
|
||||
echo "Hello, World"
|
||||
}
|
||||
|
Loading…
Reference in a new issue