{ self, nixpkgs, ... }@inputs: let mapDir = dir: builtins.attrNames (nixpkgs.lib.filterAttrs (name: type: type == "directory") ( builtins.readDir ../../${dir})); filterDir = filterBy: dir: builtins.filter (name: name != filterBy) (mapDir dir); filterSuffix = suffix: attr: nixpkgs.lib.filterAttrs (name: v: !(nixpkgs.lib.hasSuffix suffix name)) attr; genColmenaCfg = name: host: { deployment = { allowLocalDeployment = builtins.any (hostName: hostName == name) [ "ryuuko" ]; targetHost = nixpkgs.lib.findFirst (el: el != null) host.config.networking.fqdn [ host.config.kyouma.deployment.targetHost ]; targetPort = 22; # change back to null after switching ryuuko to nixos targetUser = "emily"; tags = host.config.kyouma.deployment.tags; }; imports = host._module.args.modules; nixpkgs.system = host.config.nixpkgs.system; }; genNixosCfg = { hostname, system ? "x86_64-linux" }: nixpkgs.lib.nixosSystem { system = system; specialArgs = { inherit inputs; }; modules = [ ../../config/hosts/${hostname}/configuration.nix inputs.sops-nix.nixosModules.sops ({ ... }: { nixpkgs.overlays = [ self.overlays.kyouma ]; nixpkgs.hostPlatform = system; }) ]; }; in { mapHosts = hostCfg: nixpkgs.lib.recursiveUpdate ( nixpkgs.lib.genAttrs (filterDir "_minimal" "config/hosts") (host: { hostname = host; })) hostCfg; mapColmenaCfg = extraColmenaCfg: nixpkgs.lib.recursiveUpdate (builtins.mapAttrs (genColmenaCfg) ( filterSuffix "-minimal" self.nixosConfigurations)) extraColmenaCfg; mapNixosCfg = extraNixosCfg: nixpkgs.lib.recursiveUpdate (builtins.mapAttrs (name: value: genNixosCfg value) self.hosts) extraNixosCfg; mapPackages = overlayPkgs: otherPackages: nixpkgs.lib.recursiveUpdate ( nixpkgs.lib.genAttrs (mapDir "pkgs") (name: overlayPkgs.${name})) otherPackages; mapHydraHosts = hosts: builtins.mapAttrs (name: host: host.config.system.build.toplevel) hosts; }