71 lines
1.7 KiB
Nix
71 lines
1.7 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
inherit (lib) types;
|
|
inherit (lib.options) mkEnableOption mkOption;
|
|
cfg = config.services.smooooth;
|
|
in
|
|
{
|
|
options.services.smooooth = {
|
|
enable = mkEnableOption "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;
|
|
};
|
|
nixPackage = mkOption {
|
|
description = "Your preferred package providing a `nix` executable.";
|
|
default = pkgs.nix;
|
|
type = types.package;
|
|
};
|
|
package = mkOption {
|
|
description = "smooooth package";
|
|
type = types.package;
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
# idk probably need more soteria workarounds
|
|
security.polkit.enable = lib.mkIf (config.security.soteria.enable == false) true;
|
|
systemd.user = {
|
|
services.smooooth = {
|
|
enable = true;
|
|
path = [
|
|
cfg.package
|
|
];
|
|
serviceConfig = {
|
|
Restart = "always";
|
|
Type = "exec";
|
|
ExecStart =
|
|
let
|
|
blockers = builtins.concatStringsSep "|" cfg.blockers;
|
|
in
|
|
"${lib.getExe cfg.package} ${cfg.path} ${blockers} ${toString cfg.pollingRate}";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|