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 = [
./hardware-configuration.nix
server.hardware-configuration
];
boot.loader = {

View file

@ -5,18 +5,32 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
};
outputs = {
self,
nixpkgs,
...
} @ attrs: {
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra;
nixosConfigurations.jefke = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = attrs;
modules = [
./configuration.nix
];
outputs = {nixpkgs, ...}: let
servers = {
jefke = {
hardware-configuration = import ./hardware-configuration/jefke.nix;
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;
nixosConfigurations = genNixosConfigurations (
server: {
system = server.system-arch;
specialArgs = {inherit server;};
modules = [
./configuration.nix
];
}
);
};
}