mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
swayidle: assert events migration warning
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
options,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
@@ -99,22 +100,14 @@ in
|
||||
events = mkOption {
|
||||
type =
|
||||
with types;
|
||||
(coercedTo (listOf attrs)) (
|
||||
coercedTo (listOf attrs) (
|
||||
events:
|
||||
lib.warn
|
||||
''
|
||||
The syntax of services.swayidle.events has changed. While it
|
||||
previously accepted a list of events, it now accepts an attrset
|
||||
keyed by the event name.
|
||||
''
|
||||
(
|
||||
lib.listToAttrs (
|
||||
map (e: {
|
||||
name = e.event;
|
||||
value = e.command;
|
||||
}) events
|
||||
)
|
||||
)
|
||||
lib.listToAttrs (
|
||||
map (e: {
|
||||
name = e.event;
|
||||
value = e.command;
|
||||
}) events
|
||||
)
|
||||
) (submodule eventsModule);
|
||||
default = { };
|
||||
example = literalExpression ''
|
||||
@@ -145,6 +138,21 @@ in
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
warnings = lib.optional (lib.any builtins.isList options.services.swayidle.events.definitions) (
|
||||
lib.hm.deprecations.mkDeprecatedOptionValueWarning {
|
||||
option = [
|
||||
"services"
|
||||
"swayidle"
|
||||
"events"
|
||||
];
|
||||
old = "a list";
|
||||
replacement = "an attribute set keyed by event name";
|
||||
details = ''
|
||||
Use event names as attribute keys and commands as values.
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
||||
assertions = [
|
||||
(lib.hm.assertions.assertPlatform "services.swayidle" pkgs lib.platforms.linux)
|
||||
];
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
{ config, ... }:
|
||||
{
|
||||
# Exercise merging legacy list definitions with new attrset definitions.
|
||||
imports = [
|
||||
{
|
||||
services.swayidle.events.after-resume = "notify-send resumed";
|
||||
}
|
||||
];
|
||||
|
||||
services.swayidle = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { outPath = "@swayidle@"; };
|
||||
@@ -15,11 +22,13 @@
|
||||
];
|
||||
};
|
||||
|
||||
test.asserts.evalWarnings.expected = [
|
||||
test.asserts.warnings.expected = [
|
||||
''
|
||||
The syntax of services.swayidle.events has changed. While it
|
||||
previously accepted a list of events, it now accepts an attrset
|
||||
keyed by the event name.
|
||||
Using `services.swayidle.events` as a list is deprecated and will be
|
||||
removed in a future release. Please use an attribute set keyed by event name instead.
|
||||
|
||||
Use event names as attribute keys and commands as values.
|
||||
|
||||
''
|
||||
];
|
||||
|
||||
@@ -36,7 +45,7 @@
|
||||
|
||||
[Service]
|
||||
Environment=PATH=@bash-interactive@/bin
|
||||
ExecStart=@swayidle@/bin/dummy -w before-sleep 'swaylock -fF' lock 'swaylock -fF'
|
||||
ExecStart=@swayidle@/bin/dummy -w after-resume 'notify-send resumed' before-sleep 'swaylock -fF' lock 'swaylock -fF'
|
||||
Restart=always
|
||||
Type=simple
|
||||
|
||||
|
||||
Reference in New Issue
Block a user