programs: port to programs.services interface

This commit is contained in:
2023-09-12 04:44:38 +00:00
parent 3e33313bf0
commit 8a6fcd92ae
4 changed files with 45 additions and 52 deletions

View File

@@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { config, pkgs, ... }:
{ {
sane.programs.conky = { sane.programs.conky = {
fs.".config/conky/conky.conf".symlink.target = fs.".config/conky/conky.conf".symlink.target =
@@ -12,25 +12,23 @@
bat = "${battery_estimate}/bin/battery_estimate"; bat = "${battery_estimate}/bin/battery_estimate";
weather = "timeout 20 ${pkgs.sane-weather}/bin/sane-weather"; weather = "timeout 20 ${pkgs.sane-weather}/bin/sane-weather";
}; };
};
# TODO: give `sane.programs` native support for defining services services.conky = {
systemd.user.services.conky = lib.mkIf config.sane.programs.conky.enabled { description = "conky dynamic desktop background";
description = "conky dynamic desktop background"; wantedBy = [ "default.target" ];
wantedBy = [ "default.target" ]; # XXX: should be part of graphical-session.target, but whatever mix of greetd/sway
# XXX: should be part of graphical-session.target, but whatever mix of greetd/sway # i'm using means that target's never reached...
# i'm using means that target's never reached... # wantedBy = [ "graphical-session.target" ];
# wantedBy = [ "graphical-session.target" ]; # partOf = [ "graphical-session.target" ];
# partOf = [ "graphical-session.target" ];
# TODO: might want `ConditionUser=!@system`
serviceConfig.ExecStart = "${pkgs.conky}/bin/conky"; serviceConfig.ExecStart = "${config.sane.programs.conky.package}/bin/conky";
serviceConfig.Type = "simple"; serviceConfig.Type = "simple";
serviceConfig.Restart = "on-failure"; serviceConfig.Restart = "on-failure";
serviceConfig.RestartSec = "10s"; serviceConfig.RestartSec = "10s";
# serviceConfig.Slice = "session.slice"; # serviceConfig.Slice = "session.slice";
# don't start conky until after sway # don't start conky until after sway
preStart = ''test -n "$SWAYSOCK"''; preStart = ''test -n "$SWAYSOCK"'';
};
}; };
} }

View File

@@ -1,6 +1,6 @@
# config docs: # config docs:
# - `man 5 mako` # - `man 5 mako`
{ lib, config, pkgs, ... }: { config, lib, pkgs, ... }:
{ {
sane.programs.mako = { sane.programs.mako = {
# we control mako as a systemd service, so have dbus not automatically activate it. # we control mako as a systemd service, so have dbus not automatically activate it.
@@ -47,23 +47,21 @@
text-color=#ffffff text-color=#ffffff
background-color=#ff0000 background-color=#ff0000
''; '';
};
# mako supports activation via dbus (i.e. the daemon will be started on-demand when a # mako supports activation via dbus (i.e. the daemon will be started on-demand when a
# dbus client tries to talk to it): that works out-of-the-box just by putting mako # dbus client tries to talk to it): that works out-of-the-box just by putting mako
# on environment.packages, but then logs are blackholed. # on environment.packages, but then logs are blackholed.
# TODO: give `sane.programs` native support for defining services services.mako = {
systemd.user.services.mako = lib.mkIf config.sane.programs.mako.enabled { description = "mako desktop notification daemon";
description = "mako desktop notification daemon"; wantedBy = [ "default.target" ];
wantedBy = [ "default.target" ]; # XXX: should be part of graphical-session.target, but whatever mix of greetd/sway
# XXX: should be part of graphical-session.target, but whatever mix of greetd/sway # i'm using means that target's never reached...
# i'm using means that target's never reached...
# TODO: might want `ConditionUser=!@system`
serviceConfig.ExecStart = "${config.sane.programs.mako.package}/bin/mako"; serviceConfig.ExecStart = "${config.sane.programs.mako.package}/bin/mako";
serviceConfig.Type = "simple"; serviceConfig.Type = "simple";
# mako will predictably fail if launched before the wayland server is fully initialized # mako will predictably fail if launched before the wayland server is fully initialized
serviceConfig.Restart = "on-failure"; serviceConfig.Restart = "on-failure";
serviceConfig.RestartSec = "10s"; serviceConfig.RestartSec = "10s";
};
}; };
} }

View File

@@ -1,7 +1,6 @@
{ config, lib, pkgs, ... }: { config, lib, ... }:
{ {
# TODO: give `sane.programs` native support for defining services sane.programs.playerctl.services.playerctld = {
systemd.user.services.playerctld = lib.mkIf config.sane.programs.playerctl.enabled {
description = "playerctl daemon to keep track of which MPRIS players were recently active"; description = "playerctl daemon to keep track of which MPRIS players were recently active";
documentation = [ "https://github.com/altdesktop/playerctl/issues/161" ]; documentation = [ "https://github.com/altdesktop/playerctl/issues/161" ];
wantedBy = [ "default.target" ]; wantedBy = [ "default.target" ];

View File

@@ -146,19 +146,17 @@
}; };
}; };
}; };
}; services.swaync = {
# swaync ships its own service, but i want to add `environment` variables and flags for easier debugging.
# TODO: give `sane.programs` native support for defining services # seems that's not possible without defining an entire nix-native service (i.e. this).
systemd.user.services.swaync = lib.mkIf config.sane.programs.swaynotificationcenter.enabled { description = "Swaync desktop notification daemon";
# swaync ships its own service, but i want to add `environment` variables and flags for easier debugging. wantedBy = [ "default.target" ];
# seems that's not possible without defining an entire nix-native service (i.e. this). serviceConfig.ExecStart = "${config.sane.programs.swaynotificationcenter.package}/bin/swaync";
description = "Swaync desktop notification daemon"; serviceConfig.Type = "simple";
wantedBy = [ "default.target" ]; # serviceConfig.BusName = "org.freedesktop.Notifications";
serviceConfig.ExecStart = "${config.sane.programs.swaynotificationcenter.package}/bin/swaync"; serviceConfig.Restart = "on-failure";
serviceConfig.Type = "dbus"; serviceConfig.RestartSec = "10s";
serviceConfig.BusName = "org.freedesktop.Notifications"; environment.G_MESSAGES_DEBUG = "all";
serviceConfig.Restart = "on-failure"; };
serviceConfig.RestartSec = "10s";
environment.G_MESSAGES_DEBUG = "all";
}; };
} }