mirror of
https://github.com/nix-community/home-manager.git
synced 2026-10-03 12:09:19 +00:00
wbg: add module
This commit is contained in:
9
modules/misc/news/2026/07/2026-07-29_03-27-10.nix
Normal file
9
modules/misc/news/2026/07/2026-07-29_03-27-10.nix
Normal file
@@ -0,0 +1,9 @@
|
||||
{ pkgs, ... }: {
|
||||
time = "2026-07-29T02:27:10+00:00";
|
||||
condition = pkgs.stdenv.hostPlatform.isLinux;
|
||||
message = ''
|
||||
A new module is available: 'services.wbg'.
|
||||
|
||||
wbg is a super simple wallpaper application for Wayland compositors.
|
||||
'';
|
||||
}
|
||||
63
modules/services/wbg.nix
Normal file
63
modules/services/wbg.nix
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
mkEnableOption
|
||||
mkOption
|
||||
mkIf
|
||||
getExe
|
||||
escapeShellArgs
|
||||
mkPackageOption
|
||||
types
|
||||
;
|
||||
|
||||
cfg = config.services.wbg;
|
||||
in
|
||||
{
|
||||
meta.maintainers = with lib.maintainers; [ yarn ];
|
||||
|
||||
options.services.wbg = {
|
||||
enable = mkEnableOption "wbg, a super simple wallpaper application for Wayland compositors";
|
||||
package = mkPackageOption pkgs "wbg" { };
|
||||
|
||||
image = mkOption {
|
||||
type = types.either types.path types.str;
|
||||
description = "Path to the wallpaper image.";
|
||||
};
|
||||
|
||||
extraArgs = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
example = [ "-s" ];
|
||||
description = "Extra command-line arguments to pass to wbg.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enable && pkgs.stdenv.hostPlatform.isLinux) {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
systemd.user.services.wbg = {
|
||||
Unit = {
|
||||
ConditionEnvironment = "WAYLAND_DISPLAY";
|
||||
Description = "wbg";
|
||||
After = [ config.wayland.systemd.target ];
|
||||
PartOf = [ config.wayland.systemd.target ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
ExecStart = escapeShellArgs ([ (getExe cfg.package) ] ++ cfg.extraArgs ++ [ (toString cfg.image) ]);
|
||||
Restart = "on-failure";
|
||||
RestartSec = 10;
|
||||
};
|
||||
|
||||
Install = {
|
||||
WantedBy = [ config.wayland.systemd.target ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
5
tests/modules/services/wbg/default.nix
Normal file
5
tests/modules/services/wbg/default.nix
Normal file
@@ -0,0 +1,5 @@
|
||||
{ lib, pkgs, ... }:
|
||||
|
||||
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||
wbg-service = ./service.nix;
|
||||
}
|
||||
13
tests/modules/services/wbg/service.nix
Normal file
13
tests/modules/services/wbg/service.nix
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
services.wbg = {
|
||||
enable = true;
|
||||
image = "/tmp/wallpaper.png";
|
||||
extraArgs = [ "-s" ];
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
serviceFile=home-files/.config/systemd/user/wbg.service
|
||||
assertFileExists $serviceFile
|
||||
assertFileContent $serviceFile ${./wbg.service}
|
||||
'';
|
||||
}
|
||||
13
tests/modules/services/wbg/wbg.service
Normal file
13
tests/modules/services/wbg/wbg.service
Normal file
@@ -0,0 +1,13 @@
|
||||
[Install]
|
||||
WantedBy=graphical-session.target
|
||||
|
||||
[Service]
|
||||
ExecStart=@wbg@/bin/wbg -s /tmp/wallpaper.png
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
|
||||
[Unit]
|
||||
After=graphical-session.target
|
||||
ConditionEnvironment=WAYLAND_DISPLAY
|
||||
Description=wbg
|
||||
PartOf=graphical-session.target
|
||||
Reference in New Issue
Block a user