xserver.nix: Check whether Polkit is enabled

Our X session script requires Polkit because it calls systemd-inhibit.
This commit is contained in:
Eelco Dolstra 2013-01-24 13:06:32 +01:00
parent bd328680ce
commit 8e1f243b30

View File

@ -43,6 +43,7 @@ let
pkgs.xorg.fontadobe75dpi pkgs.xorg.fontadobe75dpi
]; ];
# Just enumerate all heads without discarding XRandR output information. # Just enumerate all heads without discarding XRandR output information.
xrandrHeads = let xrandrHeads = let
mkHead = num: output: { mkHead = num: output: {
@ -74,6 +75,7 @@ let
monitors = foldl mkMonitor [] xrandrHeads; monitors = foldl mkMonitor [] xrandrHeads;
in concatMapStrings (getAttr "value") monitors; in concatMapStrings (getAttr "value") monitors;
configFile = pkgs.stdenv.mkDerivation { configFile = pkgs.stdenv.mkDerivation {
name = "xserver.conf"; name = "xserver.conf";
@ -107,6 +109,17 @@ let
''; # */ ''; # */
}; };
checkAgent = mkAssert (!(cfg.startOpenSSHAgent && cfg.startGnuPGAgent))
''
The OpenSSH agent and GnuPG agent cannot be started both.
Choose between `startOpenSSHAgent' and `startGnuPGAgent'.
'';
checkPolkit = mkAssert config.security.polkit.enable
"X11 requires Polkit to be enabled (security.polkit.enable = true).";
in in
{ {
@ -374,13 +387,7 @@ in
###### implementation ###### implementation
config = mkIf cfg.enable config = mkIf cfg.enable (checkAgent (checkPolkit {
(mkAssert (!(cfg.startOpenSSHAgent && cfg.startGnuPGAgent))
''
The OpenSSH agent and GnuPG agent cannot be started both.
Choose between `startOpenSSHAgent' and `startGnuPGAgent'.
''
{
boot.extraModulePackages = boot.extraModulePackages =
optional (elem "nvidia" driverNames) kernelPackages.nvidia_x11 ++ optional (elem "nvidia" driverNames) kernelPackages.nvidia_x11 ++
@ -601,6 +608,6 @@ in
${xrandrMonitorSections} ${xrandrMonitorSections}
''; '';
}); }));
} }