smooooth/nix/impl.nix
2025-05-25 20:11:20 +10:00

47 lines
1.1 KiB
Nix

{
lib,
config,
...
}:
let
cfg = config.services.smooooth;
in
{
config = lib.mkIf config.services.smooooth.enable {
environment.etc."smooooth.json".text = builtins.toJSON {
inherit (cfg) path;
blockers =
let
withDefaults = map (
b: if builtins.typeOf b == "string" then { "${b}" = "stop"; } else b
) cfg.blockers;
merged = lib.mergeAttrsList withDefaults;
# FIXME clumsy, could do better
transformed = lib.mapAttrsToList (n: v: {
name = n;
cond = [
(lib.toSentenceCase v)
];
}) merged;
in
transformed;
};
systemd.user = {
services.smooooth = {
enable = true;
path = [
cfg.package
cfg.nixPackage
];
wantedBy = [ "graphical-session.target" ];
after = [ "graphical-session.target" ];
serviceConfig = {
Restart = "always";
Type = "notify";
ExecStart = "${lib.getExe cfg.package}";
};
};
};
};
}