From c31e43641e20c66ed5ebbffffb5c6913a80e9951 Mon Sep 17 00:00:00 2001 From: oddlama Date: Fri, 9 Dec 2022 15:42:27 +0100 Subject: [PATCH] feat: add home-manager --- nix/home-manager.nix | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 nix/home-manager.nix diff --git a/nix/home-manager.nix b/nix/home-manager.nix new file mode 100644 index 0000000..cf3c1b6 --- /dev/null +++ b/nix/home-manager.nix @@ -0,0 +1,49 @@ +{ + self, + home-manager, + nixpkgs, + templates, + ... +}: let + inherit (nixpkgs) lib; + hosts = (import ./hosts.nix).homeManager.all; + + genModules = hostName: {homeDirectory, ...}: { + config, + pkgs, + ... + }: { + imports = [(../hosts + "/${hostName}")]; + nix.registry = { + nixpkgs.flake = nixpkgs; + p.flake = nixpkgs; + pkgs.flake = nixpkgs; + templates.flake = templates; + }; + + home = { + inherit homeDirectory; + sessionVariables.NIX_PATH = lib.concatStringsSep ":" [ + "nixpkgs=${config.xdg.dataHome}/nixpkgs" + "nixpkgs-overlays=${config.xdg.dataHome}/overlays" + ]; + }; + + xdg = { + dataFile = { + nixpkgs.source = nixpkgs; + overlays.source = ../nix/overlays; + }; + configFile."nix/nix.conf".text = '' + flake-registry = ${config.xdg.configHome}/nix/registry.json + ''; + }; + }; + + genConfiguration = hostName: {hostPlatform, ...} @ attrs: + home-manager.lib.homeManagerConfiguration { + pkgs = self.pkgs.${hostPlatform}; + modules = [(genModules hostName attrs)]; + }; +in + lib.mapAttrs genConfiguration hosts