/ top-level / configuration.nix
configuration.nix
 1  { self, lib, inputs, inputs', modulesPath, ... } @ v:
 2  {
 3    flake = let
 4      mkConfs = { dir, trigger }: let
 5        dirs = builtins.readDir dir;
 6        filtered = lib.filterAttrs (k: v:
 7          v == "directory" &&
 8          lib.pathIsRegularFile "${dir}/${k}/${trigger}"
 9        ) dirs;
10      in lib.listToAttrs (map (name: {
11        inherit name;
12        value = lib.fmway.withImport' "${dir}/${name}/${trigger}" v;
13      }) (lib.attrNames filtered));
14      system = "x86_64-linux";
15    in {
16      hostConfs = mkConfs {
17        dir = "${self.outPath}/hosts";
18        trigger = "configuration.nix";
19      };
20      homeConfs = mkConfs {
21        dir = "${self.outPath}/home";
22        trigger = "default.nix";
23      };
24      nixosConfigurations = lib.mapAttrs (_: module:
25        lib.nixosSystem {
26          inherit system;
27          modules = [
28            module
29            {
30              nixpkgs.overlays = [
31                (self: super: {
32                  inherit lib;
33                })
34              ];
35            }
36          ];
37          specialArgs = {
38            inherit inputs lib;
39          };
40        }
41      ) self.hostConfs;
42      homeConfigurations = lib.mapAttrs (_: module:
43        lib.homeManagerConfiguration {
44          pkgs = self.legacyPackages.${system};
45          extraSpecialArgs = {
46            inherit inputs;
47          };
48          modules = [
49            module
50          ];
51        }
52      ) self.homeConfs;
53    };
54  }