1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

nushell: Add plugin support

This commit is contained in:
Joaquín Triñanes 2024-06-03 09:33:03 +02:00
parent c41e54ac3d
commit 28e62eb5eb
No known key found for this signature in database
GPG key ID: 6E1446DD451C6BAF

View file

@ -39,7 +39,7 @@ let
};
});
in {
meta.maintainers = [ maintainers.Philipp-M ];
meta.maintainers = with maintainers; [ Philipp-M joaquintrinanes ];
imports = [
(mkRemovedOptionModule [ "programs" "nushell" "settings" ] ''
@ -152,6 +152,13 @@ in {
An attribute set that maps an environment variable to a shell interpreted string.
'';
};
plugins = mkOption {
type = types.listOf types.package;
default = [ ];
example = lib.literalExpression "[ pkgs.nushellPlugins.formats ]";
description = "List of nushell plugins ";
};
};
config = mkIf cfg.enable {
@ -188,5 +195,23 @@ in {
cfg.extraLogin
];
};
home.file."${configDir}/plugin.msgpackz" = let
pluginExprs = map (plugin: "plugin add ${lib.getExe plugin}") cfg.plugins;
in mkIf (cfg.plugins != [ ]) {
source = pkgs.runCommandLocal "plugin.msgpackz" { } ''
touch $out {config,env}.nu
${lib.getExe cfg.package} \
--config config.nu \
--env-config env.nu \
--plugin-config plugin.msgpackz \
--no-history \
--no-std-lib \
--commands '${lib.concatStringsSep ";" pluginExprs};'
cp plugin.msgpackz $out
'';
};
};
}