initial support for multiple servers

This commit is contained in:
Pim Kunis 2023-11-05 20:11:51 +01:00
parent a4a0e587c3
commit 397d6ab765
3 changed files with 32 additions and 14 deletions

View file

@ -1,6 +1,10 @@
{pkgs, ...}: { {
pkgs,
server,
...
}: {
imports = [ imports = [
./hardware-configuration.nix server.hardware-configuration
]; ];
boot.loader = { boot.loader = {

View file

@ -5,18 +5,32 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
}; };
outputs = { outputs = {nixpkgs, ...}: let
self, servers = {
nixpkgs, jefke = {
... hardware-configuration = import ./hardware-configuration/jefke.nix;
} @ attrs: { system-arch = "x86_64-linux";
};
};
serverNames = builtins.attrNames servers;
serverWithNameAttr = name: (builtins.getAttr name servers) // {name = name;};
genNixosConfigurations = config:
nixpkgs.lib.genAttrs serverNames (
serverName:
nixpkgs.lib.nixosSystem (config (serverWithNameAttr serverName))
);
in {
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra; formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra;
nixosConfigurations.jefke = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; nixosConfigurations = genNixosConfigurations (
specialArgs = attrs; server: {
system = server.system-arch;
specialArgs = {inherit server;};
modules = [ modules = [
./configuration.nix ./configuration.nix
]; ];
}; }
);
}; };
} }