From 45ab2f83aa754054e438a15a10f5f90b298cf39f Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Mon, 19 Jun 2023 22:51:29 -0700 Subject: [PATCH] Allow access to the main home manager user directly --- modules/user/default.nix | 105 ++++++++++++++++++++++----------------- 1 file changed, 59 insertions(+), 46 deletions(-) diff --git a/modules/user/default.nix b/modules/user/default.nix index 7762905..a9f6573 100644 --- a/modules/user/default.nix +++ b/modules/user/default.nix @@ -1,67 +1,80 @@ -{ system, inputs, config, pkgs, ... }: let +{ system, inputs, config, lib, pkgs, ... }: let username = "admin"; homeDirectory = "/home/${username}"; in { imports = [ inputs.home-manager.nixosModules.home-manager ]; - users.users.${username} = { - isNormalUser = true; - uid = 1000; - extraGroups = [ "wheel" ]; - initialPassword = "test"; + options.user = lib.mkOption { + type = with lib.types; attrsOf anything; + default = {}; }; - fonts = { - enableDefaultFonts = false; + config = { + users.users.${username} = { + isNormalUser = true; + uid = 1000; + extraGroups = [ "wheel" ]; + initialPassword = "test"; + }; - fonts = with inputs.stable.legacyPackages.${system}; [ - dejavu_fonts - nerdfonts - noto-fonts - noto-fonts-cjk - ]; - }; + fonts = { + enableDefaultFonts = false; - systemd = { - # kde polkit agent - user.services.polkit-agent = { - wants = [ "graphical-session.target" ]; - after = [ "graphical-session.target" ]; + fonts = with inputs.stable.legacyPackages.${system}; [ + dejavu_fonts + nerdfonts + noto-fonts + noto-fonts-cjk + ]; + }; - serviceConfig = { - Type = "simple"; - ExecStart = "${pkgs.polkit-kde-agent}/libexec/polkit-kde-authentication-agent-1"; - Restart = "on-failure"; - RestartSec = 1; - TimeoutStopSec = 10; + systemd = { + # kde polkit agent + user.services.polkit-agent = { + wants = [ "graphical-session.target" ]; + after = [ "graphical-session.target" ]; + + serviceConfig = { + Type = "simple"; + ExecStart = "${pkgs.polkit-kde-agent}/libexec/polkit-kde-authentication-agent-1"; + Restart = "on-failure"; + RestartSec = 1; + TimeoutStopSec = 10; + }; }; }; - }; - programs.gnupg.agent = { - enable = true; - pinentryFlavor = "gnome3"; - }; - - environment.variables = { - XCURSOR_SIZE = "24"; - }; - - programs.hyprland.enable = true; - - home-manager = { - extraSpecialArgs = { - inherit system inputs; - systemConfig = config; + programs.gnupg.agent = { + enable = true; + pinentryFlavor = "gnome3"; }; - # use system nixpkgs instead of home-manager nixpkgs - useGlobalPkgs = true; + environment.variables = { + XCURSOR_SIZE = "24"; + }; - users.${username} = { system, inputs, systemConfig, pkgs, ... }: { + programs.hyprland.enable = true; + + home-manager = { + extraSpecialArgs = { + inherit system inputs; + }; + + # use system nixpkgs instead of home-manager nixpkgs + useGlobalPkgs = true; + + users.${username} = config.user; + }; + + # pass the user config as a system module argument + _module.args = { + homeConfig = config.home-manager.users.${username}; + }; + + user = { home = { inherit username homeDirectory; - stateVersion = systemConfig.system.stateVersion; + stateVersion = config.system.stateVersion; }; }; };