home-environment: add username and homeDirectory options

This commit is contained in:
Silvan Mosberger 2017-10-06 00:15:22 +02:00 committed by Robert Helgesson
parent f0a1d69f50
commit 3bc3b34d97
No known key found for this signature in database
GPG key ID: C3DB11069E65DC86

View file

@ -96,6 +96,20 @@ in
meta.maintainers = [ maintainers.rycee ]; meta.maintainers = [ maintainers.rycee ];
options = { 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 { home.language = mkOption {
type = languageSubModule; type = languageSubModule;
default = {}; default = {};
@ -178,6 +192,20 @@ in
}; };
config = { 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 = home.sessionVariables =
let let
maybeSet = name: value: maybeSet = name: value: