diff --git a/config/configuration.nix b/config/configuration.nix index 399e9d7..8bdbd48 100644 --- a/config/configuration.nix +++ b/config/configuration.nix @@ -7,5 +7,8 @@ ./nixos ./users/alice.nix ]; + + # to use zsh as a login shell, it has to be enabled globally. + programs.zsh.enable = true; } diff --git a/config/flake.nix b/config/flake.nix index 4e6eec3..a7e7b42 100644 --- a/config/flake.nix +++ b/config/flake.nix @@ -24,9 +24,12 @@ { home-manager.useGlobalPkgs = true; # Use global packages in home-manager home-manager.useUserPackages = true; # Use user packages in home-manager - # home-manager.users.alice = ./users/alice.nix; # Define user-specific home-manager configuration } ]; + + specialArgs = { + inherit home-manager; + }; }; }; }; diff --git a/config/users/alice.nix b/config/users/alice.nix index c906717..cf5cd7e 100644 --- a/config/users/alice.nix +++ b/config/users/alice.nix @@ -19,21 +19,20 @@ inputs @ { pkgs, lib, ...}: let }; }; }; -in - { - imports = [(lib.modules.importApply ./user.nix { - user = { - userName = "alice"; - defaultPassword = "password"; - shell = pkgs.zsh; - packages = with pkgs; [ - tree - vim - wget - curl - git - ]; - userModule = aliceUserFn; - }; - })]; - } +in { + imports = [(lib.modules.importApply ./user.nix { + user = { + userName = "alice"; + defaultPassword = "password"; + shell = pkgs.zsh; + packages = with pkgs; [ + tree + vim + wget + curl + git + ]; + userModule = aliceUserFn; + }; + })]; +} diff --git a/config/users/user.nix b/config/users/user.nix index 2c5cb23..c4a9877 100644 --- a/config/users/user.nix +++ b/config/users/user.nix @@ -5,19 +5,16 @@ # - `packages`: List of packages to install for the user account. # - `userModule`: A module that provides additional configuration for the user account. -{user}: inputs @ {lib, pkgs, ...}: +{user}: inputs @ {lib, home-manager, pkgs, ...}: let - userName = user.userName or "alice"; + username = user.userName or "alice"; base = import ../options.nix {}; in let - homeDirectory = "/home/${userName}"; - passwordConfig = lib.mkIf user.defaultPassword { - initialPassword = user.defaultPassword; - }; + homeDirectory = "/home/${username}"; in { - users.users.${userName} = { + users.users.${username} = { shell = user.shell or pkgs.zsh; # Default shell for the user home = homeDirectory; @@ -25,14 +22,18 @@ in { group = "users"; # Default group isNormalUser = true; extraGroups = [ "wheel" ]; # Add to wheel group for sudo access - } // passwordConfig; + } // lib.optionalAttrs (lib.hasAttr "defaultPassword" user) { + initialPassword = user.defaultPassword; + }; - home-manager.users.${userName} = {...}: { - imports = [ user.userModule (inputs) ]; + home-manager.users.${username} = { + imports = [ user.userModule ]; + + # programs.home-manager.enable = true; home = { - inherit userName; - inherit (user) homeDirectory; + inherit username; + inherit homeDirectory; inherit (user) packages; stateVersion = "${base.stateVersion}";