1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-10 14:50:40 +02:00

feat: add home-manager

This commit is contained in:
oddlama 2022-12-09 15:42:27 +01:00
parent 04fc94267a
commit c31e43641e
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A

49
nix/home-manager.nix Normal file
View file

@ -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