2024-04-27 19:34:17 +02:00
|
|
|
{ self, nixpkgs, ... }@inputs: let
|
|
|
|
readHostDir = builtins.filter (name: name != "_minimal") (
|
|
|
|
builtins.attrNames (nixpkgs.lib.filterAttrs (name: type: type == "directory") (
|
|
|
|
builtins.readDir ../../config/hosts)));
|
|
|
|
|
|
|
|
filterMinimal = attr: nixpkgs.lib.filterAttrs (name: v: !(nixpkgs.lib.hasSuffix "-minimal" 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
|
|
|
|
({ ... }: {
|
|
|
|
nixpkgs.overlays = [ self.overlays.kyouma ];
|
2024-04-29 12:22:22 +02:00
|
|
|
nixpkgs.hostPlatform = system;
|
2024-04-27 19:34:17 +02:00
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
in {
|
|
|
|
mapHosts = hostCfg: nixpkgs.lib.recursiveUpdate (
|
|
|
|
nixpkgs.lib.genAttrs readHostDir (host: { hostname = host; })) hostCfg;
|
|
|
|
|
|
|
|
mapColmenaCfg = extraColmenaCfg: nixpkgs.lib.recursiveUpdate (builtins.mapAttrs (genColmenaCfg) (
|
|
|
|
filterMinimal self.nixosConfigurations)) extraColmenaCfg;
|
|
|
|
|
|
|
|
mapNixosCfg = extraNixosCfg: nixpkgs.lib.recursiveUpdate (builtins.mapAttrs (name: value:
|
|
|
|
genNixosCfg value) self.hosts) extraNixosCfg;
|
|
|
|
}
|