home: automatically find and all all module files

This commit is contained in:
Julian Mutter 2024-01-30 10:21:12 +01:00
parent 900d07ae77
commit fd6cd027fc

View File

@ -32,20 +32,25 @@
config.allowUnfree = true;
overlays = [ unstable-overlay ];
};
# Does not follow symlinks
listNixFilesRec = dir:
pkgs.lib.lists.flatten (pkgs.lib.attrsets.mapAttrsToList (name: value:
let path = "${toString dir}/${name}";
in if value == "directory" && builtins.pathExists path then
listNixFilesRec path
else if value == "regular" && pkgs.lib.hasSuffix ".nix" name then
path
else
[ ]) (builtins.readDir dir));
in {
homeConfigurations."julian" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
# Specify your home configuration modules here, for example,
# the path to your home.nix.
modules = [
./home-manager/home.nix
./home-manager/modules/shell/zsh/default.nix
./home-manager/modules/shell/direnv.nix
./home-manager/modules/topgrade.nix
./home-manager/modules/neovim.nix
./home-manager/modules/alacritty.nix
];
modules = [ ./home-manager/home.nix ]
++ listNixFilesRec ./home-manager/modules;
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix