summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Chilton <chpatrick@gmail.com>2021-02-21 23:17:27 +0100
committerPatrick Chilton <chpatrick@gmail.com>2021-05-28 13:10:17 +0200
commit424cd7d999bb9a35ec3a545883530f9c7c9fd6c1 (patch)
treed73f58e8fee07b622ca4ebe376aec9b8dcfb2da4
parent572eb44019605daee52760585084d2f31a1ec1ba (diff)
downloadnixpkgs-424cd7d999bb9a35ec3a545883530f9c7c9fd6c1.tar
nixpkgs-424cd7d999bb9a35ec3a545883530f9c7c9fd6c1.tar.gz
nixpkgs-424cd7d999bb9a35ec3a545883530f9c7c9fd6c1.tar.bz2
nixpkgs-424cd7d999bb9a35ec3a545883530f9c7c9fd6c1.tar.lz
nixpkgs-424cd7d999bb9a35ec3a545883530f9c7c9fd6c1.tar.xz
nixpkgs-424cd7d999bb9a35ec3a545883530f9c7c9fd6c1.tar.zst
nixpkgs-424cd7d999bb9a35ec3a545883530f9c7c9fd6c1.zip
gnome-flashback: add option to remove gnome-panel, auto-generate wmName
-rw-r--r--nixos/modules/services/x11/desktop-managers/gnome.nix61
-rw-r--r--nixos/modules/services/x11/desktop-managers/gnome.xml1
-rw-r--r--pkgs/desktops/gnome/misc/gnome-flashback/default.nix24
3 files changed, 53 insertions, 33 deletions
diff --git a/nixos/modules/services/x11/desktop-managers/gnome.nix b/nixos/modules/services/x11/desktop-managers/gnome.nix
index bacada9cbe7..c5e6caeea90 100644
--- a/nixos/modules/services/x11/desktop-managers/gnome.nix
+++ b/nixos/modules/services/x11/desktop-managers/gnome.nix
@@ -56,6 +56,12 @@ let
     '';
 
   flashbackEnabled = cfg.flashback.enableMetacity || length cfg.flashback.customSessions > 0;
+  flashbackWms = optional cfg.flashback.enableMetacity {
+    wmName = "metacity";
+    wmLabel = "Metacity";
+    wmCommand = "${pkgs.gnome.metacity}/bin/metacity";
+    enableGnomePanel = true;
+  } ++ cfg.flashback.customSessions;
 
   notExcluded = pkg: mkDefault (!(lib.elem pkg config.environment.gnome.excludePackages));
 
@@ -216,20 +222,25 @@ in
       debug = mkEnableOption "gnome-session debug messages";
 
       flashback = {
-        enableMetacity = mkEnableOption "the standard GNOME Flashback session with Metacity";
+        enableMetacity = mkOption {
+          type = types.bool;
+          default = true;
+          example = "false";
+          description = "Whether to enable the standard Metacity GNOME flashback session.";
+        };
 
         customSessions = mkOption {
           type = types.listOf (types.submodule {
             options = {
               wmName = mkOption {
-                type = types.str;
-                description = "The filename-compatible name of the window manager to use.";
+                type = types.strMatching "[a-zA-Z0-9_-]+";
+                description = "A unique identifier for the window manager.";
                 example = "xmonad";
               };
 
               wmLabel = mkOption {
                 type = types.str;
-                description = "The pretty name of the window manager to use.";
+                description = "The name of the window manager to show in the session chooser.";
                 example = "XMonad";
               };
 
@@ -238,6 +249,13 @@ in
                 description = "The executable of the window manager to use.";
                 example = "\${pkgs.haskellPackages.xmonad}/bin/xmonad";
               };
+
+              enableGnomePanel = mkOption {
+                type = types.bool;
+                default = true;
+                example = "false";
+                description = "Whether to enable the GNOME panel in this session.";
+              };
             };
           });
           default = [];
@@ -295,14 +313,18 @@ in
     })
 
     (mkIf flashbackEnabled {
-      services.xserver.displayManager.sessionPackages =  map
-        (wm: pkgs.gnome.gnome-flashback.mkSessionForWm {
-          inherit (wm) wmName wmLabel wmCommand;
-        }) (optional cfg.flashback.enableMetacity {
-              wmName = "metacity";
-              wmLabel = "Metacity";
-              wmCommand = "${pkgs.gnome.metacity}/bin/metacity";
-            } ++ cfg.flashback.customSessions);
+      services.xserver.displayManager.sessionPackages =
+        let
+          wmNames = map (wm: wm.wmName) flashbackWms;
+          namesAreUnique = lib.unique wmNames == wmNames;
+        in
+          assert (assertMsg namesAreUnique "Flashback WM names must be unique.");
+          map
+            (wm:
+              pkgs.gnome.gnome-flashback.mkSessionForWm {
+                inherit (wm) wmName wmLabel wmCommand enableGnomePanel;
+              }
+            ) flashbackWms;
 
       security.pam.services.gnome-flashback = {
         enableGnomeKeyring = true;
@@ -310,15 +332,12 @@ in
 
       systemd.packages = with pkgs.gnome; [
         gnome-flashback
-      ] ++ (map
-        (wm: gnome-flashback.mkSystemdTargetForWm {
-          inherit (wm) wmName;
-        }) cfg.flashback.customSessions);
-
-        # gnome-panel needs these for menu applet
-        environment.sessionVariables.XDG_DATA_DIRS = [ "${pkgs.gnome.gnome-flashback}/share" ];
-        # TODO: switch to sessionVariables (resolve conflict)
-        environment.variables.XDG_CONFIG_DIRS = [ "${pkgs.gnome.gnome-flashback}/etc/xdg" ];
+      ] ++ map gnome-flashback.mkSystemdTargetForWm flashbackWms;
+
+      # gnome-panel needs these for menu applet
+      environment.sessionVariables.XDG_DATA_DIRS = [ "${pkgs.gnome.gnome-flashback}/share" ];
+      # TODO: switch to sessionVariables (resolve conflict)
+      environment.variables.XDG_CONFIG_DIRS = [ "${pkgs.gnome.gnome-flashback}/etc/xdg" ];
     })
 
     (mkIf serviceCfg.core-os-services.enable {
diff --git a/nixos/modules/services/x11/desktop-managers/gnome.xml b/nixos/modules/services/x11/desktop-managers/gnome.xml
index 624d5c894e7..6c53bacacb3 100644
--- a/nixos/modules/services/x11/desktop-managers/gnome.xml
+++ b/nixos/modules/services/x11/desktop-managers/gnome.xml
@@ -120,6 +120,7 @@
     wmName = "xmonad";
     wmLabel = "XMonad";
     wmCommand = "${pkgs.haskellPackages.xmonad}/bin/xmonad";
+    enableGnomePanel = false;
   }
 ];
 </programlisting>
diff --git a/pkgs/desktops/gnome/misc/gnome-flashback/default.nix b/pkgs/desktops/gnome/misc/gnome-flashback/default.nix
index 7e578f27cd2..2e8662ede0c 100644
--- a/pkgs/desktops/gnome/misc/gnome-flashback/default.nix
+++ b/pkgs/desktops/gnome/misc/gnome-flashback/default.nix
@@ -33,10 +33,9 @@ let
   version = "3.40.0";
 
   # From data/sessions/Makefile.am
-  requiredComponentsCommon = [
-    "gnome-flashback"
-    "gnome-panel"
-  ];
+  requiredComponentsCommon = enableGnomePanel:
+    [ "gnome-flashback" ]
+    ++ lib.optional enableGnomePanel "gnome-panel";
   requiredComponentsGsd = [
     "org.gnome.SettingsDaemon.A11ySettings"
     "org.gnome.SettingsDaemon.Color"
@@ -55,7 +54,8 @@ let
     "org.gnome.SettingsDaemon.Wacom"
     "org.gnome.SettingsDaemon.XSettings"
   ];
-  requiredComponents = wmName: "RequiredComponents=${lib.concatStringsSep ";" ([ wmName ] ++ requiredComponentsCommon ++ requiredComponentsGsd)};";
+  requiredComponents = wmName: enableGnomePanel: "RequiredComponents=${lib.concatStringsSep ";" ([ wmName ] ++ requiredComponentsCommon enableGnomePanel ++ requiredComponentsGsd)};";
+
   gnome-flashback = stdenv.mkDerivation rec {
     name = "${pname}-${version}";
 
@@ -77,7 +77,7 @@ let
     postInstall = ''
       # Check that our expected RequiredComponents match the stock session files, but then don't install them.
       # They can be installed using mkSessionForWm.
-      grep '${requiredComponents "metacity"}' $out/share/gnome-session/sessions/gnome-flashback-metacity.session || (echo "RequiredComponents have changed, please update gnome-flashback/default.nix."; false)
+      grep '${requiredComponents "metacity" true}' $out/share/gnome-session/sessions/gnome-flashback-metacity.session || (echo "RequiredComponents have changed, please update gnome-flashback/default.nix."; false)
 
       rm -r $out/share/gnome-session
       rm -r $out/share/xsessions
@@ -126,7 +126,7 @@ let
         versionPolicy = "odd-unstable";
       };
 
-      mkSessionForWm = { wmName, wmLabel, wmCommand }:
+      mkSessionForWm = { wmName, wmLabel, wmCommand, enableGnomePanel }:
         let
           wmApplication = writeTextFile {
             name = "gnome-flashback-${wmName}-wm";
@@ -151,7 +151,7 @@ let
             text = ''
               [GNOME Session]
               Name=GNOME Flashback (${wmLabel})
-              ${requiredComponents wmName}
+              ${requiredComponents wmName enableGnomePanel}
             '';
           };
 
@@ -183,11 +183,11 @@ let
           providedSessions = [ "gnome-flashback-${wmName}" ];
         };
 
-      mkSystemdTargetForWm = { wmName }:
-        runCommand "gnome-flashback-${wmName}.target" { } ''
+      mkSystemdTargetForWm = { wmName, wmLabel, wmCommand, enableGnomePanel }:
+        runCommand "gnome-flashback-${wmName}.target" {} ''
           mkdir -p $out/lib/systemd/user
-          cp "${gnome-flashback}/lib/systemd/user/gnome-session-x11@gnome-flashback-metacity.target" \
-            "$out/lib/systemd/user/gnome-session-x11@gnome-flashback-${wmName}.target"
+          cp -r "${gnome-flashback}/lib/systemd/user/gnome-session@gnome-flashback-metacity.target.d" \
+            "$out/lib/systemd/user/gnome-session@gnome-flashback-${wmName}.target.d"
         '';
     };