diff --git a/modules/programs/nushell.nix b/modules/programs/nushell.nix index a977bd4a..b72cbb69 100644 --- a/modules/programs/nushell.nix +++ b/modules/programs/nushell.nix @@ -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. + + + See 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 + ]; + }) ]; }; } diff --git a/tests/modules/programs/nushell/example-settings.nix b/tests/modules/programs/nushell/example-settings.nix index d8cb01a7..7259db6d 100644 --- a/tests/modules/programs/nushell/example-settings.nix +++ b/tests/modules/programs/nushell/example-settings.nix @@ -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} ''; } diff --git a/tests/modules/programs/nushell/login-expected.nu b/tests/modules/programs/nushell/login-expected.nu new file mode 100644 index 00000000..9c21789d --- /dev/null +++ b/tests/modules/programs/nushell/login-expected.nu @@ -0,0 +1,5 @@ +# Prints "Hello, World" upon logging into tty1 +if (tty) == "/dev/tty1" { + echo "Hello, World" +} +