{
  config,
  marleylib,
  osConfig,
  lib,
  ...
}: let
  inherit (marleylib.module) mkEnableOption';

  osCfg = osConfig.marleyos.programs.nh.enable;
  cfg = config.marleyos.programs.nh;
in {
  options.marleyos.programs.nh.enable = mkEnableOption' "nh" osCfg;

  config = lib.mkIf cfg.enable {
    programs.nh = {
      enable = true;

      clean =
        osConfig.programs.nh.clean
        or {
          enable = true;
          dates = "daily";
          extraArgs = "--keep-since 7d --keep 3";
        };
    };

    home.sessionVariables.FLAKE = "${config.home.homeDirectory}/marleyos";

    home.shellAbbrs = {
      nhs = "nh search";
    };
  };
}
