2009-01-25 16:22:17 +01:00
|
|
|
{pkgs, config, ...}:
|
2009-01-09 01:23:07 +01:00
|
|
|
let
|
|
|
|
inherit(pkgs.lib) mkOption;
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services = {
|
|
|
|
guestUsers = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
|
|
|
Whether to enable automatic addition of users with empty passwords
|
|
|
|
";
|
|
|
|
};
|
|
|
|
users = mkOption {
|
|
|
|
default = ["guest"];
|
|
|
|
description = "
|
|
|
|
List of usernames to add
|
|
|
|
";
|
|
|
|
};
|
|
|
|
includeRoot = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
|
|
|
LEAVE THAT ALONE; whether to reset root password
|
|
|
|
";
|
|
|
|
};
|
|
|
|
extraGroups = mkOption {
|
|
|
|
default = ["audio"];
|
|
|
|
description = "
|
|
|
|
Extra groups to grant
|
|
|
|
";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
inherit (pkgs.lib) concatStringsSep optional optionalString;
|
|
|
|
|
|
|
|
inherit (config.services.guestUsers) enable users includeRoot extraGroups;
|
|
|
|
|
|
|
|
userEntry = user:
|
|
|
|
{
|
|
|
|
name = user;
|
|
|
|
description = "NixOS guest user";
|
|
|
|
home = "/home/${user}";
|
|
|
|
createHome = true;
|
|
|
|
group = "users";
|
|
|
|
extraGroups = extraGroups;
|
|
|
|
shell = "/bin/sh";
|
|
|
|
};
|
|
|
|
|
|
|
|
nameString = (concatStringsSep " " users) + optionalString includeRoot " root";
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
require = options;
|
|
|
|
services = {
|
2009-05-25 00:49:06 +02:00
|
|
|
# !!! Better to do this as an activation script plugin rather
|
|
|
|
# than an Upstart job.
|
2009-01-09 01:23:07 +01:00
|
|
|
extraJobs = optional enable {
|
|
|
|
name = "clear-passwords";
|
|
|
|
job = ''
|
|
|
|
description "Clear guest passwords"
|
|
|
|
start on startup
|
|
|
|
script
|
|
|
|
for i in ${nameString}; do
|
|
|
|
echo | ${pkgs.pwdutils}/bin/passwd --stdin $i
|
|
|
|
done
|
|
|
|
end script
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
mingetty = {
|
2009-05-25 00:49:06 +02:00
|
|
|
helpLine = optionalString enable "\nThese users have empty passwords: ${nameString}";
|
2009-01-09 01:23:07 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
users = {
|
|
|
|
extraUsers = map userEntry users;
|
|
|
|
};
|
|
|
|
}
|