mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-01 07:01:54 +00:00
1e95e114e5
While systemd suggests using the pre-defined graphical-session user target, I found that this interface is difficult to use. Additionally, no other major distribution, even in their unstable versions, currently use this mechanism. The window or desktop manager is supposed to run in a systemd user service which activates graphical-session.target and the user services that are binding to this target. The issue is that we can't elegantly pass the xsession environment to the window manager session, in particular whereas the PassEnvironment option does work for DISPLAY, it for some mysterious reason won't for PATH. This commit implements a new graphical user target that works just like default.target. Services which should be run in a graphical session just need to declare wantedBy graphical.target. The graphical target will be activated in the xsession before executing the window or display manager. Fixes #17858.
64 lines
1.5 KiB
Nix
64 lines
1.5 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.arbtt;
|
|
in {
|
|
options = {
|
|
services.arbtt = {
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = ''
|
|
Enable the arbtt statistics capture service.
|
|
'';
|
|
};
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.haskellPackages.arbtt;
|
|
defaultText = "pkgs.haskellPackages.arbtt";
|
|
example = literalExample "pkgs.haskellPackages.arbtt";
|
|
description = ''
|
|
The package to use for the arbtt binaries.
|
|
'';
|
|
};
|
|
|
|
logFile = mkOption {
|
|
type = types.str;
|
|
default = "%h/.arbtt/capture.log";
|
|
example = "/home/username/.arbtt-capture.log";
|
|
description = ''
|
|
The log file for captured samples.
|
|
'';
|
|
};
|
|
|
|
sampleRate = mkOption {
|
|
type = types.int;
|
|
default = 60;
|
|
example = 120;
|
|
description = ''
|
|
The sampling interval in seconds.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
systemd.user.services.arbtt = {
|
|
description = "arbtt statistics capture service";
|
|
wantedBy = [ "graphical-session.target" ];
|
|
partOf = [ "graphical-session.target" ];
|
|
|
|
serviceConfig = {
|
|
Type = "simple";
|
|
ExecStart = "${cfg.package}/bin/arbtt-capture --logfile=${cfg.logFile} --sample-rate=${toString cfg.sampleRate}";
|
|
Restart = "always";
|
|
};
|
|
};
|
|
};
|
|
|
|
meta.maintainers = [ maintainers.michaelpj ];
|
|
}
|