summary refs log tree commit diff
path: root/nixos/modules/config/qt-plugin-env.nix
blob: c598656041658732c5174cc01222dba74dcc840b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{ config, pkgs, lib, ... }:

{
  imports = [
  ];

  options = {
    qtPlugins = lib.mkOption {
      type = lib.types.listOf lib.types.path;
      default = [];
      description = ''
        Plugin packages for Qt such as input methods.
      '';
    };
  };

  config = {
    environment.variables = if builtins.length config.qtPlugins > 0
      then
        let
          paths = [ pkgs.qt48 ] ++ config.qtPlugins;
          env = pkgs.buildEnv {
            name = "qt-plugin-env";

            inherit paths;

            postBuild = lib.concatStringsSep "\n"
              (map (d: d.qtPluginEnvPostBuild or "") paths);

            ignoreCollisions = true;
          };
        in {
          QT_PLUGIN_PATH = [ (builtins.toString env) ];
        }
      else {};
  };
}