nixos/preload: init
[NixPkgs.git] / nixos / modules / services / x11 / desktop-managers / deepin.nix
blobf70e316a230946934453389ddddae81d949f2869
1 { config, lib, pkgs, utils, ... }:
3 with lib;
5 let
6   xcfg = config.services.xserver;
7   cfg = xcfg.desktopManager.deepin;
9   nixos-gsettings-overrides = pkgs.deepin.dde-gsettings-schemas.override {
10     extraGSettingsOverridePackages = cfg.extraGSettingsOverridePackages;
11     extraGSettingsOverrides = cfg.extraGSettingsOverrides;
12   };
15   options = {
17     services.xserver.desktopManager.deepin = {
18       enable = mkEnableOption (lib.mdDoc "Deepin desktop manager");
19       extraGSettingsOverrides = mkOption {
20         default = "";
21         type = types.lines;
22         description = lib.mdDoc "Additional gsettings overrides.";
23       };
24       extraGSettingsOverridePackages = mkOption {
25         default = [ ];
26         type = types.listOf types.path;
27         description = lib.mdDoc "List of packages for which gsettings are overridden.";
28       };
29     };
31     environment.deepin.excludePackages = mkOption {
32       default = [ ];
33       type = types.listOf types.package;
34       description = lib.mdDoc "List of default packages to exclude from the configuration";
35     };
37   };
39   config = mkIf cfg.enable
40     {
41       services.xserver.displayManager.sessionPackages = [ pkgs.deepin.startdde ];
42       services.xserver.displayManager.defaultSession = mkDefault "deepin";
44       # Update the DBus activation environment after launching the desktop manager.
45       services.xserver.displayManager.sessionCommands = ''
46         ${lib.getBin pkgs.dbus}/bin/dbus-update-activation-environment --systemd --all
47       '';
49       hardware.bluetooth.enable = mkDefault true;
50       hardware.pulseaudio.enable = mkDefault true;
51       security.polkit.enable = true;
53       services.deepin.dde-daemon.enable = mkForce true;
54       services.deepin.dde-api.enable = mkForce true;
55       services.deepin.app-services.enable = mkForce true;
57       services.colord.enable = mkDefault true;
58       services.accounts-daemon.enable = mkDefault true;
59       services.gvfs.enable = mkDefault true;
60       services.gnome.glib-networking.enable = mkDefault true;
61       services.gnome.gnome-keyring.enable = mkDefault true;
62       services.bamf.enable = mkDefault true;
64       services.xserver.libinput.enable = mkDefault true;
65       services.udisks2.enable = true;
66       services.upower.enable = mkDefault config.powerManagement.enable;
67       networking.networkmanager.enable = mkDefault true;
68       programs.dconf.enable = mkDefault true;
70       fonts.packages = with pkgs; [ noto-fonts ];
71       xdg.mime.enable = true;
72       xdg.menus.enable = true;
73       xdg.icons.enable = true;
74       xdg.portal.enable = mkDefault true;
75       xdg.portal.extraPortals = mkDefault [
76         (pkgs.xdg-desktop-portal-gtk.override {
77           buildPortalsInGnome = false;
78         })
79       ];
81       # https://github.com/NixOS/nixpkgs/pull/247766#issuecomment-1722839259
82       xdg.portal.config.deepin.default = mkDefault [ "gtk" ];
84       environment.sessionVariables = {
85         NIX_GSETTINGS_OVERRIDES_DIR = "${nixos-gsettings-overrides}/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas";
86         DDE_POLKIT_AGENT_PLUGINS_DIRS = [ "${pkgs.deepin.dpa-ext-gnomekeyring}/lib/polkit-1-dde/plugins" ];
87       };
89       environment.pathsToLink = [
90         "/lib/dde-dock/plugins"
91         "/lib/dde-control-center"
92         "/lib/dde-session-shell"
93         "/lib/dde-file-manager"
94         "/share/backgrounds"
95         "/share/wallpapers"
96       ];
98       environment.etc = {
99         "distribution.info".text = ''
100           [Distribution]
101           Name=NixOS
102           WebsiteName=www.nixos.org
103           Website=https://www.nixos.org
104           Logo=${pkgs.nixos-icons}/share/icons/hicolor/96x96/apps/nix-snowflake.png
105           LogoLight=${pkgs.nixos-icons}/share/icons/hicolor/32x32/apps/nix-snowflake.png
106           LogoTransparent=${pkgs.deepin.deepin-desktop-base}/share/pixmaps/distribution_logo_transparent.svg
107         '';
108         "deepin-installer.conf".text = ''
109           system_info_vendor_name="Copyright (c) 2003-2023 NixOS contributors"
110         '';
111       };
113       systemd.tmpfiles.rules = [
114         "d /var/lib/AccountsService 0775 root root - -"
115         "C /var/lib/AccountsService/icons 0775 root root - ${pkgs.deepin.dde-account-faces}/var/lib/AccountsService/icons"
116       ];
118       security.pam.services.dde-lock.text = ''
119         # original at {dde-session-shell}/etc/pam.d/dde-lock
120         auth      substack      login
121         account   include       login
122         password  substack      login
123         session   include       login
124       '';
126       environment.systemPackages = with pkgs; with deepin;
127         let
128           requiredPackages = [
129             pciutils # for dtkcore/startdde
130             xdotool # for dde-daemon
131             glib # for gsettings program / gdbus
132             gtk3 # for gtk-launch program
133             xdg-user-dirs # Update user dirs
134             util-linux # runuser
135             polkit_gnome
136             librsvg # dde-api use rsvg-convert
137             lshw # for dtkcore
138             libsForQt5.kde-gtk-config # deepin-api/gtk-thumbnailer need
139             libsForQt5.kglobalaccel
140             xsettingsd # lightdm-deepin-greeter
141             qt5platform-plugins
142             deepin-pw-check
143             deepin-turbo
145             dde-account-faces
146             deepin-icon-theme
147             deepin-sound-theme
148             deepin-gtk-theme
149             deepin-wallpapers
151             startdde
152             dde-dock
153             dde-launcher
154             dde-session-ui
155             dde-session-shell
156             dde-file-manager
157             dde-control-center
158             dde-network-core
159             dde-clipboard
160             dde-calendar
161             dde-polkit-agent
162             dpa-ext-gnomekeyring
163             deepin-desktop-schemas
164             deepin-terminal
165             dde-kwin
166             deepin-kwin
167           ];
168           optionalPackages = [
169             onboard # dde-dock plugin
170             deepin-camera
171             deepin-calculator
172             deepin-compressor
173             deepin-editor
174             deepin-picker
175             deepin-draw
176             deepin-album
177             deepin-image-viewer
178             deepin-music
179             deepin-movie-reborn
180             deepin-system-monitor
181             deepin-screen-recorder
182             deepin-shortcut-viewer
183           ];
184         in
185         requiredPackages
186         ++ utils.removePackagesByName optionalPackages config.environment.deepin.excludePackages;
188       services.dbus.packages = with pkgs.deepin; [
189         dde-dock
190         dde-launcher
191         dde-session-ui
192         dde-session-shell
193         dde-file-manager
194         dde-control-center
195         dde-calendar
196         dde-clipboard
197         dde-kwin
198         deepin-kwin
199         deepin-pw-check
200       ];
202       systemd.packages = with pkgs.deepin; [
203         dde-launcher
204         dde-file-manager
205         dde-calendar
206         dde-clipboard
207         deepin-kwin
208       ];
209     };