5f433eb164
Before, loading a module would be guarded by an optional platform condition. This made it possible to avoid loading and evaluating a module if it did not support the host platform. Unfortunately, this made it impossible to share a single configuration between GNU/Linux and Darwin hosts, which some wish to do. This removes the conditional load and instead inserts host platform assertions in the modules that are platform specific. Fixes #1906
67 lines
1.6 KiB
Nix
67 lines
1.6 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let cfg = config.services.unclutter;
|
|
|
|
in {
|
|
options.services.unclutter = {
|
|
|
|
enable = mkEnableOption "unclutter";
|
|
|
|
package = mkOption {
|
|
description = "unclutter derivation to use.";
|
|
type = types.package;
|
|
default = pkgs.unclutter-xfixes;
|
|
defaultText = literalExample "pkgs.unclutter-xfixes";
|
|
};
|
|
|
|
timeout = mkOption {
|
|
description = "Number of seconds before the cursor is marked inactive.";
|
|
type = types.int;
|
|
default = 1;
|
|
};
|
|
|
|
threshold = mkOption {
|
|
description = "Minimum number of pixels considered cursor movement.";
|
|
type = types.int;
|
|
default = 1;
|
|
};
|
|
|
|
extraOptions = mkOption {
|
|
description = "More arguments to pass to the unclutter command.";
|
|
type = types.listOf types.str;
|
|
default = [ ];
|
|
example = [ "exclude-root" "ignore-scrolling" ];
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
assertions = [
|
|
(lib.hm.assertions.assertPlatform "services.unclutter" pkgs
|
|
lib.platforms.linux)
|
|
];
|
|
|
|
systemd.user.services.unclutter = {
|
|
Unit = {
|
|
Description = "unclutter";
|
|
After = [ "graphical-session-pre.target" ];
|
|
PartOf = [ "graphical-session.target" ];
|
|
};
|
|
|
|
Service = {
|
|
ExecStart = ''
|
|
${cfg.package}/bin/unclutter \
|
|
--timeout ${toString cfg.timeout} \
|
|
--jitter ${toString (cfg.threshold - 1)} \
|
|
${concatMapStrings (x: " --${x}") cfg.extraOptions}
|
|
'';
|
|
RestartSec = 3;
|
|
Restart = "always";
|
|
};
|
|
|
|
Install = { WantedBy = [ "graphical-session.target" ]; };
|
|
};
|
|
};
|
|
}
|