2009-09-26 01:06:38 +02:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
2009-09-26 02:07:52 +02:00
|
|
|
let
|
|
|
|
|
|
|
|
conf = pkgs.writeText "PolicyKit.conf"
|
|
|
|
''
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
|
|
|
<!DOCTYPE pkconfig PUBLIC "-//freedesktop//DTD PolicyKit Configuration 1.0//EN"
|
|
|
|
"http://hal.freedesktop.org/releases/PolicyKit/1.0/config.dtd">
|
|
|
|
|
|
|
|
<config version="0.1">
|
|
|
|
</config>
|
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
|
2009-09-26 01:06:38 +02:00
|
|
|
{
|
|
|
|
|
2011-07-25 02:52:59 +02:00
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2011-07-25 02:52:59 +02:00
|
|
|
security.policykit.enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "Enable PolicyKit (obsolete).";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
config = mkIf config.security.policykit.enable {
|
2009-09-26 01:06:38 +02:00
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.policykit ];
|
|
|
|
|
|
|
|
services.dbus.packages = [ pkgs.policykit ];
|
|
|
|
|
|
|
|
security.pam.services = [ { name = "polkit"; } ];
|
|
|
|
|
|
|
|
users.extraUsers = singleton
|
|
|
|
{ name = "polkituser";
|
|
|
|
uid = config.ids.uids.polkituser;
|
|
|
|
description = "PolicyKit user";
|
|
|
|
};
|
|
|
|
|
|
|
|
users.extraGroups = singleton
|
|
|
|
{ name = "polkituser";
|
|
|
|
gid = config.ids.gids.polkituser;
|
|
|
|
};
|
|
|
|
|
2009-09-26 12:32:57 +02:00
|
|
|
environment.etc =
|
|
|
|
[ { source = conf;
|
|
|
|
target = "PolicyKit/PolicyKit.conf";
|
|
|
|
}
|
|
|
|
{ source = (pkgs.buildEnv {
|
|
|
|
name = "PolicyKit-policies";
|
|
|
|
pathsToLink = [ "/share/PolicyKit/policy" ];
|
|
|
|
paths = [ pkgs.policykit pkgs.consolekit pkgs.hal ];
|
|
|
|
}) + "/share/PolicyKit/policy";
|
|
|
|
target = "PolicyKit/policy";
|
|
|
|
}
|
|
|
|
];
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2010-09-13 17:41:38 +02:00
|
|
|
system.activationScripts.policyKit = stringAfter [ "users" ]
|
2009-09-26 01:06:38 +02:00
|
|
|
''
|
|
|
|
mkdir -m 0770 -p /var/run/PolicyKit
|
2012-05-17 21:43:32 +02:00
|
|
|
chown root:polkituser /var/run/PolicyKit
|
2009-09-26 01:06:38 +02:00
|
|
|
|
|
|
|
mkdir -m 0770 -p /var/lib/PolicyKit
|
2012-05-17 21:43:32 +02:00
|
|
|
chown root:polkituser /var/lib/PolicyKit
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-09-26 01:06:38 +02:00
|
|
|
mkdir -p /var/lib/misc
|
|
|
|
touch /var/lib/misc/PolicyKit.reload
|
|
|
|
chmod 0664 /var/lib/misc/PolicyKit.reload
|
2012-05-17 21:43:32 +02:00
|
|
|
chown polkituser:polkituser /var/lib/misc/PolicyKit.reload
|
2010-09-13 17:41:38 +02:00
|
|
|
'';
|
2009-09-26 01:06:38 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|