nix/flake.nix

51 lines
1.4 KiB
Nix

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, disko, ... }:
let
# Helper to build a NixOS host config from hosts/<name>/
mkHost = name: system: nixpkgs.lib.nixosSystem {
modules = [
{ nixpkgs.hostPlatform = system; }
disko.nixosModules.disko
./modules/common.nix
./hosts/${name}
];
};
hosts = {
telefonmann = { system = "x86_64-linux"; };
};
in {
# nixosConfigurations is used by nixos-anywhere for initial install
nixosConfigurations = nixpkgs.lib.mapAttrs
(name: cfg: mkHost name cfg.system)
hosts;
# colmena hive for ongoing deployments
colmena = {
meta = {
nixpkgs = import nixpkgs { system = "x86_64-linux"; }; # fallback for colmena internals
specialArgs = { inherit disko; };
};
} // nixpkgs.lib.mapAttrs (name: cfg: {
deployment = {
# Set targetHost per host in hosts/<name>/default.nix or override here
# targetHost = "telefonmann.example.com";
targetUser = "root";
};
imports = [
{ nixpkgs.hostPlatform = cfg.system; }
disko.nixosModules.disko
./modules/common.nix
./hosts/${name}
];
}) hosts;
};
}