Merge pull request #330634 from r-ryantm/auto-update/circumflex
[NixPkgs.git] / pkgs / desktops / gnome / misc / gnome-flashback / default.nix
blobf54860ba19add6dfa85108997497018b1863fb74
1 { stdenv
2 , lib
3 , autoreconfHook
4 , fetchurl
5 , gettext
6 , glib
7 , gnome-bluetooth
8 , gnome-desktop
9 , gnome-panel
10 , gnome-session
11 , gnome
12 , gsettings-desktop-schemas
13 , gtk3
14 , ibus
15 , libcanberra-gtk3
16 , libpulseaudio
17 , libxkbfile
18 , libxml2
19 , pkg-config
20 , polkit
21 , gdm
22 , systemd
23 , upower
24 , pam
25 , wrapGAppsHook3
26 , writeTextFile
27 , xkeyboard_config
28 , xorg
29 , runCommand
30 , buildEnv
32 let
33   pname = "gnome-flashback";
34   version = "3.52.1";
36   # From data/sessions/Makefile.am
37   requiredComponentsCommon = enableGnomePanel:
38     [ ]
39     ++ lib.optional enableGnomePanel "gnome-panel";
40   requiredComponentsGsd = [
41     "org.gnome.SettingsDaemon.A11ySettings"
42     "org.gnome.SettingsDaemon.Color"
43     "org.gnome.SettingsDaemon.Datetime"
44     "org.gnome.SettingsDaemon.Housekeeping"
45     "org.gnome.SettingsDaemon.Keyboard"
46     "org.gnome.SettingsDaemon.MediaKeys"
47     "org.gnome.SettingsDaemon.Power"
48     "org.gnome.SettingsDaemon.PrintNotifications"
49     "org.gnome.SettingsDaemon.Rfkill"
50     "org.gnome.SettingsDaemon.ScreensaverProxy"
51     "org.gnome.SettingsDaemon.Sharing"
52     "org.gnome.SettingsDaemon.Smartcard"
53     "org.gnome.SettingsDaemon.Sound"
54     "org.gnome.SettingsDaemon.UsbProtection"
55     "org.gnome.SettingsDaemon.Wacom"
56     "org.gnome.SettingsDaemon.XSettings"
57   ];
58   requiredComponents = wmName: enableGnomePanel: "RequiredComponents=${lib.concatStringsSep ";" ([ wmName ] ++ requiredComponentsCommon enableGnomePanel ++ requiredComponentsGsd)};";
60   gnome-flashback = stdenv.mkDerivation rec {
61     name = "${pname}-${version}";
63     src = fetchurl {
64       url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${name}.tar.xz";
65       hash = "sha256-ugRhPNrbYr2iBkN8BHKZ4WAlzeG9gJXglKp3dpx4YDo=";
66     };
68     # make .desktop Execs absolute
69     postPatch = ''
70       patch -p0 <<END_PATCH
71       +++ data/applications/gnome-flashback.desktop.in
72       @@ -4 +4 @@
73       -Exec=gnome-flashback
74       +Exec=$out/bin/gnome-flashback
75       END_PATCH
76     '';
78     postInstall = ''
79       # Check that our expected RequiredComponents match the stock session files, but then don't install them.
80       # They can be installed using mkSessionForWm.
81       grep '${requiredComponents "metacity" true}' $out/share/gnome-session/sessions/gnome-flashback-metacity.session || (echo "RequiredComponents have changed, please update gnome-flashback/default.nix."; false)
83       rm -r $out/share/gnome-session
84       rm -r $out/share/xsessions
85       rm $out/libexec/gnome-flashback-metacity
86     '';
88     nativeBuildInputs = [
89       autoreconfHook
90       gettext
91       libxml2
92       pkg-config
93       wrapGAppsHook3
94     ];
96     buildInputs = [
97       glib
98       gnome-bluetooth
99       gnome-desktop
100       gsettings-desktop-schemas
101       gtk3
102       ibus
103       libcanberra-gtk3
104       libpulseaudio
105       libxkbfile
106       xorg.libXxf86vm
107       polkit
108       gdm
109       gnome-panel
110       systemd
111       upower
112       pam
113       xkeyboard_config
114     ];
116     doCheck = true;
118     enableParallelBuilding = true;
120     PKG_CONFIG_LIBGNOME_PANEL_LAYOUTSDIR = "${placeholder "out"}/share/gnome-panel/layouts";
121     PKG_CONFIG_LIBGNOME_PANEL_MODULESDIR = "${placeholder "out"}/lib/gnome-panel/modules";
123     passthru = {
124       updateScript = gnome.updateScript {
125         packageName = pname;
126         attrPath = "gnome.${pname}";
127         versionPolicy = "odd-unstable";
128       };
130       mkWmApplication = { wmName, wmLabel, wmCommand }:
131         writeTextFile {
132           name = "gnome-flashback-${wmName}-wm";
133           destination = "/share/applications/${wmName}.desktop";
134           text = ''
135             [Desktop Entry]
136             Type=Application
137             Encoding=UTF-8
138             Name=${wmLabel}
139             Exec=${wmCommand}
140             NoDisplay=true
141             X-GNOME-WMName=${wmLabel}
142             X-GNOME-Autostart-Phase=WindowManager
143             X-GNOME-Provides=windowmanager
144             X-GNOME-Autostart-Notify=false
145           '';
146         };
148       mkGnomeSession = { wmName, wmLabel, enableGnomePanel }:
149         writeTextFile {
150           name = "gnome-flashback-${wmName}-gnome-session";
151           destination = "/share/gnome-session/sessions/gnome-flashback-${wmName}.session";
152           text = ''
153             [GNOME Session]
154             Name=GNOME Flashback (${wmLabel})
155             ${requiredComponents wmName enableGnomePanel}
156           '';
157         };
159       mkSessionForWm = { wmName, wmLabel, wmCommand }:
160         writeTextFile
161           {
162             name = "gnome-flashback-${wmName}-xsession";
163             destination = "/share/xsessions/gnome-flashback-${wmName}.desktop";
164             text = ''
165               [Desktop Entry]
166               Name=GNOME Flashback (${wmLabel})
167               Comment=This session logs you into GNOME Flashback with ${wmLabel}
168               Exec=${gnome-session}/bin/gnome-session --session=gnome-flashback-${wmName}
169               TryExec=${wmCommand}
170               Type=Application
171               DesktopNames=GNOME-Flashback;GNOME;
172             '';
173           } // {
174           providedSessions = [ "gnome-flashback-${wmName}" ];
175         };
177       mkSystemdTargetForWm = { wmName, wmLabel, wmCommand, enableGnomePanel }:
178         runCommand "gnome-flashback-${wmName}.target" { } ''
179           mkdir -p $out/lib/systemd/user
180           cp -r "${gnome-flashback}/lib/systemd/user/gnome-session@gnome-flashback-metacity.target.d" \
181             "$out/lib/systemd/user/gnome-session@gnome-flashback-${wmName}.target.d"
182         '';
183     };
185     meta = with lib; {
186       description = "GNOME 2.x-like session for GNOME 3";
187       mainProgram = "gnome-flashback";
188       homepage = "https://gitlab.gnome.org/GNOME/gnome-flashback";
189       license = licenses.gpl2;
190       maintainers = teams.gnome.members;
191       platforms = platforms.linux;
192     };
193   };
195 gnome-flashback