add username and homeDirectory options

This commit is contained in:
Silvan Mosberger 2017-10-06 00:15:22 +02:00
parent 12fc9c54fa
commit 3d48f84f0c
No known key found for this signature in database
GPG key ID: 9424360B4B85C9E7

View file

@ -96,6 +96,20 @@ in
meta.maintainers = [ maintainers.rycee ];
options = {
home.username = mkOption {
type = types.str;
defaultText = "$USER";
readOnly = true;
description = "The user's username";
};
home.homeDirectory = mkOption {
type = types.path;
defaultText = "$HOME";
readOnly = true;
description = "The user's home directory";
};
home.language = mkOption {
type = languageSubModule;
default = {};
@ -167,6 +181,20 @@ in
};
config = {
assertions = [
{
assertion = config.home.username != "";
message = "Username could not be determined";
}
{
assertion = config.home.homeDirectory != "";
message = "Home directory could not be determined";
}
];
home.username = mkDefault (builtins.getEnv "USER");
home.homeDirectory = mkDefault (builtins.getEnv "HOME");
home.sessionVariables =
let
maybeSet = name: value: