wbg: add module

This commit is contained in:
y3
2026-09-16 09:43:02 +01:00
committed by Austin Horstman
parent 9d485f74cd
commit 067bb9844c
5 changed files with 103 additions and 0 deletions

View 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
View 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 ];
};
};
};
}

View File

@@ -0,0 +1,5 @@
{ lib, pkgs, ... }:
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
wbg-service = ./service.nix;
}

View 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}
'';
}

View 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