{ inputs, self, ... }: let mkNhAttrs = config: { enable = true; flake = config.info.rootPath; clean = config.features.applications.cli.nh.clean; }; in { imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "globalOptions" ({ lib, ... }: { options.features.applications.cli.nh = { enable = lib.mkEnableOption "NH: Yet another Nix CLI helper"; clean = { enable = lib.mkEnableOption "automatic cleaning of the system with `nh clean`"; dates = lib.mkOption { type = lib.types.str; description = "This option defines when the cleaning job should run, in the format of [`systemd.time` calendar events](https://www.man7.org/linux/man-pages/man7/systemd.time.7.html#CALENDAR_EVENTS)."; default = "daily"; example = "Sun 05:00"; }; extraArgs = lib.mkOption { type = lib.types.str; description = "This option sets any extra arguments that should be passed to the `nh clean` command when it is called by this automated service."; default = "--keep 10 --keep-since 7d"; }; }; }; })) ]; flake.nixosModules.global = { pkgs, config, lib, ... }: { config = lib.mkIf (config.features.applications.cli.nh.enable) { programs.nh = mkNhAttrs config; home-manager.users.grey = lib.mkIf (config.features.nixos.home-manager.enable) { features.applications.cli.nh = lib.mkDefault config.features.applications.cli.nh; }; }; }; flake.homeModules.global = { pkgs, config, lib, ... }: { config = lib.mkIf (config.features.applications.cli.nh.enable && config.info.isStandalone) { programs.nh = mkNhAttrs config; }; }; }