From 3bc3b34d9715a2750f2a7b7880eb532260ec6dde Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 6 Oct 2017 00:15:22 +0200 Subject: [PATCH] home-environment: add username and homeDirectory options --- modules/home-environment.nix | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 2026e7d4b..38049290f 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -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 = {}; @@ -178,6 +192,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: