diff --git a/flake.lock b/flake.lock index bc0ddcf..e28e66c 100644 --- a/flake.lock +++ b/flake.lock @@ -19,6 +19,27 @@ "type": "github" } }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1715077503, + "narHash": "sha256-AfHQshzLQfUqk/efMtdebHaQHqVntCMjhymQzVFLes0=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "6e277d9566de9976f47228dd8c580b97488734d4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "6e277d9566de9976f47228dd8c580b97488734d4", + "repo": "home-manager", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1714532603, @@ -69,6 +90,7 @@ "root": { "inputs": { "flake-utils": "flake-utils", + "home-manager": "home-manager", "nixpkgs": "nixpkgs", "sops-nix": "sops-nix" } diff --git a/flake.nix b/flake.nix index a208145..0281e84 100644 --- a/flake.nix +++ b/flake.nix @@ -4,10 +4,16 @@ inputs = { nixpkgs.url = "nixpkgs/38c01297e7ec11f7b9e3f2cae7d6fcec6cc767ec"; flake-utils.url = "github:numtide/flake-utils?ref=b1d9ab70662946ef0850d488da1c9019f3a9752a"; + + home-manager = { + url = "github:nix-community/home-manager?ref=6e277d9566de9976f47228dd8c580b97488734d4"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + sops-nix.url = "github:Mic92/sops-nix?ref=f1b0adc27265274e3b0c9b872a8f476a098679bd"; }; - outputs = { self, nixpkgs, flake-utils, sops-nix }: ( + outputs = { self, nixpkgs, flake-utils, home-manager, sops-nix }: ( let inherit (nixpkgs) lib; @@ -83,6 +89,7 @@ }; }; }) + home-manager.nixosModules.home-manager sops-nix.nixosModules.sops ./lib/configuration.nix (tryFiles [ ./lib/machines/${name}.nix ] ./lib/hardware/base.nix) @@ -109,7 +116,7 @@ in lib.attrsets.concatMapAttrs ( username: user: { - "${username}@${hostname}" = { + "${username}@${hostname}" = home-manager.lib.homeManagerConfiguration { modules = let getUserConfig = import ./lib/utils/user-config.nix { inherit lib; }; diff --git a/lib/configuration.nix b/lib/configuration.nix index 6ec7bd1..620fc48 100644 --- a/lib/configuration.nix +++ b/lib/configuration.nix @@ -1,4 +1,4 @@ -{ hostname, machineConfig, ... }: { +{ hostname, lib, machineConfig, ... }: { imports = [ ./modules/custom-build-vm.nix ./modules/custom-sops-nix.nix @@ -29,6 +29,28 @@ users.myUsers = machineConfig.users; + home-manager = { + useUserPackages = true; + useGlobalPkgs = true; + + users = + lib.attrsets.concatMapAttrs (username: user: + let + getUserConfig = import ./utils/user-config.nix { inherit lib; }; + configPath = getUserConfig { inherit hostname username; }; + in + if (configPath != null) + then { + ${username} = { pkgs, ... }@args: import configPath ({ + userConfig = { + inherit hostname username; + } // user; + } // args); + } + else {}) + machineConfig.users; + }; + # Networking networking.hostName = hostname;