From b63959f307ce6d568ed988901921bd99f726dde6 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Mon, 7 Jul 2025 18:11:33 +0800 Subject: [PATCH] refactor(configurations): centralise home-manager config --- nix/configurations.nix | 16 +++++++++++----- nix/modules/home-manager.nix | 18 ------------------ 2 files changed, 11 insertions(+), 23 deletions(-) delete mode 100644 nix/modules/home-manager.nix diff --git a/nix/configurations.nix b/nix/configurations.nix index 645e60e..9375b15 100644 --- a/nix/configurations.nix +++ b/nix/configurations.nix @@ -7,7 +7,14 @@ let inherit (lib) nixosSystem; inherit (lib.attrsets) mapAttrs; + inherit (cfg.lib.modules) forAllUsers'; cfg = config.flake; + globalCfg = { + useGlobalPkgs = true; + useUserPackages = true; + sharedModules = [ cfg.modules.homeManager.default ]; + users = forAllUsers' (name: _: cfg.homes.${name}); + }; hosts = cfg.manifest.hosts or { }; mkConfigurations = class: hosts: @@ -15,13 +22,11 @@ let name: value: if class == "nixos" then nixosSystem { - specialArgs = { - inherit inputs; - inherit (cfg) manifest; - hostName = name; - }; + specialArgs.hostName = name; modules = [ cfg.modules.nixos.default + inputs.home-manager.nixosModules.home-manager + { home-manager = globalCfg; } (value.extraCfg or { }) ]; } @@ -30,5 +35,6 @@ let ) hosts; in { + imports = [ inputs.home-manager.flakeModules.home-manager ]; flake.nixosConfigurations = mkConfigurations "nixos" hosts.nixos; } diff --git a/nix/modules/home-manager.nix b/nix/modules/home-manager.nix deleted file mode 100644 index e33893c..0000000 --- a/nix/modules/home-manager.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ inputs, config, ... }: -let - inherit (cfg.lib.modules) forAllUsers'; - cfg = config.flake; - hm = inputs.home-manager; - globalCfg = { - useGlobalPkgs = true; - useUserPackages = true; - extraSpecialArgs = { inherit (cfg) manifest; }; - sharedModules = [ cfg.modules.homeManager.default ]; - users = forAllUsers' (name: _: cfg.homes.${name}); - }; -in -{ - imports = [ hm.flakeModules.home-manager ]; - flake.modules.nixos.default.imports = [ hm.nixosModules.home-manager ]; - flake.modules.nixos.default.config.home-manager = globalCfg; -}