From dc1e9d1bc6229f7da14d5141c28711e9cb5df52a Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 3 Jun 2018 17:32:57 +0200 Subject: [PATCH] qt: add option `qt.systemdServicePath` This option contains a string suitable as value for the PATH environment variable in systemd services that run Qt 5 applications. Qt applications need this special treatment because they use PATH to locate plugins that sometimes are necessary for proper functioning. For now the option is not visible in the manual since the default value is expected to work in most, if not all, cases. --- modules/misc/qt.nix | 16 ++++++++++++++++ modules/services/flameshot.nix | 2 +- modules/services/owncloud-client.nix | 2 +- modules/services/syncthing.nix | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/modules/misc/qt.nix b/modules/misc/qt.nix index c644c704..e366d504 100644 --- a/modules/misc/qt.nix +++ b/modules/misc/qt.nix @@ -24,6 +24,22 @@ in settings. ''; }; + + systemdServicePath = mkOption { + type = types.envVar; + default = lib.makeSearchPath "bin" [ + "/etc/profiles/per-user/%u" + "%h/.nix-profile" + "/nix/var/nix/profiles/default" + "/run/current-system/sw" + ]; + visible = false; + description = '' + Path to use for systemd services that run Qt 5 applications. + This is to ensure that the application is able to locate any + necessary Qt plugins. + ''; + }; }; }; diff --git a/modules/services/flameshot.nix b/modules/services/flameshot.nix index 7c259d43..85f0fa36 100644 --- a/modules/services/flameshot.nix +++ b/modules/services/flameshot.nix @@ -33,7 +33,7 @@ in }; Service = { - Environment = "PATH=%h/.nix-profile/bin"; + Environment = "PATH=${config.qt.systemdServicePath}"; ExecStart = "${package}/bin/flameshot"; Restart = "on-abort"; }; diff --git a/modules/services/owncloud-client.nix b/modules/services/owncloud-client.nix index 353e0136..9c90aff0 100644 --- a/modules/services/owncloud-client.nix +++ b/modules/services/owncloud-client.nix @@ -18,7 +18,7 @@ with lib; }; Service = { - Environment = "PATH=%h/.nix-profile/bin"; + Environment = "PATH=${config.qt.systemdServicePath}"; ExecStart = "${pkgs.owncloud-client}/bin/owncloud"; }; diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index 11511725..2a3de135 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -54,7 +54,7 @@ with lib; }; Service = { - Environment = "PATH=%h/.nix-profile/bin"; + Environment = "PATH=${config.qt.systemdServicePath}"; ExecStart = "${pkgs.qsyncthingtray}/bin/QSyncthingTray"; };