From cb42df54ec1b6ef3c2f496720dce434f48ea321b Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Sun, 27 Apr 2025 15:06:02 +0800 Subject: [PATCH] refactor(hmModules): moved home-manager to module --- configs/users.nix | 23 +---------------------- flake.nix | 1 + hosts/common.nix | 1 + modules/hm/default.nix | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 modules/hm/default.nix diff --git a/configs/users.nix b/configs/users.nix index 59a80bf..ad034ad 100644 --- a/configs/users.nix +++ b/configs/users.nix @@ -1,20 +1,5 @@ +{ config, ... }: { - inputs, - config, - specialArgs, - ... -}: -{ - imports = [ - inputs.home-manager.nixosModules.home-manager - ]; - - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - extraSpecialArgs = specialArgs; - }; - time.timeZone = "Asia/Singapore"; i18n.defaultLocale = "en_SG.UTF-8"; @@ -42,10 +27,4 @@ ]; }; }; - - home-manager.users.rafiq.home = { - username = "rafiq"; - homeDirectory = "/home/rafiq"; - stateVersion = "25.05"; - }; } diff --git a/flake.nix b/flake.nix index e746b32..de5e657 100644 --- a/flake.nix +++ b/flake.nix @@ -24,6 +24,7 @@ specialArgs = args; modules = [ ./modules/nixos + ./modules/hm ./hosts/common.nix ./hosts/${hostname}.nix ]; diff --git a/hosts/common.nix b/hosts/common.nix index 90517b9..f9f4484 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -12,6 +12,7 @@ ../configs/graphical.nix ]; nixosModules.enable = true; + hmModules.enable = true; nix-config.enable = true; boot-config.enable = true; hardware-config.usbAutoMount = true; diff --git a/modules/hm/default.nix b/modules/hm/default.nix new file mode 100644 index 0000000..ba2d634 --- /dev/null +++ b/modules/hm/default.nix @@ -0,0 +1,33 @@ +{ + inputs, + config, + specialArgs, + lib, + ... +}: +let + moduleName = "hmModules"; + cfg = config."${moduleName}"; +in +{ + imports = [ inputs.home-manager.nixosModules.home-manager ]; + + options = { + "${moduleName}" = { + enable = lib.mkEnableOption "Enable ${moduleName}."; + }; + }; + + config = lib.mkIf cfg.enable { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + extraSpecialArgs = specialArgs; + users.rafiq.home = { + username = "rafiq"; + homeDirectory = "/home/rafiq"; + stateVersion = "25.05"; + }; + }; + }; +}