summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services/misc/graphical-desktop.nix
blob: 906601d1fc0c48155605ca7a5cdf73f206869ea3 (plain)
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
67
68
69
70
71
{
  config,
  lib,
  pkgs,
  ...
}:
let
  cfg = config.services.graphical-desktop;
  xcfg = config.services.xserver;
  dmcfg = config.services.displayManager;
in
{
  options = {
    services.graphical-desktop.enable =
      lib.mkEnableOption "bits and pieces required for a graphical desktop session"
      // {
        default = xcfg.enable || dmcfg.enable;
        defaultText = lib.literalExpression "(config.services.xserver.enable || config.services.displayManager.enable)";
        internal = true;
      };
  };

  config = lib.mkIf cfg.enable {
    environment = {
      # systemd-localed looks into 00-keyboard.conf
      # systemd-localed does not like if Option values are ""
      etc."X11/xorg.conf.d/00-keyboard.conf".text =
        let
          optionLine =
            name: value: lib.optionalString (value != null && value != "") ''Option "${name}" "${value}"'';
        in
        ''
          Section "InputClass"
            Identifier "Keyboard catchall"
            MatchIsKeyboard "on"
            ${optionLine "XkbModel" xcfg.xkb.model}
            ${optionLine "XkbLayout" xcfg.xkb.layout}
            ${optionLine "XkbOptions" xcfg.xkb.options}
            ${optionLine "XkbVariant" xcfg.xkb.variant}
          EndSection
        '';
      systemPackages = with pkgs; [
        nixos-icons # needed for gnome and pantheon about dialog, nixos-manual and maybe more
        xdg-utils
      ];
    };

    fonts.enableDefaultPackages = lib.mkDefault true;

    hardware.graphics.enable = lib.mkDefault true;

    programs.gnupg.agent.pinentryPackage = lib.mkOverride 1100 pkgs.pinentry-gnome3;

    services.speechd.enable = lib.mkDefault true;

    services.pipewire = {
      enable = lib.mkDefault true;
      pulse.enable = lib.mkDefault true;
      alsa.enable = lib.mkDefault true;
    };

    systemd.defaultUnit = lib.mkIf (xcfg.autorun || dmcfg.enable) "graphical.target";

    xdg = {
      autostart.enable = true;
      menus.enable = true;
      mime.enable = true;
      icons.enable = true;
    };
  };
}