{
  lib,
  pkgs,
  config,
  ...
}:
let
  inherit (lib.options) mkOption mkPackageOption mkEnableOption;
  inherit (lib.modules) mkIf;
  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 {
    environment = {
      systemPackages = [ cfg.package ];
      shells = [
        (lib.getExe' cfg.package "nu")
        "/run/current-system/sw/bin/nu"
      ];
    };
  };
}
