alqueva/hosts/shared/nushell.nix

38 lines
824 B
Nix

{
lib,
pkgs,
config,
...
}:
let
inherit (lib.options) mkOption mkPackageOption mkEnableOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) nullOr str;
cfg = config.alqueva.shells.nushell;
in
{
options.alqueva.shells.nushell = {
enable = mkEnableOption "Nushell";
package = mkPackageOption pkgs "nushell" { };
config = mkOption {
type = nullOr str;
default = null;
description = "Nushell code to load by default with Nushell.";
};
};
config = mkIf cfg.enable (mkMerge [
{
environment = {
systemPackages = [ cfg.package ];
shells = [
(lib.getExe' cfg.package "nu")
"/run/current-system/sw/bin/nu"
];
};
}
(mkIf (cfg.config != null) {
environment.systemPackages = [ ];
})
]);
}