{
  lib,
  inputs',
  config,
  pkgs,
  ...
}:
let
  inherit (lib) mkEnableOption mkOption mkIf;
  inherit (lib.types) package;
  cfg = config.modules.services.nysh;
in
{
  options.modules.services.nysh = {
    enable = mkEnableOption "nysh";
    package = mkOption {
      type = package;
      default = inputs'.nysh.packages.nysh;
    };
  };

  config = mkIf cfg.enable {
    systemd.user.services.nysh = {
      path = [
        pkgs.curl
        pkgs.brightnessctl
        pkgs.networkmanager
      ];
      wantedBy = [
        "multi-user.target"
        "graphical-session.target"
      ];
      partOf = [ "graphical-session.target" ];
      after = [ "graphical-session-pre.target" ];

      serviceConfig = {
        Type = "simple";
        ExecStart = "/bin/sh -lc ${cfg.package}/bin/nysh";
        Restart = "on-failure";

        NoNewPrivileges = true;
      };
    };
  };
}
