68 lines
1.6 KiB
Nix
68 lines
1.6 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
smooooth,
|
|
...
|
|
}:
|
|
let
|
|
inherit (lib.options) types mkEnable mkOption;
|
|
cfg = config.smooooth;
|
|
in
|
|
{
|
|
options.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 = {
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
ExecStart =
|
|
let
|
|
blockers = builtins.concatStringsSep "|" cfg.blockers;
|
|
in
|
|
"smooooth ${cfg.path} ${blockers} ${toString cfg.pollingRate}";
|
|
};
|
|
};
|
|
paths.smooooth = {
|
|
path = [ (smooooth cfg.preferredNix) ];
|
|
pathConfig = {
|
|
PathChanged = cfg.path;
|
|
Unit = "smoooth.service";
|
|
TriggerLimitIntervalSec = cfg.pollingRate * 2;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|