let mods = import ./modules; users = import ./users; sources = import ./npins; inherit (import sources.nix-patches { patchFile = ./patches; }) mkNixpkgsSrc; unstable = { nixpkgs = import (mkNixpkgsSrc { src = sources.nixpkgs-unstable; version = "unstable"; }) { }; home-manager = "${sources.home-manager-unstable}/nixos"; nixvim = import sources.nixvim-unstable; }; stable = { nixpkgs = import (mkNixpkgsSrc { src = sources.nixpkgs-stable; version = "stable"; }) { }; home-manager = "${sources.home-manager-stable}/nixos"; nixvim = import sources.nixvim-stable; }; inherit (unstable.nixpkgs) lib; nodes = lib.mapAttrs' (name: _: { name = lib.removeSuffix ".nix" name; value = import ./machines/${name}; }) (builtins.readDir ./machines); nodes-meta = lib.mapAttrs (_: n: n.meta) nodes; in { meta = rec { inherit (unstable) nixpkgs; specialArgs = { inherit mods users sources; meta = nodes-meta; versions = { inherit unstable stable; }; }; nodeNixpkgs = lib.mapAttrs ( _: node: lib.foldl ( pkgs: patch: import (mkNixpkgsSrc { src = pkgs; version = patch; }) { } ) (if node.unstable then unstable else stable).nixpkgs (node.nixPatches or []) ) nodes-meta; nodeSpecialArgs = lib.mapAttrs (name: node: { inherit (node) unstable; self-version = (if node.unstable then unstable else stable) // { nixpkgs = nodeNixpkgs."${name}"; }; }) nodes-meta; }; defaults = { name, ... }: { imports = [ ./kat ]; networking.hostName = name; }; } // lib.mapAttrs (_: n: n.config) nodes