Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nushell: allow installing plugins #6176

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions modules/misc/news.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1890,6 +1890,15 @@ in {
NOTE: The minus symbol means to NOT use that particular TLS version.
'';
}

{
time = "2024-12-10T22:20:10+00:00";
condition = config.programs.nushell.enable;
message = ''
The module 'programs.nushell' can now manage the Nushell plugin
registry with the option 'programs.nushell.plugins'.
'';
}
];
};
}
26 changes: 25 additions & 1 deletion modules/programs/nushell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ let
};
});
in {
meta.maintainers = [ maintainers.Philipp-M maintainers.joaquintrinanes ];
meta.maintainers =
[ maintainers.Philipp-M maintainers.joaquintrinanes maintainers.aidalgol ];

imports = [
(mkRemovedOptionModule [ "programs" "nushell" "settings" ] ''
Expand Down Expand Up @@ -134,6 +135,15 @@ in {
'';
};

plugins = mkOption {
type = types.listOf types.package;
default = [ ];
example = lib.literalExpression "[ pkgs.nushellPlugins.formats ]";
description = ''
A list of nushell plugins to write to the plugin registry file.
'';
};

shellAliases = mkOption {
type = types.attrsOf types.str;
default = { };
Expand Down Expand Up @@ -203,6 +213,20 @@ in {
cfg.extraLogin
];
})

(let
msgPackz = pkgs.runCommand "nushellMsgPackz" { } ''
mkdir -p "$out"
${lib.getExe cfg.package} \
--plugin-config "$out/plugin.msgpackz" \
--commands '${
concatStringsSep "; "
(map (plugin: "plugin add ${lib.getExe plugin}") cfg.plugins)
}'
'';
in mkIf (cfg.plugins != [ ]) {
"${configDir}/plugin.msgpackz".source = "${msgPackz}/plugin.msgpackz";
})
];
};
}
6 changes: 4 additions & 2 deletions tests/modules/programs/nushell/example-settings.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
}
'';

plugins = [ pkgs.nushellPlugins.formats ];

shellAliases = {
"lsname" = "(ls | get name)";
"ll" = "ls -a";
Expand All @@ -41,8 +43,6 @@
};
};

test.stubs.nushell = { };

nmt.script = let
configDir = if pkgs.stdenv.isDarwin && !config.xdg.enable then
"home-files/Library/Application Support/nushell"
Expand All @@ -58,5 +58,7 @@
assertFileContent \
"${configDir}/login.nu" \
${./login-expected.nu}
assertFileExists \
"${configDir}/plugin.msgpackz"
'';
}
Loading