mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
sxhkd: fix environment (#1892)
* sxhkd: move to xsession.initExtra When sxhkd is launched as systemd service it doesn't have $PATH a user expects to see. * sxhkd: add news entry
This commit is contained in:
parent
86944b0fb1
commit
ff959fd49a
3 changed files with 38 additions and 37 deletions
|
@ -1954,6 +1954,18 @@ in
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
time = "2021-05-02T11:22:42+00:00";
|
||||||
|
condition = hostPlatform.isLinux && config.services.sxhkd.enable;
|
||||||
|
message = ''
|
||||||
|
The sxhkd service now is started using 'xsession.initExtra',
|
||||||
|
therefore this module loses systemd service management capabilities
|
||||||
|
and works only if Home Manager starts the user X session.
|
||||||
|
|
||||||
|
The option 'services.sxhkd.extraPath' has been deprecated.
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
time = "2021-05-06T20:47:37+00:00";
|
time = "2021-05-06T20:47:37+00:00";
|
||||||
condition = hostPlatform.isLinux;
|
condition = hostPlatform.isLinux;
|
||||||
|
|
|
@ -19,6 +19,11 @@ let
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
imports = [
|
||||||
|
(mkRemovedOptionModule ["services" "sxhkd" "extraPath"]
|
||||||
|
"This option is no longer needed and can be removed.")
|
||||||
|
];
|
||||||
|
|
||||||
options.services.sxhkd = {
|
options.services.sxhkd = {
|
||||||
enable = mkEnableOption "simple X hotkey daemon";
|
enable = mkEnableOption "simple X hotkey daemon";
|
||||||
|
|
||||||
|
@ -57,44 +62,19 @@ in
|
||||||
i3-msg {workspace,move container to workspace} {1-10}
|
i3-msg {workspace,move container to workspace} {1-10}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
extraPath = mkOption {
|
|
||||||
default = "";
|
|
||||||
type = types.envVar;
|
|
||||||
description = ''
|
|
||||||
Additional <envar>PATH</envar> entries to search for commands.
|
|
||||||
'';
|
|
||||||
example = "/home/some-user/bin:/extra/path/bin";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
home.packages = [ pkgs.sxhkd ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
xdg.configFile."sxhkd/sxhkdrc".text = concatStringsSep "\n" [
|
xdg.configFile."sxhkd/sxhkdrc".text = concatStringsSep "\n" [
|
||||||
keybindingsStr
|
keybindingsStr
|
||||||
cfg.extraConfig
|
cfg.extraConfig
|
||||||
];
|
];
|
||||||
|
|
||||||
systemd.user.services.sxhkd = {
|
xsession.initExtra = ''
|
||||||
Unit = {
|
systemd-cat -t sxhkd systemd-run --user --scope -u sxhkd \
|
||||||
Description = "simple X hotkey daemon";
|
${cfg.package}/bin/sxhkd ${toString cfg.extraOptions} &
|
||||||
After = [ "graphical-session-pre.target" ];
|
'';
|
||||||
PartOf = [ "graphical-session.target" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
Service = {
|
|
||||||
Environment =
|
|
||||||
"PATH="
|
|
||||||
+ "${config.home.profileDirectory}/bin"
|
|
||||||
+ optionalString (cfg.extraPath != "") ":"
|
|
||||||
+ cfg.extraPath;
|
|
||||||
ExecStart = "${cfg.package}/bin/sxhkd ${toString cfg.extraOptions}";
|
|
||||||
};
|
|
||||||
|
|
||||||
Install = {
|
|
||||||
WantedBy = [ "graphical-session.target" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,31 @@
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
expectedFileRegex = ''
|
||||||
|
systemd-cat -t sxhkd systemd-run --user --scope -u sxhkd \
|
||||||
|
@sxhkd@/bin/sxhkd -m 1 &
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
|
xsession = {
|
||||||
|
enable = true;
|
||||||
|
windowManager.command = "";
|
||||||
|
};
|
||||||
|
|
||||||
services.sxhkd = {
|
services.sxhkd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out" // { outPath = "@sxhkd@"; };
|
package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out" // { outPath = "@sxhkd@"; };
|
||||||
extraOptions = [ "-m 1" ];
|
extraOptions = [ "-m 1" ];
|
||||||
extraPath = "/home/the-user/bin:/extra/path/bin";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
serviceFile=home-files/.config/systemd/user/sxhkd.service
|
xsessionFile=home-files/.xsession
|
||||||
|
|
||||||
assertFileExists $serviceFile
|
assertFileExists $xsessionFile
|
||||||
|
|
||||||
assertFileRegex $serviceFile 'ExecStart=@sxhkd@/bin/sxhkd -m 1'
|
assertFileRegex $xsessionFile ${expectedFileRegex}
|
||||||
|
|
||||||
assertFileRegex $serviceFile \
|
|
||||||
'Environment=PATH=.*\.nix-profile/bin:/home/the-user/bin:/extra/path/bin'
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue