summary refs log tree commit diff
path: root/nixos/modules/programs/dconf.nix
blob: 298abac8afa980ec5530e60123f617c931714f54 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.programs.dconf;
  cfgDir = pkgs.symlinkJoin {
    name = "dconf-system-config";
    paths = map (x: "${x}/etc/dconf") cfg.packages;
    postBuild = ''
      mkdir -p $out/profile
      mkdir -p $out/db
    '' + (
      concatStringsSep "\n" (
        mapAttrsToList (
          name: path: ''
            ln -s ${path} $out/profile/${name}
          ''
        ) cfg.profiles
      )
    ) + ''
      ${pkgs.dconf}/bin/dconf update $out/db
    '';
  };
in
{
  ###### interface

  options = {
    programs.dconf = {
      enable = mkEnableOption "dconf";

      profiles = mkOption {
        type = types.attrsOf types.path;
        default = {};
        description = "Set of dconf profile files, installed at <filename>/etc/dconf/profiles/<replaceable>name</replaceable></filename>.";
        internal = true;
      };

      packages = mkOption {
        type = types.listOf types.package;
        default = [];
        description = "A list of packages which provide dconf profiles and databases in <filename>/etc/dconf</filename>.";
      };
    };
  };

  ###### implementation

  config = mkIf (cfg.profiles != {} || cfg.enable) {
    environment.etc.dconf = mkIf (cfg.profiles != {} || cfg.packages != []) {
      source = cfgDir;
    };

    services.dbus.packages = [ pkgs.dconf ];

    systemd.packages = [ pkgs.dconf ];

    # For dconf executable
    environment.systemPackages = [ pkgs.dconf ];

    # Needed for unwrapped applications
    environment.variables.GIO_EXTRA_MODULES = mkIf cfg.enable [ "${pkgs.dconf.lib}/lib/gio/modules" ];
  };

}