Allow access to the main home manager user directly

This commit is contained in:
outfoxxed 2023-06-19 22:51:29 -07:00
parent 9b4ec6e0a1
commit 45ab2f83aa
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E

View file

@ -1,9 +1,15 @@
{ system, inputs, config, pkgs, ... }: let { system, inputs, config, lib, pkgs, ... }: let
username = "admin"; username = "admin";
homeDirectory = "/home/${username}"; homeDirectory = "/home/${username}";
in { in {
imports = [ inputs.home-manager.nixosModules.home-manager ]; imports = [ inputs.home-manager.nixosModules.home-manager ];
options.user = lib.mkOption {
type = with lib.types; attrsOf anything;
default = {};
};
config = {
users.users.${username} = { users.users.${username} = {
isNormalUser = true; isNormalUser = true;
uid = 1000; uid = 1000;
@ -52,16 +58,23 @@ in {
home-manager = { home-manager = {
extraSpecialArgs = { extraSpecialArgs = {
inherit system inputs; inherit system inputs;
systemConfig = config;
}; };
# use system nixpkgs instead of home-manager nixpkgs # use system nixpkgs instead of home-manager nixpkgs
useGlobalPkgs = true; useGlobalPkgs = true;
users.${username} = { system, inputs, systemConfig, pkgs, ... }: { users.${username} = config.user;
};
# pass the user config as a system module argument
_module.args = {
homeConfig = config.home-manager.users.${username};
};
user = {
home = { home = {
inherit username homeDirectory; inherit username homeDirectory;
stateVersion = systemConfig.system.stateVersion; stateVersion = config.system.stateVersion;
}; };
}; };
}; };