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
];
# Just enumerate all heads without discarding XRandR output information.
xrandrHeads = let
mkHead = num: output: {
@ -74,6 +75,7 @@ let
monitors = foldl mkMonitor [] xrandrHeads;
in concatMapStrings (getAttr "value") monitors;
configFile = pkgs.stdenv.mkDerivation {
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
{
@ -374,13 +387,7 @@ in
###### implementation
config = mkIf cfg.enable
(mkAssert (!(cfg.startOpenSSHAgent && cfg.startGnuPGAgent))
''
The OpenSSH agent and GnuPG agent cannot be started both.
Choose between `startOpenSSHAgent' and `startGnuPGAgent'.
''
{
config = mkIf cfg.enable (checkAgent (checkPolkit {
boot.extraModulePackages =
optional (elem "nvidia" driverNames) kernelPackages.nvidia_x11 ++
@ -601,6 +608,6 @@ in
${xrandrMonitorSections}
'';
});
}));
}