From 91bb55c48fc2c6eb09b35f19df00e1afdaca114b Mon Sep 17 00:00:00 2001 From: xezo360hye Date: Tue, 3 Jun 2025 23:36:19 +0300 Subject: [PATCH] refactor(flake): integrate home-manager into nixos configuration --- flake.nix | 53 ++++++++++++++++++------------------------------- home/common.nix | 6 ------ 2 files changed, 19 insertions(+), 40 deletions(-) diff --git a/flake.nix b/flake.nix index 17da758..8d2d957 100644 --- a/flake.nix +++ b/flake.nix @@ -44,6 +44,7 @@ "${hostname}" = nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs; }; modules = [ + home-manager.nixosModules.home-manager nur.modules.nixos.default ./system/common.nix @@ -53,43 +54,28 @@ { system.stateVersion = stateVersion; networking.hostName = hostname; - } - ]; - }; - }; + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; - makeHome = hostname: - let - extractModules = map - (module: - let hm = module.homeManagerModules; - in hm.${lib.head (lib.attrNames hm)}); - in - { - "${username}@${hostname}" = home-manager.lib.homeManagerConfiguration - { - extraSpecialArgs = { inherit inputs; }; - pkgs = import nixpkgs { - system = "x86_64-linux"; - overlays = [ nur.overlays.default ]; - }; + home-manager.users.${username} = { + imports = [ + ./home/${hostname}.nix + ./home/common.nix + ] ++ (map + (module: + let hm = module.homeManagerModules; + in hm.${lib.head (lib.attrNames hm)}) + [ nixvim nethack plasma-manager ]); - modules = (extractModules [ - nixvim - nethack - plasma-manager - ]) ++ [ - nur.modules.homeManager.default + home = { + username = username; + homeDirectory = "/home/${username}"; + stateVersion = stateVersion; + }; - ./home/${hostname}.nix - ./home/common.nix - - { - news.display = "show"; - home.username = username; - home.homeDirectory = "/home/${username}"; - home.stateVersion = stateVersion; + news.display = "show"; + }; } ]; }; @@ -98,6 +84,5 @@ forEachHost = fn: lib.mergeAttrsList (map fn hostnames); in { nixosConfigurations = forEachHost makeSystem; - homeConfigurations = forEachHost makeHome; }; } diff --git a/home/common.nix b/home/common.nix index b04fb9f..318f64b 100644 --- a/home/common.nix +++ b/home/common.nix @@ -48,8 +48,6 @@ }; }; - nixpkgs.config.allowUnfree = true; - home = { packages = with pkgs; let sent' = sent.overrideAttrs (oldAttrs: { @@ -88,9 +86,5 @@ sessionVariables = { ANI_CLI_PLAYER = "mpv"; }; - - file = { - ".config/nixpkgs/config.nix".text = "{ allowUnfree = true; }"; - }; }; }