{ pkgs, lib, config, self, ... }: let inherit (lib.options) types mkEnable mkOption; cfg = config.smooooth; in { options.programs.smooooth = { enable = mkEnable "the smooooth nixos hot reloader"; blockers = mkOption { description = "Names of processes that may block reloading when holding a flake (sub)path open."; default = [ "nano" "nvim" "vim" "vi" "hx" ]; example = '' [ "hx" ] ''; type = types.listOf types.str; }; path = mkOption { description = "Path to the root of your flake."; type = types.str; }; pollingRate = mkOption { description = "How frequently to poll for blockers when waiting on a reload."; default = 10; type = types.int; }; preferredNix = mkOption { description = "Your preferred package that provides a nix-compatible executable."; default = pkgs.nix; type = types.package; }; }; config = lib.mkIf cfg.enable { systemd.user = { services.smooooth = { path = [ (self.packages.${pkgs.system}.smooooth cfg.preferredNix) ]; serviceConfig = { Type = "oneshot"; ExecStart = let blockers = builtins.concatStringsSep "|" cfg.blockers; in "smooooth ${cfg.path} ${blockers} ${toString cfg.pollingRate}"; }; }; paths.smooooth = { pathConfig = { PathChanged = cfg.path; Unit = "smoooth.service"; TriggerLimitIntervalSec = cfg.pollingRate * 2; }; }; }; }; }