{ self, lib, inputs, ... }: let mkNixosModule = name: [{ ${name} = import ./${name}; }]; mkBaseImport = name: [ self.nixosModules.${name} ]; # create a list of directory names from given folder filterModules = dir: builtins.attrNames (lib.attrsets.filterAttrs (n: v: v == "directory") (builtins.readDir dir)); # create nixosModules imports from list flakeNixosModulesList = modules: lib.attrsets.mergeAttrsList (builtins.concatMap mkNixosModule modules); flakeNixosBaseImports = modules: lib.lists.flatten (builtins.concatMap mkBaseImport modules); in { # Configuration common to all Linux systems flake = { nixosModules = rec {} // (flakeNixosModulesList (filterModules ./.)) // { base.imports = [ self.nixosModules.home-manager self.nixosModules.overlays inputs.agenix.nixosModules.default inputs.musnix.nixosModules.musnix inputs.nixmodules-hensoko.nixosModules.all ({ flake, pkgs, lib, unstable, master, ... }: { nixpkgs.overlays = [ (prev: next: { nixd = inputs.unstable.legacyPackages.${prev.system}.nixd; # needed by sway module waybar = inputs.master.legacyPackages.${prev.system}.waybar; # unstable appflowy = inputs.unstable.legacyPackages.${prev.system}.appflowy; docker_24 = inputs.unstable.legacyPackages.${prev.system}.docker_24; home-assistant = inputs.unstable.legacyPackages.${prev.system}.home-assistant; scan2paperless = inputs.scan2paperless.legacyPackages.${prev.system}.scan2paperless; paperless-ngx = inputs.unstable.legacyPackages.${prev.system}.paperless-ngx; adlist = inputs.adblock-unbound.packages.${prev.system}; }) (prev: next: { vimPlugins = next.vimPlugins // { inherit (inputs.master.legacyPackages.${prev.system}.vimPlugins) nvim-lspconfig; }; }) ]; nix.nixPath = [ "nixpkgs=${inputs.nixpkgs}" "nixos-config=${../lib/compat/nixos}" "home-manager=${inputs.home-manager}" ]; }) ] ++ (flakeNixosBaseImports (filterModules ./.)); }; }; }