2007-11-16 13:26:34 +00:00
|
|
|
{pkgs, config, upstartJobs, defaultShell}:
|
2007-06-08 16:41:12 +01:00
|
|
|
|
|
|
|
let ids = import ./ids.nix; in
|
|
|
|
|
|
|
|
rec {
|
|
|
|
|
2007-11-16 13:26:34 +00:00
|
|
|
# User accounts to be created/updated by NixOS.
|
|
|
|
users =
|
2007-06-08 16:41:12 +01:00
|
|
|
let
|
|
|
|
jobUsers = pkgs.lib.concatLists (map (job: job.users) upstartJobs.jobs);
|
|
|
|
|
|
|
|
defaultUsers =
|
|
|
|
[
|
|
|
|
{ name = "root";
|
|
|
|
uid = ids.uids.root;
|
|
|
|
description = "System administrator";
|
|
|
|
home = "/root";
|
|
|
|
shell = defaultShell;
|
2007-11-12 14:59:23 +00:00
|
|
|
group = "root";
|
2007-06-08 16:41:12 +01:00
|
|
|
}
|
|
|
|
{ name = "nobody";
|
|
|
|
uid = ids.uids.nobody;
|
|
|
|
description = "Unprivileged account (don't use!)";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
makeNixBuildUser = nr:
|
|
|
|
{ name = "nixbld${toString nr}";
|
|
|
|
description = "Nix build user ${toString nr}";
|
|
|
|
uid = builtins.add ids.uids.nixbld nr;
|
|
|
|
extraGroups = ["nixbld"];
|
|
|
|
};
|
|
|
|
|
|
|
|
nixBuildUsers = map makeNixBuildUser (pkgs.lib.range 1 10);
|
|
|
|
|
|
|
|
addAttrs =
|
|
|
|
{ name
|
|
|
|
, description
|
|
|
|
, uid ? ""
|
|
|
|
, group ? "nogroup"
|
|
|
|
, extraGroups ? []
|
|
|
|
, home ? "/var/empty"
|
2007-11-16 13:26:34 +00:00
|
|
|
, shell ? (if useDefaultShell then defaultShell else "/noshell")
|
|
|
|
, createHome ? false
|
|
|
|
, useDefaultShell ? false
|
2007-06-08 16:41:12 +01:00
|
|
|
}:
|
2007-11-16 13:26:34 +00:00
|
|
|
{ inherit name description uid group extraGroups home shell createHome; };
|
2007-06-08 16:41:12 +01:00
|
|
|
|
2007-11-16 13:26:34 +00:00
|
|
|
in map addAttrs (defaultUsers ++ jobUsers ++ nixBuildUsers ++ config.users.extraUsers);
|
2007-06-08 16:41:12 +01:00
|
|
|
|
|
|
|
|
2007-11-16 13:26:34 +00:00
|
|
|
# Groups to be created/updated by NixOS.
|
|
|
|
groups =
|
2007-06-10 21:13:12 +01:00
|
|
|
let
|
|
|
|
jobGroups = pkgs.lib.concatLists (map (job: job.groups) upstartJobs.jobs);
|
|
|
|
|
|
|
|
defaultGroups =
|
|
|
|
[
|
|
|
|
{ name = "root";
|
|
|
|
gid = ids.gids.root;
|
|
|
|
}
|
2007-08-16 16:09:06 +01:00
|
|
|
{ name = "wheel";
|
|
|
|
gid = ids.gids.wheel;
|
|
|
|
}
|
2008-07-02 19:03:43 +01:00
|
|
|
{ name = "disk";
|
|
|
|
gid = ids.gids.disk;
|
|
|
|
}
|
|
|
|
{ name = "kmem";
|
|
|
|
gid = ids.gids.kmem;
|
|
|
|
}
|
|
|
|
{ name = "tty";
|
|
|
|
gid = ids.gids.tty;
|
|
|
|
}
|
|
|
|
{ name = "floppy";
|
|
|
|
gid = ids.gids.floppy;
|
|
|
|
}
|
|
|
|
{ name = "uucp";
|
|
|
|
gid = ids.gids.uucp;
|
|
|
|
}
|
|
|
|
{ name = "lp";
|
|
|
|
gid = ids.gids.lp;
|
|
|
|
}
|
2007-06-10 21:13:12 +01:00
|
|
|
{ name = "nogroup";
|
|
|
|
gid = ids.gids.nogroup;
|
|
|
|
}
|
|
|
|
{ name = "users";
|
|
|
|
gid = ids.gids.users;
|
|
|
|
}
|
|
|
|
{ name = "nixbld";
|
|
|
|
gid = ids.gids.nixbld;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
addAttrs =
|
|
|
|
{ name, gid ? "" }:
|
|
|
|
{ inherit name gid; };
|
|
|
|
|
2007-11-16 13:26:34 +00:00
|
|
|
in map addAttrs (defaultGroups ++ jobGroups ++ config.users.extraGroups);
|
2007-06-08 16:41:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Awful hackery necessary to pass the users/groups to the activation script.
|
|
|
|
createUsersGroups = ../helpers/create-users-groups.sh;
|
2008-01-11 16:59:39 +00:00
|
|
|
usersList = pkgs.writeText "users" (pkgs.lib.concatStrings (map (u: "${u.name}\n${u.description}\n${toString u.uid}\n${u.group}\n${toString (pkgs.lib.concatStringsSep "," u.extraGroups)}\n${u.home}\n${u.shell}\n${toString u.createHome}\n") users));
|
2007-11-16 13:26:34 +00:00
|
|
|
groupsList = pkgs.writeText "groups" (pkgs.lib.concatStrings (map (g: "${g.name}\n${toString g.gid}\n") groups));
|
2007-06-08 16:41:12 +01:00
|
|
|
|
2007-11-09 18:49:45 +00:00
|
|
|
}
|