mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
avizo: don't write a config file if settings are empty
Before this change, the default config provided by this module wrote an empty file to `$HOME/.config/avizo/config.ini`, which caused a bunch of errors, as Avizo tries to read a 'group' from the ini file, which fails. This commit also adds associated test cases. PR #3871
This commit is contained in:
parent
ac4c5c6fd8
commit
cc05d26326
5 changed files with 96 additions and 3 deletions
|
@ -47,10 +47,11 @@ in {
|
|||
assertions =
|
||||
[ (hm.assertions.assertPlatform "services.avizo" pkgs platforms.linux) ];
|
||||
|
||||
home.packages = [ cfg.package ];
|
||||
xdg.configFile."avizo/config.ini" = mkIf (cfg.settings != { }) {
|
||||
source = settingsFormat.generate "avizo-config.ini" cfg.settings;
|
||||
};
|
||||
|
||||
xdg.configFile."avizo/config.ini".source =
|
||||
settingsFormat.generate "avizo-config.ini" cfg.settings;
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
systemd.user = {
|
||||
services.avizo = {
|
||||
|
|
|
@ -169,6 +169,7 @@ import nmt {
|
|||
./modules/programs/wlogout
|
||||
./modules/programs/xmobar
|
||||
./modules/programs/yt-dlp
|
||||
./modules/services/avizo
|
||||
./modules/services/barrier
|
||||
./modules/services/borgmatic
|
||||
./modules/services/cachix-agent
|
||||
|
|
4
tests/modules/services/avizo/default.nix
Normal file
4
tests/modules/services/avizo/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
avizo-with-settings = ./with-settings.nix;
|
||||
avizo-without-settings = ./without-settings.nix;
|
||||
}
|
54
tests/modules/services/avizo/with-settings.nix
Normal file
54
tests/modules/services/avizo/with-settings.nix
Normal file
|
@ -0,0 +1,54 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
services.avizo = {
|
||||
enable = true;
|
||||
settings = {
|
||||
default = {
|
||||
time = 1.0;
|
||||
y-offset = 0.5;
|
||||
fade-in = 0.1;
|
||||
fade-out = 0.2;
|
||||
padding = 10;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
test.stubs.avizo = { };
|
||||
|
||||
nmt.script = ''
|
||||
serviceFile=home-files/.config/systemd/user/avizo.service
|
||||
assertFileExists $serviceFile
|
||||
assertFileContent $serviceFile ${
|
||||
builtins.toFile "expected" ''
|
||||
[Install]
|
||||
WantedBy=graphical-session.target
|
||||
|
||||
[Service]
|
||||
ExecStart=@avizo@/bin/avizo-service
|
||||
Restart=always
|
||||
Type=simple
|
||||
|
||||
[Unit]
|
||||
After=graphical-session.target
|
||||
ConditionEnvironment=WAYLAND_DISPLAY
|
||||
Description=Volume/backlight OSD indicator
|
||||
Documentation=man:avizo(1)
|
||||
PartOf=graphical-session.target
|
||||
''
|
||||
}
|
||||
|
||||
configFile=home-files/.config/avizo/config.ini
|
||||
assertFileExists $configFile
|
||||
assertFileContent $configFile ${
|
||||
builtins.toFile "expected" ''
|
||||
[default]
|
||||
fade-in=0.100000
|
||||
fade-out=0.200000
|
||||
padding=10
|
||||
time=1.000000
|
||||
y-offset=0.500000
|
||||
''
|
||||
}
|
||||
'';
|
||||
}
|
33
tests/modules/services/avizo/without-settings.nix
Normal file
33
tests/modules/services/avizo/without-settings.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
services.avizo.enable = true;
|
||||
|
||||
test.stubs.avizo = { };
|
||||
|
||||
nmt.script = ''
|
||||
serviceFile=home-files/.config/systemd/user/avizo.service
|
||||
assertFileExists $serviceFile
|
||||
assertFileContent $serviceFile ${
|
||||
builtins.toFile "expected" ''
|
||||
[Install]
|
||||
WantedBy=graphical-session.target
|
||||
|
||||
[Service]
|
||||
ExecStart=@avizo@/bin/avizo-service
|
||||
Restart=always
|
||||
Type=simple
|
||||
|
||||
[Unit]
|
||||
After=graphical-session.target
|
||||
ConditionEnvironment=WAYLAND_DISPLAY
|
||||
Description=Volume/backlight OSD indicator
|
||||
Documentation=man:avizo(1)
|
||||
PartOf=graphical-session.target
|
||||
''
|
||||
}
|
||||
|
||||
configFile=home-files/.config/avizo/config.ini
|
||||
assertPathNotExists $configFile
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue