gnome-flashback: add option to remove gnome-panel, auto-generate wmName
This commit is contained in:
parent
572eb44019
commit
424cd7d999
|
@ -56,6 +56,12 @@ let
|
||||||
'';
|
'';
|
||||||
|
|
||||||
flashbackEnabled = cfg.flashback.enableMetacity || length cfg.flashback.customSessions > 0;
|
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));
|
notExcluded = pkg: mkDefault (!(lib.elem pkg config.environment.gnome.excludePackages));
|
||||||
|
|
||||||
|
@ -216,20 +222,25 @@ in
|
||||||
debug = mkEnableOption "gnome-session debug messages";
|
debug = mkEnableOption "gnome-session debug messages";
|
||||||
|
|
||||||
flashback = {
|
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 {
|
customSessions = mkOption {
|
||||||
type = types.listOf (types.submodule {
|
type = types.listOf (types.submodule {
|
||||||
options = {
|
options = {
|
||||||
wmName = mkOption {
|
wmName = mkOption {
|
||||||
type = types.str;
|
type = types.strMatching "[a-zA-Z0-9_-]+";
|
||||||
description = "The filename-compatible name of the window manager to use.";
|
description = "A unique identifier for the window manager.";
|
||||||
example = "xmonad";
|
example = "xmonad";
|
||||||
};
|
};
|
||||||
|
|
||||||
wmLabel = mkOption {
|
wmLabel = mkOption {
|
||||||
type = types.str;
|
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";
|
example = "XMonad";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -238,6 +249,13 @@ in
|
||||||
description = "The executable of the window manager to use.";
|
description = "The executable of the window manager to use.";
|
||||||
example = "\${pkgs.haskellPackages.xmonad}/bin/xmonad";
|
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 = [];
|
default = [];
|
||||||
|
@ -295,14 +313,18 @@ in
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf flashbackEnabled {
|
(mkIf flashbackEnabled {
|
||||||
services.xserver.displayManager.sessionPackages = map
|
services.xserver.displayManager.sessionPackages =
|
||||||
(wm: pkgs.gnome.gnome-flashback.mkSessionForWm {
|
let
|
||||||
inherit (wm) wmName wmLabel wmCommand;
|
wmNames = map (wm: wm.wmName) flashbackWms;
|
||||||
}) (optional cfg.flashback.enableMetacity {
|
namesAreUnique = lib.unique wmNames == wmNames;
|
||||||
wmName = "metacity";
|
in
|
||||||
wmLabel = "Metacity";
|
assert (assertMsg namesAreUnique "Flashback WM names must be unique.");
|
||||||
wmCommand = "${pkgs.gnome.metacity}/bin/metacity";
|
map
|
||||||
} ++ cfg.flashback.customSessions);
|
(wm:
|
||||||
|
pkgs.gnome.gnome-flashback.mkSessionForWm {
|
||||||
|
inherit (wm) wmName wmLabel wmCommand enableGnomePanel;
|
||||||
|
}
|
||||||
|
) flashbackWms;
|
||||||
|
|
||||||
security.pam.services.gnome-flashback = {
|
security.pam.services.gnome-flashback = {
|
||||||
enableGnomeKeyring = true;
|
enableGnomeKeyring = true;
|
||||||
|
@ -310,15 +332,12 @@ in
|
||||||
|
|
||||||
systemd.packages = with pkgs.gnome; [
|
systemd.packages = with pkgs.gnome; [
|
||||||
gnome-flashback
|
gnome-flashback
|
||||||
] ++ (map
|
] ++ map gnome-flashback.mkSystemdTargetForWm flashbackWms;
|
||||||
(wm: gnome-flashback.mkSystemdTargetForWm {
|
|
||||||
inherit (wm) wmName;
|
|
||||||
}) cfg.flashback.customSessions);
|
|
||||||
|
|
||||||
# gnome-panel needs these for menu applet
|
# gnome-panel needs these for menu applet
|
||||||
environment.sessionVariables.XDG_DATA_DIRS = [ "${pkgs.gnome.gnome-flashback}/share" ];
|
environment.sessionVariables.XDG_DATA_DIRS = [ "${pkgs.gnome.gnome-flashback}/share" ];
|
||||||
# TODO: switch to sessionVariables (resolve conflict)
|
# TODO: switch to sessionVariables (resolve conflict)
|
||||||
environment.variables.XDG_CONFIG_DIRS = [ "${pkgs.gnome.gnome-flashback}/etc/xdg" ];
|
environment.variables.XDG_CONFIG_DIRS = [ "${pkgs.gnome.gnome-flashback}/etc/xdg" ];
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf serviceCfg.core-os-services.enable {
|
(mkIf serviceCfg.core-os-services.enable {
|
||||||
|
|
|
@ -120,6 +120,7 @@
|
||||||
wmName = "xmonad";
|
wmName = "xmonad";
|
||||||
wmLabel = "XMonad";
|
wmLabel = "XMonad";
|
||||||
wmCommand = "${pkgs.haskellPackages.xmonad}/bin/xmonad";
|
wmCommand = "${pkgs.haskellPackages.xmonad}/bin/xmonad";
|
||||||
|
enableGnomePanel = false;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
|
@ -33,10 +33,9 @@ let
|
||||||
version = "3.40.0";
|
version = "3.40.0";
|
||||||
|
|
||||||
# From data/sessions/Makefile.am
|
# From data/sessions/Makefile.am
|
||||||
requiredComponentsCommon = [
|
requiredComponentsCommon = enableGnomePanel:
|
||||||
"gnome-flashback"
|
[ "gnome-flashback" ]
|
||||||
"gnome-panel"
|
++ lib.optional enableGnomePanel "gnome-panel";
|
||||||
];
|
|
||||||
requiredComponentsGsd = [
|
requiredComponentsGsd = [
|
||||||
"org.gnome.SettingsDaemon.A11ySettings"
|
"org.gnome.SettingsDaemon.A11ySettings"
|
||||||
"org.gnome.SettingsDaemon.Color"
|
"org.gnome.SettingsDaemon.Color"
|
||||||
|
@ -55,7 +54,8 @@ let
|
||||||
"org.gnome.SettingsDaemon.Wacom"
|
"org.gnome.SettingsDaemon.Wacom"
|
||||||
"org.gnome.SettingsDaemon.XSettings"
|
"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 {
|
gnome-flashback = stdenv.mkDerivation rec {
|
||||||
name = "${pname}-${version}";
|
name = "${pname}-${version}";
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ let
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
# Check that our expected RequiredComponents match the stock session files, but then don't install them.
|
# Check that our expected RequiredComponents match the stock session files, but then don't install them.
|
||||||
# They can be installed using mkSessionForWm.
|
# 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/gnome-session
|
||||||
rm -r $out/share/xsessions
|
rm -r $out/share/xsessions
|
||||||
|
@ -126,7 +126,7 @@ let
|
||||||
versionPolicy = "odd-unstable";
|
versionPolicy = "odd-unstable";
|
||||||
};
|
};
|
||||||
|
|
||||||
mkSessionForWm = { wmName, wmLabel, wmCommand }:
|
mkSessionForWm = { wmName, wmLabel, wmCommand, enableGnomePanel }:
|
||||||
let
|
let
|
||||||
wmApplication = writeTextFile {
|
wmApplication = writeTextFile {
|
||||||
name = "gnome-flashback-${wmName}-wm";
|
name = "gnome-flashback-${wmName}-wm";
|
||||||
|
@ -151,7 +151,7 @@ let
|
||||||
text = ''
|
text = ''
|
||||||
[GNOME Session]
|
[GNOME Session]
|
||||||
Name=GNOME Flashback (${wmLabel})
|
Name=GNOME Flashback (${wmLabel})
|
||||||
${requiredComponents wmName}
|
${requiredComponents wmName enableGnomePanel}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -183,11 +183,11 @@ let
|
||||||
providedSessions = [ "gnome-flashback-${wmName}" ];
|
providedSessions = [ "gnome-flashback-${wmName}" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
mkSystemdTargetForWm = { wmName }:
|
mkSystemdTargetForWm = { wmName, wmLabel, wmCommand, enableGnomePanel }:
|
||||||
runCommand "gnome-flashback-${wmName}.target" { } ''
|
runCommand "gnome-flashback-${wmName}.target" {} ''
|
||||||
mkdir -p $out/lib/systemd/user
|
mkdir -p $out/lib/systemd/user
|
||||||
cp "${gnome-flashback}/lib/systemd/user/gnome-session-x11@gnome-flashback-metacity.target" \
|
cp -r "${gnome-flashback}/lib/systemd/user/gnome-session@gnome-flashback-metacity.target.d" \
|
||||||
"$out/lib/systemd/user/gnome-session-x11@gnome-flashback-${wmName}.target"
|
"$out/lib/systemd/user/gnome-session@gnome-flashback-${wmName}.target.d"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue